babylon.module.d.ts 5.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module "babylonjs/Misc/logger" {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module "babylonjs/Misc/typeStore" {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module "babylonjs/Misc/deepCopier" {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module "babylonjs/Misc/precisionDate" {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module "babylonjs/Misc/devTools" {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module "babylonjs/Misc/webRequest" {
  409. /**
  410. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module "babylonjs/Misc/fileRequest" {
  480. import { Observable } from "babylonjs/Misc/observable";
  481. /**
  482. * File request interface
  483. */
  484. export interface IFileRequest {
  485. /**
  486. * Raised when the request is complete (success or error).
  487. */
  488. onCompleteObservable: Observable<IFileRequest>;
  489. /**
  490. * Aborts the request for a file.
  491. */
  492. abort: () => void;
  493. }
  494. }
  495. declare module "babylonjs/Misc/performanceMonitor" {
  496. /**
  497. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  498. */
  499. export class PerformanceMonitor {
  500. private _enabled;
  501. private _rollingFrameTime;
  502. private _lastFrameTimeMs;
  503. /**
  504. * constructor
  505. * @param frameSampleSize The number of samples required to saturate the sliding window
  506. */
  507. constructor(frameSampleSize?: number);
  508. /**
  509. * Samples current frame
  510. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  511. */
  512. sampleFrame(timeMs?: number): void;
  513. /**
  514. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  515. */
  516. readonly averageFrameTime: number;
  517. /**
  518. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  519. */
  520. readonly averageFrameTimeVariance: number;
  521. /**
  522. * Returns the frame time of the most recent frame
  523. */
  524. readonly instantaneousFrameTime: number;
  525. /**
  526. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  527. */
  528. readonly averageFPS: number;
  529. /**
  530. * Returns the average framerate in frames per second using the most recent frame time
  531. */
  532. readonly instantaneousFPS: number;
  533. /**
  534. * Returns true if enough samples have been taken to completely fill the sliding window
  535. */
  536. readonly isSaturated: boolean;
  537. /**
  538. * Enables contributions to the sliding window sample set
  539. */
  540. enable(): void;
  541. /**
  542. * Disables contributions to the sliding window sample set
  543. * Samples will not be interpolated over the disabled period
  544. */
  545. disable(): void;
  546. /**
  547. * Returns true if sampling is enabled
  548. */
  549. readonly isEnabled: boolean;
  550. /**
  551. * Resets performance monitor
  552. */
  553. reset(): void;
  554. }
  555. /**
  556. * RollingAverage
  557. *
  558. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  559. */
  560. export class RollingAverage {
  561. /**
  562. * Current average
  563. */
  564. average: number;
  565. /**
  566. * Current variance
  567. */
  568. variance: number;
  569. protected _samples: Array<number>;
  570. protected _sampleCount: number;
  571. protected _pos: number;
  572. protected _m2: number;
  573. /**
  574. * constructor
  575. * @param length The number of samples required to saturate the sliding window
  576. */
  577. constructor(length: number);
  578. /**
  579. * Adds a sample to the sample set
  580. * @param v The sample value
  581. */
  582. add(v: number): void;
  583. /**
  584. * Returns previously added values or null if outside of history or outside the sliding window domain
  585. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  586. * @return Value previously recorded with add() or null if outside of range
  587. */
  588. history(i: number): number;
  589. /**
  590. * Returns true if enough samples have been taken to completely fill the sliding window
  591. * @return true if sample-set saturated
  592. */
  593. isSaturated(): boolean;
  594. /**
  595. * Resets the rolling average (equivalent to 0 samples taken so far)
  596. */
  597. reset(): void;
  598. /**
  599. * Wraps a value around the sample range boundaries
  600. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  601. * @return Wrapped position in sample range
  602. */
  603. protected _wrapPosition(i: number): number;
  604. }
  605. }
  606. declare module "babylonjs/Misc/stringDictionary" {
  607. import { Nullable } from "babylonjs/types";
  608. /**
  609. * This class implement a typical dictionary using a string as key and the generic type T as value.
  610. * The underlying implementation relies on an associative array to ensure the best performances.
  611. * The value can be anything including 'null' but except 'undefined'
  612. */
  613. export class StringDictionary<T> {
  614. /**
  615. * This will clear this dictionary and copy the content from the 'source' one.
  616. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  617. * @param source the dictionary to take the content from and copy to this dictionary
  618. */
  619. copyFrom(source: StringDictionary<T>): void;
  620. /**
  621. * Get a value based from its key
  622. * @param key the given key to get the matching value from
  623. * @return the value if found, otherwise undefined is returned
  624. */
  625. get(key: string): T | undefined;
  626. /**
  627. * Get a value from its key or add it if it doesn't exist.
  628. * This method will ensure you that a given key/data will be present in the dictionary.
  629. * @param key the given key to get the matching value from
  630. * @param factory the factory that will create the value if the key is not present in the dictionary.
  631. * The factory will only be invoked if there's no data for the given key.
  632. * @return the value corresponding to the key.
  633. */
  634. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  635. /**
  636. * Get a value from its key if present in the dictionary otherwise add it
  637. * @param key the key to get the value from
  638. * @param val if there's no such key/value pair in the dictionary add it with this value
  639. * @return the value corresponding to the key
  640. */
  641. getOrAdd(key: string, val: T): T;
  642. /**
  643. * Check if there's a given key in the dictionary
  644. * @param key the key to check for
  645. * @return true if the key is present, false otherwise
  646. */
  647. contains(key: string): boolean;
  648. /**
  649. * Add a new key and its corresponding value
  650. * @param key the key to add
  651. * @param value the value corresponding to the key
  652. * @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
  653. */
  654. add(key: string, value: T): boolean;
  655. /**
  656. * Update a specific value associated to a key
  657. * @param key defines the key to use
  658. * @param value defines the value to store
  659. * @returns true if the value was updated (or false if the key was not found)
  660. */
  661. set(key: string, value: T): boolean;
  662. /**
  663. * Get the element of the given key and remove it from the dictionary
  664. * @param key defines the key to search
  665. * @returns the value associated with the key or null if not found
  666. */
  667. getAndRemove(key: string): Nullable<T>;
  668. /**
  669. * Remove a key/value from the dictionary.
  670. * @param key the key to remove
  671. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  672. */
  673. remove(key: string): boolean;
  674. /**
  675. * Clear the whole content of the dictionary
  676. */
  677. clear(): void;
  678. /**
  679. * Gets the current count
  680. */
  681. readonly count: number;
  682. /**
  683. * Execute a callback on each key/val of the dictionary.
  684. * Note that you can remove any element in this dictionary in the callback implementation
  685. * @param callback the callback to execute on a given key/value pair
  686. */
  687. forEach(callback: (key: string, val: T) => void): void;
  688. /**
  689. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  690. * If the callback returns null or undefined the method will iterate to the next key/value pair
  691. * Note that you can remove any element in this dictionary in the callback implementation
  692. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  693. * @returns the first item
  694. */
  695. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  696. private _count;
  697. private _data;
  698. }
  699. }
  700. declare module "babylonjs/Meshes/dataBuffer" {
  701. /**
  702. * Class used to store gfx data (like WebGLBuffer)
  703. */
  704. export class DataBuffer {
  705. /**
  706. * Gets or sets the number of objects referencing this buffer
  707. */
  708. references: number;
  709. /** Gets or sets the size of the underlying buffer */
  710. capacity: number;
  711. /**
  712. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  713. */
  714. is32Bits: boolean;
  715. /**
  716. * Gets the underlying buffer
  717. */
  718. readonly underlyingResource: any;
  719. }
  720. }
  721. declare module "babylonjs/Meshes/buffer" {
  722. import { Nullable, DataArray } from "babylonjs/types";
  723. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  724. /**
  725. * Class used to store data that will be store in GPU memory
  726. */
  727. export class Buffer {
  728. private _engine;
  729. private _buffer;
  730. /** @hidden */
  731. _data: Nullable<DataArray>;
  732. private _updatable;
  733. private _instanced;
  734. /**
  735. * Gets the byte stride.
  736. */
  737. readonly byteStride: number;
  738. /**
  739. * Constructor
  740. * @param engine the engine
  741. * @param data the data to use for this buffer
  742. * @param updatable whether the data is updatable
  743. * @param stride the stride (optional)
  744. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  745. * @param instanced whether the buffer is instanced (optional)
  746. * @param useBytes set to true if the stride in in bytes (optional)
  747. */
  748. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  749. /**
  750. * Create a new VertexBuffer based on the current buffer
  751. * @param kind defines the vertex buffer kind (position, normal, etc.)
  752. * @param offset defines offset in the buffer (0 by default)
  753. * @param size defines the size in floats of attributes (position is 3 for instance)
  754. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  755. * @param instanced defines if the vertex buffer contains indexed data
  756. * @param useBytes defines if the offset and stride are in bytes
  757. * @returns the new vertex buffer
  758. */
  759. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  760. /**
  761. * Gets a boolean indicating if the Buffer is updatable?
  762. * @returns true if the buffer is updatable
  763. */
  764. isUpdatable(): boolean;
  765. /**
  766. * Gets current buffer's data
  767. * @returns a DataArray or null
  768. */
  769. getData(): Nullable<DataArray>;
  770. /**
  771. * Gets underlying native buffer
  772. * @returns underlying native buffer
  773. */
  774. getBuffer(): Nullable<DataBuffer>;
  775. /**
  776. * Gets the stride in float32 units (i.e. byte stride / 4).
  777. * May not be an integer if the byte stride is not divisible by 4.
  778. * DEPRECATED. Use byteStride instead.
  779. * @returns the stride in float32 units
  780. */
  781. getStrideSize(): number;
  782. /**
  783. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  784. * @param data defines the data to store
  785. */
  786. create(data?: Nullable<DataArray>): void;
  787. /** @hidden */
  788. _rebuild(): void;
  789. /**
  790. * Update current buffer data
  791. * @param data defines the data to store
  792. */
  793. update(data: DataArray): void;
  794. /**
  795. * Updates the data directly.
  796. * @param data the new data
  797. * @param offset the new offset
  798. * @param vertexCount the vertex count (optional)
  799. * @param useBytes set to true if the offset is in bytes
  800. */
  801. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  802. /**
  803. * Release all resources
  804. */
  805. dispose(): void;
  806. }
  807. /**
  808. * Specialized buffer used to store vertex data
  809. */
  810. export class VertexBuffer {
  811. /** @hidden */
  812. _buffer: Buffer;
  813. private _kind;
  814. private _size;
  815. private _ownsBuffer;
  816. private _instanced;
  817. private _instanceDivisor;
  818. /**
  819. * The byte type.
  820. */
  821. static readonly BYTE: number;
  822. /**
  823. * The unsigned byte type.
  824. */
  825. static readonly UNSIGNED_BYTE: number;
  826. /**
  827. * The short type.
  828. */
  829. static readonly SHORT: number;
  830. /**
  831. * The unsigned short type.
  832. */
  833. static readonly UNSIGNED_SHORT: number;
  834. /**
  835. * The integer type.
  836. */
  837. static readonly INT: number;
  838. /**
  839. * The unsigned integer type.
  840. */
  841. static readonly UNSIGNED_INT: number;
  842. /**
  843. * The float type.
  844. */
  845. static readonly FLOAT: number;
  846. /**
  847. * Gets or sets the instance divisor when in instanced mode
  848. */
  849. instanceDivisor: number;
  850. /**
  851. * Gets the byte stride.
  852. */
  853. readonly byteStride: number;
  854. /**
  855. * Gets the byte offset.
  856. */
  857. readonly byteOffset: number;
  858. /**
  859. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  860. */
  861. readonly normalized: boolean;
  862. /**
  863. * Gets the data type of each component in the array.
  864. */
  865. readonly type: number;
  866. /**
  867. * Constructor
  868. * @param engine the engine
  869. * @param data the data to use for this vertex buffer
  870. * @param kind the vertex buffer kind
  871. * @param updatable whether the data is updatable
  872. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  873. * @param stride the stride (optional)
  874. * @param instanced whether the buffer is instanced (optional)
  875. * @param offset the offset of the data (optional)
  876. * @param size the number of components (optional)
  877. * @param type the type of the component (optional)
  878. * @param normalized whether the data contains normalized data (optional)
  879. * @param useBytes set to true if stride and offset are in bytes (optional)
  880. */
  881. 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);
  882. /** @hidden */
  883. _rebuild(): void;
  884. /**
  885. * Returns the kind of the VertexBuffer (string)
  886. * @returns a string
  887. */
  888. getKind(): string;
  889. /**
  890. * Gets a boolean indicating if the VertexBuffer is updatable?
  891. * @returns true if the buffer is updatable
  892. */
  893. isUpdatable(): boolean;
  894. /**
  895. * Gets current buffer's data
  896. * @returns a DataArray or null
  897. */
  898. getData(): Nullable<DataArray>;
  899. /**
  900. * Gets underlying native buffer
  901. * @returns underlying native buffer
  902. */
  903. getBuffer(): Nullable<DataBuffer>;
  904. /**
  905. * Gets the stride in float32 units (i.e. byte stride / 4).
  906. * May not be an integer if the byte stride is not divisible by 4.
  907. * DEPRECATED. Use byteStride instead.
  908. * @returns the stride in float32 units
  909. */
  910. getStrideSize(): number;
  911. /**
  912. * Returns the offset as a multiple of the type byte length.
  913. * DEPRECATED. Use byteOffset instead.
  914. * @returns the offset in bytes
  915. */
  916. getOffset(): number;
  917. /**
  918. * Returns the number of components per vertex attribute (integer)
  919. * @returns the size in float
  920. */
  921. getSize(): number;
  922. /**
  923. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  924. * @returns true if this buffer is instanced
  925. */
  926. getIsInstanced(): boolean;
  927. /**
  928. * Returns the instancing divisor, zero for non-instanced (integer).
  929. * @returns a number
  930. */
  931. getInstanceDivisor(): number;
  932. /**
  933. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  934. * @param data defines the data to store
  935. */
  936. create(data?: DataArray): void;
  937. /**
  938. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  939. * This function will create a new buffer if the current one is not updatable
  940. * @param data defines the data to store
  941. */
  942. update(data: DataArray): void;
  943. /**
  944. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  945. * Returns the directly updated WebGLBuffer.
  946. * @param data the new data
  947. * @param offset the new offset
  948. * @param useBytes set to true if the offset is in bytes
  949. */
  950. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  951. /**
  952. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  953. */
  954. dispose(): void;
  955. /**
  956. * Enumerates each value of this vertex buffer as numbers.
  957. * @param count the number of values to enumerate
  958. * @param callback the callback function called for each value
  959. */
  960. forEach(count: number, callback: (value: number, index: number) => void): void;
  961. /**
  962. * Positions
  963. */
  964. static readonly PositionKind: string;
  965. /**
  966. * Normals
  967. */
  968. static readonly NormalKind: string;
  969. /**
  970. * Tangents
  971. */
  972. static readonly TangentKind: string;
  973. /**
  974. * Texture coordinates
  975. */
  976. static readonly UVKind: string;
  977. /**
  978. * Texture coordinates 2
  979. */
  980. static readonly UV2Kind: string;
  981. /**
  982. * Texture coordinates 3
  983. */
  984. static readonly UV3Kind: string;
  985. /**
  986. * Texture coordinates 4
  987. */
  988. static readonly UV4Kind: string;
  989. /**
  990. * Texture coordinates 5
  991. */
  992. static readonly UV5Kind: string;
  993. /**
  994. * Texture coordinates 6
  995. */
  996. static readonly UV6Kind: string;
  997. /**
  998. * Colors
  999. */
  1000. static readonly ColorKind: string;
  1001. /**
  1002. * Matrix indices (for bones)
  1003. */
  1004. static readonly MatricesIndicesKind: string;
  1005. /**
  1006. * Matrix weights (for bones)
  1007. */
  1008. static readonly MatricesWeightsKind: string;
  1009. /**
  1010. * Additional matrix indices (for bones)
  1011. */
  1012. static readonly MatricesIndicesExtraKind: string;
  1013. /**
  1014. * Additional matrix weights (for bones)
  1015. */
  1016. static readonly MatricesWeightsExtraKind: string;
  1017. /**
  1018. * Deduces the stride given a kind.
  1019. * @param kind The kind string to deduce
  1020. * @returns The deduced stride
  1021. */
  1022. static DeduceStride(kind: string): number;
  1023. /**
  1024. * Gets the byte length of the given type.
  1025. * @param type the type
  1026. * @returns the number of bytes
  1027. */
  1028. static GetTypeByteLength(type: number): number;
  1029. /**
  1030. * Enumerates each value of the given parameters as numbers.
  1031. * @param data the data to enumerate
  1032. * @param byteOffset the byte offset of the data
  1033. * @param byteStride the byte stride of the data
  1034. * @param componentCount the number of components per element
  1035. * @param componentType the type of the component
  1036. * @param count the number of values to enumerate
  1037. * @param normalized whether the data is normalized
  1038. * @param callback the callback function called for each value
  1039. */
  1040. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1041. private static _GetFloatValue;
  1042. }
  1043. }
  1044. declare module "babylonjs/Maths/math.scalar" {
  1045. /**
  1046. * Scalar computation library
  1047. */
  1048. export class Scalar {
  1049. /**
  1050. * Two pi constants convenient for computation.
  1051. */
  1052. static TwoPi: number;
  1053. /**
  1054. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1055. * @param a number
  1056. * @param b number
  1057. * @param epsilon (default = 1.401298E-45)
  1058. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1059. */
  1060. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1061. /**
  1062. * Returns a string : the upper case translation of the number i to hexadecimal.
  1063. * @param i number
  1064. * @returns the upper case translation of the number i to hexadecimal.
  1065. */
  1066. static ToHex(i: number): string;
  1067. /**
  1068. * Returns -1 if value is negative and +1 is value is positive.
  1069. * @param value the value
  1070. * @returns the value itself if it's equal to zero.
  1071. */
  1072. static Sign(value: number): number;
  1073. /**
  1074. * Returns the value itself if it's between min and max.
  1075. * Returns min if the value is lower than min.
  1076. * Returns max if the value is greater than max.
  1077. * @param value the value to clmap
  1078. * @param min the min value to clamp to (default: 0)
  1079. * @param max the max value to clamp to (default: 1)
  1080. * @returns the clamped value
  1081. */
  1082. static Clamp(value: number, min?: number, max?: number): number;
  1083. /**
  1084. * the log2 of value.
  1085. * @param value the value to compute log2 of
  1086. * @returns the log2 of value.
  1087. */
  1088. static Log2(value: number): number;
  1089. /**
  1090. * Loops the value, so that it is never larger than length and never smaller than 0.
  1091. *
  1092. * This is similar to the modulo operator but it works with floating point numbers.
  1093. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1094. * With t = 5 and length = 2.5, the result would be 0.0.
  1095. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1096. * @param value the value
  1097. * @param length the length
  1098. * @returns the looped value
  1099. */
  1100. static Repeat(value: number, length: number): number;
  1101. /**
  1102. * Normalize the value between 0.0 and 1.0 using min and max values
  1103. * @param value value to normalize
  1104. * @param min max to normalize between
  1105. * @param max min to normalize between
  1106. * @returns the normalized value
  1107. */
  1108. static Normalize(value: number, min: number, max: number): number;
  1109. /**
  1110. * Denormalize the value from 0.0 and 1.0 using min and max values
  1111. * @param normalized value to denormalize
  1112. * @param min max to denormalize between
  1113. * @param max min to denormalize between
  1114. * @returns the denormalized value
  1115. */
  1116. static Denormalize(normalized: number, min: number, max: number): number;
  1117. /**
  1118. * Calculates the shortest difference between two given angles given in degrees.
  1119. * @param current current angle in degrees
  1120. * @param target target angle in degrees
  1121. * @returns the delta
  1122. */
  1123. static DeltaAngle(current: number, target: number): number;
  1124. /**
  1125. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1126. * @param tx value
  1127. * @param length length
  1128. * @returns The returned value will move back and forth between 0 and length
  1129. */
  1130. static PingPong(tx: number, length: number): number;
  1131. /**
  1132. * Interpolates between min and max with smoothing at the limits.
  1133. *
  1134. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1135. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1136. * @param from from
  1137. * @param to to
  1138. * @param tx value
  1139. * @returns the smooth stepped value
  1140. */
  1141. static SmoothStep(from: number, to: number, tx: number): number;
  1142. /**
  1143. * Moves a value current towards target.
  1144. *
  1145. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1146. * Negative values of maxDelta pushes the value away from target.
  1147. * @param current current value
  1148. * @param target target value
  1149. * @param maxDelta max distance to move
  1150. * @returns resulting value
  1151. */
  1152. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1153. /**
  1154. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1155. *
  1156. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1157. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1158. * @param current current value
  1159. * @param target target value
  1160. * @param maxDelta max distance to move
  1161. * @returns resulting angle
  1162. */
  1163. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1164. /**
  1165. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1166. * @param start start value
  1167. * @param end target value
  1168. * @param amount amount to lerp between
  1169. * @returns the lerped value
  1170. */
  1171. static Lerp(start: number, end: number, amount: number): number;
  1172. /**
  1173. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1174. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1175. * @param start start value
  1176. * @param end target value
  1177. * @param amount amount to lerp between
  1178. * @returns the lerped value
  1179. */
  1180. static LerpAngle(start: number, end: number, amount: number): number;
  1181. /**
  1182. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1183. * @param a start value
  1184. * @param b target value
  1185. * @param value value between a and b
  1186. * @returns the inverseLerp value
  1187. */
  1188. static InverseLerp(a: number, b: number, value: number): number;
  1189. /**
  1190. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1191. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1192. * @param value1 spline value
  1193. * @param tangent1 spline value
  1194. * @param value2 spline value
  1195. * @param tangent2 spline value
  1196. * @param amount input value
  1197. * @returns hermite result
  1198. */
  1199. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1200. /**
  1201. * Returns a random float number between and min and max values
  1202. * @param min min value of random
  1203. * @param max max value of random
  1204. * @returns random value
  1205. */
  1206. static RandomRange(min: number, max: number): number;
  1207. /**
  1208. * This function returns percentage of a number in a given range.
  1209. *
  1210. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1211. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1212. * @param number to convert to percentage
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the percentage
  1216. */
  1217. static RangeToPercent(number: number, min: number, max: number): number;
  1218. /**
  1219. * This function returns number that corresponds to the percentage in a given range.
  1220. *
  1221. * PercentToRange(0.34,0,100) will return 34.
  1222. * @param percent to convert to number
  1223. * @param min min range
  1224. * @param max max range
  1225. * @returns the number
  1226. */
  1227. static PercentToRange(percent: number, min: number, max: number): number;
  1228. /**
  1229. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1230. * @param angle The angle to normalize in radian.
  1231. * @return The converted angle.
  1232. */
  1233. static NormalizeRadians(angle: number): number;
  1234. }
  1235. }
  1236. declare module "babylonjs/Maths/math.constants" {
  1237. /**
  1238. * Constant used to convert a value to gamma space
  1239. * @ignorenaming
  1240. */
  1241. export const ToGammaSpace: number;
  1242. /**
  1243. * Constant used to convert a value to linear space
  1244. * @ignorenaming
  1245. */
  1246. export const ToLinearSpace = 2.2;
  1247. /**
  1248. * Constant used to define the minimal number value in Babylon.js
  1249. * @ignorenaming
  1250. */
  1251. let Epsilon: number;
  1252. export { Epsilon };
  1253. }
  1254. declare module "babylonjs/Maths/math.viewport" {
  1255. /**
  1256. * Class used to represent a viewport on screen
  1257. */
  1258. export class Viewport {
  1259. /** viewport left coordinate */
  1260. x: number;
  1261. /** viewport top coordinate */
  1262. y: number;
  1263. /**viewport width */
  1264. width: number;
  1265. /** viewport height */
  1266. height: number;
  1267. /**
  1268. * Creates a Viewport object located at (x, y) and sized (width, height)
  1269. * @param x defines viewport left coordinate
  1270. * @param y defines viewport top coordinate
  1271. * @param width defines the viewport width
  1272. * @param height defines the viewport height
  1273. */
  1274. constructor(
  1275. /** viewport left coordinate */
  1276. x: number,
  1277. /** viewport top coordinate */
  1278. y: number,
  1279. /**viewport width */
  1280. width: number,
  1281. /** viewport height */
  1282. height: number);
  1283. /**
  1284. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1285. * @param renderWidth defines the rendering width
  1286. * @param renderHeight defines the rendering height
  1287. * @returns a new Viewport
  1288. */
  1289. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1290. /**
  1291. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1292. * @param renderWidth defines the rendering width
  1293. * @param renderHeight defines the rendering height
  1294. * @param ref defines the target viewport
  1295. * @returns the current viewport
  1296. */
  1297. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1298. /**
  1299. * Returns a new Viewport copied from the current one
  1300. * @returns a new Viewport
  1301. */
  1302. clone(): Viewport;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/arrayTools" {
  1306. /**
  1307. * Class containing a set of static utilities functions for arrays.
  1308. */
  1309. export class ArrayTools {
  1310. /**
  1311. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1312. * @param size the number of element to construct and put in the array
  1313. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1314. * @returns a new array filled with new objects
  1315. */
  1316. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1317. }
  1318. }
  1319. declare module "babylonjs/Maths/math.like" {
  1320. import { float, int, DeepImmutable } from "babylonjs/types";
  1321. /**
  1322. * @hidden
  1323. */
  1324. export interface IColor4Like {
  1325. r: float;
  1326. g: float;
  1327. b: float;
  1328. a: float;
  1329. }
  1330. /**
  1331. * @hidden
  1332. */
  1333. export interface IColor3Like {
  1334. r: float;
  1335. g: float;
  1336. b: float;
  1337. }
  1338. /**
  1339. * @hidden
  1340. */
  1341. export interface IVector4Like {
  1342. x: float;
  1343. y: float;
  1344. z: float;
  1345. w: float;
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export interface IVector3Like {
  1351. x: float;
  1352. y: float;
  1353. z: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IVector2Like {
  1359. x: float;
  1360. y: float;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IMatrixLike {
  1366. toArray(): DeepImmutable<Float32Array>;
  1367. updateFlag: int;
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export interface IViewportLike {
  1373. x: float;
  1374. y: float;
  1375. width: float;
  1376. height: float;
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export interface IPlaneLike {
  1382. normal: IVector3Like;
  1383. d: float;
  1384. normalize(): void;
  1385. }
  1386. }
  1387. declare module "babylonjs/Maths/math.vector" {
  1388. import { Viewport } from "babylonjs/Maths/math.viewport";
  1389. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1390. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1391. /**
  1392. * Class representing a vector containing 2 coordinates
  1393. */
  1394. export class Vector2 {
  1395. /** defines the first coordinate */
  1396. x: number;
  1397. /** defines the second coordinate */
  1398. y: number;
  1399. /**
  1400. * Creates a new Vector2 from the given x and y coordinates
  1401. * @param x defines the first coordinate
  1402. * @param y defines the second coordinate
  1403. */
  1404. constructor(
  1405. /** defines the first coordinate */
  1406. x?: number,
  1407. /** defines the second coordinate */
  1408. y?: number);
  1409. /**
  1410. * Gets a string with the Vector2 coordinates
  1411. * @returns a string with the Vector2 coordinates
  1412. */
  1413. toString(): string;
  1414. /**
  1415. * Gets class name
  1416. * @returns the string "Vector2"
  1417. */
  1418. getClassName(): string;
  1419. /**
  1420. * Gets current vector hash code
  1421. * @returns the Vector2 hash code as a number
  1422. */
  1423. getHashCode(): number;
  1424. /**
  1425. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1426. * @param array defines the source array
  1427. * @param index defines the offset in source array
  1428. * @returns the current Vector2
  1429. */
  1430. toArray(array: FloatArray, index?: number): Vector2;
  1431. /**
  1432. * Copy the current vector to an array
  1433. * @returns a new array with 2 elements: the Vector2 coordinates.
  1434. */
  1435. asArray(): number[];
  1436. /**
  1437. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1438. * @param source defines the source Vector2
  1439. * @returns the current updated Vector2
  1440. */
  1441. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1442. /**
  1443. * Sets the Vector2 coordinates with the given floats
  1444. * @param x defines the first coordinate
  1445. * @param y defines the second coordinate
  1446. * @returns the current updated Vector2
  1447. */
  1448. copyFromFloats(x: number, y: number): Vector2;
  1449. /**
  1450. * Sets the Vector2 coordinates with the given floats
  1451. * @param x defines the first coordinate
  1452. * @param y defines the second coordinate
  1453. * @returns the current updated Vector2
  1454. */
  1455. set(x: number, y: number): Vector2;
  1456. /**
  1457. * Add another vector with the current one
  1458. * @param otherVector defines the other vector
  1459. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1460. */
  1461. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1462. /**
  1463. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1464. * @param otherVector defines the other vector
  1465. * @param result defines the target vector
  1466. * @returns the unmodified current Vector2
  1467. */
  1468. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1469. /**
  1470. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1471. * @param otherVector defines the other vector
  1472. * @returns the current updated Vector2
  1473. */
  1474. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1475. /**
  1476. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1477. * @param otherVector defines the other vector
  1478. * @returns a new Vector2
  1479. */
  1480. addVector3(otherVector: Vector3): Vector2;
  1481. /**
  1482. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1483. * @param otherVector defines the other vector
  1484. * @returns a new Vector2
  1485. */
  1486. subtract(otherVector: Vector2): Vector2;
  1487. /**
  1488. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1489. * @param otherVector defines the other vector
  1490. * @param result defines the target vector
  1491. * @returns the unmodified current Vector2
  1492. */
  1493. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1494. /**
  1495. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1496. * @param otherVector defines the other vector
  1497. * @returns the current updated Vector2
  1498. */
  1499. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1500. /**
  1501. * Multiplies in place the current Vector2 coordinates by the given ones
  1502. * @param otherVector defines the other vector
  1503. * @returns the current updated Vector2
  1504. */
  1505. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1506. /**
  1507. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1508. * @param otherVector defines the other vector
  1509. * @returns a new Vector2
  1510. */
  1511. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1512. /**
  1513. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1514. * @param otherVector defines the other vector
  1515. * @param result defines the target vector
  1516. * @returns the unmodified current Vector2
  1517. */
  1518. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1519. /**
  1520. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1521. * @param x defines the first coordinate
  1522. * @param y defines the second coordinate
  1523. * @returns a new Vector2
  1524. */
  1525. multiplyByFloats(x: number, y: number): Vector2;
  1526. /**
  1527. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1528. * @param otherVector defines the other vector
  1529. * @returns a new Vector2
  1530. */
  1531. divide(otherVector: Vector2): Vector2;
  1532. /**
  1533. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1534. * @param otherVector defines the other vector
  1535. * @param result defines the target vector
  1536. * @returns the unmodified current Vector2
  1537. */
  1538. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1539. /**
  1540. * Divides the current Vector2 coordinates by the given ones
  1541. * @param otherVector defines the other vector
  1542. * @returns the current updated Vector2
  1543. */
  1544. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1545. /**
  1546. * Gets a new Vector2 with current Vector2 negated coordinates
  1547. * @returns a new Vector2
  1548. */
  1549. negate(): Vector2;
  1550. /**
  1551. * Multiply the Vector2 coordinates by scale
  1552. * @param scale defines the scaling factor
  1553. * @returns the current updated Vector2
  1554. */
  1555. scaleInPlace(scale: number): Vector2;
  1556. /**
  1557. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1558. * @param scale defines the scaling factor
  1559. * @returns a new Vector2
  1560. */
  1561. scale(scale: number): Vector2;
  1562. /**
  1563. * Scale the current Vector2 values by a factor to a given Vector2
  1564. * @param scale defines the scale factor
  1565. * @param result defines the Vector2 object where to store the result
  1566. * @returns the unmodified current Vector2
  1567. */
  1568. scaleToRef(scale: number, result: Vector2): Vector2;
  1569. /**
  1570. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1571. * @param scale defines the scale factor
  1572. * @param result defines the Vector2 object where to store the result
  1573. * @returns the unmodified current Vector2
  1574. */
  1575. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1576. /**
  1577. * Gets a boolean if two vectors are equals
  1578. * @param otherVector defines the other vector
  1579. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1580. */
  1581. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1582. /**
  1583. * Gets a boolean if two vectors are equals (using an epsilon value)
  1584. * @param otherVector defines the other vector
  1585. * @param epsilon defines the minimal distance to consider equality
  1586. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1587. */
  1588. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. floor(): Vector2;
  1594. /**
  1595. * Gets a new Vector2 from current Vector2 floored values
  1596. * @returns a new Vector2
  1597. */
  1598. fract(): Vector2;
  1599. /**
  1600. * Gets the length of the vector
  1601. * @returns the vector length (float)
  1602. */
  1603. length(): number;
  1604. /**
  1605. * Gets the vector squared length
  1606. * @returns the vector squared length (float)
  1607. */
  1608. lengthSquared(): number;
  1609. /**
  1610. * Normalize the vector
  1611. * @returns the current updated Vector2
  1612. */
  1613. normalize(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 copied from the Vector2
  1616. * @returns a new Vector2
  1617. */
  1618. clone(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(0, 0)
  1621. * @returns a new Vector2
  1622. */
  1623. static Zero(): Vector2;
  1624. /**
  1625. * Gets a new Vector2(1, 1)
  1626. * @returns a new Vector2
  1627. */
  1628. static One(): Vector2;
  1629. /**
  1630. * Gets a new Vector2 set from the given index element of the given array
  1631. * @param array defines the data source
  1632. * @param offset defines the offset in the data source
  1633. * @returns a new Vector2
  1634. */
  1635. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1636. /**
  1637. * Sets "result" from the given index element of the given array
  1638. * @param array defines the data source
  1639. * @param offset defines the offset in the data source
  1640. * @param result defines the target vector
  1641. */
  1642. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1643. /**
  1644. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1645. * @param value1 defines 1st point of control
  1646. * @param value2 defines 2nd point of control
  1647. * @param value3 defines 3rd point of control
  1648. * @param value4 defines 4th point of control
  1649. * @param amount defines the interpolation factor
  1650. * @returns a new Vector2
  1651. */
  1652. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1653. /**
  1654. * 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".
  1655. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1656. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1657. * @param value defines the value to clamp
  1658. * @param min defines the lower limit
  1659. * @param max defines the upper limit
  1660. * @returns a new Vector2
  1661. */
  1662. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1665. * @param value1 defines the 1st control point
  1666. * @param tangent1 defines the outgoing tangent
  1667. * @param value2 defines the 2nd control point
  1668. * @param tangent2 defines the incoming tangent
  1669. * @param amount defines the interpolation factor
  1670. * @returns a new Vector2
  1671. */
  1672. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1673. /**
  1674. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1675. * @param start defines the start vector
  1676. * @param end defines the end vector
  1677. * @param amount defines the interpolation factor
  1678. * @returns a new Vector2
  1679. */
  1680. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1681. /**
  1682. * Gets the dot product of the vector "left" and the vector "right"
  1683. * @param left defines first vector
  1684. * @param right defines second vector
  1685. * @returns the dot product (float)
  1686. */
  1687. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1688. /**
  1689. * Returns a new Vector2 equal to the normalized given vector
  1690. * @param vector defines the vector to normalize
  1691. * @returns a new Vector2
  1692. */
  1693. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1694. /**
  1695. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1696. * @param left defines 1st vector
  1697. * @param right defines 2nd vector
  1698. * @returns a new Vector2
  1699. */
  1700. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1701. /**
  1702. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1703. * @param left defines 1st vector
  1704. * @param right defines 2nd vector
  1705. * @returns a new Vector2
  1706. */
  1707. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1708. /**
  1709. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1710. * @param vector defines the vector to transform
  1711. * @param transformation defines the matrix to apply
  1712. * @returns a new Vector2
  1713. */
  1714. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1715. /**
  1716. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1717. * @param vector defines the vector to transform
  1718. * @param transformation defines the matrix to apply
  1719. * @param result defines the target vector
  1720. */
  1721. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1722. /**
  1723. * Determines if a given vector is included in a triangle
  1724. * @param p defines the vector to test
  1725. * @param p0 defines 1st triangle point
  1726. * @param p1 defines 2nd triangle point
  1727. * @param p2 defines 3rd triangle point
  1728. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1729. */
  1730. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1731. /**
  1732. * Gets the distance between the vectors "value1" and "value2"
  1733. * @param value1 defines first vector
  1734. * @param value2 defines second vector
  1735. * @returns the distance between vectors
  1736. */
  1737. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1738. /**
  1739. * Returns the squared distance between the vectors "value1" and "value2"
  1740. * @param value1 defines first vector
  1741. * @param value2 defines second vector
  1742. * @returns the squared distance between vectors
  1743. */
  1744. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1745. /**
  1746. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1747. * @param value1 defines first vector
  1748. * @param value2 defines second vector
  1749. * @returns a new Vector2
  1750. */
  1751. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1752. /**
  1753. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1754. * @param p defines the middle point
  1755. * @param segA defines one point of the segment
  1756. * @param segB defines the other point of the segment
  1757. * @returns the shortest distance
  1758. */
  1759. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1760. }
  1761. /**
  1762. * Classed used to store (x,y,z) vector representation
  1763. * A Vector3 is the main object used in 3D geometry
  1764. * It can represent etiher the coordinates of a point the space, either a direction
  1765. * Reminder: js uses a left handed forward facing system
  1766. */
  1767. export class Vector3 {
  1768. /**
  1769. * Defines the first coordinates (on X axis)
  1770. */
  1771. x: number;
  1772. /**
  1773. * Defines the second coordinates (on Y axis)
  1774. */
  1775. y: number;
  1776. /**
  1777. * Defines the third coordinates (on Z axis)
  1778. */
  1779. z: number;
  1780. private static _UpReadOnly;
  1781. private static _ZeroReadOnly;
  1782. /**
  1783. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1784. * @param x defines the first coordinates (on X axis)
  1785. * @param y defines the second coordinates (on Y axis)
  1786. * @param z defines the third coordinates (on Z axis)
  1787. */
  1788. constructor(
  1789. /**
  1790. * Defines the first coordinates (on X axis)
  1791. */
  1792. x?: number,
  1793. /**
  1794. * Defines the second coordinates (on Y axis)
  1795. */
  1796. y?: number,
  1797. /**
  1798. * Defines the third coordinates (on Z axis)
  1799. */
  1800. z?: number);
  1801. /**
  1802. * Creates a string representation of the Vector3
  1803. * @returns a string with the Vector3 coordinates.
  1804. */
  1805. toString(): string;
  1806. /**
  1807. * Gets the class name
  1808. * @returns the string "Vector3"
  1809. */
  1810. getClassName(): string;
  1811. /**
  1812. * Creates the Vector3 hash code
  1813. * @returns a number which tends to be unique between Vector3 instances
  1814. */
  1815. getHashCode(): number;
  1816. /**
  1817. * Creates an array containing three elements : the coordinates of the Vector3
  1818. * @returns a new array of numbers
  1819. */
  1820. asArray(): number[];
  1821. /**
  1822. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1823. * @param array defines the destination array
  1824. * @param index defines the offset in the destination array
  1825. * @returns the current Vector3
  1826. */
  1827. toArray(array: FloatArray, index?: number): Vector3;
  1828. /**
  1829. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1830. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1831. */
  1832. toQuaternion(): Quaternion;
  1833. /**
  1834. * Adds the given vector to the current Vector3
  1835. * @param otherVector defines the second operand
  1836. * @returns the current updated Vector3
  1837. */
  1838. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1839. /**
  1840. * Adds the given coordinates to the current Vector3
  1841. * @param x defines the x coordinate of the operand
  1842. * @param y defines the y coordinate of the operand
  1843. * @param z defines the z coordinate of the operand
  1844. * @returns the current updated Vector3
  1845. */
  1846. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1847. /**
  1848. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1849. * @param otherVector defines the second operand
  1850. * @returns the resulting Vector3
  1851. */
  1852. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1853. /**
  1854. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1855. * @param otherVector defines the second operand
  1856. * @param result defines the Vector3 object where to store the result
  1857. * @returns the current Vector3
  1858. */
  1859. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1860. /**
  1861. * Subtract the given vector from the current Vector3
  1862. * @param otherVector defines the second operand
  1863. * @returns the current updated Vector3
  1864. */
  1865. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1866. /**
  1867. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1868. * @param otherVector defines the second operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1872. /**
  1873. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1874. * @param otherVector defines the second operand
  1875. * @param result defines the Vector3 object where to store the result
  1876. * @returns the current Vector3
  1877. */
  1878. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1879. /**
  1880. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1881. * @param x defines the x coordinate of the operand
  1882. * @param y defines the y coordinate of the operand
  1883. * @param z defines the z coordinate of the operand
  1884. * @returns the resulting Vector3
  1885. */
  1886. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1887. /**
  1888. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1889. * @param x defines the x coordinate of the operand
  1890. * @param y defines the y coordinate of the operand
  1891. * @param z defines the z coordinate of the operand
  1892. * @param result defines the Vector3 object where to store the result
  1893. * @returns the current Vector3
  1894. */
  1895. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1896. /**
  1897. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1898. * @returns a new Vector3
  1899. */
  1900. negate(): Vector3;
  1901. /**
  1902. * Multiplies the Vector3 coordinates by the float "scale"
  1903. * @param scale defines the multiplier factor
  1904. * @returns the current updated Vector3
  1905. */
  1906. scaleInPlace(scale: number): Vector3;
  1907. /**
  1908. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1909. * @param scale defines the multiplier factor
  1910. * @returns a new Vector3
  1911. */
  1912. scale(scale: number): Vector3;
  1913. /**
  1914. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1915. * @param scale defines the multiplier factor
  1916. * @param result defines the Vector3 object where to store the result
  1917. * @returns the current Vector3
  1918. */
  1919. scaleToRef(scale: number, result: Vector3): Vector3;
  1920. /**
  1921. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1922. * @param scale defines the scale factor
  1923. * @param result defines the Vector3 object where to store the result
  1924. * @returns the unmodified current Vector3
  1925. */
  1926. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1927. /**
  1928. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1929. * @param otherVector defines the second operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1933. /**
  1934. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1935. * @param otherVector defines the second operand
  1936. * @param epsilon defines the minimal distance to define values as equals
  1937. * @returns true if both vectors are distant less than epsilon
  1938. */
  1939. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1940. /**
  1941. * Returns true if the current Vector3 coordinates equals the given floats
  1942. * @param x defines the x coordinate of the operand
  1943. * @param y defines the y coordinate of the operand
  1944. * @param z defines the z coordinate of the operand
  1945. * @returns true if both vectors are equals
  1946. */
  1947. equalsToFloats(x: number, y: number, z: number): boolean;
  1948. /**
  1949. * Multiplies the current Vector3 coordinates by the given ones
  1950. * @param otherVector defines the second operand
  1951. * @returns the current updated Vector3
  1952. */
  1953. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1954. /**
  1955. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1956. * @param otherVector defines the second operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1960. /**
  1961. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1962. * @param otherVector defines the second operand
  1963. * @param result defines the Vector3 object where to store the result
  1964. * @returns the current Vector3
  1965. */
  1966. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1967. /**
  1968. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1969. * @param x defines the x coordinate of the operand
  1970. * @param y defines the y coordinate of the operand
  1971. * @param z defines the z coordinate of the operand
  1972. * @returns the new Vector3
  1973. */
  1974. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1975. /**
  1976. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1977. * @param otherVector defines the second operand
  1978. * @returns the new Vector3
  1979. */
  1980. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1981. /**
  1982. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1983. * @param otherVector defines the second operand
  1984. * @param result defines the Vector3 object where to store the result
  1985. * @returns the current Vector3
  1986. */
  1987. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1988. /**
  1989. * Divides the current Vector3 coordinates by the given ones.
  1990. * @param otherVector defines the second operand
  1991. * @returns the current updated Vector3
  1992. */
  1993. divideInPlace(otherVector: Vector3): Vector3;
  1994. /**
  1995. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1996. * @param other defines the second operand
  1997. * @returns the current updated Vector3
  1998. */
  1999. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2000. /**
  2001. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2002. * @param other defines the second operand
  2003. * @returns the current updated Vector3
  2004. */
  2005. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2006. /**
  2007. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2008. * @param x defines the x coordinate of the operand
  2009. * @param y defines the y coordinate of the operand
  2010. * @param z defines the z coordinate of the operand
  2011. * @returns the current updated Vector3
  2012. */
  2013. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2014. /**
  2015. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2016. * @param x defines the x coordinate of the operand
  2017. * @param y defines the y coordinate of the operand
  2018. * @param z defines the z coordinate of the operand
  2019. * @returns the current updated Vector3
  2020. */
  2021. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2022. /**
  2023. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2024. * Check if is non uniform within a certain amount of decimal places to account for this
  2025. * @param epsilon the amount the values can differ
  2026. * @returns if the the vector is non uniform to a certain number of decimal places
  2027. */
  2028. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2029. /**
  2030. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2031. */
  2032. readonly isNonUniform: boolean;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. floor(): Vector3;
  2038. /**
  2039. * Gets a new Vector3 from current Vector3 floored values
  2040. * @returns a new Vector3
  2041. */
  2042. fract(): Vector3;
  2043. /**
  2044. * Gets the length of the Vector3
  2045. * @returns the length of the Vector3
  2046. */
  2047. length(): number;
  2048. /**
  2049. * Gets the squared length of the Vector3
  2050. * @returns squared length of the Vector3
  2051. */
  2052. lengthSquared(): number;
  2053. /**
  2054. * Normalize the current Vector3.
  2055. * Please note that this is an in place operation.
  2056. * @returns the current updated Vector3
  2057. */
  2058. normalize(): Vector3;
  2059. /**
  2060. * Reorders the x y z properties of the vector in place
  2061. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2062. * @returns the current updated vector
  2063. */
  2064. reorderInPlace(order: string): this;
  2065. /**
  2066. * Rotates the vector around 0,0,0 by a quaternion
  2067. * @param quaternion the rotation quaternion
  2068. * @param result vector to store the result
  2069. * @returns the resulting vector
  2070. */
  2071. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2072. /**
  2073. * Rotates a vector around a given point
  2074. * @param quaternion the rotation quaternion
  2075. * @param point the point to rotate around
  2076. * @param result vector to store the result
  2077. * @returns the resulting vector
  2078. */
  2079. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2080. /**
  2081. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2082. * The cross product is then orthogonal to both current and "other"
  2083. * @param other defines the right operand
  2084. * @returns the cross product
  2085. */
  2086. cross(other: Vector3): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 with the given input length.
  2089. * Please note that this is an in place operation.
  2090. * @param len the length of the vector
  2091. * @returns the current updated Vector3
  2092. */
  2093. normalizeFromLength(len: number): Vector3;
  2094. /**
  2095. * Normalize the current Vector3 to a new vector
  2096. * @returns the new Vector3
  2097. */
  2098. normalizeToNew(): Vector3;
  2099. /**
  2100. * Normalize the current Vector3 to the reference
  2101. * @param reference define the Vector3 to update
  2102. * @returns the updated Vector3
  2103. */
  2104. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2105. /**
  2106. * Creates a new Vector3 copied from the current Vector3
  2107. * @returns the new Vector3
  2108. */
  2109. clone(): Vector3;
  2110. /**
  2111. * Copies the given vector coordinates to the current Vector3 ones
  2112. * @param source defines the source Vector3
  2113. * @returns the current updated Vector3
  2114. */
  2115. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2116. /**
  2117. * Copies the given floats to the current Vector3 coordinates
  2118. * @param x defines the x coordinate of the operand
  2119. * @param y defines the y coordinate of the operand
  2120. * @param z defines the z coordinate of the operand
  2121. * @returns the current updated Vector3
  2122. */
  2123. copyFromFloats(x: number, y: number, z: number): Vector3;
  2124. /**
  2125. * Copies the given floats to the current Vector3 coordinates
  2126. * @param x defines the x coordinate of the operand
  2127. * @param y defines the y coordinate of the operand
  2128. * @param z defines the z coordinate of the operand
  2129. * @returns the current updated Vector3
  2130. */
  2131. set(x: number, y: number, z: number): Vector3;
  2132. /**
  2133. * Copies the given float to the current Vector3 coordinates
  2134. * @param v defines the x, y and z coordinates of the operand
  2135. * @returns the current updated Vector3
  2136. */
  2137. setAll(v: number): Vector3;
  2138. /**
  2139. * Get the clip factor between two vectors
  2140. * @param vector0 defines the first operand
  2141. * @param vector1 defines the second operand
  2142. * @param axis defines the axis to use
  2143. * @param size defines the size along the axis
  2144. * @returns the clip factor
  2145. */
  2146. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2147. /**
  2148. * Get angle between two vectors
  2149. * @param vector0 angle between vector0 and vector1
  2150. * @param vector1 angle between vector0 and vector1
  2151. * @param normal direction of the normal
  2152. * @return the angle between vector0 and vector1
  2153. */
  2154. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2155. /**
  2156. * Returns a new Vector3 set from the index "offset" of the given array
  2157. * @param array defines the source array
  2158. * @param offset defines the offset in the source array
  2159. * @returns the new Vector3
  2160. */
  2161. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2162. /**
  2163. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2164. * This function is deprecated. Use FromArray instead
  2165. * @param array defines the source array
  2166. * @param offset defines the offset in the source array
  2167. * @returns the new Vector3
  2168. */
  2169. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2170. /**
  2171. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2172. * @param array defines the source array
  2173. * @param offset defines the offset in the source array
  2174. * @param result defines the Vector3 where to store the result
  2175. */
  2176. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2177. /**
  2178. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2179. * This function is deprecated. Use FromArrayToRef instead.
  2180. * @param array defines the source array
  2181. * @param offset defines the offset in the source array
  2182. * @param result defines the Vector3 where to store the result
  2183. */
  2184. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2185. /**
  2186. * Sets the given vector "result" with the given floats.
  2187. * @param x defines the x coordinate of the source
  2188. * @param y defines the y coordinate of the source
  2189. * @param z defines the z coordinate of the source
  2190. * @param result defines the Vector3 where to store the result
  2191. */
  2192. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2193. /**
  2194. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2195. * @returns a new empty Vector3
  2196. */
  2197. static Zero(): Vector3;
  2198. /**
  2199. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2200. * @returns a new unit Vector3
  2201. */
  2202. static One(): Vector3;
  2203. /**
  2204. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2205. * @returns a new up Vector3
  2206. */
  2207. static Up(): Vector3;
  2208. /**
  2209. * Gets a up Vector3 that must not be updated
  2210. */
  2211. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2212. /**
  2213. * Gets a zero Vector3 that must not be updated
  2214. */
  2215. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2216. /**
  2217. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2218. * @returns a new down Vector3
  2219. */
  2220. static Down(): Vector3;
  2221. /**
  2222. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2223. * @returns a new forward Vector3
  2224. */
  2225. static Forward(): Vector3;
  2226. /**
  2227. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2228. * @returns a new forward Vector3
  2229. */
  2230. static Backward(): Vector3;
  2231. /**
  2232. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2233. * @returns a new right Vector3
  2234. */
  2235. static Right(): Vector3;
  2236. /**
  2237. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2238. * @returns a new left Vector3
  2239. */
  2240. static Left(): Vector3;
  2241. /**
  2242. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2243. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2244. * @param vector defines the Vector3 to transform
  2245. * @param transformation defines the transformation matrix
  2246. * @returns the transformed Vector3
  2247. */
  2248. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2249. /**
  2250. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2251. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2252. * @param vector defines the Vector3 to transform
  2253. * @param transformation defines the transformation matrix
  2254. * @param result defines the Vector3 where to store the result
  2255. */
  2256. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2257. /**
  2258. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2259. * This method computes tranformed coordinates only, not transformed direction vectors
  2260. * @param x define the x coordinate of the source vector
  2261. * @param y define the y coordinate of the source vector
  2262. * @param z define the z coordinate of the source vector
  2263. * @param transformation defines the transformation matrix
  2264. * @param result defines the Vector3 where to store the result
  2265. */
  2266. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2267. /**
  2268. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2269. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2270. * @param vector defines the Vector3 to transform
  2271. * @param transformation defines the transformation matrix
  2272. * @returns the new Vector3
  2273. */
  2274. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2275. /**
  2276. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2277. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2278. * @param vector defines the Vector3 to transform
  2279. * @param transformation defines the transformation matrix
  2280. * @param result defines the Vector3 where to store the result
  2281. */
  2282. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2283. /**
  2284. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2285. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2286. * @param x define the x coordinate of the source vector
  2287. * @param y define the y coordinate of the source vector
  2288. * @param z define the z coordinate of the source vector
  2289. * @param transformation defines the transformation matrix
  2290. * @param result defines the Vector3 where to store the result
  2291. */
  2292. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2293. /**
  2294. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2295. * @param value1 defines the first control point
  2296. * @param value2 defines the second control point
  2297. * @param value3 defines the third control point
  2298. * @param value4 defines the fourth control point
  2299. * @param amount defines the amount on the spline to use
  2300. * @returns the new Vector3
  2301. */
  2302. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2303. /**
  2304. * 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"
  2305. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2306. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2307. * @param value defines the current value
  2308. * @param min defines the lower range value
  2309. * @param max defines the upper range value
  2310. * @returns the new Vector3
  2311. */
  2312. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2313. /**
  2314. * 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"
  2315. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2316. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2317. * @param value defines the current value
  2318. * @param min defines the lower range value
  2319. * @param max defines the upper range value
  2320. * @param result defines the Vector3 where to store the result
  2321. */
  2322. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2323. /**
  2324. * Checks if a given vector is inside a specific range
  2325. * @param v defines the vector to test
  2326. * @param min defines the minimum range
  2327. * @param max defines the maximum range
  2328. */
  2329. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2330. /**
  2331. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2332. * @param value1 defines the first control point
  2333. * @param tangent1 defines the first tangent vector
  2334. * @param value2 defines the second control point
  2335. * @param tangent2 defines the second tangent vector
  2336. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2337. * @returns the new Vector3
  2338. */
  2339. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2340. /**
  2341. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2342. * @param start defines the start value
  2343. * @param end defines the end value
  2344. * @param amount max defines amount between both (between 0 and 1)
  2345. * @returns the new Vector3
  2346. */
  2347. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2348. /**
  2349. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2350. * @param start defines the start value
  2351. * @param end defines the end value
  2352. * @param amount max defines amount between both (between 0 and 1)
  2353. * @param result defines the Vector3 where to store the result
  2354. */
  2355. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2356. /**
  2357. * Returns the dot product (float) between the vectors "left" and "right"
  2358. * @param left defines the left operand
  2359. * @param right defines the right operand
  2360. * @returns the dot product
  2361. */
  2362. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2363. /**
  2364. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2365. * The cross product is then orthogonal to both "left" and "right"
  2366. * @param left defines the left operand
  2367. * @param right defines the right operand
  2368. * @returns the cross product
  2369. */
  2370. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Sets the given vector "result" with the cross product of "left" and "right"
  2373. * The cross product is then orthogonal to both "left" and "right"
  2374. * @param left defines the left operand
  2375. * @param right defines the right operand
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2379. /**
  2380. * Returns a new Vector3 as the normalization of the given vector
  2381. * @param vector defines the Vector3 to normalize
  2382. * @returns the new Vector3
  2383. */
  2384. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2385. /**
  2386. * Sets the given vector "result" with the normalization of the given first vector
  2387. * @param vector defines the Vector3 to normalize
  2388. * @param result defines the Vector3 where to store the result
  2389. */
  2390. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2391. /**
  2392. * Project a Vector3 onto screen space
  2393. * @param vector defines the Vector3 to project
  2394. * @param world defines the world matrix to use
  2395. * @param transform defines the transform (view x projection) matrix to use
  2396. * @param viewport defines the screen viewport to use
  2397. * @returns the new Vector3
  2398. */
  2399. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2400. /** @hidden */
  2401. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2402. /**
  2403. * Unproject from screen space to object space
  2404. * @param source defines the screen space Vector3 to use
  2405. * @param viewportWidth defines the current width of the viewport
  2406. * @param viewportHeight defines the current height of the viewport
  2407. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2408. * @param transform defines the transform (view x projection) matrix to use
  2409. * @returns the new Vector3
  2410. */
  2411. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2412. /**
  2413. * Unproject from screen space to object space
  2414. * @param source defines the screen space Vector3 to use
  2415. * @param viewportWidth defines the current width of the viewport
  2416. * @param viewportHeight defines the current height of the viewport
  2417. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2418. * @param view defines the view matrix to use
  2419. * @param projection defines the projection matrix to use
  2420. * @returns the new Vector3
  2421. */
  2422. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2423. /**
  2424. * Unproject from screen space to object space
  2425. * @param source defines the screen space Vector3 to use
  2426. * @param viewportWidth defines the current width of the viewport
  2427. * @param viewportHeight defines the current height of the viewport
  2428. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2429. * @param view defines the view matrix to use
  2430. * @param projection defines the projection matrix to use
  2431. * @param result defines the Vector3 where to store the result
  2432. */
  2433. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2434. /**
  2435. * Unproject from screen space to object space
  2436. * @param sourceX defines the screen space x coordinate to use
  2437. * @param sourceY defines the screen space y coordinate to use
  2438. * @param sourceZ defines the screen space z coordinate to use
  2439. * @param viewportWidth defines the current width of the viewport
  2440. * @param viewportHeight defines the current height of the viewport
  2441. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2442. * @param view defines the view matrix to use
  2443. * @param projection defines the projection matrix to use
  2444. * @param result defines the Vector3 where to store the result
  2445. */
  2446. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2447. /**
  2448. * Gets the minimal coordinate values between two Vector3
  2449. * @param left defines the first operand
  2450. * @param right defines the second operand
  2451. * @returns the new Vector3
  2452. */
  2453. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2454. /**
  2455. * Gets the maximal coordinate values between two Vector3
  2456. * @param left defines the first operand
  2457. * @param right defines the second operand
  2458. * @returns the new Vector3
  2459. */
  2460. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2461. /**
  2462. * Returns the distance between the vectors "value1" and "value2"
  2463. * @param value1 defines the first operand
  2464. * @param value2 defines the second operand
  2465. * @returns the distance
  2466. */
  2467. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2468. /**
  2469. * Returns the squared distance between the vectors "value1" and "value2"
  2470. * @param value1 defines the first operand
  2471. * @param value2 defines the second operand
  2472. * @returns the squared distance
  2473. */
  2474. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2475. /**
  2476. * Returns a new Vector3 located at the center between "value1" and "value2"
  2477. * @param value1 defines the first operand
  2478. * @param value2 defines the second operand
  2479. * @returns the new Vector3
  2480. */
  2481. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2484. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2485. * to something in order to rotate it from its local system to the given target system
  2486. * Note: axis1, axis2 and axis3 are normalized during this operation
  2487. * @param axis1 defines the first axis
  2488. * @param axis2 defines the second axis
  2489. * @param axis3 defines the third axis
  2490. * @returns a new Vector3
  2491. */
  2492. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2493. /**
  2494. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2495. * @param axis1 defines the first axis
  2496. * @param axis2 defines the second axis
  2497. * @param axis3 defines the third axis
  2498. * @param ref defines the Vector3 where to store the result
  2499. */
  2500. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2501. }
  2502. /**
  2503. * Vector4 class created for EulerAngle class conversion to Quaternion
  2504. */
  2505. export class Vector4 {
  2506. /** x value of the vector */
  2507. x: number;
  2508. /** y value of the vector */
  2509. y: number;
  2510. /** z value of the vector */
  2511. z: number;
  2512. /** w value of the vector */
  2513. w: number;
  2514. /**
  2515. * Creates a Vector4 object from the given floats.
  2516. * @param x x value of the vector
  2517. * @param y y value of the vector
  2518. * @param z z value of the vector
  2519. * @param w w value of the vector
  2520. */
  2521. constructor(
  2522. /** x value of the vector */
  2523. x: number,
  2524. /** y value of the vector */
  2525. y: number,
  2526. /** z value of the vector */
  2527. z: number,
  2528. /** w value of the vector */
  2529. w: number);
  2530. /**
  2531. * Returns the string with the Vector4 coordinates.
  2532. * @returns a string containing all the vector values
  2533. */
  2534. toString(): string;
  2535. /**
  2536. * Returns the string "Vector4".
  2537. * @returns "Vector4"
  2538. */
  2539. getClassName(): string;
  2540. /**
  2541. * Returns the Vector4 hash code.
  2542. * @returns a unique hash code
  2543. */
  2544. getHashCode(): number;
  2545. /**
  2546. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2547. * @returns the resulting array
  2548. */
  2549. asArray(): number[];
  2550. /**
  2551. * Populates the given array from the given index with the Vector4 coordinates.
  2552. * @param array array to populate
  2553. * @param index index of the array to start at (default: 0)
  2554. * @returns the Vector4.
  2555. */
  2556. toArray(array: FloatArray, index?: number): Vector4;
  2557. /**
  2558. * Adds the given vector to the current Vector4.
  2559. * @param otherVector the vector to add
  2560. * @returns the updated Vector4.
  2561. */
  2562. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2563. /**
  2564. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2565. * @param otherVector the vector to add
  2566. * @returns the resulting vector
  2567. */
  2568. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2569. /**
  2570. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2571. * @param otherVector the vector to add
  2572. * @param result the vector to store the result
  2573. * @returns the current Vector4.
  2574. */
  2575. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2576. /**
  2577. * Subtract in place the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @returns the updated Vector4.
  2580. */
  2581. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2582. /**
  2583. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2584. * @param otherVector the vector to add
  2585. * @returns the new vector with the result
  2586. */
  2587. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2588. /**
  2589. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2590. * @param otherVector the vector to subtract
  2591. * @param result the vector to store the result
  2592. * @returns the current Vector4.
  2593. */
  2594. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2595. /**
  2596. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. */
  2598. /**
  2599. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2600. * @param x value to subtract
  2601. * @param y value to subtract
  2602. * @param z value to subtract
  2603. * @param w value to subtract
  2604. * @returns new vector containing the result
  2605. */
  2606. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2607. /**
  2608. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2609. * @param x value to subtract
  2610. * @param y value to subtract
  2611. * @param z value to subtract
  2612. * @param w value to subtract
  2613. * @param result the vector to store the result in
  2614. * @returns the current Vector4.
  2615. */
  2616. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2617. /**
  2618. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2619. * @returns a new vector with the negated values
  2620. */
  2621. negate(): Vector4;
  2622. /**
  2623. * Multiplies the current Vector4 coordinates by scale (float).
  2624. * @param scale the number to scale with
  2625. * @returns the updated Vector4.
  2626. */
  2627. scaleInPlace(scale: number): Vector4;
  2628. /**
  2629. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2630. * @param scale the number to scale with
  2631. * @returns a new vector with the result
  2632. */
  2633. scale(scale: number): Vector4;
  2634. /**
  2635. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2636. * @param scale the number to scale with
  2637. * @param result a vector to store the result in
  2638. * @returns the current Vector4.
  2639. */
  2640. scaleToRef(scale: number, result: Vector4): Vector4;
  2641. /**
  2642. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2643. * @param scale defines the scale factor
  2644. * @param result defines the Vector4 object where to store the result
  2645. * @returns the unmodified current Vector4
  2646. */
  2647. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2648. /**
  2649. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2650. * @param otherVector the vector to compare against
  2651. * @returns true if they are equal
  2652. */
  2653. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2654. /**
  2655. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2656. * @param otherVector vector to compare against
  2657. * @param epsilon (Default: very small number)
  2658. * @returns true if they are equal
  2659. */
  2660. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2661. /**
  2662. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2663. * @param x x value to compare against
  2664. * @param y y value to compare against
  2665. * @param z z value to compare against
  2666. * @param w w value to compare against
  2667. * @returns true if equal
  2668. */
  2669. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2670. /**
  2671. * Multiplies in place the current Vector4 by the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @returns the updated Vector4.
  2674. */
  2675. multiplyInPlace(otherVector: Vector4): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2678. * @param otherVector vector to multiple with
  2679. * @returns resulting new vector
  2680. */
  2681. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2682. /**
  2683. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2684. * @param otherVector vector to multiple with
  2685. * @param result vector to store the result
  2686. * @returns the current Vector4.
  2687. */
  2688. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2689. /**
  2690. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2691. * @param x x value multiply with
  2692. * @param y y value multiply with
  2693. * @param z z value multiply with
  2694. * @param w w value multiply with
  2695. * @returns resulting new vector
  2696. */
  2697. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2698. /**
  2699. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2700. * @param otherVector vector to devide with
  2701. * @returns resulting new vector
  2702. */
  2703. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2704. /**
  2705. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2706. * @param otherVector vector to devide with
  2707. * @param result vector to store the result
  2708. * @returns the current Vector4.
  2709. */
  2710. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2711. /**
  2712. * Divides the current Vector3 coordinates by the given ones.
  2713. * @param otherVector vector to devide with
  2714. * @returns the updated Vector3.
  2715. */
  2716. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2719. * @param other defines the second operand
  2720. * @returns the current updated Vector4
  2721. */
  2722. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2723. /**
  2724. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2725. * @param other defines the second operand
  2726. * @returns the current updated Vector4
  2727. */
  2728. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2729. /**
  2730. * Gets a new Vector4 from current Vector4 floored values
  2731. * @returns a new Vector4
  2732. */
  2733. floor(): Vector4;
  2734. /**
  2735. * Gets a new Vector4 from current Vector3 floored values
  2736. * @returns a new Vector4
  2737. */
  2738. fract(): Vector4;
  2739. /**
  2740. * Returns the Vector4 length (float).
  2741. * @returns the length
  2742. */
  2743. length(): number;
  2744. /**
  2745. * Returns the Vector4 squared length (float).
  2746. * @returns the length squared
  2747. */
  2748. lengthSquared(): number;
  2749. /**
  2750. * Normalizes in place the Vector4.
  2751. * @returns the updated Vector4.
  2752. */
  2753. normalize(): Vector4;
  2754. /**
  2755. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2756. * @returns this converted to a new vector3
  2757. */
  2758. toVector3(): Vector3;
  2759. /**
  2760. * Returns a new Vector4 copied from the current one.
  2761. * @returns the new cloned vector
  2762. */
  2763. clone(): Vector4;
  2764. /**
  2765. * Updates the current Vector4 with the given one coordinates.
  2766. * @param source the source vector to copy from
  2767. * @returns the updated Vector4.
  2768. */
  2769. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2770. /**
  2771. * Updates the current Vector4 coordinates with the given floats.
  2772. * @param x float to copy from
  2773. * @param y float to copy from
  2774. * @param z float to copy from
  2775. * @param w float to copy from
  2776. * @returns the updated Vector4.
  2777. */
  2778. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2779. /**
  2780. * Updates the current Vector4 coordinates with the given floats.
  2781. * @param x float to set from
  2782. * @param y float to set from
  2783. * @param z float to set from
  2784. * @param w float to set from
  2785. * @returns the updated Vector4.
  2786. */
  2787. set(x: number, y: number, z: number, w: number): Vector4;
  2788. /**
  2789. * Copies the given float to the current Vector3 coordinates
  2790. * @param v defines the x, y, z and w coordinates of the operand
  2791. * @returns the current updated Vector3
  2792. */
  2793. setAll(v: number): Vector4;
  2794. /**
  2795. * Returns a new Vector4 set from the starting index of the given array.
  2796. * @param array the array to pull values from
  2797. * @param offset the offset into the array to start at
  2798. * @returns the new vector
  2799. */
  2800. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2801. /**
  2802. * Updates the given vector "result" from the starting index of the given array.
  2803. * @param array the array to pull values from
  2804. * @param offset the offset into the array to start at
  2805. * @param result the vector to store the result in
  2806. */
  2807. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2808. /**
  2809. * Updates the given vector "result" from the starting index of the given Float32Array.
  2810. * @param array the array to pull values from
  2811. * @param offset the offset into the array to start at
  2812. * @param result the vector to store the result in
  2813. */
  2814. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2815. /**
  2816. * Updates the given vector "result" coordinates from the given floats.
  2817. * @param x float to set from
  2818. * @param y float to set from
  2819. * @param z float to set from
  2820. * @param w float to set from
  2821. * @param result the vector to the floats in
  2822. */
  2823. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2824. /**
  2825. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2826. * @returns the new vector
  2827. */
  2828. static Zero(): Vector4;
  2829. /**
  2830. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2831. * @returns the new vector
  2832. */
  2833. static One(): Vector4;
  2834. /**
  2835. * Returns a new normalized Vector4 from the given one.
  2836. * @param vector the vector to normalize
  2837. * @returns the vector
  2838. */
  2839. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2840. /**
  2841. * Updates the given vector "result" from the normalization of the given one.
  2842. * @param vector the vector to normalize
  2843. * @param result the vector to store the result in
  2844. */
  2845. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2846. /**
  2847. * Returns a vector with the minimum values from the left and right vectors
  2848. * @param left left vector to minimize
  2849. * @param right right vector to minimize
  2850. * @returns a new vector with the minimum of the left and right vector values
  2851. */
  2852. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2853. /**
  2854. * Returns a vector with the maximum values from the left and right vectors
  2855. * @param left left vector to maximize
  2856. * @param right right vector to maximize
  2857. * @returns a new vector with the maximum of the left and right vector values
  2858. */
  2859. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2860. /**
  2861. * Returns the distance (float) between the vectors "value1" and "value2".
  2862. * @param value1 value to calulate the distance between
  2863. * @param value2 value to calulate the distance between
  2864. * @return the distance between the two vectors
  2865. */
  2866. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2867. /**
  2868. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2869. * @param value1 value to calulate the distance between
  2870. * @param value2 value to calulate the distance between
  2871. * @return the distance between the two vectors squared
  2872. */
  2873. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2874. /**
  2875. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2876. * @param value1 value to calulate the center between
  2877. * @param value2 value to calulate the center between
  2878. * @return the center between the two vectors
  2879. */
  2880. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2881. /**
  2882. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2883. * This methods computes transformed normalized direction vectors only.
  2884. * @param vector the vector to transform
  2885. * @param transformation the transformation matrix to apply
  2886. * @returns the new vector
  2887. */
  2888. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2889. /**
  2890. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2891. * This methods computes transformed normalized direction vectors only.
  2892. * @param vector the vector to transform
  2893. * @param transformation the transformation matrix to apply
  2894. * @param result the vector to store the result in
  2895. */
  2896. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2897. /**
  2898. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2899. * This methods computes transformed normalized direction vectors only.
  2900. * @param x value to transform
  2901. * @param y value to transform
  2902. * @param z value to transform
  2903. * @param w value to transform
  2904. * @param transformation the transformation matrix to apply
  2905. * @param result the vector to store the results in
  2906. */
  2907. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2908. /**
  2909. * Creates a new Vector4 from a Vector3
  2910. * @param source defines the source data
  2911. * @param w defines the 4th component (default is 0)
  2912. * @returns a new Vector4
  2913. */
  2914. static FromVector3(source: Vector3, w?: number): Vector4;
  2915. }
  2916. /**
  2917. * Class used to store quaternion data
  2918. * @see https://en.wikipedia.org/wiki/Quaternion
  2919. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2920. */
  2921. export class Quaternion {
  2922. /** defines the first component (0 by default) */
  2923. x: number;
  2924. /** defines the second component (0 by default) */
  2925. y: number;
  2926. /** defines the third component (0 by default) */
  2927. z: number;
  2928. /** defines the fourth component (1.0 by default) */
  2929. w: number;
  2930. /**
  2931. * Creates a new Quaternion from the given floats
  2932. * @param x defines the first component (0 by default)
  2933. * @param y defines the second component (0 by default)
  2934. * @param z defines the third component (0 by default)
  2935. * @param w defines the fourth component (1.0 by default)
  2936. */
  2937. constructor(
  2938. /** defines the first component (0 by default) */
  2939. x?: number,
  2940. /** defines the second component (0 by default) */
  2941. y?: number,
  2942. /** defines the third component (0 by default) */
  2943. z?: number,
  2944. /** defines the fourth component (1.0 by default) */
  2945. w?: number);
  2946. /**
  2947. * Gets a string representation for the current quaternion
  2948. * @returns a string with the Quaternion coordinates
  2949. */
  2950. toString(): string;
  2951. /**
  2952. * Gets the class name of the quaternion
  2953. * @returns the string "Quaternion"
  2954. */
  2955. getClassName(): string;
  2956. /**
  2957. * Gets a hash code for this quaternion
  2958. * @returns the quaternion hash code
  2959. */
  2960. getHashCode(): number;
  2961. /**
  2962. * Copy the quaternion to an array
  2963. * @returns a new array populated with 4 elements from the quaternion coordinates
  2964. */
  2965. asArray(): number[];
  2966. /**
  2967. * Check if two quaternions are equals
  2968. * @param otherQuaternion defines the second operand
  2969. * @return true if the current quaternion and the given one coordinates are strictly equals
  2970. */
  2971. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2972. /**
  2973. * Clone the current quaternion
  2974. * @returns a new quaternion copied from the current one
  2975. */
  2976. clone(): Quaternion;
  2977. /**
  2978. * Copy a quaternion to the current one
  2979. * @param other defines the other quaternion
  2980. * @returns the updated current quaternion
  2981. */
  2982. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2983. /**
  2984. * Updates the current quaternion with the given float coordinates
  2985. * @param x defines the x coordinate
  2986. * @param y defines the y coordinate
  2987. * @param z defines the z coordinate
  2988. * @param w defines the w coordinate
  2989. * @returns the updated current quaternion
  2990. */
  2991. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2992. /**
  2993. * Updates the current quaternion from the given float coordinates
  2994. * @param x defines the x coordinate
  2995. * @param y defines the y coordinate
  2996. * @param z defines the z coordinate
  2997. * @param w defines the w coordinate
  2998. * @returns the updated current quaternion
  2999. */
  3000. set(x: number, y: number, z: number, w: number): Quaternion;
  3001. /**
  3002. * Adds two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3005. */
  3006. add(other: DeepImmutable<Quaternion>): Quaternion;
  3007. /**
  3008. * Add a quaternion to the current one
  3009. * @param other defines the quaternion to add
  3010. * @returns the current quaternion
  3011. */
  3012. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3013. /**
  3014. * Subtract two quaternions
  3015. * @param other defines the second operand
  3016. * @returns a new quaternion as the subtraction result of the given one from the current one
  3017. */
  3018. subtract(other: Quaternion): Quaternion;
  3019. /**
  3020. * Multiplies the current quaternion by a scale factor
  3021. * @param value defines the scale factor
  3022. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3023. */
  3024. scale(value: number): Quaternion;
  3025. /**
  3026. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3027. * @param scale defines the scale factor
  3028. * @param result defines the Quaternion object where to store the result
  3029. * @returns the unmodified current quaternion
  3030. */
  3031. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3032. /**
  3033. * Multiplies in place the current quaternion by a scale factor
  3034. * @param value defines the scale factor
  3035. * @returns the current modified quaternion
  3036. */
  3037. scaleInPlace(value: number): Quaternion;
  3038. /**
  3039. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3040. * @param scale defines the scale factor
  3041. * @param result defines the Quaternion object where to store the result
  3042. * @returns the unmodified current quaternion
  3043. */
  3044. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3045. /**
  3046. * Multiplies two quaternions
  3047. * @param q1 defines the second operand
  3048. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3049. */
  3050. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3051. /**
  3052. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3053. * @param q1 defines the second operand
  3054. * @param result defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3058. /**
  3059. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3060. * @param q1 defines the second operand
  3061. * @returns the currentupdated quaternion
  3062. */
  3063. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3064. /**
  3065. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3066. * @param ref defines the target quaternion
  3067. * @returns the current quaternion
  3068. */
  3069. conjugateToRef(ref: Quaternion): Quaternion;
  3070. /**
  3071. * Conjugates in place (1-q) the current quaternion
  3072. * @returns the current updated quaternion
  3073. */
  3074. conjugateInPlace(): Quaternion;
  3075. /**
  3076. * Conjugates in place (1-q) the current quaternion
  3077. * @returns a new quaternion
  3078. */
  3079. conjugate(): Quaternion;
  3080. /**
  3081. * Gets length of current quaternion
  3082. * @returns the quaternion length (float)
  3083. */
  3084. length(): number;
  3085. /**
  3086. * Normalize in place the current quaternion
  3087. * @returns the current updated quaternion
  3088. */
  3089. normalize(): Quaternion;
  3090. /**
  3091. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3092. * @param order is a reserved parameter and is ignore for now
  3093. * @returns a new Vector3 containing the Euler angles
  3094. */
  3095. toEulerAngles(order?: string): Vector3;
  3096. /**
  3097. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3098. * @param result defines the vector which will be filled with the Euler angles
  3099. * @param order is a reserved parameter and is ignore for now
  3100. * @returns the current unchanged quaternion
  3101. */
  3102. toEulerAnglesToRef(result: Vector3): Quaternion;
  3103. /**
  3104. * Updates the given rotation matrix with the current quaternion values
  3105. * @param result defines the target matrix
  3106. * @returns the current unchanged quaternion
  3107. */
  3108. toRotationMatrix(result: Matrix): Quaternion;
  3109. /**
  3110. * Updates the current quaternion from the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @returns the current updated quaternion
  3113. */
  3114. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3115. /**
  3116. * Creates a new quaternion from a rotation matrix
  3117. * @param matrix defines the source matrix
  3118. * @returns a new quaternion created from the given rotation matrix values
  3119. */
  3120. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3121. /**
  3122. * Updates the given quaternion with the given rotation matrix values
  3123. * @param matrix defines the source matrix
  3124. * @param result defines the target quaternion
  3125. */
  3126. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3127. /**
  3128. * Returns the dot product (float) between the quaternions "left" and "right"
  3129. * @param left defines the left operand
  3130. * @param right defines the right operand
  3131. * @returns the dot product
  3132. */
  3133. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3134. /**
  3135. * Checks if the two quaternions are close to each other
  3136. * @param quat0 defines the first quaternion to check
  3137. * @param quat1 defines the second quaternion to check
  3138. * @returns true if the two quaternions are close to each other
  3139. */
  3140. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3141. /**
  3142. * Creates an empty quaternion
  3143. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3144. */
  3145. static Zero(): Quaternion;
  3146. /**
  3147. * Inverse a given quaternion
  3148. * @param q defines the source quaternion
  3149. * @returns a new quaternion as the inverted current quaternion
  3150. */
  3151. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3152. /**
  3153. * Inverse a given quaternion
  3154. * @param q defines the source quaternion
  3155. * @param result the quaternion the result will be stored in
  3156. * @returns the result quaternion
  3157. */
  3158. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3159. /**
  3160. * Creates an identity quaternion
  3161. * @returns the identity quaternion
  3162. */
  3163. static Identity(): Quaternion;
  3164. /**
  3165. * Gets a boolean indicating if the given quaternion is identity
  3166. * @param quaternion defines the quaternion to check
  3167. * @returns true if the quaternion is identity
  3168. */
  3169. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3170. /**
  3171. * Creates a quaternion from a rotation around an axis
  3172. * @param axis defines the axis to use
  3173. * @param angle defines the angle to use
  3174. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3175. */
  3176. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3177. /**
  3178. * Creates a rotation around an axis and stores it into the given quaternion
  3179. * @param axis defines the axis to use
  3180. * @param angle defines the angle to use
  3181. * @param result defines the target quaternion
  3182. * @returns the target quaternion
  3183. */
  3184. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3185. /**
  3186. * Creates a new quaternion from data stored into an array
  3187. * @param array defines the data source
  3188. * @param offset defines the offset in the source array where the data starts
  3189. * @returns a new quaternion
  3190. */
  3191. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3192. /**
  3193. * Create a quaternion from Euler rotation angles
  3194. * @param x Pitch
  3195. * @param y Yaw
  3196. * @param z Roll
  3197. * @returns the new Quaternion
  3198. */
  3199. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3200. /**
  3201. * Updates a quaternion from Euler rotation angles
  3202. * @param x Pitch
  3203. * @param y Yaw
  3204. * @param z Roll
  3205. * @param result the quaternion to store the result
  3206. * @returns the updated quaternion
  3207. */
  3208. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3209. /**
  3210. * Create a quaternion from Euler rotation vector
  3211. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3212. * @returns the new Quaternion
  3213. */
  3214. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3215. /**
  3216. * Updates a quaternion from Euler rotation vector
  3217. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3218. * @param result the quaternion to store the result
  3219. * @returns the updated quaternion
  3220. */
  3221. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3222. /**
  3223. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3224. * @param yaw defines the rotation around Y axis
  3225. * @param pitch defines the rotation around X axis
  3226. * @param roll defines the rotation around Z axis
  3227. * @returns the new quaternion
  3228. */
  3229. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3230. /**
  3231. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3232. * @param yaw defines the rotation around Y axis
  3233. * @param pitch defines the rotation around X axis
  3234. * @param roll defines the rotation around Z axis
  3235. * @param result defines the target quaternion
  3236. */
  3237. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3238. /**
  3239. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3240. * @param alpha defines the rotation around first axis
  3241. * @param beta defines the rotation around second axis
  3242. * @param gamma defines the rotation around third axis
  3243. * @returns the new quaternion
  3244. */
  3245. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3246. /**
  3247. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3248. * @param alpha defines the rotation around first axis
  3249. * @param beta defines the rotation around second axis
  3250. * @param gamma defines the rotation around third axis
  3251. * @param result defines the target quaternion
  3252. */
  3253. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3254. /**
  3255. * 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)
  3256. * @param axis1 defines the first axis
  3257. * @param axis2 defines the second axis
  3258. * @param axis3 defines the third axis
  3259. * @returns the new quaternion
  3260. */
  3261. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3262. /**
  3263. * 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
  3264. * @param axis1 defines the first axis
  3265. * @param axis2 defines the second axis
  3266. * @param axis3 defines the third axis
  3267. * @param ref defines the target quaternion
  3268. */
  3269. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3270. /**
  3271. * Interpolates between two quaternions
  3272. * @param left defines first quaternion
  3273. * @param right defines second quaternion
  3274. * @param amount defines the gradient to use
  3275. * @returns the new interpolated quaternion
  3276. */
  3277. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3278. /**
  3279. * Interpolates between two quaternions and stores it into a target quaternion
  3280. * @param left defines first quaternion
  3281. * @param right defines second quaternion
  3282. * @param amount defines the gradient to use
  3283. * @param result defines the target quaternion
  3284. */
  3285. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3286. /**
  3287. * Interpolate between two quaternions using Hermite interpolation
  3288. * @param value1 defines first quaternion
  3289. * @param tangent1 defines the incoming tangent
  3290. * @param value2 defines second quaternion
  3291. * @param tangent2 defines the outgoing tangent
  3292. * @param amount defines the target quaternion
  3293. * @returns the new interpolated quaternion
  3294. */
  3295. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3296. }
  3297. /**
  3298. * Class used to store matrix data (4x4)
  3299. */
  3300. export class Matrix {
  3301. private static _updateFlagSeed;
  3302. private static _identityReadOnly;
  3303. private _isIdentity;
  3304. private _isIdentityDirty;
  3305. private _isIdentity3x2;
  3306. private _isIdentity3x2Dirty;
  3307. /**
  3308. * Gets the update flag of the matrix which is an unique number for the matrix.
  3309. * It will be incremented every time the matrix data change.
  3310. * You can use it to speed the comparison between two versions of the same matrix.
  3311. */
  3312. updateFlag: number;
  3313. private readonly _m;
  3314. /**
  3315. * Gets the internal data of the matrix
  3316. */
  3317. readonly m: DeepImmutable<Float32Array>;
  3318. /** @hidden */
  3319. _markAsUpdated(): void;
  3320. /** @hidden */
  3321. private _updateIdentityStatus;
  3322. /**
  3323. * Creates an empty matrix (filled with zeros)
  3324. */
  3325. constructor();
  3326. /**
  3327. * Check if the current matrix is identity
  3328. * @returns true is the matrix is the identity matrix
  3329. */
  3330. isIdentity(): boolean;
  3331. /**
  3332. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3333. * @returns true is the matrix is the identity matrix
  3334. */
  3335. isIdentityAs3x2(): boolean;
  3336. /**
  3337. * Gets the determinant of the matrix
  3338. * @returns the matrix determinant
  3339. */
  3340. determinant(): number;
  3341. /**
  3342. * Returns the matrix as a Float32Array
  3343. * @returns the matrix underlying array
  3344. */
  3345. toArray(): DeepImmutable<Float32Array>;
  3346. /**
  3347. * Returns the matrix as a Float32Array
  3348. * @returns the matrix underlying array.
  3349. */
  3350. asArray(): DeepImmutable<Float32Array>;
  3351. /**
  3352. * Inverts the current matrix in place
  3353. * @returns the current inverted matrix
  3354. */
  3355. invert(): Matrix;
  3356. /**
  3357. * Sets all the matrix elements to zero
  3358. * @returns the current matrix
  3359. */
  3360. reset(): Matrix;
  3361. /**
  3362. * Adds the current matrix with a second one
  3363. * @param other defines the matrix to add
  3364. * @returns a new matrix as the addition of the current matrix and the given one
  3365. */
  3366. add(other: DeepImmutable<Matrix>): Matrix;
  3367. /**
  3368. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3369. * @param other defines the matrix to add
  3370. * @param result defines the target matrix
  3371. * @returns the current matrix
  3372. */
  3373. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3374. /**
  3375. * Adds in place the given matrix to the current matrix
  3376. * @param other defines the second operand
  3377. * @returns the current updated matrix
  3378. */
  3379. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3380. /**
  3381. * Sets the given matrix to the current inverted Matrix
  3382. * @param other defines the target matrix
  3383. * @returns the unmodified current matrix
  3384. */
  3385. invertToRef(other: Matrix): Matrix;
  3386. /**
  3387. * add a value at the specified position in the current Matrix
  3388. * @param index the index of the value within the matrix. between 0 and 15.
  3389. * @param value the value to be added
  3390. * @returns the current updated matrix
  3391. */
  3392. addAtIndex(index: number, value: number): Matrix;
  3393. /**
  3394. * mutiply the specified position in the current Matrix by a value
  3395. * @param index the index of the value within the matrix. between 0 and 15.
  3396. * @param value the value to be added
  3397. * @returns the current updated matrix
  3398. */
  3399. multiplyAtIndex(index: number, value: number): Matrix;
  3400. /**
  3401. * Inserts the translation vector (using 3 floats) in the current matrix
  3402. * @param x defines the 1st component of the translation
  3403. * @param y defines the 2nd component of the translation
  3404. * @param z defines the 3rd component of the translation
  3405. * @returns the current updated matrix
  3406. */
  3407. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3408. /**
  3409. * Adds the translation vector (using 3 floats) in the current matrix
  3410. * @param x defines the 1st component of the translation
  3411. * @param y defines the 2nd component of the translation
  3412. * @param z defines the 3rd component of the translation
  3413. * @returns the current updated matrix
  3414. */
  3415. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3416. /**
  3417. * Inserts the translation vector in the current matrix
  3418. * @param vector3 defines the translation to insert
  3419. * @returns the current updated matrix
  3420. */
  3421. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3422. /**
  3423. * Gets the translation value of the current matrix
  3424. * @returns a new Vector3 as the extracted translation from the matrix
  3425. */
  3426. getTranslation(): Vector3;
  3427. /**
  3428. * Fill a Vector3 with the extracted translation from the matrix
  3429. * @param result defines the Vector3 where to store the translation
  3430. * @returns the current matrix
  3431. */
  3432. getTranslationToRef(result: Vector3): Matrix;
  3433. /**
  3434. * Remove rotation and scaling part from the matrix
  3435. * @returns the updated matrix
  3436. */
  3437. removeRotationAndScaling(): Matrix;
  3438. /**
  3439. * Multiply two matrices
  3440. * @param other defines the second operand
  3441. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3442. */
  3443. multiply(other: DeepImmutable<Matrix>): Matrix;
  3444. /**
  3445. * Copy the current matrix from the given one
  3446. * @param other defines the source matrix
  3447. * @returns the current updated matrix
  3448. */
  3449. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3450. /**
  3451. * Populates the given array from the starting index with the current matrix values
  3452. * @param array defines the target array
  3453. * @param offset defines the offset in the target array where to start storing values
  3454. * @returns the current matrix
  3455. */
  3456. copyToArray(array: Float32Array, offset?: number): Matrix;
  3457. /**
  3458. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3459. * @param other defines the second operand
  3460. * @param result defines the matrix where to store the multiplication
  3461. * @returns the current matrix
  3462. */
  3463. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3464. /**
  3465. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3466. * @param other defines the second operand
  3467. * @param result defines the array where to store the multiplication
  3468. * @param offset defines the offset in the target array where to start storing values
  3469. * @returns the current matrix
  3470. */
  3471. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3472. /**
  3473. * Check equality between this matrix and a second one
  3474. * @param value defines the second matrix to compare
  3475. * @returns true is the current matrix and the given one values are strictly equal
  3476. */
  3477. equals(value: DeepImmutable<Matrix>): boolean;
  3478. /**
  3479. * Clone the current matrix
  3480. * @returns a new matrix from the current matrix
  3481. */
  3482. clone(): Matrix;
  3483. /**
  3484. * Returns the name of the current matrix class
  3485. * @returns the string "Matrix"
  3486. */
  3487. getClassName(): string;
  3488. /**
  3489. * Gets the hash code of the current matrix
  3490. * @returns the hash code
  3491. */
  3492. getHashCode(): number;
  3493. /**
  3494. * Decomposes the current Matrix into a translation, rotation and scaling components
  3495. * @param scale defines the scale vector3 given as a reference to update
  3496. * @param rotation defines the rotation quaternion given as a reference to update
  3497. * @param translation defines the translation vector3 given as a reference to update
  3498. * @returns true if operation was successful
  3499. */
  3500. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3501. /**
  3502. * Gets specific row of the matrix
  3503. * @param index defines the number of the row to get
  3504. * @returns the index-th row of the current matrix as a new Vector4
  3505. */
  3506. getRow(index: number): Nullable<Vector4>;
  3507. /**
  3508. * Sets the index-th row of the current matrix to the vector4 values
  3509. * @param index defines the number of the row to set
  3510. * @param row defines the target vector4
  3511. * @returns the updated current matrix
  3512. */
  3513. setRow(index: number, row: Vector4): Matrix;
  3514. /**
  3515. * Compute the transpose of the matrix
  3516. * @returns the new transposed matrix
  3517. */
  3518. transpose(): Matrix;
  3519. /**
  3520. * Compute the transpose of the matrix and store it in a given matrix
  3521. * @param result defines the target matrix
  3522. * @returns the current matrix
  3523. */
  3524. transposeToRef(result: Matrix): Matrix;
  3525. /**
  3526. * Sets the index-th row of the current matrix with the given 4 x float values
  3527. * @param index defines the row index
  3528. * @param x defines the x component to set
  3529. * @param y defines the y component to set
  3530. * @param z defines the z component to set
  3531. * @param w defines the w component to set
  3532. * @returns the updated current matrix
  3533. */
  3534. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3535. /**
  3536. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3537. * @param scale defines the scale factor
  3538. * @returns a new matrix
  3539. */
  3540. scale(scale: number): Matrix;
  3541. /**
  3542. * Scale the current matrix values by a factor to a given result matrix
  3543. * @param scale defines the scale factor
  3544. * @param result defines the matrix to store the result
  3545. * @returns the current matrix
  3546. */
  3547. scaleToRef(scale: number, result: Matrix): Matrix;
  3548. /**
  3549. * Scale the current matrix values by a factor and add the result to a given matrix
  3550. * @param scale defines the scale factor
  3551. * @param result defines the Matrix to store the result
  3552. * @returns the current matrix
  3553. */
  3554. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3555. /**
  3556. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3557. * @param ref matrix to store the result
  3558. */
  3559. toNormalMatrix(ref: Matrix): void;
  3560. /**
  3561. * Gets only rotation part of the current matrix
  3562. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3563. */
  3564. getRotationMatrix(): Matrix;
  3565. /**
  3566. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3567. * @param result defines the target matrix to store data to
  3568. * @returns the current matrix
  3569. */
  3570. getRotationMatrixToRef(result: Matrix): Matrix;
  3571. /**
  3572. * Toggles model matrix from being right handed to left handed in place and vice versa
  3573. */
  3574. toggleModelMatrixHandInPlace(): void;
  3575. /**
  3576. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3577. */
  3578. toggleProjectionMatrixHandInPlace(): void;
  3579. /**
  3580. * Creates a matrix from an array
  3581. * @param array defines the source array
  3582. * @param offset defines an offset in the source array
  3583. * @returns a new Matrix set from the starting index of the given array
  3584. */
  3585. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3586. /**
  3587. * Copy the content of an array into a given matrix
  3588. * @param array defines the source array
  3589. * @param offset defines an offset in the source array
  3590. * @param result defines the target matrix
  3591. */
  3592. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3593. /**
  3594. * Stores an array into a matrix after having multiplied each component by a given factor
  3595. * @param array defines the source array
  3596. * @param offset defines the offset in the source array
  3597. * @param scale defines the scaling factor
  3598. * @param result defines the target matrix
  3599. */
  3600. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3601. /**
  3602. * Gets an identity matrix that must not be updated
  3603. */
  3604. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3605. /**
  3606. * Stores a list of values (16) inside a given matrix
  3607. * @param initialM11 defines 1st value of 1st row
  3608. * @param initialM12 defines 2nd value of 1st row
  3609. * @param initialM13 defines 3rd value of 1st row
  3610. * @param initialM14 defines 4th value of 1st row
  3611. * @param initialM21 defines 1st value of 2nd row
  3612. * @param initialM22 defines 2nd value of 2nd row
  3613. * @param initialM23 defines 3rd value of 2nd row
  3614. * @param initialM24 defines 4th value of 2nd row
  3615. * @param initialM31 defines 1st value of 3rd row
  3616. * @param initialM32 defines 2nd value of 3rd row
  3617. * @param initialM33 defines 3rd value of 3rd row
  3618. * @param initialM34 defines 4th value of 3rd row
  3619. * @param initialM41 defines 1st value of 4th row
  3620. * @param initialM42 defines 2nd value of 4th row
  3621. * @param initialM43 defines 3rd value of 4th row
  3622. * @param initialM44 defines 4th value of 4th row
  3623. * @param result defines the target matrix
  3624. */
  3625. 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;
  3626. /**
  3627. * Creates new matrix from a list of values (16)
  3628. * @param initialM11 defines 1st value of 1st row
  3629. * @param initialM12 defines 2nd value of 1st row
  3630. * @param initialM13 defines 3rd value of 1st row
  3631. * @param initialM14 defines 4th value of 1st row
  3632. * @param initialM21 defines 1st value of 2nd row
  3633. * @param initialM22 defines 2nd value of 2nd row
  3634. * @param initialM23 defines 3rd value of 2nd row
  3635. * @param initialM24 defines 4th value of 2nd row
  3636. * @param initialM31 defines 1st value of 3rd row
  3637. * @param initialM32 defines 2nd value of 3rd row
  3638. * @param initialM33 defines 3rd value of 3rd row
  3639. * @param initialM34 defines 4th value of 3rd row
  3640. * @param initialM41 defines 1st value of 4th row
  3641. * @param initialM42 defines 2nd value of 4th row
  3642. * @param initialM43 defines 3rd value of 4th row
  3643. * @param initialM44 defines 4th value of 4th row
  3644. * @returns the new matrix
  3645. */
  3646. 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;
  3647. /**
  3648. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3649. * @param scale defines the scale vector3
  3650. * @param rotation defines the rotation quaternion
  3651. * @param translation defines the translation vector3
  3652. * @returns a new matrix
  3653. */
  3654. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3655. /**
  3656. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3657. * @param scale defines the scale vector3
  3658. * @param rotation defines the rotation quaternion
  3659. * @param translation defines the translation vector3
  3660. * @param result defines the target matrix
  3661. */
  3662. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3663. /**
  3664. * Creates a new identity matrix
  3665. * @returns a new identity matrix
  3666. */
  3667. static Identity(): Matrix;
  3668. /**
  3669. * Creates a new identity matrix and stores the result in a given matrix
  3670. * @param result defines the target matrix
  3671. */
  3672. static IdentityToRef(result: Matrix): void;
  3673. /**
  3674. * Creates a new zero matrix
  3675. * @returns a new zero matrix
  3676. */
  3677. static Zero(): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis
  3680. * @param angle defines the angle (in radians) to use
  3681. * @return the new matrix
  3682. */
  3683. static RotationX(angle: number): Matrix;
  3684. /**
  3685. * Creates a new matrix as the invert of a given matrix
  3686. * @param source defines the source matrix
  3687. * @returns the new matrix
  3688. */
  3689. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationXToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Y axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationY(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationYToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the Z axis
  3710. * @param angle defines the angle (in radians) to use
  3711. * @return the new matrix
  3712. */
  3713. static RotationZ(angle: number): Matrix;
  3714. /**
  3715. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3716. * @param angle defines the angle (in radians) to use
  3717. * @param result defines the target matrix
  3718. */
  3719. static RotationZToRef(angle: number, result: Matrix): void;
  3720. /**
  3721. * Creates a new rotation matrix for "angle" radians around the given axis
  3722. * @param axis defines the axis to use
  3723. * @param angle defines the angle (in radians) to use
  3724. * @return the new matrix
  3725. */
  3726. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3727. /**
  3728. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3729. * @param axis defines the axis to use
  3730. * @param angle defines the angle (in radians) to use
  3731. * @param result defines the target matrix
  3732. */
  3733. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3734. /**
  3735. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3736. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3737. * @param from defines the vector to align
  3738. * @param to defines the vector to align to
  3739. * @param result defines the target matrix
  3740. */
  3741. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3742. /**
  3743. * Creates a rotation matrix
  3744. * @param yaw defines the yaw angle in radians (Y axis)
  3745. * @param pitch defines the pitch angle in radians (X axis)
  3746. * @param roll defines the roll angle in radians (X axis)
  3747. * @returns the new rotation matrix
  3748. */
  3749. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3750. /**
  3751. * Creates a rotation matrix and stores it in a given matrix
  3752. * @param yaw defines the yaw angle in radians (Y axis)
  3753. * @param pitch defines the pitch angle in radians (X axis)
  3754. * @param roll defines the roll angle in radians (X axis)
  3755. * @param result defines the target matrix
  3756. */
  3757. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3758. /**
  3759. * Creates a scaling matrix
  3760. * @param x defines the scale factor on X axis
  3761. * @param y defines the scale factor on Y axis
  3762. * @param z defines the scale factor on Z axis
  3763. * @returns the new matrix
  3764. */
  3765. static Scaling(x: number, y: number, z: number): Matrix;
  3766. /**
  3767. * Creates a scaling matrix and stores it in a given matrix
  3768. * @param x defines the scale factor on X axis
  3769. * @param y defines the scale factor on Y axis
  3770. * @param z defines the scale factor on Z axis
  3771. * @param result defines the target matrix
  3772. */
  3773. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3774. /**
  3775. * Creates a translation matrix
  3776. * @param x defines the translation on X axis
  3777. * @param y defines the translation on Y axis
  3778. * @param z defines the translationon Z axis
  3779. * @returns the new matrix
  3780. */
  3781. static Translation(x: number, y: number, z: number): Matrix;
  3782. /**
  3783. * Creates a translation matrix and stores it in a given matrix
  3784. * @param x defines the translation on X axis
  3785. * @param y defines the translation on Y axis
  3786. * @param z defines the translationon Z axis
  3787. * @param result defines the target matrix
  3788. */
  3789. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3790. /**
  3791. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3792. * @param startValue defines the start value
  3793. * @param endValue defines the end value
  3794. * @param gradient defines the gradient factor
  3795. * @returns the new matrix
  3796. */
  3797. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3798. /**
  3799. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3800. * @param startValue defines the start value
  3801. * @param endValue defines the end value
  3802. * @param gradient defines the gradient factor
  3803. * @param result defines the Matrix object where to store data
  3804. */
  3805. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3806. /**
  3807. * Builds a new matrix whose values are computed by:
  3808. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3809. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3810. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3811. * @param startValue defines the first matrix
  3812. * @param endValue defines the second matrix
  3813. * @param gradient defines the gradient between the two matrices
  3814. * @returns the new matrix
  3815. */
  3816. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3817. /**
  3818. * Update a matrix to values which are computed by:
  3819. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3820. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3821. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3822. * @param startValue defines the first matrix
  3823. * @param endValue defines the second matrix
  3824. * @param gradient defines the gradient between the two matrices
  3825. * @param result defines the target matrix
  3826. */
  3827. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3828. /**
  3829. * 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"
  3830. * This function works in left handed mode
  3831. * @param eye defines the final position of the entity
  3832. * @param target defines where the entity should look at
  3833. * @param up defines the up vector for the entity
  3834. * @returns the new matrix
  3835. */
  3836. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3837. /**
  3838. * 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".
  3839. * This function works in left handed mode
  3840. * @param eye defines the final position of the entity
  3841. * @param target defines where the entity should look at
  3842. * @param up defines the up vector for the entity
  3843. * @param result defines the target matrix
  3844. */
  3845. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3846. /**
  3847. * 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"
  3848. * This function works in right handed mode
  3849. * @param eye defines the final position of the entity
  3850. * @param target defines where the entity should look at
  3851. * @param up defines the up vector for the entity
  3852. * @returns the new matrix
  3853. */
  3854. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3855. /**
  3856. * 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".
  3857. * This function works in right handed mode
  3858. * @param eye defines the final position of the entity
  3859. * @param target defines where the entity should look at
  3860. * @param up defines the up vector for the entity
  3861. * @param result defines the target matrix
  3862. */
  3863. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3864. /**
  3865. * Create a left-handed orthographic projection matrix
  3866. * @param width defines the viewport width
  3867. * @param height defines the viewport height
  3868. * @param znear defines the near clip plane
  3869. * @param zfar defines the far clip plane
  3870. * @returns a new matrix as a left-handed orthographic projection matrix
  3871. */
  3872. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3873. /**
  3874. * Store a left-handed orthographic projection to a given matrix
  3875. * @param width defines the viewport width
  3876. * @param height defines the viewport height
  3877. * @param znear defines the near clip plane
  3878. * @param zfar defines the far clip plane
  3879. * @param result defines the target matrix
  3880. */
  3881. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3882. /**
  3883. * Create a left-handed orthographic projection matrix
  3884. * @param left defines the viewport left coordinate
  3885. * @param right defines the viewport right coordinate
  3886. * @param bottom defines the viewport bottom coordinate
  3887. * @param top defines the viewport top coordinate
  3888. * @param znear defines the near clip plane
  3889. * @param zfar defines the far clip plane
  3890. * @returns a new matrix as a left-handed orthographic projection matrix
  3891. */
  3892. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3893. /**
  3894. * Stores a left-handed orthographic projection into a given matrix
  3895. * @param left defines the viewport left coordinate
  3896. * @param right defines the viewport right coordinate
  3897. * @param bottom defines the viewport bottom coordinate
  3898. * @param top defines the viewport top coordinate
  3899. * @param znear defines the near clip plane
  3900. * @param zfar defines the far clip plane
  3901. * @param result defines the target matrix
  3902. */
  3903. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3904. /**
  3905. * Creates a right-handed orthographic projection matrix
  3906. * @param left defines the viewport left coordinate
  3907. * @param right defines the viewport right coordinate
  3908. * @param bottom defines the viewport bottom coordinate
  3909. * @param top defines the viewport top coordinate
  3910. * @param znear defines the near clip plane
  3911. * @param zfar defines the far clip plane
  3912. * @returns a new matrix as a right-handed orthographic projection matrix
  3913. */
  3914. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3915. /**
  3916. * Stores a right-handed orthographic projection into a given matrix
  3917. * @param left defines the viewport left coordinate
  3918. * @param right defines the viewport right coordinate
  3919. * @param bottom defines the viewport bottom coordinate
  3920. * @param top defines the viewport top coordinate
  3921. * @param znear defines the near clip plane
  3922. * @param zfar defines the far clip plane
  3923. * @param result defines the target matrix
  3924. */
  3925. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3926. /**
  3927. * Creates a left-handed perspective projection matrix
  3928. * @param width defines the viewport width
  3929. * @param height defines the viewport height
  3930. * @param znear defines the near clip plane
  3931. * @param zfar defines the far clip plane
  3932. * @returns a new matrix as a left-handed perspective projection matrix
  3933. */
  3934. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3935. /**
  3936. * Creates a left-handed perspective projection matrix
  3937. * @param fov defines the horizontal field of view
  3938. * @param aspect defines the aspect ratio
  3939. * @param znear defines the near clip plane
  3940. * @param zfar defines the far clip plane
  3941. * @returns a new matrix as a left-handed perspective projection matrix
  3942. */
  3943. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3944. /**
  3945. * Stores a left-handed perspective projection into a given matrix
  3946. * @param fov defines the horizontal field of view
  3947. * @param aspect defines the aspect ratio
  3948. * @param znear defines the near clip plane
  3949. * @param zfar defines the far clip plane
  3950. * @param result defines the target matrix
  3951. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3952. */
  3953. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3954. /**
  3955. * Creates a right-handed perspective projection matrix
  3956. * @param fov defines the horizontal field of view
  3957. * @param aspect defines the aspect ratio
  3958. * @param znear defines the near clip plane
  3959. * @param zfar defines the far clip plane
  3960. * @returns a new matrix as a right-handed perspective projection matrix
  3961. */
  3962. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3963. /**
  3964. * Stores a right-handed perspective projection into a given matrix
  3965. * @param fov defines the horizontal field of view
  3966. * @param aspect defines the aspect ratio
  3967. * @param znear defines the near clip plane
  3968. * @param zfar defines the far clip plane
  3969. * @param result defines the target matrix
  3970. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3971. */
  3972. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3973. /**
  3974. * Stores a perspective projection for WebVR info a given matrix
  3975. * @param fov defines the field of view
  3976. * @param znear defines the near clip plane
  3977. * @param zfar defines the far clip plane
  3978. * @param result defines the target matrix
  3979. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3980. */
  3981. static PerspectiveFovWebVRToRef(fov: {
  3982. upDegrees: number;
  3983. downDegrees: number;
  3984. leftDegrees: number;
  3985. rightDegrees: number;
  3986. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3987. /**
  3988. * Computes a complete transformation matrix
  3989. * @param viewport defines the viewport to use
  3990. * @param world defines the world matrix
  3991. * @param view defines the view matrix
  3992. * @param projection defines the projection matrix
  3993. * @param zmin defines the near clip plane
  3994. * @param zmax defines the far clip plane
  3995. * @returns the transformation matrix
  3996. */
  3997. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3998. /**
  3999. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4000. * @param matrix defines the matrix to use
  4001. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4002. */
  4003. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4004. /**
  4005. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4006. * @param matrix defines the matrix to use
  4007. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4008. */
  4009. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4010. /**
  4011. * Compute the transpose of a given matrix
  4012. * @param matrix defines the matrix to transpose
  4013. * @returns the new matrix
  4014. */
  4015. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4016. /**
  4017. * Compute the transpose of a matrix and store it in a target matrix
  4018. * @param matrix defines the matrix to transpose
  4019. * @param result defines the target matrix
  4020. */
  4021. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4022. /**
  4023. * Computes a reflection matrix from a plane
  4024. * @param plane defines the reflection plane
  4025. * @returns a new matrix
  4026. */
  4027. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4028. /**
  4029. * Computes a reflection matrix from a plane
  4030. * @param plane defines the reflection plane
  4031. * @param result defines the target matrix
  4032. */
  4033. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4034. /**
  4035. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4036. * @param xaxis defines the value of the 1st axis
  4037. * @param yaxis defines the value of the 2nd axis
  4038. * @param zaxis defines the value of the 3rd axis
  4039. * @param result defines the target matrix
  4040. */
  4041. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4042. /**
  4043. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4044. * @param quat defines the quaternion to use
  4045. * @param result defines the target matrix
  4046. */
  4047. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4048. }
  4049. /**
  4050. * @hidden
  4051. */
  4052. export class TmpVectors {
  4053. static Vector2: Vector2[];
  4054. static Vector3: Vector3[];
  4055. static Vector4: Vector4[];
  4056. static Quaternion: Quaternion[];
  4057. static Matrix: Matrix[];
  4058. }
  4059. }
  4060. declare module "babylonjs/Engines/constants" {
  4061. /** Defines the cross module used constants to avoid circular dependncies */
  4062. export class Constants {
  4063. /** Defines that alpha blending is disabled */
  4064. static readonly ALPHA_DISABLE: number;
  4065. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4066. static readonly ALPHA_ADD: number;
  4067. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4068. static readonly ALPHA_COMBINE: number;
  4069. /** Defines that alpha blending to DEST - SRC * DEST */
  4070. static readonly ALPHA_SUBTRACT: number;
  4071. /** Defines that alpha blending to SRC * DEST */
  4072. static readonly ALPHA_MULTIPLY: number;
  4073. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4074. static readonly ALPHA_MAXIMIZED: number;
  4075. /** Defines that alpha blending to SRC + DEST */
  4076. static readonly ALPHA_ONEONE: number;
  4077. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4078. static readonly ALPHA_PREMULTIPLIED: number;
  4079. /**
  4080. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4081. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4082. */
  4083. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4084. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4085. static readonly ALPHA_INTERPOLATE: number;
  4086. /**
  4087. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4088. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4089. */
  4090. static readonly ALPHA_SCREENMODE: number;
  4091. /**
  4092. * Defines that alpha blending to SRC + DST
  4093. * Alpha will be set to SRC ALPHA + DST ALPHA
  4094. */
  4095. static readonly ALPHA_ONEONE_ONEONE: number;
  4096. /**
  4097. * Defines that alpha blending to SRC * DST ALPHA + DST
  4098. * Alpha will be set to 0
  4099. */
  4100. static readonly ALPHA_ALPHATOCOLOR: number;
  4101. /**
  4102. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4103. */
  4104. static readonly ALPHA_REVERSEONEMINUS: number;
  4105. /**
  4106. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4107. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4108. */
  4109. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4110. /**
  4111. * Defines that alpha blending to SRC + DST
  4112. * Alpha will be set to SRC ALPHA
  4113. */
  4114. static readonly ALPHA_ONEONE_ONEZERO: number;
  4115. /** Defines that alpha blending equation a SUM */
  4116. static readonly ALPHA_EQUATION_ADD: number;
  4117. /** Defines that alpha blending equation a SUBSTRACTION */
  4118. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4119. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4120. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4121. /** Defines that alpha blending equation a MAX operation */
  4122. static readonly ALPHA_EQUATION_MAX: number;
  4123. /** Defines that alpha blending equation a MIN operation */
  4124. static readonly ALPHA_EQUATION_MIN: number;
  4125. /**
  4126. * Defines that alpha blending equation a DARKEN operation:
  4127. * It takes the min of the src and sums the alpha channels.
  4128. */
  4129. static readonly ALPHA_EQUATION_DARKEN: number;
  4130. /** Defines that the ressource is not delayed*/
  4131. static readonly DELAYLOADSTATE_NONE: number;
  4132. /** Defines that the ressource was successfully delay loaded */
  4133. static readonly DELAYLOADSTATE_LOADED: number;
  4134. /** Defines that the ressource is currently delay loading */
  4135. static readonly DELAYLOADSTATE_LOADING: number;
  4136. /** Defines that the ressource is delayed and has not started loading */
  4137. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4138. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4139. static readonly NEVER: number;
  4140. /** 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 */
  4141. static readonly ALWAYS: number;
  4142. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4143. static readonly LESS: number;
  4144. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4145. static readonly EQUAL: number;
  4146. /** 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 */
  4147. static readonly LEQUAL: number;
  4148. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4149. static readonly GREATER: number;
  4150. /** 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 */
  4151. static readonly GEQUAL: number;
  4152. /** 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 */
  4153. static readonly NOTEQUAL: number;
  4154. /** Passed to stencilOperation to specify that stencil value must be kept */
  4155. static readonly KEEP: number;
  4156. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4157. static readonly REPLACE: number;
  4158. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4159. static readonly INCR: number;
  4160. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4161. static readonly DECR: number;
  4162. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4163. static readonly INVERT: number;
  4164. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4165. static readonly INCR_WRAP: number;
  4166. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4167. static readonly DECR_WRAP: number;
  4168. /** Texture is not repeating outside of 0..1 UVs */
  4169. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4170. /** Texture is repeating outside of 0..1 UVs */
  4171. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4172. /** Texture is repeating and mirrored */
  4173. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4174. /** ALPHA */
  4175. static readonly TEXTUREFORMAT_ALPHA: number;
  4176. /** LUMINANCE */
  4177. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4178. /** LUMINANCE_ALPHA */
  4179. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4180. /** RGB */
  4181. static readonly TEXTUREFORMAT_RGB: number;
  4182. /** RGBA */
  4183. static readonly TEXTUREFORMAT_RGBA: number;
  4184. /** RED */
  4185. static readonly TEXTUREFORMAT_RED: number;
  4186. /** RED (2nd reference) */
  4187. static readonly TEXTUREFORMAT_R: number;
  4188. /** RG */
  4189. static readonly TEXTUREFORMAT_RG: number;
  4190. /** RED_INTEGER */
  4191. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4192. /** RED_INTEGER (2nd reference) */
  4193. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4194. /** RG_INTEGER */
  4195. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4196. /** RGB_INTEGER */
  4197. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4198. /** RGBA_INTEGER */
  4199. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4200. /** UNSIGNED_BYTE */
  4201. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4202. /** UNSIGNED_BYTE (2nd reference) */
  4203. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4204. /** FLOAT */
  4205. static readonly TEXTURETYPE_FLOAT: number;
  4206. /** HALF_FLOAT */
  4207. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4208. /** BYTE */
  4209. static readonly TEXTURETYPE_BYTE: number;
  4210. /** SHORT */
  4211. static readonly TEXTURETYPE_SHORT: number;
  4212. /** UNSIGNED_SHORT */
  4213. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4214. /** INT */
  4215. static readonly TEXTURETYPE_INT: number;
  4216. /** UNSIGNED_INT */
  4217. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4218. /** UNSIGNED_SHORT_4_4_4_4 */
  4219. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4220. /** UNSIGNED_SHORT_5_5_5_1 */
  4221. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4222. /** UNSIGNED_SHORT_5_6_5 */
  4223. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4224. /** UNSIGNED_INT_2_10_10_10_REV */
  4225. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4226. /** UNSIGNED_INT_24_8 */
  4227. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4228. /** UNSIGNED_INT_10F_11F_11F_REV */
  4229. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4230. /** UNSIGNED_INT_5_9_9_9_REV */
  4231. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4232. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4233. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4234. /** nearest is mag = nearest and min = nearest and mip = linear */
  4235. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4237. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4238. /** Trilinear is mag = linear and min = linear and mip = linear */
  4239. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4240. /** nearest is mag = nearest and min = nearest and mip = linear */
  4241. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4242. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4243. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4244. /** Trilinear is mag = linear and min = linear and mip = linear */
  4245. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4246. /** mag = nearest and min = nearest and mip = nearest */
  4247. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4248. /** mag = nearest and min = linear and mip = nearest */
  4249. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4250. /** mag = nearest and min = linear and mip = linear */
  4251. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4252. /** mag = nearest and min = linear and mip = none */
  4253. static readonly TEXTURE_NEAREST_LINEAR: number;
  4254. /** mag = nearest and min = nearest and mip = none */
  4255. static readonly TEXTURE_NEAREST_NEAREST: number;
  4256. /** mag = linear and min = nearest and mip = nearest */
  4257. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4258. /** mag = linear and min = nearest and mip = linear */
  4259. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4260. /** mag = linear and min = linear and mip = none */
  4261. static readonly TEXTURE_LINEAR_LINEAR: number;
  4262. /** mag = linear and min = nearest and mip = none */
  4263. static readonly TEXTURE_LINEAR_NEAREST: number;
  4264. /** Explicit coordinates mode */
  4265. static readonly TEXTURE_EXPLICIT_MODE: number;
  4266. /** Spherical coordinates mode */
  4267. static readonly TEXTURE_SPHERICAL_MODE: number;
  4268. /** Planar coordinates mode */
  4269. static readonly TEXTURE_PLANAR_MODE: number;
  4270. /** Cubic coordinates mode */
  4271. static readonly TEXTURE_CUBIC_MODE: number;
  4272. /** Projection coordinates mode */
  4273. static readonly TEXTURE_PROJECTION_MODE: number;
  4274. /** Skybox coordinates mode */
  4275. static readonly TEXTURE_SKYBOX_MODE: number;
  4276. /** Inverse Cubic coordinates mode */
  4277. static readonly TEXTURE_INVCUBIC_MODE: number;
  4278. /** Equirectangular coordinates mode */
  4279. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4280. /** Equirectangular Fixed coordinates mode */
  4281. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4282. /** Equirectangular Fixed Mirrored coordinates mode */
  4283. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4284. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4285. static readonly SCALEMODE_FLOOR: number;
  4286. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4287. static readonly SCALEMODE_NEAREST: number;
  4288. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4289. static readonly SCALEMODE_CEILING: number;
  4290. /**
  4291. * The dirty texture flag value
  4292. */
  4293. static readonly MATERIAL_TextureDirtyFlag: number;
  4294. /**
  4295. * The dirty light flag value
  4296. */
  4297. static readonly MATERIAL_LightDirtyFlag: number;
  4298. /**
  4299. * The dirty fresnel flag value
  4300. */
  4301. static readonly MATERIAL_FresnelDirtyFlag: number;
  4302. /**
  4303. * The dirty attribute flag value
  4304. */
  4305. static readonly MATERIAL_AttributesDirtyFlag: number;
  4306. /**
  4307. * The dirty misc flag value
  4308. */
  4309. static readonly MATERIAL_MiscDirtyFlag: number;
  4310. /**
  4311. * The all dirty flag value
  4312. */
  4313. static readonly MATERIAL_AllDirtyFlag: number;
  4314. /**
  4315. * Returns the triangle fill mode
  4316. */
  4317. static readonly MATERIAL_TriangleFillMode: number;
  4318. /**
  4319. * Returns the wireframe mode
  4320. */
  4321. static readonly MATERIAL_WireFrameFillMode: number;
  4322. /**
  4323. * Returns the point fill mode
  4324. */
  4325. static readonly MATERIAL_PointFillMode: number;
  4326. /**
  4327. * Returns the point list draw mode
  4328. */
  4329. static readonly MATERIAL_PointListDrawMode: number;
  4330. /**
  4331. * Returns the line list draw mode
  4332. */
  4333. static readonly MATERIAL_LineListDrawMode: number;
  4334. /**
  4335. * Returns the line loop draw mode
  4336. */
  4337. static readonly MATERIAL_LineLoopDrawMode: number;
  4338. /**
  4339. * Returns the line strip draw mode
  4340. */
  4341. static readonly MATERIAL_LineStripDrawMode: number;
  4342. /**
  4343. * Returns the triangle strip draw mode
  4344. */
  4345. static readonly MATERIAL_TriangleStripDrawMode: number;
  4346. /**
  4347. * Returns the triangle fan draw mode
  4348. */
  4349. static readonly MATERIAL_TriangleFanDrawMode: number;
  4350. /**
  4351. * Stores the clock-wise side orientation
  4352. */
  4353. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4354. /**
  4355. * Stores the counter clock-wise side orientation
  4356. */
  4357. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4358. /**
  4359. * Nothing
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_NothingTrigger: number;
  4363. /**
  4364. * On pick
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPickTrigger: number;
  4368. /**
  4369. * On left pick
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnLeftPickTrigger: number;
  4373. /**
  4374. * On right pick
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnRightPickTrigger: number;
  4378. /**
  4379. * On center pick
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnCenterPickTrigger: number;
  4383. /**
  4384. * On pick down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnPickDownTrigger: number;
  4388. /**
  4389. * On double pick
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnDoublePickTrigger: number;
  4393. /**
  4394. * On pick up
  4395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4396. */
  4397. static readonly ACTION_OnPickUpTrigger: number;
  4398. /**
  4399. * On pick out.
  4400. * This trigger will only be raised if you also declared a OnPickDown
  4401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4402. */
  4403. static readonly ACTION_OnPickOutTrigger: number;
  4404. /**
  4405. * On long press
  4406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4407. */
  4408. static readonly ACTION_OnLongPressTrigger: number;
  4409. /**
  4410. * On pointer over
  4411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4412. */
  4413. static readonly ACTION_OnPointerOverTrigger: number;
  4414. /**
  4415. * On pointer out
  4416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4417. */
  4418. static readonly ACTION_OnPointerOutTrigger: number;
  4419. /**
  4420. * On every frame
  4421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4422. */
  4423. static readonly ACTION_OnEveryFrameTrigger: number;
  4424. /**
  4425. * On intersection enter
  4426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4427. */
  4428. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4429. /**
  4430. * On intersection exit
  4431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4432. */
  4433. static readonly ACTION_OnIntersectionExitTrigger: number;
  4434. /**
  4435. * On key down
  4436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4437. */
  4438. static readonly ACTION_OnKeyDownTrigger: number;
  4439. /**
  4440. * On key up
  4441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4442. */
  4443. static readonly ACTION_OnKeyUpTrigger: number;
  4444. /**
  4445. * Billboard mode will only apply to Y axis
  4446. */
  4447. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4448. /**
  4449. * Billboard mode will apply to all axes
  4450. */
  4451. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4452. /**
  4453. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4454. */
  4455. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4456. /**
  4457. * Gets or sets base Assets URL
  4458. */
  4459. static PARTICLES_BaseAssetsUrl: string;
  4460. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4461. * Test order :
  4462. * Is the bounding sphere outside the frustum ?
  4463. * If not, are the bounding box vertices outside the frustum ?
  4464. * It not, then the cullable object is in the frustum.
  4465. */
  4466. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4467. /** Culling strategy : Bounding Sphere Only.
  4468. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4469. * It's also less accurate than the standard because some not visible objects can still be selected.
  4470. * Test : is the bounding sphere outside the frustum ?
  4471. * If not, then the cullable object is in the frustum.
  4472. */
  4473. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4474. /** Culling strategy : Optimistic Inclusion.
  4475. * This in an inclusion test first, then the standard exclusion test.
  4476. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4477. * 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.
  4478. * Anyway, it's as accurate as the standard strategy.
  4479. * Test :
  4480. * Is the cullable object bounding sphere center in the frustum ?
  4481. * If not, apply the default culling strategy.
  4482. */
  4483. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4484. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4485. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4486. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4487. * 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.
  4488. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4489. * Test :
  4490. * Is the cullable object bounding sphere center in the frustum ?
  4491. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4492. */
  4493. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4494. /**
  4495. * No logging while loading
  4496. */
  4497. static readonly SCENELOADER_NO_LOGGING: number;
  4498. /**
  4499. * Minimal logging while loading
  4500. */
  4501. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4502. /**
  4503. * Summary logging while loading
  4504. */
  4505. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4506. /**
  4507. * Detailled logging while loading
  4508. */
  4509. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4510. }
  4511. }
  4512. declare module "babylonjs/Engines/IPipelineContext" {
  4513. /**
  4514. * Class used to store and describe the pipeline context associated with an effect
  4515. */
  4516. export interface IPipelineContext {
  4517. /**
  4518. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4519. */
  4520. isAsync: boolean;
  4521. /**
  4522. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4523. */
  4524. isReady: boolean;
  4525. /** @hidden */
  4526. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4527. }
  4528. }
  4529. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4530. /** @hidden */
  4531. export interface IShaderProcessor {
  4532. attributeProcessor?: (attribute: string) => string;
  4533. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4534. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4535. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4536. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4537. lineProcessor?: (line: string, isFragment: boolean) => string;
  4538. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4539. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4540. }
  4541. }
  4542. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4543. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4544. /** @hidden */
  4545. export interface ProcessingOptions {
  4546. defines: string[];
  4547. indexParameters: any;
  4548. isFragment: boolean;
  4549. shouldUseHighPrecisionShader: boolean;
  4550. supportsUniformBuffers: boolean;
  4551. shadersRepository: string;
  4552. includesShadersStore: {
  4553. [key: string]: string;
  4554. };
  4555. processor?: IShaderProcessor;
  4556. version: string;
  4557. platformName: string;
  4558. lookForClosingBracketForUniformBuffer?: boolean;
  4559. }
  4560. }
  4561. declare module "babylonjs/Misc/stringTools" {
  4562. /**
  4563. * Helper to manipulate strings
  4564. */
  4565. export class StringTools {
  4566. /**
  4567. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4568. * @param str Source string
  4569. * @param suffix Suffix to search for in the source string
  4570. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4571. */
  4572. static EndsWith(str: string, suffix: string): boolean;
  4573. /**
  4574. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4575. * @param str Source string
  4576. * @param suffix Suffix to search for in the source string
  4577. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4578. */
  4579. static StartsWith(str: string, suffix: string): boolean;
  4580. }
  4581. }
  4582. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4583. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4584. /** @hidden */
  4585. export class ShaderCodeNode {
  4586. line: string;
  4587. children: ShaderCodeNode[];
  4588. additionalDefineKey?: string;
  4589. additionalDefineValue?: string;
  4590. isValid(preprocessors: {
  4591. [key: string]: string;
  4592. }): boolean;
  4593. process(preprocessors: {
  4594. [key: string]: string;
  4595. }, options: ProcessingOptions): string;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4599. /** @hidden */
  4600. export class ShaderCodeCursor {
  4601. private _lines;
  4602. lineIndex: number;
  4603. readonly currentLine: string;
  4604. readonly canRead: boolean;
  4605. lines: string[];
  4606. }
  4607. }
  4608. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4609. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4610. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4611. /** @hidden */
  4612. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4613. process(preprocessors: {
  4614. [key: string]: string;
  4615. }, options: ProcessingOptions): string;
  4616. }
  4617. }
  4618. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4619. /** @hidden */
  4620. export class ShaderDefineExpression {
  4621. isTrue(preprocessors: {
  4622. [key: string]: string;
  4623. }): boolean;
  4624. }
  4625. }
  4626. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4627. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4628. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4629. /** @hidden */
  4630. export class ShaderCodeTestNode extends ShaderCodeNode {
  4631. testExpression: ShaderDefineExpression;
  4632. isValid(preprocessors: {
  4633. [key: string]: string;
  4634. }): boolean;
  4635. }
  4636. }
  4637. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4638. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4639. /** @hidden */
  4640. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4641. define: string;
  4642. not: boolean;
  4643. constructor(define: string, not?: boolean);
  4644. isTrue(preprocessors: {
  4645. [key: string]: string;
  4646. }): boolean;
  4647. }
  4648. }
  4649. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4650. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4651. /** @hidden */
  4652. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4653. leftOperand: ShaderDefineExpression;
  4654. rightOperand: ShaderDefineExpression;
  4655. isTrue(preprocessors: {
  4656. [key: string]: string;
  4657. }): boolean;
  4658. }
  4659. }
  4660. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4661. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4662. /** @hidden */
  4663. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4664. leftOperand: ShaderDefineExpression;
  4665. rightOperand: ShaderDefineExpression;
  4666. isTrue(preprocessors: {
  4667. [key: string]: string;
  4668. }): boolean;
  4669. }
  4670. }
  4671. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4672. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4673. /** @hidden */
  4674. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4675. define: string;
  4676. operand: string;
  4677. testValue: string;
  4678. constructor(define: string, operand: string, testValue: string);
  4679. isTrue(preprocessors: {
  4680. [key: string]: string;
  4681. }): boolean;
  4682. }
  4683. }
  4684. declare module "babylonjs/Misc/loadFileError" {
  4685. import { WebRequest } from "babylonjs/Misc/webRequest";
  4686. /**
  4687. * @ignore
  4688. * Application error to support additional information when loading a file
  4689. */
  4690. export class LoadFileError extends Error {
  4691. /** defines the optional web request */
  4692. request?: WebRequest | undefined;
  4693. private static _setPrototypeOf;
  4694. /**
  4695. * Creates a new LoadFileError
  4696. * @param message defines the message of the error
  4697. * @param request defines the optional web request
  4698. */
  4699. constructor(message: string,
  4700. /** defines the optional web request */
  4701. request?: WebRequest | undefined);
  4702. }
  4703. }
  4704. declare module "babylonjs/Offline/IOfflineProvider" {
  4705. /**
  4706. * Class used to enable access to offline support
  4707. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4708. */
  4709. export interface IOfflineProvider {
  4710. /**
  4711. * Gets a boolean indicating if scene must be saved in the database
  4712. */
  4713. enableSceneOffline: boolean;
  4714. /**
  4715. * Gets a boolean indicating if textures must be saved in the database
  4716. */
  4717. enableTexturesOffline: boolean;
  4718. /**
  4719. * Open the offline support and make it available
  4720. * @param successCallback defines the callback to call on success
  4721. * @param errorCallback defines the callback to call on error
  4722. */
  4723. open(successCallback: () => void, errorCallback: () => void): void;
  4724. /**
  4725. * Loads an image from the offline support
  4726. * @param url defines the url to load from
  4727. * @param image defines the target DOM image
  4728. */
  4729. loadImage(url: string, image: HTMLImageElement): void;
  4730. /**
  4731. * Loads a file from offline support
  4732. * @param url defines the URL to load from
  4733. * @param sceneLoaded defines a callback to call on success
  4734. * @param progressCallBack defines a callback to call when progress changed
  4735. * @param errorCallback defines a callback to call on error
  4736. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4737. */
  4738. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4739. }
  4740. }
  4741. declare module "babylonjs/Misc/filesInputStore" {
  4742. /**
  4743. * Class used to help managing file picking and drag'n'drop
  4744. * File Storage
  4745. */
  4746. export class FilesInputStore {
  4747. /**
  4748. * List of files ready to be loaded
  4749. */
  4750. static FilesToLoad: {
  4751. [key: string]: File;
  4752. };
  4753. }
  4754. }
  4755. declare module "babylonjs/Misc/retryStrategy" {
  4756. import { WebRequest } from "babylonjs/Misc/webRequest";
  4757. /**
  4758. * Class used to define a retry strategy when error happens while loading assets
  4759. */
  4760. export class RetryStrategy {
  4761. /**
  4762. * Function used to defines an exponential back off strategy
  4763. * @param maxRetries defines the maximum number of retries (3 by default)
  4764. * @param baseInterval defines the interval between retries
  4765. * @returns the strategy function to use
  4766. */
  4767. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4768. }
  4769. }
  4770. declare module "babylonjs/Misc/fileTools" {
  4771. import { WebRequest } from "babylonjs/Misc/webRequest";
  4772. import { Nullable } from "babylonjs/types";
  4773. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4774. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4775. /**
  4776. * @hidden
  4777. */
  4778. export class FileTools {
  4779. /**
  4780. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4781. */
  4782. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4783. /**
  4784. * Gets or sets the base URL to use to load assets
  4785. */
  4786. static BaseUrl: string;
  4787. /**
  4788. * Default behaviour for cors in the application.
  4789. * It can be a string if the expected behavior is identical in the entire app.
  4790. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4791. */
  4792. static CorsBehavior: string | ((url: string | string[]) => string);
  4793. /**
  4794. * Gets or sets a function used to pre-process url before using them to load assets
  4795. */
  4796. static PreprocessUrl: (url: string) => string;
  4797. /**
  4798. * Removes unwanted characters from an url
  4799. * @param url defines the url to clean
  4800. * @returns the cleaned url
  4801. */
  4802. private static _CleanUrl;
  4803. /**
  4804. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4805. * @param url define the url we are trying
  4806. * @param element define the dom element where to configure the cors policy
  4807. */
  4808. static SetCorsBehavior(url: string | string[], element: {
  4809. crossOrigin: string | null;
  4810. }): void;
  4811. /**
  4812. * Loads an image as an HTMLImageElement.
  4813. * @param input url string, ArrayBuffer, or Blob to load
  4814. * @param onLoad callback called when the image successfully loads
  4815. * @param onError callback called when the image fails to load
  4816. * @param offlineProvider offline provider for caching
  4817. * @returns the HTMLImageElement of the loaded image
  4818. */
  4819. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4820. /**
  4821. * Loads a file
  4822. * @param fileToLoad defines the file to load
  4823. * @param callback defines the callback to call when data is loaded
  4824. * @param progressCallBack defines the callback to call during loading process
  4825. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4826. * @returns a file request object
  4827. */
  4828. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4829. /**
  4830. * Loads a file
  4831. * @param url url string, ArrayBuffer, or Blob to load
  4832. * @param onSuccess callback called when the file successfully loads
  4833. * @param onProgress callback called while file is loading (if the server supports this mode)
  4834. * @param offlineProvider defines the offline provider for caching
  4835. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4836. * @param onError callback called when the file fails to load
  4837. * @returns a file request object
  4838. */
  4839. 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;
  4840. /**
  4841. * Checks if the loaded document was accessed via `file:`-Protocol.
  4842. * @returns boolean
  4843. */
  4844. static IsFileURL(): boolean;
  4845. }
  4846. }
  4847. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4848. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4849. /** @hidden */
  4850. export class ShaderProcessor {
  4851. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4852. private static _ProcessPrecision;
  4853. private static _ExtractOperation;
  4854. private static _BuildSubExpression;
  4855. private static _BuildExpression;
  4856. private static _MoveCursorWithinIf;
  4857. private static _MoveCursor;
  4858. private static _EvaluatePreProcessors;
  4859. private static _PreparePreProcessors;
  4860. private static _ProcessShaderConversion;
  4861. private static _ProcessIncludes;
  4862. }
  4863. }
  4864. declare module "babylonjs/Maths/math.color" {
  4865. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4866. /**
  4867. * Class used to hold a RBG color
  4868. */
  4869. export class Color3 {
  4870. /**
  4871. * Defines the red component (between 0 and 1, default is 0)
  4872. */
  4873. r: number;
  4874. /**
  4875. * Defines the green component (between 0 and 1, default is 0)
  4876. */
  4877. g: number;
  4878. /**
  4879. * Defines the blue component (between 0 and 1, default is 0)
  4880. */
  4881. b: number;
  4882. /**
  4883. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4884. * @param r defines the red component (between 0 and 1, default is 0)
  4885. * @param g defines the green component (between 0 and 1, default is 0)
  4886. * @param b defines the blue component (between 0 and 1, default is 0)
  4887. */
  4888. constructor(
  4889. /**
  4890. * Defines the red component (between 0 and 1, default is 0)
  4891. */
  4892. r?: number,
  4893. /**
  4894. * Defines the green component (between 0 and 1, default is 0)
  4895. */
  4896. g?: number,
  4897. /**
  4898. * Defines the blue component (between 0 and 1, default is 0)
  4899. */
  4900. b?: number);
  4901. /**
  4902. * Creates a string with the Color3 current values
  4903. * @returns the string representation of the Color3 object
  4904. */
  4905. toString(): string;
  4906. /**
  4907. * Returns the string "Color3"
  4908. * @returns "Color3"
  4909. */
  4910. getClassName(): string;
  4911. /**
  4912. * Compute the Color3 hash code
  4913. * @returns an unique number that can be used to hash Color3 objects
  4914. */
  4915. getHashCode(): number;
  4916. /**
  4917. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4918. * @param array defines the array where to store the r,g,b components
  4919. * @param index defines an optional index in the target array to define where to start storing values
  4920. * @returns the current Color3 object
  4921. */
  4922. toArray(array: FloatArray, index?: number): Color3;
  4923. /**
  4924. * Returns a new Color4 object from the current Color3 and the given alpha
  4925. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4926. * @returns a new Color4 object
  4927. */
  4928. toColor4(alpha?: number): Color4;
  4929. /**
  4930. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4931. * @returns the new array
  4932. */
  4933. asArray(): number[];
  4934. /**
  4935. * Returns the luminance value
  4936. * @returns a float value
  4937. */
  4938. toLuminance(): number;
  4939. /**
  4940. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4941. * @param otherColor defines the second operand
  4942. * @returns the new Color3 object
  4943. */
  4944. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4945. /**
  4946. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4947. * @param otherColor defines the second operand
  4948. * @param result defines the Color3 object where to store the result
  4949. * @returns the current Color3
  4950. */
  4951. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4952. /**
  4953. * Determines equality between Color3 objects
  4954. * @param otherColor defines the second operand
  4955. * @returns true if the rgb values are equal to the given ones
  4956. */
  4957. equals(otherColor: DeepImmutable<Color3>): boolean;
  4958. /**
  4959. * Determines equality between the current Color3 object and a set of r,b,g values
  4960. * @param r defines the red component to check
  4961. * @param g defines the green component to check
  4962. * @param b defines the blue component to check
  4963. * @returns true if the rgb values are equal to the given ones
  4964. */
  4965. equalsFloats(r: number, g: number, b: number): boolean;
  4966. /**
  4967. * Multiplies in place each rgb value by scale
  4968. * @param scale defines the scaling factor
  4969. * @returns the updated Color3
  4970. */
  4971. scale(scale: number): Color3;
  4972. /**
  4973. * Multiplies the rgb values by scale and stores the result into "result"
  4974. * @param scale defines the scaling factor
  4975. * @param result defines the Color3 object where to store the result
  4976. * @returns the unmodified current Color3
  4977. */
  4978. scaleToRef(scale: number, result: Color3): Color3;
  4979. /**
  4980. * Scale the current Color3 values by a factor and add the result to a given Color3
  4981. * @param scale defines the scale factor
  4982. * @param result defines color to store the result into
  4983. * @returns the unmodified current Color3
  4984. */
  4985. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4986. /**
  4987. * Clamps the rgb values by the min and max values and stores the result into "result"
  4988. * @param min defines minimum clamping value (default is 0)
  4989. * @param max defines maximum clamping value (default is 1)
  4990. * @param result defines color to store the result into
  4991. * @returns the original Color3
  4992. */
  4993. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4994. /**
  4995. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4996. * @param otherColor defines the second operand
  4997. * @returns the new Color3
  4998. */
  4999. add(otherColor: DeepImmutable<Color3>): Color3;
  5000. /**
  5001. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5002. * @param otherColor defines the second operand
  5003. * @param result defines Color3 object to store the result into
  5004. * @returns the unmodified current Color3
  5005. */
  5006. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5007. /**
  5008. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5009. * @param otherColor defines the second operand
  5010. * @returns the new Color3
  5011. */
  5012. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5013. /**
  5014. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5015. * @param otherColor defines the second operand
  5016. * @param result defines Color3 object to store the result into
  5017. * @returns the unmodified current Color3
  5018. */
  5019. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5020. /**
  5021. * Copy the current object
  5022. * @returns a new Color3 copied the current one
  5023. */
  5024. clone(): Color3;
  5025. /**
  5026. * Copies the rgb values from the source in the current Color3
  5027. * @param source defines the source Color3 object
  5028. * @returns the updated Color3 object
  5029. */
  5030. copyFrom(source: DeepImmutable<Color3>): Color3;
  5031. /**
  5032. * Updates the Color3 rgb values from the given floats
  5033. * @param r defines the red component to read from
  5034. * @param g defines the green component to read from
  5035. * @param b defines the blue component to read from
  5036. * @returns the current Color3 object
  5037. */
  5038. copyFromFloats(r: number, g: number, b: number): Color3;
  5039. /**
  5040. * Updates the Color3 rgb values from the given floats
  5041. * @param r defines the red component to read from
  5042. * @param g defines the green component to read from
  5043. * @param b defines the blue component to read from
  5044. * @returns the current Color3 object
  5045. */
  5046. set(r: number, g: number, b: number): Color3;
  5047. /**
  5048. * Compute the Color3 hexadecimal code as a string
  5049. * @returns a string containing the hexadecimal representation of the Color3 object
  5050. */
  5051. toHexString(): string;
  5052. /**
  5053. * Computes a new Color3 converted from the current one to linear space
  5054. * @returns a new Color3 object
  5055. */
  5056. toLinearSpace(): Color3;
  5057. /**
  5058. * Converts current color in rgb space to HSV values
  5059. * @returns a new color3 representing the HSV values
  5060. */
  5061. toHSV(): Color3;
  5062. /**
  5063. * Converts current color in rgb space to HSV values
  5064. * @param result defines the Color3 where to store the HSV values
  5065. */
  5066. toHSVToRef(result: Color3): void;
  5067. /**
  5068. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5069. * @param convertedColor defines the Color3 object where to store the linear space version
  5070. * @returns the unmodified Color3
  5071. */
  5072. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5073. /**
  5074. * Computes a new Color3 converted from the current one to gamma space
  5075. * @returns a new Color3 object
  5076. */
  5077. toGammaSpace(): Color3;
  5078. /**
  5079. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5080. * @param convertedColor defines the Color3 object where to store the gamma space version
  5081. * @returns the unmodified Color3
  5082. */
  5083. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5084. private static _BlackReadOnly;
  5085. /**
  5086. * Convert Hue, saturation and value to a Color3 (RGB)
  5087. * @param hue defines the hue
  5088. * @param saturation defines the saturation
  5089. * @param value defines the value
  5090. * @param result defines the Color3 where to store the RGB values
  5091. */
  5092. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5093. /**
  5094. * Creates a new Color3 from the string containing valid hexadecimal values
  5095. * @param hex defines a string containing valid hexadecimal values
  5096. * @returns a new Color3 object
  5097. */
  5098. static FromHexString(hex: string): Color3;
  5099. /**
  5100. * Creates a new Color3 from the starting index of the given array
  5101. * @param array defines the source array
  5102. * @param offset defines an offset in the source array
  5103. * @returns a new Color3 object
  5104. */
  5105. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5106. /**
  5107. * Creates a new Color3 from integer values (< 256)
  5108. * @param r defines the red component to read from (value between 0 and 255)
  5109. * @param g defines the green component to read from (value between 0 and 255)
  5110. * @param b defines the blue component to read from (value between 0 and 255)
  5111. * @returns a new Color3 object
  5112. */
  5113. static FromInts(r: number, g: number, b: number): Color3;
  5114. /**
  5115. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5116. * @param start defines the start Color3 value
  5117. * @param end defines the end Color3 value
  5118. * @param amount defines the gradient value between start and end
  5119. * @returns a new Color3 object
  5120. */
  5121. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5122. /**
  5123. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5124. * @param left defines the start value
  5125. * @param right defines the end value
  5126. * @param amount defines the gradient factor
  5127. * @param result defines the Color3 object where to store the result
  5128. */
  5129. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5130. /**
  5131. * Returns a Color3 value containing a red color
  5132. * @returns a new Color3 object
  5133. */
  5134. static Red(): Color3;
  5135. /**
  5136. * Returns a Color3 value containing a green color
  5137. * @returns a new Color3 object
  5138. */
  5139. static Green(): Color3;
  5140. /**
  5141. * Returns a Color3 value containing a blue color
  5142. * @returns a new Color3 object
  5143. */
  5144. static Blue(): Color3;
  5145. /**
  5146. * Returns a Color3 value containing a black color
  5147. * @returns a new Color3 object
  5148. */
  5149. static Black(): Color3;
  5150. /**
  5151. * Gets a Color3 value containing a black color that must not be updated
  5152. */
  5153. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5154. /**
  5155. * Returns a Color3 value containing a white color
  5156. * @returns a new Color3 object
  5157. */
  5158. static White(): Color3;
  5159. /**
  5160. * Returns a Color3 value containing a purple color
  5161. * @returns a new Color3 object
  5162. */
  5163. static Purple(): Color3;
  5164. /**
  5165. * Returns a Color3 value containing a magenta color
  5166. * @returns a new Color3 object
  5167. */
  5168. static Magenta(): Color3;
  5169. /**
  5170. * Returns a Color3 value containing a yellow color
  5171. * @returns a new Color3 object
  5172. */
  5173. static Yellow(): Color3;
  5174. /**
  5175. * Returns a Color3 value containing a gray color
  5176. * @returns a new Color3 object
  5177. */
  5178. static Gray(): Color3;
  5179. /**
  5180. * Returns a Color3 value containing a teal color
  5181. * @returns a new Color3 object
  5182. */
  5183. static Teal(): Color3;
  5184. /**
  5185. * Returns a Color3 value containing a random color
  5186. * @returns a new Color3 object
  5187. */
  5188. static Random(): Color3;
  5189. }
  5190. /**
  5191. * Class used to hold a RBGA color
  5192. */
  5193. export class Color4 {
  5194. /**
  5195. * Defines the red component (between 0 and 1, default is 0)
  5196. */
  5197. r: number;
  5198. /**
  5199. * Defines the green component (between 0 and 1, default is 0)
  5200. */
  5201. g: number;
  5202. /**
  5203. * Defines the blue component (between 0 and 1, default is 0)
  5204. */
  5205. b: number;
  5206. /**
  5207. * Defines the alpha component (between 0 and 1, default is 1)
  5208. */
  5209. a: number;
  5210. /**
  5211. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5212. * @param r defines the red component (between 0 and 1, default is 0)
  5213. * @param g defines the green component (between 0 and 1, default is 0)
  5214. * @param b defines the blue component (between 0 and 1, default is 0)
  5215. * @param a defines the alpha component (between 0 and 1, default is 1)
  5216. */
  5217. constructor(
  5218. /**
  5219. * Defines the red component (between 0 and 1, default is 0)
  5220. */
  5221. r?: number,
  5222. /**
  5223. * Defines the green component (between 0 and 1, default is 0)
  5224. */
  5225. g?: number,
  5226. /**
  5227. * Defines the blue component (between 0 and 1, default is 0)
  5228. */
  5229. b?: number,
  5230. /**
  5231. * Defines the alpha component (between 0 and 1, default is 1)
  5232. */
  5233. a?: number);
  5234. /**
  5235. * Adds in place the given Color4 values to the current Color4 object
  5236. * @param right defines the second operand
  5237. * @returns the current updated Color4 object
  5238. */
  5239. addInPlace(right: DeepImmutable<Color4>): Color4;
  5240. /**
  5241. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5242. * @returns the new array
  5243. */
  5244. asArray(): number[];
  5245. /**
  5246. * Stores from the starting index in the given array the Color4 successive values
  5247. * @param array defines the array where to store the r,g,b components
  5248. * @param index defines an optional index in the target array to define where to start storing values
  5249. * @returns the current Color4 object
  5250. */
  5251. toArray(array: number[], index?: number): Color4;
  5252. /**
  5253. * Determines equality between Color4 objects
  5254. * @param otherColor defines the second operand
  5255. * @returns true if the rgba values are equal to the given ones
  5256. */
  5257. equals(otherColor: DeepImmutable<Color4>): boolean;
  5258. /**
  5259. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5260. * @param right defines the second operand
  5261. * @returns a new Color4 object
  5262. */
  5263. add(right: DeepImmutable<Color4>): Color4;
  5264. /**
  5265. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5266. * @param right defines the second operand
  5267. * @returns a new Color4 object
  5268. */
  5269. subtract(right: DeepImmutable<Color4>): Color4;
  5270. /**
  5271. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5272. * @param right defines the second operand
  5273. * @param result defines the Color4 object where to store the result
  5274. * @returns the current Color4 object
  5275. */
  5276. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5277. /**
  5278. * Creates a new Color4 with the current Color4 values multiplied by scale
  5279. * @param scale defines the scaling factor to apply
  5280. * @returns a new Color4 object
  5281. */
  5282. scale(scale: number): Color4;
  5283. /**
  5284. * Multiplies the current Color4 values by scale and stores the result in "result"
  5285. * @param scale defines the scaling factor to apply
  5286. * @param result defines the Color4 object where to store the result
  5287. * @returns the current unmodified Color4
  5288. */
  5289. scaleToRef(scale: number, result: Color4): Color4;
  5290. /**
  5291. * Scale the current Color4 values by a factor and add the result to a given Color4
  5292. * @param scale defines the scale factor
  5293. * @param result defines the Color4 object where to store the result
  5294. * @returns the unmodified current Color4
  5295. */
  5296. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5297. /**
  5298. * Clamps the rgb values by the min and max values and stores the result into "result"
  5299. * @param min defines minimum clamping value (default is 0)
  5300. * @param max defines maximum clamping value (default is 1)
  5301. * @param result defines color to store the result into.
  5302. * @returns the cuurent Color4
  5303. */
  5304. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5305. /**
  5306. * Multipy an Color4 value by another and return a new Color4 object
  5307. * @param color defines the Color4 value to multiply by
  5308. * @returns a new Color4 object
  5309. */
  5310. multiply(color: Color4): Color4;
  5311. /**
  5312. * Multipy a Color4 value by another and push the result in a reference value
  5313. * @param color defines the Color4 value to multiply by
  5314. * @param result defines the Color4 to fill the result in
  5315. * @returns the result Color4
  5316. */
  5317. multiplyToRef(color: Color4, result: Color4): Color4;
  5318. /**
  5319. * Creates a string with the Color4 current values
  5320. * @returns the string representation of the Color4 object
  5321. */
  5322. toString(): string;
  5323. /**
  5324. * Returns the string "Color4"
  5325. * @returns "Color4"
  5326. */
  5327. getClassName(): string;
  5328. /**
  5329. * Compute the Color4 hash code
  5330. * @returns an unique number that can be used to hash Color4 objects
  5331. */
  5332. getHashCode(): number;
  5333. /**
  5334. * Creates a new Color4 copied from the current one
  5335. * @returns a new Color4 object
  5336. */
  5337. clone(): Color4;
  5338. /**
  5339. * Copies the given Color4 values into the current one
  5340. * @param source defines the source Color4 object
  5341. * @returns the current updated Color4 object
  5342. */
  5343. copyFrom(source: Color4): Color4;
  5344. /**
  5345. * Copies the given float values into the current one
  5346. * @param r defines the red component to read from
  5347. * @param g defines the green component to read from
  5348. * @param b defines the blue component to read from
  5349. * @param a defines the alpha component to read from
  5350. * @returns the current updated Color4 object
  5351. */
  5352. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5353. /**
  5354. * Copies the given float values into the current one
  5355. * @param r defines the red component to read from
  5356. * @param g defines the green component to read from
  5357. * @param b defines the blue component to read from
  5358. * @param a defines the alpha component to read from
  5359. * @returns the current updated Color4 object
  5360. */
  5361. set(r: number, g: number, b: number, a: number): Color4;
  5362. /**
  5363. * Compute the Color4 hexadecimal code as a string
  5364. * @returns a string containing the hexadecimal representation of the Color4 object
  5365. */
  5366. toHexString(): string;
  5367. /**
  5368. * Computes a new Color4 converted from the current one to linear space
  5369. * @returns a new Color4 object
  5370. */
  5371. toLinearSpace(): Color4;
  5372. /**
  5373. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5374. * @param convertedColor defines the Color4 object where to store the linear space version
  5375. * @returns the unmodified Color4
  5376. */
  5377. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5378. /**
  5379. * Computes a new Color4 converted from the current one to gamma space
  5380. * @returns a new Color4 object
  5381. */
  5382. toGammaSpace(): Color4;
  5383. /**
  5384. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5385. * @param convertedColor defines the Color4 object where to store the gamma space version
  5386. * @returns the unmodified Color4
  5387. */
  5388. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5389. /**
  5390. * Creates a new Color4 from the string containing valid hexadecimal values
  5391. * @param hex defines a string containing valid hexadecimal values
  5392. * @returns a new Color4 object
  5393. */
  5394. static FromHexString(hex: string): Color4;
  5395. /**
  5396. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5397. * @param left defines the start value
  5398. * @param right defines the end value
  5399. * @param amount defines the gradient factor
  5400. * @returns a new Color4 object
  5401. */
  5402. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5403. /**
  5404. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5405. * @param left defines the start value
  5406. * @param right defines the end value
  5407. * @param amount defines the gradient factor
  5408. * @param result defines the Color4 object where to store data
  5409. */
  5410. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5411. /**
  5412. * Creates a new Color4 from a Color3 and an alpha value
  5413. * @param color3 defines the source Color3 to read from
  5414. * @param alpha defines the alpha component (1.0 by default)
  5415. * @returns a new Color4 object
  5416. */
  5417. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5418. /**
  5419. * Creates a new Color4 from the starting index element of the given array
  5420. * @param array defines the source array to read from
  5421. * @param offset defines the offset in the source array
  5422. * @returns a new Color4 object
  5423. */
  5424. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5425. /**
  5426. * Creates a new Color3 from integer values (< 256)
  5427. * @param r defines the red component to read from (value between 0 and 255)
  5428. * @param g defines the green component to read from (value between 0 and 255)
  5429. * @param b defines the blue component to read from (value between 0 and 255)
  5430. * @param a defines the alpha component to read from (value between 0 and 255)
  5431. * @returns a new Color3 object
  5432. */
  5433. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5434. /**
  5435. * Check the content of a given array and convert it to an array containing RGBA data
  5436. * If the original array was already containing count * 4 values then it is returned directly
  5437. * @param colors defines the array to check
  5438. * @param count defines the number of RGBA data to expect
  5439. * @returns an array containing count * 4 values (RGBA)
  5440. */
  5441. static CheckColors4(colors: number[], count: number): number[];
  5442. }
  5443. /**
  5444. * @hidden
  5445. */
  5446. export class TmpColors {
  5447. static Color3: Color3[];
  5448. static Color4: Color4[];
  5449. }
  5450. }
  5451. declare module "babylonjs/Maths/sphericalPolynomial" {
  5452. import { Vector3 } from "babylonjs/Maths/math.vector";
  5453. import { Color3 } from "babylonjs/Maths/math.color";
  5454. /**
  5455. * Class representing spherical harmonics coefficients to the 3rd degree
  5456. */
  5457. export class SphericalHarmonics {
  5458. /**
  5459. * Defines whether or not the harmonics have been prescaled for rendering.
  5460. */
  5461. preScaled: boolean;
  5462. /**
  5463. * The l0,0 coefficients of the spherical harmonics
  5464. */
  5465. l00: Vector3;
  5466. /**
  5467. * The l1,-1 coefficients of the spherical harmonics
  5468. */
  5469. l1_1: Vector3;
  5470. /**
  5471. * The l1,0 coefficients of the spherical harmonics
  5472. */
  5473. l10: Vector3;
  5474. /**
  5475. * The l1,1 coefficients of the spherical harmonics
  5476. */
  5477. l11: Vector3;
  5478. /**
  5479. * The l2,-2 coefficients of the spherical harmonics
  5480. */
  5481. l2_2: Vector3;
  5482. /**
  5483. * The l2,-1 coefficients of the spherical harmonics
  5484. */
  5485. l2_1: Vector3;
  5486. /**
  5487. * The l2,0 coefficients of the spherical harmonics
  5488. */
  5489. l20: Vector3;
  5490. /**
  5491. * The l2,1 coefficients of the spherical harmonics
  5492. */
  5493. l21: Vector3;
  5494. /**
  5495. * The l2,2 coefficients of the spherical harmonics
  5496. */
  5497. l22: Vector3;
  5498. /**
  5499. * Adds a light to the spherical harmonics
  5500. * @param direction the direction of the light
  5501. * @param color the color of the light
  5502. * @param deltaSolidAngle the delta solid angle of the light
  5503. */
  5504. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5505. /**
  5506. * Scales the spherical harmonics by the given amount
  5507. * @param scale the amount to scale
  5508. */
  5509. scaleInPlace(scale: number): void;
  5510. /**
  5511. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5512. *
  5513. * ```
  5514. * E_lm = A_l * L_lm
  5515. * ```
  5516. *
  5517. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5518. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5519. * the scaling factors are given in equation 9.
  5520. */
  5521. convertIncidentRadianceToIrradiance(): void;
  5522. /**
  5523. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5524. *
  5525. * ```
  5526. * L = (1/pi) * E * rho
  5527. * ```
  5528. *
  5529. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5530. */
  5531. convertIrradianceToLambertianRadiance(): void;
  5532. /**
  5533. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5534. * required operations at run time.
  5535. *
  5536. * This is simply done by scaling back the SH with Ylm constants parameter.
  5537. * The trigonometric part being applied by the shader at run time.
  5538. */
  5539. preScaleForRendering(): void;
  5540. /**
  5541. * Constructs a spherical harmonics from an array.
  5542. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5543. * @returns the spherical harmonics
  5544. */
  5545. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5546. /**
  5547. * Gets the spherical harmonics from polynomial
  5548. * @param polynomial the spherical polynomial
  5549. * @returns the spherical harmonics
  5550. */
  5551. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5552. }
  5553. /**
  5554. * Class representing spherical polynomial coefficients to the 3rd degree
  5555. */
  5556. export class SphericalPolynomial {
  5557. private _harmonics;
  5558. /**
  5559. * The spherical harmonics used to create the polynomials.
  5560. */
  5561. readonly preScaledHarmonics: SphericalHarmonics;
  5562. /**
  5563. * The x coefficients of the spherical polynomial
  5564. */
  5565. x: Vector3;
  5566. /**
  5567. * The y coefficients of the spherical polynomial
  5568. */
  5569. y: Vector3;
  5570. /**
  5571. * The z coefficients of the spherical polynomial
  5572. */
  5573. z: Vector3;
  5574. /**
  5575. * The xx coefficients of the spherical polynomial
  5576. */
  5577. xx: Vector3;
  5578. /**
  5579. * The yy coefficients of the spherical polynomial
  5580. */
  5581. yy: Vector3;
  5582. /**
  5583. * The zz coefficients of the spherical polynomial
  5584. */
  5585. zz: Vector3;
  5586. /**
  5587. * The xy coefficients of the spherical polynomial
  5588. */
  5589. xy: Vector3;
  5590. /**
  5591. * The yz coefficients of the spherical polynomial
  5592. */
  5593. yz: Vector3;
  5594. /**
  5595. * The zx coefficients of the spherical polynomial
  5596. */
  5597. zx: Vector3;
  5598. /**
  5599. * Adds an ambient color to the spherical polynomial
  5600. * @param color the color to add
  5601. */
  5602. addAmbient(color: Color3): void;
  5603. /**
  5604. * Scales the spherical polynomial by the given amount
  5605. * @param scale the amount to scale
  5606. */
  5607. scaleInPlace(scale: number): void;
  5608. /**
  5609. * Gets the spherical polynomial from harmonics
  5610. * @param harmonics the spherical harmonics
  5611. * @returns the spherical polynomial
  5612. */
  5613. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5614. /**
  5615. * Constructs a spherical polynomial from an array.
  5616. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5617. * @returns the spherical polynomial
  5618. */
  5619. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5620. }
  5621. }
  5622. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5623. /**
  5624. * Define options used to create a render target texture
  5625. */
  5626. export class RenderTargetCreationOptions {
  5627. /**
  5628. * Specifies is mipmaps must be generated
  5629. */
  5630. generateMipMaps?: boolean;
  5631. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5632. generateDepthBuffer?: boolean;
  5633. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5634. generateStencilBuffer?: boolean;
  5635. /** Defines texture type (int by default) */
  5636. type?: number;
  5637. /** Defines sampling mode (trilinear by default) */
  5638. samplingMode?: number;
  5639. /** Defines format (RGBA by default) */
  5640. format?: number;
  5641. }
  5642. }
  5643. declare module "babylonjs/States/alphaCullingState" {
  5644. /**
  5645. * @hidden
  5646. **/
  5647. export class _AlphaState {
  5648. private _isAlphaBlendDirty;
  5649. private _isBlendFunctionParametersDirty;
  5650. private _isBlendEquationParametersDirty;
  5651. private _isBlendConstantsDirty;
  5652. private _alphaBlend;
  5653. private _blendFunctionParameters;
  5654. private _blendEquationParameters;
  5655. private _blendConstants;
  5656. /**
  5657. * Initializes the state.
  5658. */
  5659. constructor();
  5660. readonly isDirty: boolean;
  5661. alphaBlend: boolean;
  5662. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5663. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5664. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5665. reset(): void;
  5666. apply(gl: WebGLRenderingContext): void;
  5667. }
  5668. }
  5669. declare module "babylonjs/States/depthCullingState" {
  5670. import { Nullable } from "babylonjs/types";
  5671. /**
  5672. * @hidden
  5673. **/
  5674. export class _DepthCullingState {
  5675. private _isDepthTestDirty;
  5676. private _isDepthMaskDirty;
  5677. private _isDepthFuncDirty;
  5678. private _isCullFaceDirty;
  5679. private _isCullDirty;
  5680. private _isZOffsetDirty;
  5681. private _isFrontFaceDirty;
  5682. private _depthTest;
  5683. private _depthMask;
  5684. private _depthFunc;
  5685. private _cull;
  5686. private _cullFace;
  5687. private _zOffset;
  5688. private _frontFace;
  5689. /**
  5690. * Initializes the state.
  5691. */
  5692. constructor();
  5693. readonly isDirty: boolean;
  5694. zOffset: number;
  5695. cullFace: Nullable<number>;
  5696. cull: Nullable<boolean>;
  5697. depthFunc: Nullable<number>;
  5698. depthMask: boolean;
  5699. depthTest: boolean;
  5700. frontFace: Nullable<number>;
  5701. reset(): void;
  5702. apply(gl: WebGLRenderingContext): void;
  5703. }
  5704. }
  5705. declare module "babylonjs/States/stencilState" {
  5706. /**
  5707. * @hidden
  5708. **/
  5709. export class _StencilState {
  5710. /** 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 */
  5711. static readonly ALWAYS: number;
  5712. /** Passed to stencilOperation to specify that stencil value must be kept */
  5713. static readonly KEEP: number;
  5714. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5715. static readonly REPLACE: number;
  5716. private _isStencilTestDirty;
  5717. private _isStencilMaskDirty;
  5718. private _isStencilFuncDirty;
  5719. private _isStencilOpDirty;
  5720. private _stencilTest;
  5721. private _stencilMask;
  5722. private _stencilFunc;
  5723. private _stencilFuncRef;
  5724. private _stencilFuncMask;
  5725. private _stencilOpStencilFail;
  5726. private _stencilOpDepthFail;
  5727. private _stencilOpStencilDepthPass;
  5728. readonly isDirty: boolean;
  5729. stencilFunc: number;
  5730. stencilFuncRef: number;
  5731. stencilFuncMask: number;
  5732. stencilOpStencilFail: number;
  5733. stencilOpDepthFail: number;
  5734. stencilOpStencilDepthPass: number;
  5735. stencilMask: number;
  5736. stencilTest: boolean;
  5737. constructor();
  5738. reset(): void;
  5739. apply(gl: WebGLRenderingContext): void;
  5740. }
  5741. }
  5742. declare module "babylonjs/States/index" {
  5743. export * from "babylonjs/States/alphaCullingState";
  5744. export * from "babylonjs/States/depthCullingState";
  5745. export * from "babylonjs/States/stencilState";
  5746. }
  5747. declare module "babylonjs/Instrumentation/timeToken" {
  5748. import { Nullable } from "babylonjs/types";
  5749. /**
  5750. * @hidden
  5751. **/
  5752. export class _TimeToken {
  5753. _startTimeQuery: Nullable<WebGLQuery>;
  5754. _endTimeQuery: Nullable<WebGLQuery>;
  5755. _timeElapsedQuery: Nullable<WebGLQuery>;
  5756. _timeElapsedQueryEnded: boolean;
  5757. }
  5758. }
  5759. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5760. /**
  5761. * Class used to evalaute queries containing `and` and `or` operators
  5762. */
  5763. export class AndOrNotEvaluator {
  5764. /**
  5765. * Evaluate a query
  5766. * @param query defines the query to evaluate
  5767. * @param evaluateCallback defines the callback used to filter result
  5768. * @returns true if the query matches
  5769. */
  5770. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5771. private static _HandleParenthesisContent;
  5772. private static _SimplifyNegation;
  5773. }
  5774. }
  5775. declare module "babylonjs/Misc/tags" {
  5776. /**
  5777. * Class used to store custom tags
  5778. */
  5779. export class Tags {
  5780. /**
  5781. * Adds support for tags on the given object
  5782. * @param obj defines the object to use
  5783. */
  5784. static EnableFor(obj: any): void;
  5785. /**
  5786. * Removes tags support
  5787. * @param obj defines the object to use
  5788. */
  5789. static DisableFor(obj: any): void;
  5790. /**
  5791. * Gets a boolean indicating if the given object has tags
  5792. * @param obj defines the object to use
  5793. * @returns a boolean
  5794. */
  5795. static HasTags(obj: any): boolean;
  5796. /**
  5797. * Gets the tags available on a given object
  5798. * @param obj defines the object to use
  5799. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5800. * @returns the tags
  5801. */
  5802. static GetTags(obj: any, asString?: boolean): any;
  5803. /**
  5804. * Adds tags to an object
  5805. * @param obj defines the object to use
  5806. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5807. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5808. */
  5809. static AddTagsTo(obj: any, tagsString: string): void;
  5810. /**
  5811. * @hidden
  5812. */
  5813. static _AddTagTo(obj: any, tag: string): void;
  5814. /**
  5815. * Removes specific tags from a specific object
  5816. * @param obj defines the object to use
  5817. * @param tagsString defines the tags to remove
  5818. */
  5819. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5820. /**
  5821. * @hidden
  5822. */
  5823. static _RemoveTagFrom(obj: any, tag: string): void;
  5824. /**
  5825. * Defines if tags hosted on an object match a given query
  5826. * @param obj defines the object to use
  5827. * @param tagsQuery defines the tag query
  5828. * @returns a boolean
  5829. */
  5830. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5831. }
  5832. }
  5833. declare module "babylonjs/Maths/math.path" {
  5834. import { DeepImmutable, Nullable } from "babylonjs/types";
  5835. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5836. /**
  5837. * Defines potential orientation for back face culling
  5838. */
  5839. export enum Orientation {
  5840. /**
  5841. * Clockwise
  5842. */
  5843. CW = 0,
  5844. /** Counter clockwise */
  5845. CCW = 1
  5846. }
  5847. /** Class used to represent a Bezier curve */
  5848. export class BezierCurve {
  5849. /**
  5850. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5851. * @param t defines the time
  5852. * @param x1 defines the left coordinate on X axis
  5853. * @param y1 defines the left coordinate on Y axis
  5854. * @param x2 defines the right coordinate on X axis
  5855. * @param y2 defines the right coordinate on Y axis
  5856. * @returns the interpolated value
  5857. */
  5858. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5859. }
  5860. /**
  5861. * Defines angle representation
  5862. */
  5863. export class Angle {
  5864. private _radians;
  5865. /**
  5866. * Creates an Angle object of "radians" radians (float).
  5867. * @param radians the angle in radians
  5868. */
  5869. constructor(radians: number);
  5870. /**
  5871. * Get value in degrees
  5872. * @returns the Angle value in degrees (float)
  5873. */
  5874. degrees(): number;
  5875. /**
  5876. * Get value in radians
  5877. * @returns the Angle value in radians (float)
  5878. */
  5879. radians(): number;
  5880. /**
  5881. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5882. * @param a defines first vector
  5883. * @param b defines second vector
  5884. * @returns a new Angle
  5885. */
  5886. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5887. /**
  5888. * Gets a new Angle object from the given float in radians
  5889. * @param radians defines the angle value in radians
  5890. * @returns a new Angle
  5891. */
  5892. static FromRadians(radians: number): Angle;
  5893. /**
  5894. * Gets a new Angle object from the given float in degrees
  5895. * @param degrees defines the angle value in degrees
  5896. * @returns a new Angle
  5897. */
  5898. static FromDegrees(degrees: number): Angle;
  5899. }
  5900. /**
  5901. * This represents an arc in a 2d space.
  5902. */
  5903. export class Arc2 {
  5904. /** Defines the start point of the arc */
  5905. startPoint: Vector2;
  5906. /** Defines the mid point of the arc */
  5907. midPoint: Vector2;
  5908. /** Defines the end point of the arc */
  5909. endPoint: Vector2;
  5910. /**
  5911. * Defines the center point of the arc.
  5912. */
  5913. centerPoint: Vector2;
  5914. /**
  5915. * Defines the radius of the arc.
  5916. */
  5917. radius: number;
  5918. /**
  5919. * Defines the angle of the arc (from mid point to end point).
  5920. */
  5921. angle: Angle;
  5922. /**
  5923. * Defines the start angle of the arc (from start point to middle point).
  5924. */
  5925. startAngle: Angle;
  5926. /**
  5927. * Defines the orientation of the arc (clock wise/counter clock wise).
  5928. */
  5929. orientation: Orientation;
  5930. /**
  5931. * Creates an Arc object from the three given points : start, middle and end.
  5932. * @param startPoint Defines the start point of the arc
  5933. * @param midPoint Defines the midlle point of the arc
  5934. * @param endPoint Defines the end point of the arc
  5935. */
  5936. constructor(
  5937. /** Defines the start point of the arc */
  5938. startPoint: Vector2,
  5939. /** Defines the mid point of the arc */
  5940. midPoint: Vector2,
  5941. /** Defines the end point of the arc */
  5942. endPoint: Vector2);
  5943. }
  5944. /**
  5945. * Represents a 2D path made up of multiple 2D points
  5946. */
  5947. export class Path2 {
  5948. private _points;
  5949. private _length;
  5950. /**
  5951. * If the path start and end point are the same
  5952. */
  5953. closed: boolean;
  5954. /**
  5955. * Creates a Path2 object from the starting 2D coordinates x and y.
  5956. * @param x the starting points x value
  5957. * @param y the starting points y value
  5958. */
  5959. constructor(x: number, y: number);
  5960. /**
  5961. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5962. * @param x the added points x value
  5963. * @param y the added points y value
  5964. * @returns the updated Path2.
  5965. */
  5966. addLineTo(x: number, y: number): Path2;
  5967. /**
  5968. * 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.
  5969. * @param midX middle point x value
  5970. * @param midY middle point y value
  5971. * @param endX end point x value
  5972. * @param endY end point y value
  5973. * @param numberOfSegments (default: 36)
  5974. * @returns the updated Path2.
  5975. */
  5976. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5977. /**
  5978. * Closes the Path2.
  5979. * @returns the Path2.
  5980. */
  5981. close(): Path2;
  5982. /**
  5983. * Gets the sum of the distance between each sequential point in the path
  5984. * @returns the Path2 total length (float).
  5985. */
  5986. length(): number;
  5987. /**
  5988. * Gets the points which construct the path
  5989. * @returns the Path2 internal array of points.
  5990. */
  5991. getPoints(): Vector2[];
  5992. /**
  5993. * Retreives the point at the distance aways from the starting point
  5994. * @param normalizedLengthPosition the length along the path to retreive the point from
  5995. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5996. */
  5997. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5998. /**
  5999. * Creates a new path starting from an x and y position
  6000. * @param x starting x value
  6001. * @param y starting y value
  6002. * @returns a new Path2 starting at the coordinates (x, y).
  6003. */
  6004. static StartingAt(x: number, y: number): Path2;
  6005. }
  6006. /**
  6007. * Represents a 3D path made up of multiple 3D points
  6008. */
  6009. export class Path3D {
  6010. /**
  6011. * an array of Vector3, the curve axis of the Path3D
  6012. */
  6013. path: Vector3[];
  6014. private _curve;
  6015. private _distances;
  6016. private _tangents;
  6017. private _normals;
  6018. private _binormals;
  6019. private _raw;
  6020. /**
  6021. * new Path3D(path, normal, raw)
  6022. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  6023. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  6024. * @param path an array of Vector3, the curve axis of the Path3D
  6025. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  6026. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  6027. */
  6028. constructor(
  6029. /**
  6030. * an array of Vector3, the curve axis of the Path3D
  6031. */
  6032. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  6033. /**
  6034. * Returns the Path3D array of successive Vector3 designing its curve.
  6035. * @returns the Path3D array of successive Vector3 designing its curve.
  6036. */
  6037. getCurve(): Vector3[];
  6038. /**
  6039. * Returns an array populated with tangent vectors on each Path3D curve point.
  6040. * @returns an array populated with tangent vectors on each Path3D curve point.
  6041. */
  6042. getTangents(): Vector3[];
  6043. /**
  6044. * Returns an array populated with normal vectors on each Path3D curve point.
  6045. * @returns an array populated with normal vectors on each Path3D curve point.
  6046. */
  6047. getNormals(): Vector3[];
  6048. /**
  6049. * Returns an array populated with binormal vectors on each Path3D curve point.
  6050. * @returns an array populated with binormal vectors on each Path3D curve point.
  6051. */
  6052. getBinormals(): Vector3[];
  6053. /**
  6054. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6055. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6056. */
  6057. getDistances(): number[];
  6058. /**
  6059. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6060. * @param path path which all values are copied into the curves points
  6061. * @param firstNormal which should be projected onto the curve
  6062. * @returns the same object updated.
  6063. */
  6064. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6065. private _compute;
  6066. private _getFirstNonNullVector;
  6067. private _getLastNonNullVector;
  6068. private _normalVector;
  6069. }
  6070. /**
  6071. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6072. * A Curve3 is designed from a series of successive Vector3.
  6073. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6074. */
  6075. export class Curve3 {
  6076. private _points;
  6077. private _length;
  6078. /**
  6079. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6080. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6081. * @param v1 (Vector3) the control point
  6082. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6083. * @param nbPoints (integer) the wanted number of points in the curve
  6084. * @returns the created Curve3
  6085. */
  6086. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6087. /**
  6088. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6089. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6090. * @param v1 (Vector3) the first control point
  6091. * @param v2 (Vector3) the second control point
  6092. * @param v3 (Vector3) the end point of the Cubic Bezier
  6093. * @param nbPoints (integer) the wanted number of points in the curve
  6094. * @returns the created Curve3
  6095. */
  6096. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6097. /**
  6098. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6099. * @param p1 (Vector3) the origin point of the Hermite Spline
  6100. * @param t1 (Vector3) the tangent vector at the origin point
  6101. * @param p2 (Vector3) the end point of the Hermite Spline
  6102. * @param t2 (Vector3) the tangent vector at the end point
  6103. * @param nbPoints (integer) the wanted number of points in the curve
  6104. * @returns the created Curve3
  6105. */
  6106. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6107. /**
  6108. * Returns a Curve3 object along a CatmullRom Spline curve :
  6109. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6110. * @param nbPoints (integer) the wanted number of points between each curve control points
  6111. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6112. * @returns the created Curve3
  6113. */
  6114. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6115. /**
  6116. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6117. * A Curve3 is designed from a series of successive Vector3.
  6118. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6119. * @param points points which make up the curve
  6120. */
  6121. constructor(points: Vector3[]);
  6122. /**
  6123. * @returns the Curve3 stored array of successive Vector3
  6124. */
  6125. getPoints(): Vector3[];
  6126. /**
  6127. * @returns the computed length (float) of the curve.
  6128. */
  6129. length(): number;
  6130. /**
  6131. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6132. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6133. * curveA and curveB keep unchanged.
  6134. * @param curve the curve to continue from this curve
  6135. * @returns the newly constructed curve
  6136. */
  6137. continue(curve: DeepImmutable<Curve3>): Curve3;
  6138. private _computeLength;
  6139. }
  6140. }
  6141. declare module "babylonjs/Animations/easing" {
  6142. /**
  6143. * This represents the main contract an easing function should follow.
  6144. * Easing functions are used throughout the animation system.
  6145. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6146. */
  6147. export interface IEasingFunction {
  6148. /**
  6149. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6150. * of the easing function.
  6151. * The link below provides some of the most common examples of easing functions.
  6152. * @see https://easings.net/
  6153. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6154. * @returns the corresponding value on the curve defined by the easing function
  6155. */
  6156. ease(gradient: number): number;
  6157. }
  6158. /**
  6159. * Base class used for every default easing function.
  6160. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6161. */
  6162. export class EasingFunction implements IEasingFunction {
  6163. /**
  6164. * Interpolation follows the mathematical formula associated with the easing function.
  6165. */
  6166. static readonly EASINGMODE_EASEIN: number;
  6167. /**
  6168. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6169. */
  6170. static readonly EASINGMODE_EASEOUT: number;
  6171. /**
  6172. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6173. */
  6174. static readonly EASINGMODE_EASEINOUT: number;
  6175. private _easingMode;
  6176. /**
  6177. * Sets the easing mode of the current function.
  6178. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6179. */
  6180. setEasingMode(easingMode: number): void;
  6181. /**
  6182. * Gets the current easing mode.
  6183. * @returns the easing mode
  6184. */
  6185. getEasingMode(): number;
  6186. /**
  6187. * @hidden
  6188. */
  6189. easeInCore(gradient: number): number;
  6190. /**
  6191. * Given an input gradient between 0 and 1, this returns the corresponding value
  6192. * of the easing function.
  6193. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6194. * @returns the corresponding value on the curve defined by the easing function
  6195. */
  6196. ease(gradient: number): number;
  6197. }
  6198. /**
  6199. * Easing function with a circle shape (see link below).
  6200. * @see https://easings.net/#easeInCirc
  6201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6202. */
  6203. export class CircleEase extends EasingFunction implements IEasingFunction {
  6204. /** @hidden */
  6205. easeInCore(gradient: number): number;
  6206. }
  6207. /**
  6208. * Easing function with a ease back shape (see link below).
  6209. * @see https://easings.net/#easeInBack
  6210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6211. */
  6212. export class BackEase extends EasingFunction implements IEasingFunction {
  6213. /** Defines the amplitude of the function */
  6214. amplitude: number;
  6215. /**
  6216. * Instantiates a back ease easing
  6217. * @see https://easings.net/#easeInBack
  6218. * @param amplitude Defines the amplitude of the function
  6219. */
  6220. constructor(
  6221. /** Defines the amplitude of the function */
  6222. amplitude?: number);
  6223. /** @hidden */
  6224. easeInCore(gradient: number): number;
  6225. }
  6226. /**
  6227. * Easing function with a bouncing shape (see link below).
  6228. * @see https://easings.net/#easeInBounce
  6229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6230. */
  6231. export class BounceEase extends EasingFunction implements IEasingFunction {
  6232. /** Defines the number of bounces */
  6233. bounces: number;
  6234. /** Defines the amplitude of the bounce */
  6235. bounciness: number;
  6236. /**
  6237. * Instantiates a bounce easing
  6238. * @see https://easings.net/#easeInBounce
  6239. * @param bounces Defines the number of bounces
  6240. * @param bounciness Defines the amplitude of the bounce
  6241. */
  6242. constructor(
  6243. /** Defines the number of bounces */
  6244. bounces?: number,
  6245. /** Defines the amplitude of the bounce */
  6246. bounciness?: number);
  6247. /** @hidden */
  6248. easeInCore(gradient: number): number;
  6249. }
  6250. /**
  6251. * Easing function with a power of 3 shape (see link below).
  6252. * @see https://easings.net/#easeInCubic
  6253. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6254. */
  6255. export class CubicEase extends EasingFunction implements IEasingFunction {
  6256. /** @hidden */
  6257. easeInCore(gradient: number): number;
  6258. }
  6259. /**
  6260. * Easing function with an elastic shape (see link below).
  6261. * @see https://easings.net/#easeInElastic
  6262. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6263. */
  6264. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6265. /** Defines the number of oscillations*/
  6266. oscillations: number;
  6267. /** Defines the amplitude of the oscillations*/
  6268. springiness: number;
  6269. /**
  6270. * Instantiates an elastic easing function
  6271. * @see https://easings.net/#easeInElastic
  6272. * @param oscillations Defines the number of oscillations
  6273. * @param springiness Defines the amplitude of the oscillations
  6274. */
  6275. constructor(
  6276. /** Defines the number of oscillations*/
  6277. oscillations?: number,
  6278. /** Defines the amplitude of the oscillations*/
  6279. springiness?: number);
  6280. /** @hidden */
  6281. easeInCore(gradient: number): number;
  6282. }
  6283. /**
  6284. * Easing function with an exponential shape (see link below).
  6285. * @see https://easings.net/#easeInExpo
  6286. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6287. */
  6288. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6289. /** Defines the exponent of the function */
  6290. exponent: number;
  6291. /**
  6292. * Instantiates an exponential easing function
  6293. * @see https://easings.net/#easeInExpo
  6294. * @param exponent Defines the exponent of the function
  6295. */
  6296. constructor(
  6297. /** Defines the exponent of the function */
  6298. exponent?: number);
  6299. /** @hidden */
  6300. easeInCore(gradient: number): number;
  6301. }
  6302. /**
  6303. * Easing function with a power shape (see link below).
  6304. * @see https://easings.net/#easeInQuad
  6305. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6306. */
  6307. export class PowerEase extends EasingFunction implements IEasingFunction {
  6308. /** Defines the power of the function */
  6309. power: number;
  6310. /**
  6311. * Instantiates an power base easing function
  6312. * @see https://easings.net/#easeInQuad
  6313. * @param power Defines the power of the function
  6314. */
  6315. constructor(
  6316. /** Defines the power of the function */
  6317. power?: number);
  6318. /** @hidden */
  6319. easeInCore(gradient: number): number;
  6320. }
  6321. /**
  6322. * Easing function with a power of 2 shape (see link below).
  6323. * @see https://easings.net/#easeInQuad
  6324. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6325. */
  6326. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6327. /** @hidden */
  6328. easeInCore(gradient: number): number;
  6329. }
  6330. /**
  6331. * Easing function with a power of 4 shape (see link below).
  6332. * @see https://easings.net/#easeInQuart
  6333. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6334. */
  6335. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6336. /** @hidden */
  6337. easeInCore(gradient: number): number;
  6338. }
  6339. /**
  6340. * Easing function with a power of 5 shape (see link below).
  6341. * @see https://easings.net/#easeInQuint
  6342. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6343. */
  6344. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6345. /** @hidden */
  6346. easeInCore(gradient: number): number;
  6347. }
  6348. /**
  6349. * Easing function with a sin shape (see link below).
  6350. * @see https://easings.net/#easeInSine
  6351. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6352. */
  6353. export class SineEase extends EasingFunction implements IEasingFunction {
  6354. /** @hidden */
  6355. easeInCore(gradient: number): number;
  6356. }
  6357. /**
  6358. * Easing function with a bezier shape (see link below).
  6359. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6360. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6361. */
  6362. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6363. /** Defines the x component of the start tangent in the bezier curve */
  6364. x1: number;
  6365. /** Defines the y component of the start tangent in the bezier curve */
  6366. y1: number;
  6367. /** Defines the x component of the end tangent in the bezier curve */
  6368. x2: number;
  6369. /** Defines the y component of the end tangent in the bezier curve */
  6370. y2: number;
  6371. /**
  6372. * Instantiates a bezier function
  6373. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6374. * @param x1 Defines the x component of the start tangent in the bezier curve
  6375. * @param y1 Defines the y component of the start tangent in the bezier curve
  6376. * @param x2 Defines the x component of the end tangent in the bezier curve
  6377. * @param y2 Defines the y component of the end tangent in the bezier curve
  6378. */
  6379. constructor(
  6380. /** Defines the x component of the start tangent in the bezier curve */
  6381. x1?: number,
  6382. /** Defines the y component of the start tangent in the bezier curve */
  6383. y1?: number,
  6384. /** Defines the x component of the end tangent in the bezier curve */
  6385. x2?: number,
  6386. /** Defines the y component of the end tangent in the bezier curve */
  6387. y2?: number);
  6388. /** @hidden */
  6389. easeInCore(gradient: number): number;
  6390. }
  6391. }
  6392. declare module "babylonjs/Animations/animationKey" {
  6393. /**
  6394. * Defines an interface which represents an animation key frame
  6395. */
  6396. export interface IAnimationKey {
  6397. /**
  6398. * Frame of the key frame
  6399. */
  6400. frame: number;
  6401. /**
  6402. * Value at the specifies key frame
  6403. */
  6404. value: any;
  6405. /**
  6406. * The input tangent for the cubic hermite spline
  6407. */
  6408. inTangent?: any;
  6409. /**
  6410. * The output tangent for the cubic hermite spline
  6411. */
  6412. outTangent?: any;
  6413. /**
  6414. * The animation interpolation type
  6415. */
  6416. interpolation?: AnimationKeyInterpolation;
  6417. }
  6418. /**
  6419. * Enum for the animation key frame interpolation type
  6420. */
  6421. export enum AnimationKeyInterpolation {
  6422. /**
  6423. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6424. */
  6425. STEP = 1
  6426. }
  6427. }
  6428. declare module "babylonjs/Animations/animationRange" {
  6429. /**
  6430. * Represents the range of an animation
  6431. */
  6432. export class AnimationRange {
  6433. /**The name of the animation range**/
  6434. name: string;
  6435. /**The starting frame of the animation */
  6436. from: number;
  6437. /**The ending frame of the animation*/
  6438. to: number;
  6439. /**
  6440. * Initializes the range of an animation
  6441. * @param name The name of the animation range
  6442. * @param from The starting frame of the animation
  6443. * @param to The ending frame of the animation
  6444. */
  6445. constructor(
  6446. /**The name of the animation range**/
  6447. name: string,
  6448. /**The starting frame of the animation */
  6449. from: number,
  6450. /**The ending frame of the animation*/
  6451. to: number);
  6452. /**
  6453. * Makes a copy of the animation range
  6454. * @returns A copy of the animation range
  6455. */
  6456. clone(): AnimationRange;
  6457. }
  6458. }
  6459. declare module "babylonjs/Animations/animationEvent" {
  6460. /**
  6461. * Composed of a frame, and an action function
  6462. */
  6463. export class AnimationEvent {
  6464. /** The frame for which the event is triggered **/
  6465. frame: number;
  6466. /** The event to perform when triggered **/
  6467. action: (currentFrame: number) => void;
  6468. /** Specifies if the event should be triggered only once**/
  6469. onlyOnce?: boolean | undefined;
  6470. /**
  6471. * Specifies if the animation event is done
  6472. */
  6473. isDone: boolean;
  6474. /**
  6475. * Initializes the animation event
  6476. * @param frame The frame for which the event is triggered
  6477. * @param action The event to perform when triggered
  6478. * @param onlyOnce Specifies if the event should be triggered only once
  6479. */
  6480. constructor(
  6481. /** The frame for which the event is triggered **/
  6482. frame: number,
  6483. /** The event to perform when triggered **/
  6484. action: (currentFrame: number) => void,
  6485. /** Specifies if the event should be triggered only once**/
  6486. onlyOnce?: boolean | undefined);
  6487. /** @hidden */
  6488. _clone(): AnimationEvent;
  6489. }
  6490. }
  6491. declare module "babylonjs/Behaviors/behavior" {
  6492. import { Nullable } from "babylonjs/types";
  6493. /**
  6494. * Interface used to define a behavior
  6495. */
  6496. export interface Behavior<T> {
  6497. /** gets or sets behavior's name */
  6498. name: string;
  6499. /**
  6500. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6501. */
  6502. init(): void;
  6503. /**
  6504. * Called when the behavior is attached to a target
  6505. * @param target defines the target where the behavior is attached to
  6506. */
  6507. attach(target: T): void;
  6508. /**
  6509. * Called when the behavior is detached from its target
  6510. */
  6511. detach(): void;
  6512. }
  6513. /**
  6514. * Interface implemented by classes supporting behaviors
  6515. */
  6516. export interface IBehaviorAware<T> {
  6517. /**
  6518. * Attach a behavior
  6519. * @param behavior defines the behavior to attach
  6520. * @returns the current host
  6521. */
  6522. addBehavior(behavior: Behavior<T>): T;
  6523. /**
  6524. * Remove a behavior from the current object
  6525. * @param behavior defines the behavior to detach
  6526. * @returns the current host
  6527. */
  6528. removeBehavior(behavior: Behavior<T>): T;
  6529. /**
  6530. * Gets a behavior using its name to search
  6531. * @param name defines the name to search
  6532. * @returns the behavior or null if not found
  6533. */
  6534. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6535. }
  6536. }
  6537. declare module "babylonjs/Misc/smartArray" {
  6538. /**
  6539. * Defines an array and its length.
  6540. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6541. */
  6542. export interface ISmartArrayLike<T> {
  6543. /**
  6544. * The data of the array.
  6545. */
  6546. data: Array<T>;
  6547. /**
  6548. * The active length of the array.
  6549. */
  6550. length: number;
  6551. }
  6552. /**
  6553. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6554. */
  6555. export class SmartArray<T> implements ISmartArrayLike<T> {
  6556. /**
  6557. * The full set of data from the array.
  6558. */
  6559. data: Array<T>;
  6560. /**
  6561. * The active length of the array.
  6562. */
  6563. length: number;
  6564. protected _id: number;
  6565. /**
  6566. * Instantiates a Smart Array.
  6567. * @param capacity defines the default capacity of the array.
  6568. */
  6569. constructor(capacity: number);
  6570. /**
  6571. * Pushes a value at the end of the active data.
  6572. * @param value defines the object to push in the array.
  6573. */
  6574. push(value: T): void;
  6575. /**
  6576. * Iterates over the active data and apply the lambda to them.
  6577. * @param func defines the action to apply on each value.
  6578. */
  6579. forEach(func: (content: T) => void): void;
  6580. /**
  6581. * Sorts the full sets of data.
  6582. * @param compareFn defines the comparison function to apply.
  6583. */
  6584. sort(compareFn: (a: T, b: T) => number): void;
  6585. /**
  6586. * Resets the active data to an empty array.
  6587. */
  6588. reset(): void;
  6589. /**
  6590. * Releases all the data from the array as well as the array.
  6591. */
  6592. dispose(): void;
  6593. /**
  6594. * Concats the active data with a given array.
  6595. * @param array defines the data to concatenate with.
  6596. */
  6597. concat(array: any): void;
  6598. /**
  6599. * Returns the position of a value in the active data.
  6600. * @param value defines the value to find the index for
  6601. * @returns the index if found in the active data otherwise -1
  6602. */
  6603. indexOf(value: T): number;
  6604. /**
  6605. * Returns whether an element is part of the active data.
  6606. * @param value defines the value to look for
  6607. * @returns true if found in the active data otherwise false
  6608. */
  6609. contains(value: T): boolean;
  6610. private static _GlobalId;
  6611. }
  6612. /**
  6613. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6614. * The data in this array can only be present once
  6615. */
  6616. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6617. private _duplicateId;
  6618. /**
  6619. * Pushes a value at the end of the active data.
  6620. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6621. * @param value defines the object to push in the array.
  6622. */
  6623. push(value: T): void;
  6624. /**
  6625. * Pushes a value at the end of the active data.
  6626. * If the data is already present, it won t be added again
  6627. * @param value defines the object to push in the array.
  6628. * @returns true if added false if it was already present
  6629. */
  6630. pushNoDuplicate(value: T): boolean;
  6631. /**
  6632. * Resets the active data to an empty array.
  6633. */
  6634. reset(): void;
  6635. /**
  6636. * Concats the active data with a given array.
  6637. * This ensures no dupplicate will be present in the result.
  6638. * @param array defines the data to concatenate with.
  6639. */
  6640. concatWithNoDuplicate(array: any): void;
  6641. }
  6642. }
  6643. declare module "babylonjs/Cameras/cameraInputsManager" {
  6644. import { Nullable } from "babylonjs/types";
  6645. import { Camera } from "babylonjs/Cameras/camera";
  6646. /**
  6647. * @ignore
  6648. * This is a list of all the different input types that are available in the application.
  6649. * Fo instance: ArcRotateCameraGamepadInput...
  6650. */
  6651. export var CameraInputTypes: {};
  6652. /**
  6653. * This is the contract to implement in order to create a new input class.
  6654. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6655. */
  6656. export interface ICameraInput<TCamera extends Camera> {
  6657. /**
  6658. * Defines the camera the input is attached to.
  6659. */
  6660. camera: Nullable<TCamera>;
  6661. /**
  6662. * Gets the class name of the current intput.
  6663. * @returns the class name
  6664. */
  6665. getClassName(): string;
  6666. /**
  6667. * Get the friendly name associated with the input class.
  6668. * @returns the input friendly name
  6669. */
  6670. getSimpleName(): string;
  6671. /**
  6672. * Attach the input controls to a specific dom element to get the input from.
  6673. * @param element Defines the element the controls should be listened from
  6674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6675. */
  6676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6677. /**
  6678. * Detach the current controls from the specified dom element.
  6679. * @param element Defines the element to stop listening the inputs from
  6680. */
  6681. detachControl(element: Nullable<HTMLElement>): void;
  6682. /**
  6683. * Update the current camera state depending on the inputs that have been used this frame.
  6684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6685. */
  6686. checkInputs?: () => void;
  6687. }
  6688. /**
  6689. * Represents a map of input types to input instance or input index to input instance.
  6690. */
  6691. export interface CameraInputsMap<TCamera extends Camera> {
  6692. /**
  6693. * Accessor to the input by input type.
  6694. */
  6695. [name: string]: ICameraInput<TCamera>;
  6696. /**
  6697. * Accessor to the input by input index.
  6698. */
  6699. [idx: number]: ICameraInput<TCamera>;
  6700. }
  6701. /**
  6702. * This represents the input manager used within a camera.
  6703. * It helps dealing with all the different kind of input attached to a camera.
  6704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6705. */
  6706. export class CameraInputsManager<TCamera extends Camera> {
  6707. /**
  6708. * Defines the list of inputs attahed to the camera.
  6709. */
  6710. attached: CameraInputsMap<TCamera>;
  6711. /**
  6712. * Defines the dom element the camera is collecting inputs from.
  6713. * This is null if the controls have not been attached.
  6714. */
  6715. attachedElement: Nullable<HTMLElement>;
  6716. /**
  6717. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6718. */
  6719. noPreventDefault: boolean;
  6720. /**
  6721. * Defined the camera the input manager belongs to.
  6722. */
  6723. camera: TCamera;
  6724. /**
  6725. * Update the current camera state depending on the inputs that have been used this frame.
  6726. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6727. */
  6728. checkInputs: () => void;
  6729. /**
  6730. * Instantiate a new Camera Input Manager.
  6731. * @param camera Defines the camera the input manager blongs to
  6732. */
  6733. constructor(camera: TCamera);
  6734. /**
  6735. * Add an input method to a camera
  6736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6737. * @param input camera input method
  6738. */
  6739. add(input: ICameraInput<TCamera>): void;
  6740. /**
  6741. * Remove a specific input method from a camera
  6742. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6743. * @param inputToRemove camera input method
  6744. */
  6745. remove(inputToRemove: ICameraInput<TCamera>): void;
  6746. /**
  6747. * Remove a specific input type from a camera
  6748. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6749. * @param inputType the type of the input to remove
  6750. */
  6751. removeByType(inputType: string): void;
  6752. private _addCheckInputs;
  6753. /**
  6754. * Attach the input controls to the currently attached dom element to listen the events from.
  6755. * @param input Defines the input to attach
  6756. */
  6757. attachInput(input: ICameraInput<TCamera>): void;
  6758. /**
  6759. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6760. * @param element Defines the dom element to collect the events from
  6761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6762. */
  6763. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6764. /**
  6765. * Detach the current manager inputs controls from a specific dom element.
  6766. * @param element Defines the dom element to collect the events from
  6767. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6768. */
  6769. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6770. /**
  6771. * Rebuild the dynamic inputCheck function from the current list of
  6772. * defined inputs in the manager.
  6773. */
  6774. rebuildInputCheck(): void;
  6775. /**
  6776. * Remove all attached input methods from a camera
  6777. */
  6778. clear(): void;
  6779. /**
  6780. * Serialize the current input manager attached to a camera.
  6781. * This ensures than once parsed,
  6782. * the input associated to the camera will be identical to the current ones
  6783. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6784. */
  6785. serialize(serializedCamera: any): void;
  6786. /**
  6787. * Parses an input manager serialized JSON to restore the previous list of inputs
  6788. * and states associated to a camera.
  6789. * @param parsedCamera Defines the JSON to parse
  6790. */
  6791. parse(parsedCamera: any): void;
  6792. }
  6793. }
  6794. declare module "babylonjs/Collisions/intersectionInfo" {
  6795. import { Nullable } from "babylonjs/types";
  6796. /**
  6797. * @hidden
  6798. */
  6799. export class IntersectionInfo {
  6800. bu: Nullable<number>;
  6801. bv: Nullable<number>;
  6802. distance: number;
  6803. faceId: number;
  6804. subMeshId: number;
  6805. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6806. }
  6807. }
  6808. declare module "babylonjs/Maths/math.plane" {
  6809. import { DeepImmutable } from "babylonjs/types";
  6810. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6811. /**
  6812. * Represens a plane by the equation ax + by + cz + d = 0
  6813. */
  6814. export class Plane {
  6815. private static _TmpMatrix;
  6816. /**
  6817. * Normal of the plane (a,b,c)
  6818. */
  6819. normal: Vector3;
  6820. /**
  6821. * d component of the plane
  6822. */
  6823. d: number;
  6824. /**
  6825. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6826. * @param a a component of the plane
  6827. * @param b b component of the plane
  6828. * @param c c component of the plane
  6829. * @param d d component of the plane
  6830. */
  6831. constructor(a: number, b: number, c: number, d: number);
  6832. /**
  6833. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6834. */
  6835. asArray(): number[];
  6836. /**
  6837. * @returns a new plane copied from the current Plane.
  6838. */
  6839. clone(): Plane;
  6840. /**
  6841. * @returns the string "Plane".
  6842. */
  6843. getClassName(): string;
  6844. /**
  6845. * @returns the Plane hash code.
  6846. */
  6847. getHashCode(): number;
  6848. /**
  6849. * Normalize the current Plane in place.
  6850. * @returns the updated Plane.
  6851. */
  6852. normalize(): Plane;
  6853. /**
  6854. * Applies a transformation the plane and returns the result
  6855. * @param transformation the transformation matrix to be applied to the plane
  6856. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6857. */
  6858. transform(transformation: DeepImmutable<Matrix>): Plane;
  6859. /**
  6860. * Calcualtte the dot product between the point and the plane normal
  6861. * @param point point to calculate the dot product with
  6862. * @returns the dot product (float) of the point coordinates and the plane normal.
  6863. */
  6864. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6865. /**
  6866. * Updates the current Plane from the plane defined by the three given points.
  6867. * @param point1 one of the points used to contruct the plane
  6868. * @param point2 one of the points used to contruct the plane
  6869. * @param point3 one of the points used to contruct the plane
  6870. * @returns the updated Plane.
  6871. */
  6872. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6873. /**
  6874. * Checks if the plane is facing a given direction
  6875. * @param direction the direction to check if the plane is facing
  6876. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6877. * @returns True is the vector "direction" is the same side than the plane normal.
  6878. */
  6879. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6880. /**
  6881. * Calculates the distance to a point
  6882. * @param point point to calculate distance to
  6883. * @returns the signed distance (float) from the given point to the Plane.
  6884. */
  6885. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6886. /**
  6887. * Creates a plane from an array
  6888. * @param array the array to create a plane from
  6889. * @returns a new Plane from the given array.
  6890. */
  6891. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6892. /**
  6893. * Creates a plane from three points
  6894. * @param point1 point used to create the plane
  6895. * @param point2 point used to create the plane
  6896. * @param point3 point used to create the plane
  6897. * @returns a new Plane defined by the three given points.
  6898. */
  6899. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6900. /**
  6901. * Creates a plane from an origin point and a normal
  6902. * @param origin origin of the plane to be constructed
  6903. * @param normal normal of the plane to be constructed
  6904. * @returns a new Plane the normal vector to this plane at the given origin point.
  6905. * Note : the vector "normal" is updated because normalized.
  6906. */
  6907. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6908. /**
  6909. * Calculates the distance from a plane and a point
  6910. * @param origin origin of the plane to be constructed
  6911. * @param normal normal of the plane to be constructed
  6912. * @param point point to calculate distance to
  6913. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6914. */
  6915. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6916. }
  6917. }
  6918. declare module "babylonjs/Culling/boundingSphere" {
  6919. import { DeepImmutable } from "babylonjs/types";
  6920. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6921. import { Plane } from "babylonjs/Maths/math.plane";
  6922. /**
  6923. * Class used to store bounding sphere information
  6924. */
  6925. export class BoundingSphere {
  6926. /**
  6927. * Gets the center of the bounding sphere in local space
  6928. */
  6929. readonly center: Vector3;
  6930. /**
  6931. * Radius of the bounding sphere in local space
  6932. */
  6933. radius: number;
  6934. /**
  6935. * Gets the center of the bounding sphere in world space
  6936. */
  6937. readonly centerWorld: Vector3;
  6938. /**
  6939. * Radius of the bounding sphere in world space
  6940. */
  6941. radiusWorld: number;
  6942. /**
  6943. * Gets the minimum vector in local space
  6944. */
  6945. readonly minimum: Vector3;
  6946. /**
  6947. * Gets the maximum vector in local space
  6948. */
  6949. readonly maximum: Vector3;
  6950. private _worldMatrix;
  6951. private static readonly TmpVector3;
  6952. /**
  6953. * Creates a new bounding sphere
  6954. * @param min defines the minimum vector (in local space)
  6955. * @param max defines the maximum vector (in local space)
  6956. * @param worldMatrix defines the new world matrix
  6957. */
  6958. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6959. /**
  6960. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6961. * @param min defines the new minimum vector (in local space)
  6962. * @param max defines the new maximum vector (in local space)
  6963. * @param worldMatrix defines the new world matrix
  6964. */
  6965. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6966. /**
  6967. * Scale the current bounding sphere by applying a scale factor
  6968. * @param factor defines the scale factor to apply
  6969. * @returns the current bounding box
  6970. */
  6971. scale(factor: number): BoundingSphere;
  6972. /**
  6973. * Gets the world matrix of the bounding box
  6974. * @returns a matrix
  6975. */
  6976. getWorldMatrix(): DeepImmutable<Matrix>;
  6977. /** @hidden */
  6978. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6979. /**
  6980. * Tests if the bounding sphere is intersecting the frustum planes
  6981. * @param frustumPlanes defines the frustum planes to test
  6982. * @returns true if there is an intersection
  6983. */
  6984. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6985. /**
  6986. * Tests if the bounding sphere center is in between the frustum planes.
  6987. * Used for optimistic fast inclusion.
  6988. * @param frustumPlanes defines the frustum planes to test
  6989. * @returns true if the sphere center is in between the frustum planes
  6990. */
  6991. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6992. /**
  6993. * Tests if a point is inside the bounding sphere
  6994. * @param point defines the point to test
  6995. * @returns true if the point is inside the bounding sphere
  6996. */
  6997. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6998. /**
  6999. * Checks if two sphere intersct
  7000. * @param sphere0 sphere 0
  7001. * @param sphere1 sphere 1
  7002. * @returns true if the speres intersect
  7003. */
  7004. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7005. }
  7006. }
  7007. declare module "babylonjs/Culling/boundingBox" {
  7008. import { DeepImmutable } from "babylonjs/types";
  7009. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7010. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7011. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7012. import { Plane } from "babylonjs/Maths/math.plane";
  7013. /**
  7014. * Class used to store bounding box information
  7015. */
  7016. export class BoundingBox implements ICullable {
  7017. /**
  7018. * Gets the 8 vectors representing the bounding box in local space
  7019. */
  7020. readonly vectors: Vector3[];
  7021. /**
  7022. * Gets the center of the bounding box in local space
  7023. */
  7024. readonly center: Vector3;
  7025. /**
  7026. * Gets the center of the bounding box in world space
  7027. */
  7028. readonly centerWorld: Vector3;
  7029. /**
  7030. * Gets the extend size in local space
  7031. */
  7032. readonly extendSize: Vector3;
  7033. /**
  7034. * Gets the extend size in world space
  7035. */
  7036. readonly extendSizeWorld: Vector3;
  7037. /**
  7038. * Gets the OBB (object bounding box) directions
  7039. */
  7040. readonly directions: Vector3[];
  7041. /**
  7042. * Gets the 8 vectors representing the bounding box in world space
  7043. */
  7044. readonly vectorsWorld: Vector3[];
  7045. /**
  7046. * Gets the minimum vector in world space
  7047. */
  7048. readonly minimumWorld: Vector3;
  7049. /**
  7050. * Gets the maximum vector in world space
  7051. */
  7052. readonly maximumWorld: Vector3;
  7053. /**
  7054. * Gets the minimum vector in local space
  7055. */
  7056. readonly minimum: Vector3;
  7057. /**
  7058. * Gets the maximum vector in local space
  7059. */
  7060. readonly maximum: Vector3;
  7061. private _worldMatrix;
  7062. private static readonly TmpVector3;
  7063. /**
  7064. * @hidden
  7065. */
  7066. _tag: number;
  7067. /**
  7068. * Creates a new bounding box
  7069. * @param min defines the minimum vector (in local space)
  7070. * @param max defines the maximum vector (in local space)
  7071. * @param worldMatrix defines the new world matrix
  7072. */
  7073. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7074. /**
  7075. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7076. * @param min defines the new minimum vector (in local space)
  7077. * @param max defines the new maximum vector (in local space)
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7081. /**
  7082. * Scale the current bounding box by applying a scale factor
  7083. * @param factor defines the scale factor to apply
  7084. * @returns the current bounding box
  7085. */
  7086. scale(factor: number): BoundingBox;
  7087. /**
  7088. * Gets the world matrix of the bounding box
  7089. * @returns a matrix
  7090. */
  7091. getWorldMatrix(): DeepImmutable<Matrix>;
  7092. /** @hidden */
  7093. _update(world: DeepImmutable<Matrix>): void;
  7094. /**
  7095. * Tests if the bounding box is intersecting the frustum planes
  7096. * @param frustumPlanes defines the frustum planes to test
  7097. * @returns true if there is an intersection
  7098. */
  7099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7100. /**
  7101. * Tests if the bounding box is entirely inside the frustum planes
  7102. * @param frustumPlanes defines the frustum planes to test
  7103. * @returns true if there is an inclusion
  7104. */
  7105. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7106. /**
  7107. * Tests if a point is inside the bounding box
  7108. * @param point defines the point to test
  7109. * @returns true if the point is inside the bounding box
  7110. */
  7111. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7112. /**
  7113. * Tests if the bounding box intersects with a bounding sphere
  7114. * @param sphere defines the sphere to test
  7115. * @returns true if there is an intersection
  7116. */
  7117. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7118. /**
  7119. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7120. * @param min defines the min vector to use
  7121. * @param max defines the max vector to use
  7122. * @returns true if there is an intersection
  7123. */
  7124. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7125. /**
  7126. * Tests if two bounding boxes are intersections
  7127. * @param box0 defines the first box to test
  7128. * @param box1 defines the second box to test
  7129. * @returns true if there is an intersection
  7130. */
  7131. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7132. /**
  7133. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7134. * @param minPoint defines the minimum vector of the bounding box
  7135. * @param maxPoint defines the maximum vector of the bounding box
  7136. * @param sphereCenter defines the sphere center
  7137. * @param sphereRadius defines the sphere radius
  7138. * @returns true if there is an intersection
  7139. */
  7140. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7141. /**
  7142. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7143. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7144. * @param frustumPlanes defines the frustum planes to test
  7145. * @return true if there is an inclusion
  7146. */
  7147. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7148. /**
  7149. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7150. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7151. * @param frustumPlanes defines the frustum planes to test
  7152. * @return true if there is an intersection
  7153. */
  7154. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7155. }
  7156. }
  7157. declare module "babylonjs/Collisions/collider" {
  7158. import { Nullable, IndicesArray } from "babylonjs/types";
  7159. import { Vector3 } from "babylonjs/Maths/math.vector";
  7160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7161. import { Plane } from "babylonjs/Maths/math.plane";
  7162. /** @hidden */
  7163. export class Collider {
  7164. /** Define if a collision was found */
  7165. collisionFound: boolean;
  7166. /**
  7167. * Define last intersection point in local space
  7168. */
  7169. intersectionPoint: Vector3;
  7170. /**
  7171. * Define last collided mesh
  7172. */
  7173. collidedMesh: Nullable<AbstractMesh>;
  7174. private _collisionPoint;
  7175. private _planeIntersectionPoint;
  7176. private _tempVector;
  7177. private _tempVector2;
  7178. private _tempVector3;
  7179. private _tempVector4;
  7180. private _edge;
  7181. private _baseToVertex;
  7182. private _destinationPoint;
  7183. private _slidePlaneNormal;
  7184. private _displacementVector;
  7185. /** @hidden */
  7186. _radius: Vector3;
  7187. /** @hidden */
  7188. _retry: number;
  7189. private _velocity;
  7190. private _basePoint;
  7191. private _epsilon;
  7192. /** @hidden */
  7193. _velocityWorldLength: number;
  7194. /** @hidden */
  7195. _basePointWorld: Vector3;
  7196. private _velocityWorld;
  7197. private _normalizedVelocity;
  7198. /** @hidden */
  7199. _initialVelocity: Vector3;
  7200. /** @hidden */
  7201. _initialPosition: Vector3;
  7202. private _nearestDistance;
  7203. private _collisionMask;
  7204. collisionMask: number;
  7205. /**
  7206. * Gets the plane normal used to compute the sliding response (in local space)
  7207. */
  7208. readonly slidePlaneNormal: Vector3;
  7209. /** @hidden */
  7210. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7211. /** @hidden */
  7212. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7213. /** @hidden */
  7214. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7215. /** @hidden */
  7216. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7217. /** @hidden */
  7218. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7219. /** @hidden */
  7220. _getResponse(pos: Vector3, vel: Vector3): void;
  7221. }
  7222. }
  7223. declare module "babylonjs/Culling/boundingInfo" {
  7224. import { DeepImmutable } from "babylonjs/types";
  7225. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7226. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7227. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7228. import { Plane } from "babylonjs/Maths/math.plane";
  7229. import { Collider } from "babylonjs/Collisions/collider";
  7230. /**
  7231. * Interface for cullable objects
  7232. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7233. */
  7234. export interface ICullable {
  7235. /**
  7236. * Checks if the object or part of the object is in the frustum
  7237. * @param frustumPlanes Camera near/planes
  7238. * @returns true if the object is in frustum otherwise false
  7239. */
  7240. isInFrustum(frustumPlanes: Plane[]): boolean;
  7241. /**
  7242. * Checks if a cullable object (mesh...) is in the camera frustum
  7243. * Unlike isInFrustum this cheks the full bounding box
  7244. * @param frustumPlanes Camera near/planes
  7245. * @returns true if the object is in frustum otherwise false
  7246. */
  7247. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7248. }
  7249. /**
  7250. * Info for a bounding data of a mesh
  7251. */
  7252. export class BoundingInfo implements ICullable {
  7253. /**
  7254. * Bounding box for the mesh
  7255. */
  7256. readonly boundingBox: BoundingBox;
  7257. /**
  7258. * Bounding sphere for the mesh
  7259. */
  7260. readonly boundingSphere: BoundingSphere;
  7261. private _isLocked;
  7262. private static readonly TmpVector3;
  7263. /**
  7264. * Constructs bounding info
  7265. * @param minimum min vector of the bounding box/sphere
  7266. * @param maximum max vector of the bounding box/sphere
  7267. * @param worldMatrix defines the new world matrix
  7268. */
  7269. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7270. /**
  7271. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7272. * @param min defines the new minimum vector (in local space)
  7273. * @param max defines the new maximum vector (in local space)
  7274. * @param worldMatrix defines the new world matrix
  7275. */
  7276. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7277. /**
  7278. * min vector of the bounding box/sphere
  7279. */
  7280. readonly minimum: Vector3;
  7281. /**
  7282. * max vector of the bounding box/sphere
  7283. */
  7284. readonly maximum: Vector3;
  7285. /**
  7286. * If the info is locked and won't be updated to avoid perf overhead
  7287. */
  7288. isLocked: boolean;
  7289. /**
  7290. * Updates the bounding sphere and box
  7291. * @param world world matrix to be used to update
  7292. */
  7293. update(world: DeepImmutable<Matrix>): void;
  7294. /**
  7295. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7296. * @param center New center of the bounding info
  7297. * @param extend New extend of the bounding info
  7298. * @returns the current bounding info
  7299. */
  7300. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7301. /**
  7302. * Scale the current bounding info by applying a scale factor
  7303. * @param factor defines the scale factor to apply
  7304. * @returns the current bounding info
  7305. */
  7306. scale(factor: number): BoundingInfo;
  7307. /**
  7308. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7309. * @param frustumPlanes defines the frustum to test
  7310. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7311. * @returns true if the bounding info is in the frustum planes
  7312. */
  7313. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7314. /**
  7315. * Gets the world distance between the min and max points of the bounding box
  7316. */
  7317. readonly diagonalLength: number;
  7318. /**
  7319. * Checks if a cullable object (mesh...) is in the camera frustum
  7320. * Unlike isInFrustum this cheks the full bounding box
  7321. * @param frustumPlanes Camera near/planes
  7322. * @returns true if the object is in frustum otherwise false
  7323. */
  7324. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7325. /** @hidden */
  7326. _checkCollision(collider: Collider): boolean;
  7327. /**
  7328. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7329. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7330. * @param point the point to check intersection with
  7331. * @returns if the point intersects
  7332. */
  7333. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7334. /**
  7335. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7336. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7337. * @param boundingInfo the bounding info to check intersection with
  7338. * @param precise if the intersection should be done using OBB
  7339. * @returns if the bounding info intersects
  7340. */
  7341. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7342. }
  7343. }
  7344. declare module "babylonjs/Maths/math.functions" {
  7345. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7346. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7347. /**
  7348. * Extracts minimum and maximum values from a list of indexed positions
  7349. * @param positions defines the positions to use
  7350. * @param indices defines the indices to the positions
  7351. * @param indexStart defines the start index
  7352. * @param indexCount defines the end index
  7353. * @param bias defines bias value to add to the result
  7354. * @return minimum and maximum values
  7355. */
  7356. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7357. minimum: Vector3;
  7358. maximum: Vector3;
  7359. };
  7360. /**
  7361. * Extracts minimum and maximum values from a list of positions
  7362. * @param positions defines the positions to use
  7363. * @param start defines the start index in the positions array
  7364. * @param count defines the number of positions to handle
  7365. * @param bias defines bias value to add to the result
  7366. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7367. * @return minimum and maximum values
  7368. */
  7369. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7370. minimum: Vector3;
  7371. maximum: Vector3;
  7372. };
  7373. }
  7374. declare module "babylonjs/Misc/iInspectable" {
  7375. /**
  7376. * Enum that determines the text-wrapping mode to use.
  7377. */
  7378. export enum InspectableType {
  7379. /**
  7380. * Checkbox for booleans
  7381. */
  7382. Checkbox = 0,
  7383. /**
  7384. * Sliders for numbers
  7385. */
  7386. Slider = 1,
  7387. /**
  7388. * Vector3
  7389. */
  7390. Vector3 = 2,
  7391. /**
  7392. * Quaternions
  7393. */
  7394. Quaternion = 3,
  7395. /**
  7396. * Color3
  7397. */
  7398. Color3 = 4,
  7399. /**
  7400. * String
  7401. */
  7402. String = 5
  7403. }
  7404. /**
  7405. * Interface used to define custom inspectable properties.
  7406. * This interface is used by the inspector to display custom property grids
  7407. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7408. */
  7409. export interface IInspectable {
  7410. /**
  7411. * Gets the label to display
  7412. */
  7413. label: string;
  7414. /**
  7415. * Gets the name of the property to edit
  7416. */
  7417. propertyName: string;
  7418. /**
  7419. * Gets the type of the editor to use
  7420. */
  7421. type: InspectableType;
  7422. /**
  7423. * Gets the minimum value of the property when using in "slider" mode
  7424. */
  7425. min?: number;
  7426. /**
  7427. * Gets the maximum value of the property when using in "slider" mode
  7428. */
  7429. max?: number;
  7430. /**
  7431. * Gets the setp to use when using in "slider" mode
  7432. */
  7433. step?: number;
  7434. }
  7435. }
  7436. declare module "babylonjs/Misc/timingTools" {
  7437. /**
  7438. * Class used to provide helper for timing
  7439. */
  7440. export class TimingTools {
  7441. /**
  7442. * Polyfill for setImmediate
  7443. * @param action defines the action to execute after the current execution block
  7444. */
  7445. static SetImmediate(action: () => void): void;
  7446. }
  7447. }
  7448. declare module "babylonjs/Misc/instantiationTools" {
  7449. /**
  7450. * Class used to enable instatition of objects by class name
  7451. */
  7452. export class InstantiationTools {
  7453. /**
  7454. * Use this object to register external classes like custom textures or material
  7455. * to allow the laoders to instantiate them
  7456. */
  7457. static RegisteredExternalClasses: {
  7458. [key: string]: Object;
  7459. };
  7460. /**
  7461. * Tries to instantiate a new object from a given class name
  7462. * @param className defines the class name to instantiate
  7463. * @returns the new object or null if the system was not able to do the instantiation
  7464. */
  7465. static Instantiate(className: string): any;
  7466. }
  7467. }
  7468. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7469. import { Nullable } from "babylonjs/types";
  7470. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7471. /**
  7472. * This represents the required contract to create a new type of texture loader.
  7473. */
  7474. export interface IInternalTextureLoader {
  7475. /**
  7476. * Defines wether the loader supports cascade loading the different faces.
  7477. */
  7478. supportCascades: boolean;
  7479. /**
  7480. * This returns if the loader support the current file information.
  7481. * @param extension defines the file extension of the file being loaded
  7482. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7483. * @param fallback defines the fallback internal texture if any
  7484. * @param isBase64 defines whether the texture is encoded as a base64
  7485. * @param isBuffer defines whether the texture data are stored as a buffer
  7486. * @returns true if the loader can load the specified file
  7487. */
  7488. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7489. /**
  7490. * Transform the url before loading if required.
  7491. * @param rootUrl the url of the texture
  7492. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7493. * @returns the transformed texture
  7494. */
  7495. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7496. /**
  7497. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7498. * @param rootUrl the url of the texture
  7499. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7500. * @returns the fallback texture
  7501. */
  7502. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7503. /**
  7504. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7505. * @param data contains the texture data
  7506. * @param texture defines the BabylonJS internal texture
  7507. * @param createPolynomials will be true if polynomials have been requested
  7508. * @param onLoad defines the callback to trigger once the texture is ready
  7509. * @param onError defines the callback to trigger in case of error
  7510. */
  7511. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7512. /**
  7513. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7514. * @param data contains the texture data
  7515. * @param texture defines the BabylonJS internal texture
  7516. * @param callback defines the method to call once ready to upload
  7517. */
  7518. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7519. }
  7520. }
  7521. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7522. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7523. import { Nullable } from "babylonjs/types";
  7524. import { Scene } from "babylonjs/scene";
  7525. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7526. module "babylonjs/Engines/engine" {
  7527. interface Engine {
  7528. /**
  7529. * Creates a depth stencil cube texture.
  7530. * This is only available in WebGL 2.
  7531. * @param size The size of face edge in the cube texture.
  7532. * @param options The options defining the cube texture.
  7533. * @returns The cube texture
  7534. */
  7535. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7536. /**
  7537. * Creates a cube texture
  7538. * @param rootUrl defines the url where the files to load is located
  7539. * @param scene defines the current scene
  7540. * @param files defines the list of files to load (1 per face)
  7541. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7542. * @param onLoad defines an optional callback raised when the texture is loaded
  7543. * @param onError defines an optional callback raised if there is an issue to load the texture
  7544. * @param format defines the format of the data
  7545. * @param forcedExtension defines the extension to use to pick the right loader
  7546. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7547. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7548. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7549. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7550. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7551. * @returns the cube texture as an InternalTexture
  7552. */
  7553. 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;
  7554. /**
  7555. * Creates a cube texture
  7556. * @param rootUrl defines the url where the files to load is located
  7557. * @param scene defines the current scene
  7558. * @param files defines the list of files to load (1 per face)
  7559. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7560. * @param onLoad defines an optional callback raised when the texture is loaded
  7561. * @param onError defines an optional callback raised if there is an issue to load the texture
  7562. * @param format defines the format of the data
  7563. * @param forcedExtension defines the extension to use to pick the right loader
  7564. * @returns the cube texture as an InternalTexture
  7565. */
  7566. 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;
  7567. /**
  7568. * Creates a cube texture
  7569. * @param rootUrl defines the url where the files to load is located
  7570. * @param scene defines the current scene
  7571. * @param files defines the list of files to load (1 per face)
  7572. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7573. * @param onLoad defines an optional callback raised when the texture is loaded
  7574. * @param onError defines an optional callback raised if there is an issue to load the texture
  7575. * @param format defines the format of the data
  7576. * @param forcedExtension defines the extension to use to pick the right loader
  7577. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7578. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7579. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7580. * @returns the cube texture as an InternalTexture
  7581. */
  7582. 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;
  7583. /** @hidden */
  7584. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7585. /** @hidden */
  7586. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7587. /** @hidden */
  7588. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7589. /** @hidden */
  7590. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7591. }
  7592. }
  7593. }
  7594. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7595. import { Nullable } from "babylonjs/types";
  7596. import { Scene } from "babylonjs/scene";
  7597. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7598. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7599. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7600. /**
  7601. * Class for creating a cube texture
  7602. */
  7603. export class CubeTexture extends BaseTexture {
  7604. private _delayedOnLoad;
  7605. /**
  7606. * The url of the texture
  7607. */
  7608. url: string;
  7609. /**
  7610. * Gets or sets the center of the bounding box associated with the cube texture.
  7611. * It must define where the camera used to render the texture was set
  7612. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7613. */
  7614. boundingBoxPosition: Vector3;
  7615. private _boundingBoxSize;
  7616. /**
  7617. * Gets or sets the size of the bounding box associated with the cube texture
  7618. * When defined, the cubemap will switch to local mode
  7619. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7620. * @example https://www.babylonjs-playground.com/#RNASML
  7621. */
  7622. /**
  7623. * Returns the bounding box size
  7624. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7625. */
  7626. boundingBoxSize: Vector3;
  7627. protected _rotationY: number;
  7628. /**
  7629. * Sets texture matrix rotation angle around Y axis in radians.
  7630. */
  7631. /**
  7632. * Gets texture matrix rotation angle around Y axis radians.
  7633. */
  7634. rotationY: number;
  7635. /**
  7636. * Are mip maps generated for this texture or not.
  7637. */
  7638. readonly noMipmap: boolean;
  7639. private _noMipmap;
  7640. private _files;
  7641. private _extensions;
  7642. private _textureMatrix;
  7643. private _format;
  7644. private _createPolynomials;
  7645. /** @hidden */
  7646. _prefiltered: boolean;
  7647. /**
  7648. * Creates a cube texture from an array of image urls
  7649. * @param files defines an array of image urls
  7650. * @param scene defines the hosting scene
  7651. * @param noMipmap specifies if mip maps are not used
  7652. * @returns a cube texture
  7653. */
  7654. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7655. /**
  7656. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7657. * @param url defines the url of the prefiltered texture
  7658. * @param scene defines the scene the texture is attached to
  7659. * @param forcedExtension defines the extension of the file if different from the url
  7660. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7661. * @return the prefiltered texture
  7662. */
  7663. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7664. /**
  7665. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7666. * as prefiltered data.
  7667. * @param rootUrl defines the url of the texture or the root name of the six images
  7668. * @param scene defines the scene the texture is attached to
  7669. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7670. * @param noMipmap defines if mipmaps should be created or not
  7671. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7672. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7673. * @param onError defines a callback triggered in case of error during load
  7674. * @param format defines the internal format to use for the texture once loaded
  7675. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7676. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7677. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7680. * @return the cube texture
  7681. */
  7682. 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);
  7683. /**
  7684. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7685. */
  7686. readonly isPrefiltered: boolean;
  7687. /**
  7688. * Get the current class name of the texture useful for serialization or dynamic coding.
  7689. * @returns "CubeTexture"
  7690. */
  7691. getClassName(): string;
  7692. /**
  7693. * Update the url (and optional buffer) of this texture if url was null during construction.
  7694. * @param url the url of the texture
  7695. * @param forcedExtension defines the extension to use
  7696. * @param onLoad callback called when the texture is loaded (defaults to null)
  7697. */
  7698. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7699. /**
  7700. * Delays loading of the cube texture
  7701. * @param forcedExtension defines the extension to use
  7702. */
  7703. delayLoad(forcedExtension?: string): void;
  7704. /**
  7705. * Returns the reflection texture matrix
  7706. * @returns the reflection texture matrix
  7707. */
  7708. getReflectionTextureMatrix(): Matrix;
  7709. /**
  7710. * Sets the reflection texture matrix
  7711. * @param value Reflection texture matrix
  7712. */
  7713. setReflectionTextureMatrix(value: Matrix): void;
  7714. /**
  7715. * Parses text to create a cube texture
  7716. * @param parsedTexture define the serialized text to read from
  7717. * @param scene defines the hosting scene
  7718. * @param rootUrl defines the root url of the cube texture
  7719. * @returns a cube texture
  7720. */
  7721. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7722. /**
  7723. * Makes a clone, or deep copy, of the cube texture
  7724. * @returns a new cube texture
  7725. */
  7726. clone(): CubeTexture;
  7727. }
  7728. }
  7729. declare module "babylonjs/Materials/materialDefines" {
  7730. /**
  7731. * Manages the defines for the Material
  7732. */
  7733. export class MaterialDefines {
  7734. /** @hidden */
  7735. protected _keys: string[];
  7736. private _isDirty;
  7737. /** @hidden */
  7738. _renderId: number;
  7739. /** @hidden */
  7740. _areLightsDirty: boolean;
  7741. /** @hidden */
  7742. _areLightsDisposed: boolean;
  7743. /** @hidden */
  7744. _areAttributesDirty: boolean;
  7745. /** @hidden */
  7746. _areTexturesDirty: boolean;
  7747. /** @hidden */
  7748. _areFresnelDirty: boolean;
  7749. /** @hidden */
  7750. _areMiscDirty: boolean;
  7751. /** @hidden */
  7752. _areImageProcessingDirty: boolean;
  7753. /** @hidden */
  7754. _normals: boolean;
  7755. /** @hidden */
  7756. _uvs: boolean;
  7757. /** @hidden */
  7758. _needNormals: boolean;
  7759. /** @hidden */
  7760. _needUVs: boolean;
  7761. [id: string]: any;
  7762. /**
  7763. * Specifies if the material needs to be re-calculated
  7764. */
  7765. readonly isDirty: boolean;
  7766. /**
  7767. * Marks the material to indicate that it has been re-calculated
  7768. */
  7769. markAsProcessed(): void;
  7770. /**
  7771. * Marks the material to indicate that it needs to be re-calculated
  7772. */
  7773. markAsUnprocessed(): void;
  7774. /**
  7775. * Marks the material to indicate all of its defines need to be re-calculated
  7776. */
  7777. markAllAsDirty(): void;
  7778. /**
  7779. * Marks the material to indicate that image processing needs to be re-calculated
  7780. */
  7781. markAsImageProcessingDirty(): void;
  7782. /**
  7783. * Marks the material to indicate the lights need to be re-calculated
  7784. * @param disposed Defines whether the light is dirty due to dispose or not
  7785. */
  7786. markAsLightDirty(disposed?: boolean): void;
  7787. /**
  7788. * Marks the attribute state as changed
  7789. */
  7790. markAsAttributesDirty(): void;
  7791. /**
  7792. * Marks the texture state as changed
  7793. */
  7794. markAsTexturesDirty(): void;
  7795. /**
  7796. * Marks the fresnel state as changed
  7797. */
  7798. markAsFresnelDirty(): void;
  7799. /**
  7800. * Marks the misc state as changed
  7801. */
  7802. markAsMiscDirty(): void;
  7803. /**
  7804. * Rebuilds the material defines
  7805. */
  7806. rebuild(): void;
  7807. /**
  7808. * Specifies if two material defines are equal
  7809. * @param other - A material define instance to compare to
  7810. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7811. */
  7812. isEqual(other: MaterialDefines): boolean;
  7813. /**
  7814. * Clones this instance's defines to another instance
  7815. * @param other - material defines to clone values to
  7816. */
  7817. cloneTo(other: MaterialDefines): void;
  7818. /**
  7819. * Resets the material define values
  7820. */
  7821. reset(): void;
  7822. /**
  7823. * Converts the material define values to a string
  7824. * @returns - String of material define information
  7825. */
  7826. toString(): string;
  7827. }
  7828. }
  7829. declare module "babylonjs/Materials/colorCurves" {
  7830. import { Effect } from "babylonjs/Materials/effect";
  7831. /**
  7832. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7833. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7834. * 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;
  7835. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7836. */
  7837. export class ColorCurves {
  7838. private _dirty;
  7839. private _tempColor;
  7840. private _globalCurve;
  7841. private _highlightsCurve;
  7842. private _midtonesCurve;
  7843. private _shadowsCurve;
  7844. private _positiveCurve;
  7845. private _negativeCurve;
  7846. private _globalHue;
  7847. private _globalDensity;
  7848. private _globalSaturation;
  7849. private _globalExposure;
  7850. /**
  7851. * Gets the global Hue value.
  7852. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7853. */
  7854. /**
  7855. * Sets the global Hue value.
  7856. * 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).
  7857. */
  7858. globalHue: number;
  7859. /**
  7860. * Gets the global Density value.
  7861. * 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.
  7862. * Values less than zero provide a filter of opposite hue.
  7863. */
  7864. /**
  7865. * Sets the global Density value.
  7866. * 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.
  7867. * Values less than zero provide a filter of opposite hue.
  7868. */
  7869. globalDensity: number;
  7870. /**
  7871. * Gets the global Saturation value.
  7872. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7873. */
  7874. /**
  7875. * Sets the global Saturation value.
  7876. * 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.
  7877. */
  7878. globalSaturation: number;
  7879. /**
  7880. * Gets the global Exposure value.
  7881. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7882. */
  7883. /**
  7884. * Sets the global Exposure value.
  7885. * 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.
  7886. */
  7887. globalExposure: number;
  7888. private _highlightsHue;
  7889. private _highlightsDensity;
  7890. private _highlightsSaturation;
  7891. private _highlightsExposure;
  7892. /**
  7893. * Gets the highlights Hue value.
  7894. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7895. */
  7896. /**
  7897. * Sets the highlights Hue value.
  7898. * 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).
  7899. */
  7900. highlightsHue: number;
  7901. /**
  7902. * Gets the highlights Density value.
  7903. * 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.
  7904. * Values less than zero provide a filter of opposite hue.
  7905. */
  7906. /**
  7907. * Sets the highlights Density value.
  7908. * 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.
  7909. * Values less than zero provide a filter of opposite hue.
  7910. */
  7911. highlightsDensity: number;
  7912. /**
  7913. * Gets the highlights Saturation value.
  7914. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7915. */
  7916. /**
  7917. * Sets the highlights Saturation value.
  7918. * 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.
  7919. */
  7920. highlightsSaturation: number;
  7921. /**
  7922. * Gets the highlights Exposure value.
  7923. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7924. */
  7925. /**
  7926. * Sets the highlights Exposure value.
  7927. * 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.
  7928. */
  7929. highlightsExposure: number;
  7930. private _midtonesHue;
  7931. private _midtonesDensity;
  7932. private _midtonesSaturation;
  7933. private _midtonesExposure;
  7934. /**
  7935. * Gets the midtones Hue value.
  7936. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7937. */
  7938. /**
  7939. * Sets the midtones Hue value.
  7940. * 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).
  7941. */
  7942. midtonesHue: number;
  7943. /**
  7944. * Gets the midtones Density value.
  7945. * 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.
  7946. * Values less than zero provide a filter of opposite hue.
  7947. */
  7948. /**
  7949. * Sets the midtones Density value.
  7950. * 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.
  7951. * Values less than zero provide a filter of opposite hue.
  7952. */
  7953. midtonesDensity: number;
  7954. /**
  7955. * Gets the midtones Saturation value.
  7956. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7957. */
  7958. /**
  7959. * Sets the midtones Saturation value.
  7960. * 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.
  7961. */
  7962. midtonesSaturation: number;
  7963. /**
  7964. * Gets the midtones Exposure value.
  7965. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7966. */
  7967. /**
  7968. * Sets the midtones Exposure value.
  7969. * 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.
  7970. */
  7971. midtonesExposure: number;
  7972. private _shadowsHue;
  7973. private _shadowsDensity;
  7974. private _shadowsSaturation;
  7975. private _shadowsExposure;
  7976. /**
  7977. * Gets the shadows Hue value.
  7978. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7979. */
  7980. /**
  7981. * Sets the shadows Hue value.
  7982. * 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).
  7983. */
  7984. shadowsHue: number;
  7985. /**
  7986. * Gets the shadows Density value.
  7987. * 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.
  7988. * Values less than zero provide a filter of opposite hue.
  7989. */
  7990. /**
  7991. * Sets the shadows Density value.
  7992. * 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.
  7993. * Values less than zero provide a filter of opposite hue.
  7994. */
  7995. shadowsDensity: number;
  7996. /**
  7997. * Gets the shadows Saturation value.
  7998. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7999. */
  8000. /**
  8001. * Sets the shadows Saturation value.
  8002. * 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.
  8003. */
  8004. shadowsSaturation: number;
  8005. /**
  8006. * Gets the shadows Exposure value.
  8007. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8008. */
  8009. /**
  8010. * Sets the shadows Exposure value.
  8011. * 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.
  8012. */
  8013. shadowsExposure: number;
  8014. /**
  8015. * Returns the class name
  8016. * @returns The class name
  8017. */
  8018. getClassName(): string;
  8019. /**
  8020. * Binds the color curves to the shader.
  8021. * @param colorCurves The color curve to bind
  8022. * @param effect The effect to bind to
  8023. * @param positiveUniform The positive uniform shader parameter
  8024. * @param neutralUniform The neutral uniform shader parameter
  8025. * @param negativeUniform The negative uniform shader parameter
  8026. */
  8027. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8028. /**
  8029. * Prepare the list of uniforms associated with the ColorCurves effects.
  8030. * @param uniformsList The list of uniforms used in the effect
  8031. */
  8032. static PrepareUniforms(uniformsList: string[]): void;
  8033. /**
  8034. * Returns color grading data based on a hue, density, saturation and exposure value.
  8035. * @param filterHue The hue of the color filter.
  8036. * @param filterDensity The density of the color filter.
  8037. * @param saturation The saturation.
  8038. * @param exposure The exposure.
  8039. * @param result The result data container.
  8040. */
  8041. private getColorGradingDataToRef;
  8042. /**
  8043. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8044. * @param value The input slider value in range [-100,100].
  8045. * @returns Adjusted value.
  8046. */
  8047. private static applyColorGradingSliderNonlinear;
  8048. /**
  8049. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8050. * @param hue The hue (H) input.
  8051. * @param saturation The saturation (S) input.
  8052. * @param brightness The brightness (B) input.
  8053. * @result An RGBA color represented as Vector4.
  8054. */
  8055. private static fromHSBToRef;
  8056. /**
  8057. * Returns a value clamped between min and max
  8058. * @param value The value to clamp
  8059. * @param min The minimum of value
  8060. * @param max The maximum of value
  8061. * @returns The clamped value.
  8062. */
  8063. private static clamp;
  8064. /**
  8065. * Clones the current color curve instance.
  8066. * @return The cloned curves
  8067. */
  8068. clone(): ColorCurves;
  8069. /**
  8070. * Serializes the current color curve instance to a json representation.
  8071. * @return a JSON representation
  8072. */
  8073. serialize(): any;
  8074. /**
  8075. * Parses the color curve from a json representation.
  8076. * @param source the JSON source to parse
  8077. * @return The parsed curves
  8078. */
  8079. static Parse(source: any): ColorCurves;
  8080. }
  8081. }
  8082. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8083. import { Observable } from "babylonjs/Misc/observable";
  8084. import { Nullable } from "babylonjs/types";
  8085. import { Color4 } from "babylonjs/Maths/math.color";
  8086. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8087. import { Effect } from "babylonjs/Materials/effect";
  8088. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8089. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8090. /**
  8091. * Interface to follow in your material defines to integrate easily the
  8092. * Image proccessing functions.
  8093. * @hidden
  8094. */
  8095. export interface IImageProcessingConfigurationDefines {
  8096. IMAGEPROCESSING: boolean;
  8097. VIGNETTE: boolean;
  8098. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8099. VIGNETTEBLENDMODEOPAQUE: boolean;
  8100. TONEMAPPING: boolean;
  8101. TONEMAPPING_ACES: boolean;
  8102. CONTRAST: boolean;
  8103. EXPOSURE: boolean;
  8104. COLORCURVES: boolean;
  8105. COLORGRADING: boolean;
  8106. COLORGRADING3D: boolean;
  8107. SAMPLER3DGREENDEPTH: boolean;
  8108. SAMPLER3DBGRMAP: boolean;
  8109. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8110. }
  8111. /**
  8112. * @hidden
  8113. */
  8114. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8115. IMAGEPROCESSING: boolean;
  8116. VIGNETTE: boolean;
  8117. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8118. VIGNETTEBLENDMODEOPAQUE: boolean;
  8119. TONEMAPPING: boolean;
  8120. TONEMAPPING_ACES: boolean;
  8121. CONTRAST: boolean;
  8122. COLORCURVES: boolean;
  8123. COLORGRADING: boolean;
  8124. COLORGRADING3D: boolean;
  8125. SAMPLER3DGREENDEPTH: boolean;
  8126. SAMPLER3DBGRMAP: boolean;
  8127. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8128. EXPOSURE: boolean;
  8129. constructor();
  8130. }
  8131. /**
  8132. * This groups together the common properties used for image processing either in direct forward pass
  8133. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8134. * or not.
  8135. */
  8136. export class ImageProcessingConfiguration {
  8137. /**
  8138. * Default tone mapping applied in BabylonJS.
  8139. */
  8140. static readonly TONEMAPPING_STANDARD: number;
  8141. /**
  8142. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8143. * to other engines rendering to increase portability.
  8144. */
  8145. static readonly TONEMAPPING_ACES: number;
  8146. /**
  8147. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8148. */
  8149. colorCurves: Nullable<ColorCurves>;
  8150. private _colorCurvesEnabled;
  8151. /**
  8152. * Gets wether the color curves effect is enabled.
  8153. */
  8154. /**
  8155. * Sets wether the color curves effect is enabled.
  8156. */
  8157. colorCurvesEnabled: boolean;
  8158. private _colorGradingTexture;
  8159. /**
  8160. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8161. */
  8162. /**
  8163. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8164. */
  8165. colorGradingTexture: Nullable<BaseTexture>;
  8166. private _colorGradingEnabled;
  8167. /**
  8168. * Gets wether the color grading effect is enabled.
  8169. */
  8170. /**
  8171. * Sets wether the color grading effect is enabled.
  8172. */
  8173. colorGradingEnabled: boolean;
  8174. private _colorGradingWithGreenDepth;
  8175. /**
  8176. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8177. */
  8178. /**
  8179. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8180. */
  8181. colorGradingWithGreenDepth: boolean;
  8182. private _colorGradingBGR;
  8183. /**
  8184. * Gets wether the color grading texture contains BGR values.
  8185. */
  8186. /**
  8187. * Sets wether the color grading texture contains BGR values.
  8188. */
  8189. colorGradingBGR: boolean;
  8190. /** @hidden */
  8191. _exposure: number;
  8192. /**
  8193. * Gets the Exposure used in the effect.
  8194. */
  8195. /**
  8196. * Sets the Exposure used in the effect.
  8197. */
  8198. exposure: number;
  8199. private _toneMappingEnabled;
  8200. /**
  8201. * Gets wether the tone mapping effect is enabled.
  8202. */
  8203. /**
  8204. * Sets wether the tone mapping effect is enabled.
  8205. */
  8206. toneMappingEnabled: boolean;
  8207. private _toneMappingType;
  8208. /**
  8209. * Gets the type of tone mapping effect.
  8210. */
  8211. /**
  8212. * Sets the type of tone mapping effect used in BabylonJS.
  8213. */
  8214. toneMappingType: number;
  8215. protected _contrast: number;
  8216. /**
  8217. * Gets the contrast used in the effect.
  8218. */
  8219. /**
  8220. * Sets the contrast used in the effect.
  8221. */
  8222. contrast: number;
  8223. /**
  8224. * Vignette stretch size.
  8225. */
  8226. vignetteStretch: number;
  8227. /**
  8228. * Vignette centre X Offset.
  8229. */
  8230. vignetteCentreX: number;
  8231. /**
  8232. * Vignette centre Y Offset.
  8233. */
  8234. vignetteCentreY: number;
  8235. /**
  8236. * Vignette weight or intensity of the vignette effect.
  8237. */
  8238. vignetteWeight: number;
  8239. /**
  8240. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8241. * if vignetteEnabled is set to true.
  8242. */
  8243. vignetteColor: Color4;
  8244. /**
  8245. * Camera field of view used by the Vignette effect.
  8246. */
  8247. vignetteCameraFov: number;
  8248. private _vignetteBlendMode;
  8249. /**
  8250. * Gets the vignette blend mode allowing different kind of effect.
  8251. */
  8252. /**
  8253. * Sets the vignette blend mode allowing different kind of effect.
  8254. */
  8255. vignetteBlendMode: number;
  8256. private _vignetteEnabled;
  8257. /**
  8258. * Gets wether the vignette effect is enabled.
  8259. */
  8260. /**
  8261. * Sets wether the vignette effect is enabled.
  8262. */
  8263. vignetteEnabled: boolean;
  8264. private _applyByPostProcess;
  8265. /**
  8266. * Gets wether the image processing is applied through a post process or not.
  8267. */
  8268. /**
  8269. * Sets wether the image processing is applied through a post process or not.
  8270. */
  8271. applyByPostProcess: boolean;
  8272. private _isEnabled;
  8273. /**
  8274. * Gets wether the image processing is enabled or not.
  8275. */
  8276. /**
  8277. * Sets wether the image processing is enabled or not.
  8278. */
  8279. isEnabled: boolean;
  8280. /**
  8281. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8282. */
  8283. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8284. /**
  8285. * Method called each time the image processing information changes requires to recompile the effect.
  8286. */
  8287. protected _updateParameters(): void;
  8288. /**
  8289. * Gets the current class name.
  8290. * @return "ImageProcessingConfiguration"
  8291. */
  8292. getClassName(): string;
  8293. /**
  8294. * Prepare the list of uniforms associated with the Image Processing effects.
  8295. * @param uniforms The list of uniforms used in the effect
  8296. * @param defines the list of defines currently in use
  8297. */
  8298. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8299. /**
  8300. * Prepare the list of samplers associated with the Image Processing effects.
  8301. * @param samplersList The list of uniforms used in the effect
  8302. * @param defines the list of defines currently in use
  8303. */
  8304. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8305. /**
  8306. * Prepare the list of defines associated to the shader.
  8307. * @param defines the list of defines to complete
  8308. * @param forPostProcess Define if we are currently in post process mode or not
  8309. */
  8310. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8311. /**
  8312. * Returns true if all the image processing information are ready.
  8313. * @returns True if ready, otherwise, false
  8314. */
  8315. isReady(): boolean;
  8316. /**
  8317. * Binds the image processing to the shader.
  8318. * @param effect The effect to bind to
  8319. * @param aspectRatio Define the current aspect ratio of the effect
  8320. */
  8321. bind(effect: Effect, aspectRatio?: number): void;
  8322. /**
  8323. * Clones the current image processing instance.
  8324. * @return The cloned image processing
  8325. */
  8326. clone(): ImageProcessingConfiguration;
  8327. /**
  8328. * Serializes the current image processing instance to a json representation.
  8329. * @return a JSON representation
  8330. */
  8331. serialize(): any;
  8332. /**
  8333. * Parses the image processing from a json representation.
  8334. * @param source the JSON source to parse
  8335. * @return The parsed image processing
  8336. */
  8337. static Parse(source: any): ImageProcessingConfiguration;
  8338. private static _VIGNETTEMODE_MULTIPLY;
  8339. private static _VIGNETTEMODE_OPAQUE;
  8340. /**
  8341. * Used to apply the vignette as a mix with the pixel color.
  8342. */
  8343. static readonly VIGNETTEMODE_MULTIPLY: number;
  8344. /**
  8345. * Used to apply the vignette as a replacement of the pixel color.
  8346. */
  8347. static readonly VIGNETTEMODE_OPAQUE: number;
  8348. }
  8349. }
  8350. declare module "babylonjs/Shaders/postprocess.vertex" {
  8351. /** @hidden */
  8352. export var postprocessVertexShader: {
  8353. name: string;
  8354. shader: string;
  8355. };
  8356. }
  8357. declare module "babylonjs/Maths/math.axis" {
  8358. import { Vector3 } from "babylonjs/Maths/math.vector";
  8359. /** Defines supported spaces */
  8360. export enum Space {
  8361. /** Local (object) space */
  8362. LOCAL = 0,
  8363. /** World space */
  8364. WORLD = 1,
  8365. /** Bone space */
  8366. BONE = 2
  8367. }
  8368. /** Defines the 3 main axes */
  8369. export class Axis {
  8370. /** X axis */
  8371. static X: Vector3;
  8372. /** Y axis */
  8373. static Y: Vector3;
  8374. /** Z axis */
  8375. static Z: Vector3;
  8376. }
  8377. }
  8378. declare module "babylonjs/Cameras/targetCamera" {
  8379. import { Nullable } from "babylonjs/types";
  8380. import { Camera } from "babylonjs/Cameras/camera";
  8381. import { Scene } from "babylonjs/scene";
  8382. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8383. /**
  8384. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8385. * This is the base of the follow, arc rotate cameras and Free camera
  8386. * @see http://doc.babylonjs.com/features/cameras
  8387. */
  8388. export class TargetCamera extends Camera {
  8389. private static _RigCamTransformMatrix;
  8390. private static _TargetTransformMatrix;
  8391. private static _TargetFocalPoint;
  8392. /**
  8393. * Define the current direction the camera is moving to
  8394. */
  8395. cameraDirection: Vector3;
  8396. /**
  8397. * Define the current rotation the camera is rotating to
  8398. */
  8399. cameraRotation: Vector2;
  8400. /**
  8401. * When set, the up vector of the camera will be updated by the rotation of the camera
  8402. */
  8403. updateUpVectorFromRotation: boolean;
  8404. private _tmpQuaternion;
  8405. /**
  8406. * Define the current rotation of the camera
  8407. */
  8408. rotation: Vector3;
  8409. /**
  8410. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8411. */
  8412. rotationQuaternion: Quaternion;
  8413. /**
  8414. * Define the current speed of the camera
  8415. */
  8416. speed: number;
  8417. /**
  8418. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8419. * around all axis.
  8420. */
  8421. noRotationConstraint: boolean;
  8422. /**
  8423. * Define the current target of the camera as an object or a position.
  8424. */
  8425. lockedTarget: any;
  8426. /** @hidden */
  8427. _currentTarget: Vector3;
  8428. /** @hidden */
  8429. _initialFocalDistance: number;
  8430. /** @hidden */
  8431. _viewMatrix: Matrix;
  8432. /** @hidden */
  8433. _camMatrix: Matrix;
  8434. /** @hidden */
  8435. _cameraTransformMatrix: Matrix;
  8436. /** @hidden */
  8437. _cameraRotationMatrix: Matrix;
  8438. /** @hidden */
  8439. _referencePoint: Vector3;
  8440. /** @hidden */
  8441. _transformedReferencePoint: Vector3;
  8442. protected _globalCurrentTarget: Vector3;
  8443. protected _globalCurrentUpVector: Vector3;
  8444. /** @hidden */
  8445. _reset: () => void;
  8446. private _defaultUp;
  8447. /**
  8448. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8449. * This is the base of the follow, arc rotate cameras and Free camera
  8450. * @see http://doc.babylonjs.com/features/cameras
  8451. * @param name Defines the name of the camera in the scene
  8452. * @param position Defines the start position of the camera in the scene
  8453. * @param scene Defines the scene the camera belongs to
  8454. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8455. */
  8456. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8457. /**
  8458. * Gets the position in front of the camera at a given distance.
  8459. * @param distance The distance from the camera we want the position to be
  8460. * @returns the position
  8461. */
  8462. getFrontPosition(distance: number): Vector3;
  8463. /** @hidden */
  8464. _getLockedTargetPosition(): Nullable<Vector3>;
  8465. private _storedPosition;
  8466. private _storedRotation;
  8467. private _storedRotationQuaternion;
  8468. /**
  8469. * Store current camera state of the camera (fov, position, rotation, etc..)
  8470. * @returns the camera
  8471. */
  8472. storeState(): Camera;
  8473. /**
  8474. * Restored camera state. You must call storeState() first
  8475. * @returns whether it was successful or not
  8476. * @hidden
  8477. */
  8478. _restoreStateValues(): boolean;
  8479. /** @hidden */
  8480. _initCache(): void;
  8481. /** @hidden */
  8482. _updateCache(ignoreParentClass?: boolean): void;
  8483. /** @hidden */
  8484. _isSynchronizedViewMatrix(): boolean;
  8485. /** @hidden */
  8486. _computeLocalCameraSpeed(): number;
  8487. /**
  8488. * Defines the target the camera should look at.
  8489. * @param target Defines the new target as a Vector or a mesh
  8490. */
  8491. setTarget(target: Vector3): void;
  8492. /**
  8493. * Return the current target position of the camera. This value is expressed in local space.
  8494. * @returns the target position
  8495. */
  8496. getTarget(): Vector3;
  8497. /** @hidden */
  8498. _decideIfNeedsToMove(): boolean;
  8499. /** @hidden */
  8500. _updatePosition(): void;
  8501. /** @hidden */
  8502. _checkInputs(): void;
  8503. protected _updateCameraRotationMatrix(): void;
  8504. /**
  8505. * 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)
  8506. * @returns the current camera
  8507. */
  8508. private _rotateUpVectorWithCameraRotationMatrix;
  8509. private _cachedRotationZ;
  8510. private _cachedQuaternionRotationZ;
  8511. /** @hidden */
  8512. _getViewMatrix(): Matrix;
  8513. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8514. /**
  8515. * @hidden
  8516. */
  8517. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8518. /**
  8519. * @hidden
  8520. */
  8521. _updateRigCameras(): void;
  8522. private _getRigCamPositionAndTarget;
  8523. /**
  8524. * Gets the current object class name.
  8525. * @return the class name
  8526. */
  8527. getClassName(): string;
  8528. }
  8529. }
  8530. declare module "babylonjs/Events/keyboardEvents" {
  8531. /**
  8532. * Gather the list of keyboard event types as constants.
  8533. */
  8534. export class KeyboardEventTypes {
  8535. /**
  8536. * The keydown event is fired when a key becomes active (pressed).
  8537. */
  8538. static readonly KEYDOWN: number;
  8539. /**
  8540. * The keyup event is fired when a key has been released.
  8541. */
  8542. static readonly KEYUP: number;
  8543. }
  8544. /**
  8545. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8546. */
  8547. export class KeyboardInfo {
  8548. /**
  8549. * Defines the type of event (KeyboardEventTypes)
  8550. */
  8551. type: number;
  8552. /**
  8553. * Defines the related dom event
  8554. */
  8555. event: KeyboardEvent;
  8556. /**
  8557. * Instantiates a new keyboard info.
  8558. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8559. * @param type Defines the type of event (KeyboardEventTypes)
  8560. * @param event Defines the related dom event
  8561. */
  8562. constructor(
  8563. /**
  8564. * Defines the type of event (KeyboardEventTypes)
  8565. */
  8566. type: number,
  8567. /**
  8568. * Defines the related dom event
  8569. */
  8570. event: KeyboardEvent);
  8571. }
  8572. /**
  8573. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8574. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8575. */
  8576. export class KeyboardInfoPre extends KeyboardInfo {
  8577. /**
  8578. * Defines the type of event (KeyboardEventTypes)
  8579. */
  8580. type: number;
  8581. /**
  8582. * Defines the related dom event
  8583. */
  8584. event: KeyboardEvent;
  8585. /**
  8586. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8587. */
  8588. skipOnPointerObservable: boolean;
  8589. /**
  8590. * Instantiates a new keyboard pre info.
  8591. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8592. * @param type Defines the type of event (KeyboardEventTypes)
  8593. * @param event Defines the related dom event
  8594. */
  8595. constructor(
  8596. /**
  8597. * Defines the type of event (KeyboardEventTypes)
  8598. */
  8599. type: number,
  8600. /**
  8601. * Defines the related dom event
  8602. */
  8603. event: KeyboardEvent);
  8604. }
  8605. }
  8606. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8607. import { Nullable } from "babylonjs/types";
  8608. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8609. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8610. /**
  8611. * Manage the keyboard inputs to control the movement of a free camera.
  8612. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8613. */
  8614. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8615. /**
  8616. * Defines the camera the input is attached to.
  8617. */
  8618. camera: FreeCamera;
  8619. /**
  8620. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8621. */
  8622. keysUp: number[];
  8623. /**
  8624. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8625. */
  8626. keysDown: number[];
  8627. /**
  8628. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8629. */
  8630. keysLeft: number[];
  8631. /**
  8632. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8633. */
  8634. keysRight: number[];
  8635. private _keys;
  8636. private _onCanvasBlurObserver;
  8637. private _onKeyboardObserver;
  8638. private _engine;
  8639. private _scene;
  8640. /**
  8641. * Attach the input controls to a specific dom element to get the input from.
  8642. * @param element Defines the element the controls should be listened from
  8643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8644. */
  8645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8646. /**
  8647. * Detach the current controls from the specified dom element.
  8648. * @param element Defines the element to stop listening the inputs from
  8649. */
  8650. detachControl(element: Nullable<HTMLElement>): void;
  8651. /**
  8652. * Update the current camera state depending on the inputs that have been used this frame.
  8653. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8654. */
  8655. checkInputs(): void;
  8656. /**
  8657. * Gets the class name of the current intput.
  8658. * @returns the class name
  8659. */
  8660. getClassName(): string;
  8661. /** @hidden */
  8662. _onLostFocus(): void;
  8663. /**
  8664. * Get the friendly name associated with the input class.
  8665. * @returns the input friendly name
  8666. */
  8667. getSimpleName(): string;
  8668. }
  8669. }
  8670. declare module "babylonjs/Lights/shadowLight" {
  8671. import { Camera } from "babylonjs/Cameras/camera";
  8672. import { Scene } from "babylonjs/scene";
  8673. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8675. import { Light } from "babylonjs/Lights/light";
  8676. /**
  8677. * Interface describing all the common properties and methods a shadow light needs to implement.
  8678. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8679. * as well as binding the different shadow properties to the effects.
  8680. */
  8681. export interface IShadowLight extends Light {
  8682. /**
  8683. * The light id in the scene (used in scene.findLighById for instance)
  8684. */
  8685. id: string;
  8686. /**
  8687. * The position the shdow will be casted from.
  8688. */
  8689. position: Vector3;
  8690. /**
  8691. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8692. */
  8693. direction: Vector3;
  8694. /**
  8695. * The transformed position. Position of the light in world space taking parenting in account.
  8696. */
  8697. transformedPosition: Vector3;
  8698. /**
  8699. * The transformed direction. Direction of the light in world space taking parenting in account.
  8700. */
  8701. transformedDirection: Vector3;
  8702. /**
  8703. * The friendly name of the light in the scene.
  8704. */
  8705. name: string;
  8706. /**
  8707. * Defines the shadow projection clipping minimum z value.
  8708. */
  8709. shadowMinZ: number;
  8710. /**
  8711. * Defines the shadow projection clipping maximum z value.
  8712. */
  8713. shadowMaxZ: number;
  8714. /**
  8715. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8716. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8717. */
  8718. computeTransformedInformation(): boolean;
  8719. /**
  8720. * Gets the scene the light belongs to.
  8721. * @returns The scene
  8722. */
  8723. getScene(): Scene;
  8724. /**
  8725. * Callback defining a custom Projection Matrix Builder.
  8726. * This can be used to override the default projection matrix computation.
  8727. */
  8728. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8729. /**
  8730. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8731. * @param matrix The materix to updated with the projection information
  8732. * @param viewMatrix The transform matrix of the light
  8733. * @param renderList The list of mesh to render in the map
  8734. * @returns The current light
  8735. */
  8736. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8737. /**
  8738. * Gets the current depth scale used in ESM.
  8739. * @returns The scale
  8740. */
  8741. getDepthScale(): number;
  8742. /**
  8743. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8744. * @returns true if a cube texture needs to be use
  8745. */
  8746. needCube(): boolean;
  8747. /**
  8748. * Detects if the projection matrix requires to be recomputed this frame.
  8749. * @returns true if it requires to be recomputed otherwise, false.
  8750. */
  8751. needProjectionMatrixCompute(): boolean;
  8752. /**
  8753. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8754. */
  8755. forceProjectionMatrixCompute(): void;
  8756. /**
  8757. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8758. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8759. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8760. */
  8761. getShadowDirection(faceIndex?: number): Vector3;
  8762. /**
  8763. * Gets the minZ used for shadow according to both the scene and the light.
  8764. * @param activeCamera The camera we are returning the min for
  8765. * @returns the depth min z
  8766. */
  8767. getDepthMinZ(activeCamera: Camera): number;
  8768. /**
  8769. * Gets the maxZ used for shadow according to both the scene and the light.
  8770. * @param activeCamera The camera we are returning the max for
  8771. * @returns the depth max z
  8772. */
  8773. getDepthMaxZ(activeCamera: Camera): number;
  8774. }
  8775. /**
  8776. * Base implementation IShadowLight
  8777. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8778. */
  8779. export abstract class ShadowLight extends Light implements IShadowLight {
  8780. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8781. protected _position: Vector3;
  8782. protected _setPosition(value: Vector3): void;
  8783. /**
  8784. * Sets the position the shadow will be casted from. Also use as the light position for both
  8785. * point and spot lights.
  8786. */
  8787. /**
  8788. * Sets the position the shadow will be casted from. Also use as the light position for both
  8789. * point and spot lights.
  8790. */
  8791. position: Vector3;
  8792. protected _direction: Vector3;
  8793. protected _setDirection(value: Vector3): void;
  8794. /**
  8795. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8796. * Also use as the light direction on spot and directional lights.
  8797. */
  8798. /**
  8799. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8800. * Also use as the light direction on spot and directional lights.
  8801. */
  8802. direction: Vector3;
  8803. private _shadowMinZ;
  8804. /**
  8805. * Gets the shadow projection clipping minimum z value.
  8806. */
  8807. /**
  8808. * Sets the shadow projection clipping minimum z value.
  8809. */
  8810. shadowMinZ: number;
  8811. private _shadowMaxZ;
  8812. /**
  8813. * Sets the shadow projection clipping maximum z value.
  8814. */
  8815. /**
  8816. * Gets the shadow projection clipping maximum z value.
  8817. */
  8818. shadowMaxZ: number;
  8819. /**
  8820. * Callback defining a custom Projection Matrix Builder.
  8821. * This can be used to override the default projection matrix computation.
  8822. */
  8823. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8824. /**
  8825. * The transformed position. Position of the light in world space taking parenting in account.
  8826. */
  8827. transformedPosition: Vector3;
  8828. /**
  8829. * The transformed direction. Direction of the light in world space taking parenting in account.
  8830. */
  8831. transformedDirection: Vector3;
  8832. private _needProjectionMatrixCompute;
  8833. /**
  8834. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8835. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8836. */
  8837. computeTransformedInformation(): boolean;
  8838. /**
  8839. * Return the depth scale used for the shadow map.
  8840. * @returns the depth scale.
  8841. */
  8842. getDepthScale(): number;
  8843. /**
  8844. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8845. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8846. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8847. */
  8848. getShadowDirection(faceIndex?: number): Vector3;
  8849. /**
  8850. * Returns the ShadowLight absolute position in the World.
  8851. * @returns the position vector in world space
  8852. */
  8853. getAbsolutePosition(): Vector3;
  8854. /**
  8855. * Sets the ShadowLight direction toward the passed target.
  8856. * @param target The point to target in local space
  8857. * @returns the updated ShadowLight direction
  8858. */
  8859. setDirectionToTarget(target: Vector3): Vector3;
  8860. /**
  8861. * Returns the light rotation in euler definition.
  8862. * @returns the x y z rotation in local space.
  8863. */
  8864. getRotation(): Vector3;
  8865. /**
  8866. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8867. * @returns true if a cube texture needs to be use
  8868. */
  8869. needCube(): boolean;
  8870. /**
  8871. * Detects if the projection matrix requires to be recomputed this frame.
  8872. * @returns true if it requires to be recomputed otherwise, false.
  8873. */
  8874. needProjectionMatrixCompute(): boolean;
  8875. /**
  8876. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8877. */
  8878. forceProjectionMatrixCompute(): void;
  8879. /** @hidden */
  8880. _initCache(): void;
  8881. /** @hidden */
  8882. _isSynchronized(): boolean;
  8883. /**
  8884. * Computes the world matrix of the node
  8885. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8886. * @returns the world matrix
  8887. */
  8888. computeWorldMatrix(force?: boolean): Matrix;
  8889. /**
  8890. * Gets the minZ used for shadow according to both the scene and the light.
  8891. * @param activeCamera The camera we are returning the min for
  8892. * @returns the depth min z
  8893. */
  8894. getDepthMinZ(activeCamera: Camera): number;
  8895. /**
  8896. * Gets the maxZ used for shadow according to both the scene and the light.
  8897. * @param activeCamera The camera we are returning the max for
  8898. * @returns the depth max z
  8899. */
  8900. getDepthMaxZ(activeCamera: Camera): number;
  8901. /**
  8902. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8903. * @param matrix The materix to updated with the projection information
  8904. * @param viewMatrix The transform matrix of the light
  8905. * @param renderList The list of mesh to render in the map
  8906. * @returns The current light
  8907. */
  8908. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8909. }
  8910. }
  8911. declare module "babylonjs/Materials/materialHelper" {
  8912. import { Nullable } from "babylonjs/types";
  8913. import { Scene } from "babylonjs/scene";
  8914. import { Engine } from "babylonjs/Engines/engine";
  8915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8916. import { Light } from "babylonjs/Lights/light";
  8917. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8918. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8919. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8920. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8921. /**
  8922. * "Static Class" containing the most commonly used helper while dealing with material for
  8923. * rendering purpose.
  8924. *
  8925. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8926. *
  8927. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8928. */
  8929. export class MaterialHelper {
  8930. /**
  8931. * Bind the current view position to an effect.
  8932. * @param effect The effect to be bound
  8933. * @param scene The scene the eyes position is used from
  8934. */
  8935. static BindEyePosition(effect: Effect, scene: Scene): void;
  8936. /**
  8937. * Helps preparing the defines values about the UVs in used in the effect.
  8938. * UVs are shared as much as we can accross channels in the shaders.
  8939. * @param texture The texture we are preparing the UVs for
  8940. * @param defines The defines to update
  8941. * @param key The channel key "diffuse", "specular"... used in the shader
  8942. */
  8943. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8944. /**
  8945. * Binds a texture matrix value to its corrsponding uniform
  8946. * @param texture The texture to bind the matrix for
  8947. * @param uniformBuffer The uniform buffer receivin the data
  8948. * @param key The channel key "diffuse", "specular"... used in the shader
  8949. */
  8950. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8951. /**
  8952. * Gets the current status of the fog (should it be enabled?)
  8953. * @param mesh defines the mesh to evaluate for fog support
  8954. * @param scene defines the hosting scene
  8955. * @returns true if fog must be enabled
  8956. */
  8957. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8958. /**
  8959. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8960. * @param mesh defines the current mesh
  8961. * @param scene defines the current scene
  8962. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8963. * @param pointsCloud defines if point cloud rendering has to be turned on
  8964. * @param fogEnabled defines if fog has to be turned on
  8965. * @param alphaTest defines if alpha testing has to be turned on
  8966. * @param defines defines the current list of defines
  8967. */
  8968. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8969. /**
  8970. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8971. * @param scene defines the current scene
  8972. * @param engine defines the current engine
  8973. * @param defines specifies the list of active defines
  8974. * @param useInstances defines if instances have to be turned on
  8975. * @param useClipPlane defines if clip plane have to be turned on
  8976. */
  8977. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8978. /**
  8979. * Prepares the defines for bones
  8980. * @param mesh The mesh containing the geometry data we will draw
  8981. * @param defines The defines to update
  8982. */
  8983. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8984. /**
  8985. * Prepares the defines for morph targets
  8986. * @param mesh The mesh containing the geometry data we will draw
  8987. * @param defines The defines to update
  8988. */
  8989. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8990. /**
  8991. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8992. * @param mesh The mesh containing the geometry data we will draw
  8993. * @param defines The defines to update
  8994. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8995. * @param useBones Precise whether bones should be used or not (override mesh info)
  8996. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8997. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8998. * @returns false if defines are considered not dirty and have not been checked
  8999. */
  9000. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9001. /**
  9002. * Prepares the defines related to multiview
  9003. * @param scene The scene we are intending to draw
  9004. * @param defines The defines to update
  9005. */
  9006. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9007. /**
  9008. * Prepares the defines related to the light information passed in parameter
  9009. * @param scene The scene we are intending to draw
  9010. * @param mesh The mesh the effect is compiling for
  9011. * @param light The light the effect is compiling for
  9012. * @param lightIndex The index of the light
  9013. * @param defines The defines to update
  9014. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9015. * @param state Defines the current state regarding what is needed (normals, etc...)
  9016. */
  9017. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9018. needNormals: boolean;
  9019. needRebuild: boolean;
  9020. shadowEnabled: boolean;
  9021. specularEnabled: boolean;
  9022. lightmapMode: boolean;
  9023. }): void;
  9024. /**
  9025. * Prepares the defines related to the light information passed in parameter
  9026. * @param scene The scene we are intending to draw
  9027. * @param mesh The mesh the effect is compiling for
  9028. * @param defines The defines to update
  9029. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9030. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9031. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9032. * @returns true if normals will be required for the rest of the effect
  9033. */
  9034. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9035. /**
  9036. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9037. * @param lightIndex defines the light index
  9038. * @param uniformsList The uniform list
  9039. * @param samplersList The sampler list
  9040. * @param projectedLightTexture defines if projected texture must be used
  9041. * @param uniformBuffersList defines an optional list of uniform buffers
  9042. */
  9043. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9044. /**
  9045. * Prepares the uniforms and samplers list to be used in the effect
  9046. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9047. * @param samplersList The sampler list
  9048. * @param defines The defines helping in the list generation
  9049. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9050. */
  9051. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9052. /**
  9053. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9054. * @param defines The defines to update while falling back
  9055. * @param fallbacks The authorized effect fallbacks
  9056. * @param maxSimultaneousLights The maximum number of lights allowed
  9057. * @param rank the current rank of the Effect
  9058. * @returns The newly affected rank
  9059. */
  9060. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9061. private static _TmpMorphInfluencers;
  9062. /**
  9063. * Prepares the list of attributes required for morph targets according to the effect defines.
  9064. * @param attribs The current list of supported attribs
  9065. * @param mesh The mesh to prepare the morph targets attributes for
  9066. * @param influencers The number of influencers
  9067. */
  9068. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9069. /**
  9070. * Prepares the list of attributes required for morph targets according to the effect defines.
  9071. * @param attribs The current list of supported attribs
  9072. * @param mesh The mesh to prepare the morph targets attributes for
  9073. * @param defines The current Defines of the effect
  9074. */
  9075. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9076. /**
  9077. * Prepares the list of attributes required for bones according to the effect defines.
  9078. * @param attribs The current list of supported attribs
  9079. * @param mesh The mesh to prepare the bones attributes for
  9080. * @param defines The current Defines of the effect
  9081. * @param fallbacks The current efffect fallback strategy
  9082. */
  9083. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9084. /**
  9085. * Check and prepare the list of attributes required for instances according to the effect defines.
  9086. * @param attribs The current list of supported attribs
  9087. * @param defines The current MaterialDefines of the effect
  9088. */
  9089. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9090. /**
  9091. * Add the list of attributes required for instances to the attribs array.
  9092. * @param attribs The current list of supported attribs
  9093. */
  9094. static PushAttributesForInstances(attribs: string[]): void;
  9095. /**
  9096. * Binds the light shadow information to the effect for the given mesh.
  9097. * @param light The light containing the generator
  9098. * @param scene The scene the lights belongs to
  9099. * @param mesh The mesh we are binding the information to render
  9100. * @param lightIndex The light index in the effect used to render the mesh
  9101. * @param effect The effect we are binding the data to
  9102. */
  9103. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9104. /**
  9105. * Binds the light information to the effect.
  9106. * @param light The light containing the generator
  9107. * @param effect The effect we are binding the data to
  9108. * @param lightIndex The light index in the effect used to render
  9109. */
  9110. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9111. /**
  9112. * Binds the lights information from the scene to the effect for the given mesh.
  9113. * @param light Light to bind
  9114. * @param lightIndex Light index
  9115. * @param scene The scene where the light belongs to
  9116. * @param mesh The mesh we are binding the information to render
  9117. * @param effect The effect we are binding the data to
  9118. * @param useSpecular Defines if specular is supported
  9119. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9120. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9121. */
  9122. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9123. /**
  9124. * Binds the lights information from the scene to the effect for the given mesh.
  9125. * @param scene The scene the lights belongs to
  9126. * @param mesh The mesh we are binding the information to render
  9127. * @param effect The effect we are binding the data to
  9128. * @param defines The generated defines for the effect
  9129. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9130. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9131. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9132. */
  9133. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9134. private static _tempFogColor;
  9135. /**
  9136. * Binds the fog information from the scene to the effect for the given mesh.
  9137. * @param scene The scene the lights belongs to
  9138. * @param mesh The mesh we are binding the information to render
  9139. * @param effect The effect we are binding the data to
  9140. * @param linearSpace Defines if the fog effect is applied in linear space
  9141. */
  9142. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9143. /**
  9144. * Binds the bones information from the mesh to the effect.
  9145. * @param mesh The mesh we are binding the information to render
  9146. * @param effect The effect we are binding the data to
  9147. */
  9148. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9149. /**
  9150. * Binds the morph targets information from the mesh to the effect.
  9151. * @param abstractMesh The mesh we are binding the information to render
  9152. * @param effect The effect we are binding the data to
  9153. */
  9154. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9155. /**
  9156. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9157. * @param defines The generated defines used in the effect
  9158. * @param effect The effect we are binding the data to
  9159. * @param scene The scene we are willing to render with logarithmic scale for
  9160. */
  9161. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9162. /**
  9163. * Binds the clip plane information from the scene to the effect.
  9164. * @param scene The scene the clip plane information are extracted from
  9165. * @param effect The effect we are binding the data to
  9166. */
  9167. static BindClipPlane(effect: Effect, scene: Scene): void;
  9168. }
  9169. }
  9170. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9171. /** @hidden */
  9172. export var packingFunctions: {
  9173. name: string;
  9174. shader: string;
  9175. };
  9176. }
  9177. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9178. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9179. /** @hidden */
  9180. export var shadowMapPixelShader: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9186. /** @hidden */
  9187. export var bonesDeclaration: {
  9188. name: string;
  9189. shader: string;
  9190. };
  9191. }
  9192. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9193. /** @hidden */
  9194. export var morphTargetsVertexGlobalDeclaration: {
  9195. name: string;
  9196. shader: string;
  9197. };
  9198. }
  9199. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9200. /** @hidden */
  9201. export var morphTargetsVertexDeclaration: {
  9202. name: string;
  9203. shader: string;
  9204. };
  9205. }
  9206. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9207. /** @hidden */
  9208. export var instancesDeclaration: {
  9209. name: string;
  9210. shader: string;
  9211. };
  9212. }
  9213. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9214. /** @hidden */
  9215. export var helperFunctions: {
  9216. name: string;
  9217. shader: string;
  9218. };
  9219. }
  9220. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9221. /** @hidden */
  9222. export var morphTargetsVertex: {
  9223. name: string;
  9224. shader: string;
  9225. };
  9226. }
  9227. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9228. /** @hidden */
  9229. export var instancesVertex: {
  9230. name: string;
  9231. shader: string;
  9232. };
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9235. /** @hidden */
  9236. export var bonesVertex: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9242. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9243. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9244. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9245. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9246. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9247. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9248. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9249. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9250. /** @hidden */
  9251. export var shadowMapVertexShader: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9257. /** @hidden */
  9258. export var depthBoxBlurPixelShader: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9264. import { Nullable } from "babylonjs/types";
  9265. import { Scene } from "babylonjs/scene";
  9266. import { Matrix } from "babylonjs/Maths/math.vector";
  9267. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9269. import { Mesh } from "babylonjs/Meshes/mesh";
  9270. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9271. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9272. import { Effect } from "babylonjs/Materials/effect";
  9273. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9274. import "babylonjs/Shaders/shadowMap.fragment";
  9275. import "babylonjs/Shaders/shadowMap.vertex";
  9276. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9277. import { Observable } from "babylonjs/Misc/observable";
  9278. /**
  9279. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9280. */
  9281. export interface ICustomShaderOptions {
  9282. /**
  9283. * Gets or sets the custom shader name to use
  9284. */
  9285. shaderName: string;
  9286. /**
  9287. * The list of attribute names used in the shader
  9288. */
  9289. attributes?: string[];
  9290. /**
  9291. * The list of unifrom names used in the shader
  9292. */
  9293. uniforms?: string[];
  9294. /**
  9295. * The list of sampler names used in the shader
  9296. */
  9297. samplers?: string[];
  9298. /**
  9299. * The list of defines used in the shader
  9300. */
  9301. defines?: string[];
  9302. }
  9303. /**
  9304. * Interface to implement to create a shadow generator compatible with BJS.
  9305. */
  9306. export interface IShadowGenerator {
  9307. /**
  9308. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9309. * @returns The render target texture if present otherwise, null
  9310. */
  9311. getShadowMap(): Nullable<RenderTargetTexture>;
  9312. /**
  9313. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9314. * @returns The render target texture if the shadow map is present otherwise, null
  9315. */
  9316. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9317. /**
  9318. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9319. * @param subMesh The submesh we want to render in the shadow map
  9320. * @param useInstances Defines wether will draw in the map using instances
  9321. * @returns true if ready otherwise, false
  9322. */
  9323. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9324. /**
  9325. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9326. * @param defines Defines of the material we want to update
  9327. * @param lightIndex Index of the light in the enabled light list of the material
  9328. */
  9329. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9330. /**
  9331. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9332. * defined in the generator but impacting the effect).
  9333. * It implies the unifroms available on the materials are the standard BJS ones.
  9334. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9335. * @param effect The effect we are binfing the information for
  9336. */
  9337. bindShadowLight(lightIndex: string, effect: Effect): void;
  9338. /**
  9339. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9340. * (eq to shadow prjection matrix * light transform matrix)
  9341. * @returns The transform matrix used to create the shadow map
  9342. */
  9343. getTransformMatrix(): Matrix;
  9344. /**
  9345. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9346. * Cube and 2D textures for instance.
  9347. */
  9348. recreateShadowMap(): void;
  9349. /**
  9350. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9351. * @param onCompiled Callback triggered at the and of the effects compilation
  9352. * @param options Sets of optional options forcing the compilation with different modes
  9353. */
  9354. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9355. useInstances: boolean;
  9356. }>): void;
  9357. /**
  9358. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9359. * @param options Sets of optional options forcing the compilation with different modes
  9360. * @returns A promise that resolves when the compilation completes
  9361. */
  9362. forceCompilationAsync(options?: Partial<{
  9363. useInstances: boolean;
  9364. }>): Promise<void>;
  9365. /**
  9366. * Serializes the shadow generator setup to a json object.
  9367. * @returns The serialized JSON object
  9368. */
  9369. serialize(): any;
  9370. /**
  9371. * Disposes the Shadow map and related Textures and effects.
  9372. */
  9373. dispose(): void;
  9374. }
  9375. /**
  9376. * Default implementation IShadowGenerator.
  9377. * This is the main object responsible of generating shadows in the framework.
  9378. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9379. */
  9380. export class ShadowGenerator implements IShadowGenerator {
  9381. /**
  9382. * Shadow generator mode None: no filtering applied.
  9383. */
  9384. static readonly FILTER_NONE: number;
  9385. /**
  9386. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9387. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9388. */
  9389. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9390. /**
  9391. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9392. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9393. */
  9394. static readonly FILTER_POISSONSAMPLING: number;
  9395. /**
  9396. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9397. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9398. */
  9399. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9400. /**
  9401. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9402. * edge artifacts on steep falloff.
  9403. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9404. */
  9405. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9406. /**
  9407. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9408. * edge artifacts on steep falloff.
  9409. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9410. */
  9411. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9412. /**
  9413. * Shadow generator mode PCF: Percentage Closer Filtering
  9414. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9415. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9416. */
  9417. static readonly FILTER_PCF: number;
  9418. /**
  9419. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9420. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9421. * Contact Hardening
  9422. */
  9423. static readonly FILTER_PCSS: number;
  9424. /**
  9425. * Reserved for PCF and PCSS
  9426. * Highest Quality.
  9427. *
  9428. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9429. *
  9430. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9431. */
  9432. static readonly QUALITY_HIGH: number;
  9433. /**
  9434. * Reserved for PCF and PCSS
  9435. * Good tradeoff for quality/perf cross devices
  9436. *
  9437. * Execute PCF on a 3*3 kernel.
  9438. *
  9439. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9440. */
  9441. static readonly QUALITY_MEDIUM: number;
  9442. /**
  9443. * Reserved for PCF and PCSS
  9444. * The lowest quality but the fastest.
  9445. *
  9446. * Execute PCF on a 1*1 kernel.
  9447. *
  9448. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9449. */
  9450. static readonly QUALITY_LOW: number;
  9451. /** Gets or sets the custom shader name to use */
  9452. customShaderOptions: ICustomShaderOptions;
  9453. /**
  9454. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9455. */
  9456. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9457. /**
  9458. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9459. */
  9460. onAfterShadowMapRenderObservable: Observable<Effect>;
  9461. /**
  9462. * Observable triggered before a mesh is rendered in the shadow map.
  9463. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9464. */
  9465. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9466. /**
  9467. * Observable triggered after a mesh is rendered in the shadow map.
  9468. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9469. */
  9470. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9471. private _bias;
  9472. /**
  9473. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9474. */
  9475. /**
  9476. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9477. */
  9478. bias: number;
  9479. private _normalBias;
  9480. /**
  9481. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9482. */
  9483. /**
  9484. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9485. */
  9486. normalBias: number;
  9487. private _blurBoxOffset;
  9488. /**
  9489. * Gets the blur box offset: offset applied during the blur pass.
  9490. * Only useful if useKernelBlur = false
  9491. */
  9492. /**
  9493. * Sets the blur box offset: offset applied during the blur pass.
  9494. * Only useful if useKernelBlur = false
  9495. */
  9496. blurBoxOffset: number;
  9497. private _blurScale;
  9498. /**
  9499. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9500. * 2 means half of the size.
  9501. */
  9502. /**
  9503. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9504. * 2 means half of the size.
  9505. */
  9506. blurScale: number;
  9507. private _blurKernel;
  9508. /**
  9509. * Gets the blur kernel: kernel size of the blur pass.
  9510. * Only useful if useKernelBlur = true
  9511. */
  9512. /**
  9513. * Sets the blur kernel: kernel size of the blur pass.
  9514. * Only useful if useKernelBlur = true
  9515. */
  9516. blurKernel: number;
  9517. private _useKernelBlur;
  9518. /**
  9519. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9520. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9521. */
  9522. /**
  9523. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9524. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9525. */
  9526. useKernelBlur: boolean;
  9527. private _depthScale;
  9528. /**
  9529. * Gets the depth scale used in ESM mode.
  9530. */
  9531. /**
  9532. * Sets the depth scale used in ESM mode.
  9533. * This can override the scale stored on the light.
  9534. */
  9535. depthScale: number;
  9536. private _filter;
  9537. /**
  9538. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9539. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9540. */
  9541. /**
  9542. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9543. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9544. */
  9545. filter: number;
  9546. /**
  9547. * Gets if the current filter is set to Poisson Sampling.
  9548. */
  9549. /**
  9550. * Sets the current filter to Poisson Sampling.
  9551. */
  9552. usePoissonSampling: boolean;
  9553. /**
  9554. * Gets if the current filter is set to ESM.
  9555. */
  9556. /**
  9557. * Sets the current filter is to ESM.
  9558. */
  9559. useExponentialShadowMap: boolean;
  9560. /**
  9561. * Gets if the current filter is set to filtered ESM.
  9562. */
  9563. /**
  9564. * Gets if the current filter is set to filtered ESM.
  9565. */
  9566. useBlurExponentialShadowMap: boolean;
  9567. /**
  9568. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9569. * exponential to prevent steep falloff artifacts).
  9570. */
  9571. /**
  9572. * Sets the current filter to "close ESM" (using the inverse of the
  9573. * exponential to prevent steep falloff artifacts).
  9574. */
  9575. useCloseExponentialShadowMap: boolean;
  9576. /**
  9577. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9578. * exponential to prevent steep falloff artifacts).
  9579. */
  9580. /**
  9581. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9582. * exponential to prevent steep falloff artifacts).
  9583. */
  9584. useBlurCloseExponentialShadowMap: boolean;
  9585. /**
  9586. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9587. */
  9588. /**
  9589. * Sets the current filter to "PCF" (percentage closer filtering).
  9590. */
  9591. usePercentageCloserFiltering: boolean;
  9592. private _filteringQuality;
  9593. /**
  9594. * Gets the PCF or PCSS Quality.
  9595. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9596. */
  9597. /**
  9598. * Sets the PCF or PCSS Quality.
  9599. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9600. */
  9601. filteringQuality: number;
  9602. /**
  9603. * Gets if the current filter is set to "PCSS" (contact hardening).
  9604. */
  9605. /**
  9606. * Sets the current filter to "PCSS" (contact hardening).
  9607. */
  9608. useContactHardeningShadow: boolean;
  9609. private _contactHardeningLightSizeUVRatio;
  9610. /**
  9611. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9612. * Using a ratio helps keeping shape stability independently of the map size.
  9613. *
  9614. * It does not account for the light projection as it was having too much
  9615. * instability during the light setup or during light position changes.
  9616. *
  9617. * Only valid if useContactHardeningShadow is true.
  9618. */
  9619. /**
  9620. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9621. * Using a ratio helps keeping shape stability independently of the map size.
  9622. *
  9623. * It does not account for the light projection as it was having too much
  9624. * instability during the light setup or during light position changes.
  9625. *
  9626. * Only valid if useContactHardeningShadow is true.
  9627. */
  9628. contactHardeningLightSizeUVRatio: number;
  9629. private _darkness;
  9630. /** Gets or sets the actual darkness of a shadow */
  9631. darkness: number;
  9632. /**
  9633. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9634. * 0 means strongest and 1 would means no shadow.
  9635. * @returns the darkness.
  9636. */
  9637. getDarkness(): number;
  9638. /**
  9639. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9640. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9641. * @returns the shadow generator allowing fluent coding.
  9642. */
  9643. setDarkness(darkness: number): ShadowGenerator;
  9644. private _transparencyShadow;
  9645. /** Gets or sets the ability to have transparent shadow */
  9646. transparencyShadow: boolean;
  9647. /**
  9648. * Sets the ability to have transparent shadow (boolean).
  9649. * @param transparent True if transparent else False
  9650. * @returns the shadow generator allowing fluent coding
  9651. */
  9652. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9653. private _shadowMap;
  9654. private _shadowMap2;
  9655. /**
  9656. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9657. * @returns The render target texture if present otherwise, null
  9658. */
  9659. getShadowMap(): Nullable<RenderTargetTexture>;
  9660. /**
  9661. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9662. * @returns The render target texture if the shadow map is present otherwise, null
  9663. */
  9664. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9665. /**
  9666. * Gets the class name of that object
  9667. * @returns "ShadowGenerator"
  9668. */
  9669. getClassName(): string;
  9670. /**
  9671. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9672. * @param mesh Mesh to add
  9673. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9674. * @returns the Shadow Generator itself
  9675. */
  9676. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9677. /**
  9678. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9679. * @param mesh Mesh to remove
  9680. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9681. * @returns the Shadow Generator itself
  9682. */
  9683. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9684. /**
  9685. * Controls the extent to which the shadows fade out at the edge of the frustum
  9686. * Used only by directionals and spots
  9687. */
  9688. frustumEdgeFalloff: number;
  9689. private _light;
  9690. /**
  9691. * Returns the associated light object.
  9692. * @returns the light generating the shadow
  9693. */
  9694. getLight(): IShadowLight;
  9695. /**
  9696. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9697. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9698. * It might on the other hand introduce peter panning.
  9699. */
  9700. forceBackFacesOnly: boolean;
  9701. private _scene;
  9702. private _lightDirection;
  9703. private _effect;
  9704. private _viewMatrix;
  9705. private _projectionMatrix;
  9706. private _transformMatrix;
  9707. private _cachedPosition;
  9708. private _cachedDirection;
  9709. private _cachedDefines;
  9710. private _currentRenderID;
  9711. private _boxBlurPostprocess;
  9712. private _kernelBlurXPostprocess;
  9713. private _kernelBlurYPostprocess;
  9714. private _blurPostProcesses;
  9715. private _mapSize;
  9716. private _currentFaceIndex;
  9717. private _currentFaceIndexCache;
  9718. private _textureType;
  9719. private _defaultTextureMatrix;
  9720. /** @hidden */
  9721. static _SceneComponentInitialization: (scene: Scene) => void;
  9722. /**
  9723. * Creates a ShadowGenerator object.
  9724. * A ShadowGenerator is the required tool to use the shadows.
  9725. * Each light casting shadows needs to use its own ShadowGenerator.
  9726. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9727. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9728. * @param light The light object generating the shadows.
  9729. * @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.
  9730. */
  9731. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9732. private _initializeGenerator;
  9733. private _initializeShadowMap;
  9734. private _initializeBlurRTTAndPostProcesses;
  9735. private _renderForShadowMap;
  9736. private _renderSubMeshForShadowMap;
  9737. private _applyFilterValues;
  9738. /**
  9739. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9740. * @param onCompiled Callback triggered at the and of the effects compilation
  9741. * @param options Sets of optional options forcing the compilation with different modes
  9742. */
  9743. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9744. useInstances: boolean;
  9745. }>): void;
  9746. /**
  9747. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9748. * @param options Sets of optional options forcing the compilation with different modes
  9749. * @returns A promise that resolves when the compilation completes
  9750. */
  9751. forceCompilationAsync(options?: Partial<{
  9752. useInstances: boolean;
  9753. }>): Promise<void>;
  9754. /**
  9755. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9756. * @param subMesh The submesh we want to render in the shadow map
  9757. * @param useInstances Defines wether will draw in the map using instances
  9758. * @returns true if ready otherwise, false
  9759. */
  9760. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9761. /**
  9762. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9763. * @param defines Defines of the material we want to update
  9764. * @param lightIndex Index of the light in the enabled light list of the material
  9765. */
  9766. prepareDefines(defines: any, lightIndex: number): void;
  9767. /**
  9768. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9769. * defined in the generator but impacting the effect).
  9770. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9771. * @param effect The effect we are binfing the information for
  9772. */
  9773. bindShadowLight(lightIndex: string, effect: Effect): void;
  9774. /**
  9775. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9776. * (eq to shadow prjection matrix * light transform matrix)
  9777. * @returns The transform matrix used to create the shadow map
  9778. */
  9779. getTransformMatrix(): Matrix;
  9780. /**
  9781. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9782. * Cube and 2D textures for instance.
  9783. */
  9784. recreateShadowMap(): void;
  9785. private _disposeBlurPostProcesses;
  9786. private _disposeRTTandPostProcesses;
  9787. /**
  9788. * Disposes the ShadowGenerator.
  9789. * Returns nothing.
  9790. */
  9791. dispose(): void;
  9792. /**
  9793. * Serializes the shadow generator setup to a json object.
  9794. * @returns The serialized JSON object
  9795. */
  9796. serialize(): any;
  9797. /**
  9798. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9799. * @param parsedShadowGenerator The JSON object to parse
  9800. * @param scene The scene to create the shadow map for
  9801. * @returns The parsed shadow generator
  9802. */
  9803. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9804. }
  9805. }
  9806. declare module "babylonjs/Lights/light" {
  9807. import { Nullable } from "babylonjs/types";
  9808. import { Scene } from "babylonjs/scene";
  9809. import { Vector3 } from "babylonjs/Maths/math.vector";
  9810. import { Color3 } from "babylonjs/Maths/math.color";
  9811. import { Node } from "babylonjs/node";
  9812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9813. import { Effect } from "babylonjs/Materials/effect";
  9814. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9815. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9816. /**
  9817. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9818. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9819. * 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.
  9820. */
  9821. export abstract class Light extends Node {
  9822. /**
  9823. * Falloff Default: light is falling off following the material specification:
  9824. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9825. */
  9826. static readonly FALLOFF_DEFAULT: number;
  9827. /**
  9828. * Falloff Physical: light is falling off following the inverse squared distance law.
  9829. */
  9830. static readonly FALLOFF_PHYSICAL: number;
  9831. /**
  9832. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9833. * to enhance interoperability with other engines.
  9834. */
  9835. static readonly FALLOFF_GLTF: number;
  9836. /**
  9837. * Falloff Standard: light is falling off like in the standard material
  9838. * to enhance interoperability with other materials.
  9839. */
  9840. static readonly FALLOFF_STANDARD: number;
  9841. /**
  9842. * If every light affecting the material is in this lightmapMode,
  9843. * material.lightmapTexture adds or multiplies
  9844. * (depends on material.useLightmapAsShadowmap)
  9845. * after every other light calculations.
  9846. */
  9847. static readonly LIGHTMAP_DEFAULT: number;
  9848. /**
  9849. * material.lightmapTexture as only diffuse lighting from this light
  9850. * adds only specular lighting from this light
  9851. * adds dynamic shadows
  9852. */
  9853. static readonly LIGHTMAP_SPECULAR: number;
  9854. /**
  9855. * material.lightmapTexture as only lighting
  9856. * no light calculation from this light
  9857. * only adds dynamic shadows from this light
  9858. */
  9859. static readonly LIGHTMAP_SHADOWSONLY: number;
  9860. /**
  9861. * Each light type uses the default quantity according to its type:
  9862. * point/spot lights use luminous intensity
  9863. * directional lights use illuminance
  9864. */
  9865. static readonly INTENSITYMODE_AUTOMATIC: number;
  9866. /**
  9867. * lumen (lm)
  9868. */
  9869. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9870. /**
  9871. * candela (lm/sr)
  9872. */
  9873. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9874. /**
  9875. * lux (lm/m^2)
  9876. */
  9877. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9878. /**
  9879. * nit (cd/m^2)
  9880. */
  9881. static readonly INTENSITYMODE_LUMINANCE: number;
  9882. /**
  9883. * Light type const id of the point light.
  9884. */
  9885. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9886. /**
  9887. * Light type const id of the directional light.
  9888. */
  9889. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9890. /**
  9891. * Light type const id of the spot light.
  9892. */
  9893. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9894. /**
  9895. * Light type const id of the hemispheric light.
  9896. */
  9897. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9898. /**
  9899. * Diffuse gives the basic color to an object.
  9900. */
  9901. diffuse: Color3;
  9902. /**
  9903. * Specular produces a highlight color on an object.
  9904. * Note: This is note affecting PBR materials.
  9905. */
  9906. specular: Color3;
  9907. /**
  9908. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9909. * falling off base on range or angle.
  9910. * This can be set to any values in Light.FALLOFF_x.
  9911. *
  9912. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9913. * other types of materials.
  9914. */
  9915. falloffType: number;
  9916. /**
  9917. * Strength of the light.
  9918. * Note: By default it is define in the framework own unit.
  9919. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9920. */
  9921. intensity: number;
  9922. private _range;
  9923. protected _inverseSquaredRange: number;
  9924. /**
  9925. * Defines how far from the source the light is impacting in scene units.
  9926. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9927. */
  9928. /**
  9929. * Defines how far from the source the light is impacting in scene units.
  9930. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9931. */
  9932. range: number;
  9933. /**
  9934. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9935. * of light.
  9936. */
  9937. private _photometricScale;
  9938. private _intensityMode;
  9939. /**
  9940. * Gets the photometric scale used to interpret the intensity.
  9941. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9942. */
  9943. /**
  9944. * Sets the photometric scale used to interpret the intensity.
  9945. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9946. */
  9947. intensityMode: number;
  9948. private _radius;
  9949. /**
  9950. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9951. */
  9952. /**
  9953. * sets the light radius used by PBR Materials to simulate soft area lights.
  9954. */
  9955. radius: number;
  9956. private _renderPriority;
  9957. /**
  9958. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9959. * exceeding the number allowed of the materials.
  9960. */
  9961. renderPriority: number;
  9962. private _shadowEnabled;
  9963. /**
  9964. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9965. * the current shadow generator.
  9966. */
  9967. /**
  9968. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9969. * the current shadow generator.
  9970. */
  9971. shadowEnabled: boolean;
  9972. private _includedOnlyMeshes;
  9973. /**
  9974. * Gets the only meshes impacted by this light.
  9975. */
  9976. /**
  9977. * Sets the only meshes impacted by this light.
  9978. */
  9979. includedOnlyMeshes: AbstractMesh[];
  9980. private _excludedMeshes;
  9981. /**
  9982. * Gets the meshes not impacted by this light.
  9983. */
  9984. /**
  9985. * Sets the meshes not impacted by this light.
  9986. */
  9987. excludedMeshes: AbstractMesh[];
  9988. private _excludeWithLayerMask;
  9989. /**
  9990. * Gets the layer id use to find what meshes are not impacted by the light.
  9991. * Inactive if 0
  9992. */
  9993. /**
  9994. * Sets the layer id use to find what meshes are not impacted by the light.
  9995. * Inactive if 0
  9996. */
  9997. excludeWithLayerMask: number;
  9998. private _includeOnlyWithLayerMask;
  9999. /**
  10000. * Gets the layer id use to find what meshes are impacted by the light.
  10001. * Inactive if 0
  10002. */
  10003. /**
  10004. * Sets the layer id use to find what meshes are impacted by the light.
  10005. * Inactive if 0
  10006. */
  10007. includeOnlyWithLayerMask: number;
  10008. private _lightmapMode;
  10009. /**
  10010. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10011. */
  10012. /**
  10013. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10014. */
  10015. lightmapMode: number;
  10016. /**
  10017. * Shadow generator associted to the light.
  10018. * @hidden Internal use only.
  10019. */
  10020. _shadowGenerator: Nullable<IShadowGenerator>;
  10021. /**
  10022. * @hidden Internal use only.
  10023. */
  10024. _excludedMeshesIds: string[];
  10025. /**
  10026. * @hidden Internal use only.
  10027. */
  10028. _includedOnlyMeshesIds: string[];
  10029. /**
  10030. * The current light unifom buffer.
  10031. * @hidden Internal use only.
  10032. */
  10033. _uniformBuffer: UniformBuffer;
  10034. /**
  10035. * Creates a Light object in the scene.
  10036. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10037. * @param name The firendly name of the light
  10038. * @param scene The scene the light belongs too
  10039. */
  10040. constructor(name: string, scene: Scene);
  10041. protected abstract _buildUniformLayout(): void;
  10042. /**
  10043. * Sets the passed Effect "effect" with the Light information.
  10044. * @param effect The effect to update
  10045. * @param lightIndex The index of the light in the effect to update
  10046. * @returns The light
  10047. */
  10048. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10049. /**
  10050. * Sets the passed Effect "effect" with the Light information.
  10051. * @param effect The effect to update
  10052. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10053. * @returns The light
  10054. */
  10055. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10056. /**
  10057. * Returns the string "Light".
  10058. * @returns the class name
  10059. */
  10060. getClassName(): string;
  10061. /** @hidden */
  10062. readonly _isLight: boolean;
  10063. /**
  10064. * Converts the light information to a readable string for debug purpose.
  10065. * @param fullDetails Supports for multiple levels of logging within scene loading
  10066. * @returns the human readable light info
  10067. */
  10068. toString(fullDetails?: boolean): string;
  10069. /** @hidden */
  10070. protected _syncParentEnabledState(): void;
  10071. /**
  10072. * Set the enabled state of this node.
  10073. * @param value - the new enabled state
  10074. */
  10075. setEnabled(value: boolean): void;
  10076. /**
  10077. * Returns the Light associated shadow generator if any.
  10078. * @return the associated shadow generator.
  10079. */
  10080. getShadowGenerator(): Nullable<IShadowGenerator>;
  10081. /**
  10082. * Returns a Vector3, the absolute light position in the World.
  10083. * @returns the world space position of the light
  10084. */
  10085. getAbsolutePosition(): Vector3;
  10086. /**
  10087. * Specifies if the light will affect the passed mesh.
  10088. * @param mesh The mesh to test against the light
  10089. * @return true the mesh is affected otherwise, false.
  10090. */
  10091. canAffectMesh(mesh: AbstractMesh): boolean;
  10092. /**
  10093. * Sort function to order lights for rendering.
  10094. * @param a First Light object to compare to second.
  10095. * @param b Second Light object to compare first.
  10096. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10097. */
  10098. static CompareLightsPriority(a: Light, b: Light): number;
  10099. /**
  10100. * Releases resources associated with this node.
  10101. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10102. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10103. */
  10104. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10105. /**
  10106. * Returns the light type ID (integer).
  10107. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10108. */
  10109. getTypeID(): number;
  10110. /**
  10111. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10112. * @returns the scaled intensity in intensity mode unit
  10113. */
  10114. getScaledIntensity(): number;
  10115. /**
  10116. * Returns a new Light object, named "name", from the current one.
  10117. * @param name The name of the cloned light
  10118. * @returns the new created light
  10119. */
  10120. clone(name: string): Nullable<Light>;
  10121. /**
  10122. * Serializes the current light into a Serialization object.
  10123. * @returns the serialized object.
  10124. */
  10125. serialize(): any;
  10126. /**
  10127. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10128. * This new light is named "name" and added to the passed scene.
  10129. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10130. * @param name The friendly name of the light
  10131. * @param scene The scene the new light will belong to
  10132. * @returns the constructor function
  10133. */
  10134. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10135. /**
  10136. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10137. * @param parsedLight The JSON representation of the light
  10138. * @param scene The scene to create the parsed light in
  10139. * @returns the created light after parsing
  10140. */
  10141. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10142. private _hookArrayForExcluded;
  10143. private _hookArrayForIncludedOnly;
  10144. private _resyncMeshes;
  10145. /**
  10146. * Forces the meshes to update their light related information in their rendering used effects
  10147. * @hidden Internal Use Only
  10148. */
  10149. _markMeshesAsLightDirty(): void;
  10150. /**
  10151. * Recomputes the cached photometric scale if needed.
  10152. */
  10153. private _computePhotometricScale;
  10154. /**
  10155. * Returns the Photometric Scale according to the light type and intensity mode.
  10156. */
  10157. private _getPhotometricScale;
  10158. /**
  10159. * Reorder the light in the scene according to their defined priority.
  10160. * @hidden Internal Use Only
  10161. */
  10162. _reorderLightsInScene(): void;
  10163. /**
  10164. * Prepares the list of defines specific to the light type.
  10165. * @param defines the list of defines
  10166. * @param lightIndex defines the index of the light for the effect
  10167. */
  10168. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10169. }
  10170. }
  10171. declare module "babylonjs/Actions/action" {
  10172. import { Observable } from "babylonjs/Misc/observable";
  10173. import { Condition } from "babylonjs/Actions/condition";
  10174. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10175. import { ActionManager } from "babylonjs/Actions/actionManager";
  10176. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10177. /**
  10178. * Interface used to define Action
  10179. */
  10180. export interface IAction {
  10181. /**
  10182. * Trigger for the action
  10183. */
  10184. trigger: number;
  10185. /** Options of the trigger */
  10186. triggerOptions: any;
  10187. /**
  10188. * Gets the trigger parameters
  10189. * @returns the trigger parameters
  10190. */
  10191. getTriggerParameter(): any;
  10192. /**
  10193. * Internal only - executes current action event
  10194. * @hidden
  10195. */
  10196. _executeCurrent(evt?: ActionEvent): void;
  10197. /**
  10198. * Serialize placeholder for child classes
  10199. * @param parent of child
  10200. * @returns the serialized object
  10201. */
  10202. serialize(parent: any): any;
  10203. /**
  10204. * Internal only
  10205. * @hidden
  10206. */
  10207. _prepare(): void;
  10208. /**
  10209. * Internal only - manager for action
  10210. * @hidden
  10211. */
  10212. _actionManager: AbstractActionManager;
  10213. /**
  10214. * Adds action to chain of actions, may be a DoNothingAction
  10215. * @param action defines the next action to execute
  10216. * @returns The action passed in
  10217. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10218. */
  10219. then(action: IAction): IAction;
  10220. }
  10221. /**
  10222. * The action to be carried out following a trigger
  10223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10224. */
  10225. export class Action implements IAction {
  10226. /** the trigger, with or without parameters, for the action */
  10227. triggerOptions: any;
  10228. /**
  10229. * Trigger for the action
  10230. */
  10231. trigger: number;
  10232. /**
  10233. * Internal only - manager for action
  10234. * @hidden
  10235. */
  10236. _actionManager: ActionManager;
  10237. private _nextActiveAction;
  10238. private _child;
  10239. private _condition?;
  10240. private _triggerParameter;
  10241. /**
  10242. * An event triggered prior to action being executed.
  10243. */
  10244. onBeforeExecuteObservable: Observable<Action>;
  10245. /**
  10246. * Creates a new Action
  10247. * @param triggerOptions the trigger, with or without parameters, for the action
  10248. * @param condition an optional determinant of action
  10249. */
  10250. constructor(
  10251. /** the trigger, with or without parameters, for the action */
  10252. triggerOptions: any, condition?: Condition);
  10253. /**
  10254. * Internal only
  10255. * @hidden
  10256. */
  10257. _prepare(): void;
  10258. /**
  10259. * Gets the trigger parameters
  10260. * @returns the trigger parameters
  10261. */
  10262. getTriggerParameter(): any;
  10263. /**
  10264. * Internal only - executes current action event
  10265. * @hidden
  10266. */
  10267. _executeCurrent(evt?: ActionEvent): void;
  10268. /**
  10269. * Execute placeholder for child classes
  10270. * @param evt optional action event
  10271. */
  10272. execute(evt?: ActionEvent): void;
  10273. /**
  10274. * Skips to next active action
  10275. */
  10276. skipToNextActiveAction(): void;
  10277. /**
  10278. * Adds action to chain of actions, may be a DoNothingAction
  10279. * @param action defines the next action to execute
  10280. * @returns The action passed in
  10281. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10282. */
  10283. then(action: Action): Action;
  10284. /**
  10285. * Internal only
  10286. * @hidden
  10287. */
  10288. _getProperty(propertyPath: string): string;
  10289. /**
  10290. * Internal only
  10291. * @hidden
  10292. */
  10293. _getEffectiveTarget(target: any, propertyPath: string): any;
  10294. /**
  10295. * Serialize placeholder for child classes
  10296. * @param parent of child
  10297. * @returns the serialized object
  10298. */
  10299. serialize(parent: any): any;
  10300. /**
  10301. * Internal only called by serialize
  10302. * @hidden
  10303. */
  10304. protected _serialize(serializedAction: any, parent?: any): any;
  10305. /**
  10306. * Internal only
  10307. * @hidden
  10308. */
  10309. static _SerializeValueAsString: (value: any) => string;
  10310. /**
  10311. * Internal only
  10312. * @hidden
  10313. */
  10314. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10315. name: string;
  10316. targetType: string;
  10317. value: string;
  10318. };
  10319. }
  10320. }
  10321. declare module "babylonjs/Actions/condition" {
  10322. import { ActionManager } from "babylonjs/Actions/actionManager";
  10323. /**
  10324. * A Condition applied to an Action
  10325. */
  10326. export class Condition {
  10327. /**
  10328. * Internal only - manager for action
  10329. * @hidden
  10330. */
  10331. _actionManager: ActionManager;
  10332. /**
  10333. * Internal only
  10334. * @hidden
  10335. */
  10336. _evaluationId: number;
  10337. /**
  10338. * Internal only
  10339. * @hidden
  10340. */
  10341. _currentResult: boolean;
  10342. /**
  10343. * Creates a new Condition
  10344. * @param actionManager the manager of the action the condition is applied to
  10345. */
  10346. constructor(actionManager: ActionManager);
  10347. /**
  10348. * Check if the current condition is valid
  10349. * @returns a boolean
  10350. */
  10351. isValid(): boolean;
  10352. /**
  10353. * Internal only
  10354. * @hidden
  10355. */
  10356. _getProperty(propertyPath: string): string;
  10357. /**
  10358. * Internal only
  10359. * @hidden
  10360. */
  10361. _getEffectiveTarget(target: any, propertyPath: string): any;
  10362. /**
  10363. * Serialize placeholder for child classes
  10364. * @returns the serialized object
  10365. */
  10366. serialize(): any;
  10367. /**
  10368. * Internal only
  10369. * @hidden
  10370. */
  10371. protected _serialize(serializedCondition: any): any;
  10372. }
  10373. /**
  10374. * Defines specific conditional operators as extensions of Condition
  10375. */
  10376. export class ValueCondition extends Condition {
  10377. /** path to specify the property of the target the conditional operator uses */
  10378. propertyPath: string;
  10379. /** the value compared by the conditional operator against the current value of the property */
  10380. value: any;
  10381. /** the conditional operator, default ValueCondition.IsEqual */
  10382. operator: number;
  10383. /**
  10384. * Internal only
  10385. * @hidden
  10386. */
  10387. private static _IsEqual;
  10388. /**
  10389. * Internal only
  10390. * @hidden
  10391. */
  10392. private static _IsDifferent;
  10393. /**
  10394. * Internal only
  10395. * @hidden
  10396. */
  10397. private static _IsGreater;
  10398. /**
  10399. * Internal only
  10400. * @hidden
  10401. */
  10402. private static _IsLesser;
  10403. /**
  10404. * returns the number for IsEqual
  10405. */
  10406. static readonly IsEqual: number;
  10407. /**
  10408. * Returns the number for IsDifferent
  10409. */
  10410. static readonly IsDifferent: number;
  10411. /**
  10412. * Returns the number for IsGreater
  10413. */
  10414. static readonly IsGreater: number;
  10415. /**
  10416. * Returns the number for IsLesser
  10417. */
  10418. static readonly IsLesser: number;
  10419. /**
  10420. * Internal only The action manager for the condition
  10421. * @hidden
  10422. */
  10423. _actionManager: ActionManager;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. private _target;
  10429. /**
  10430. * Internal only
  10431. * @hidden
  10432. */
  10433. private _effectiveTarget;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. private _property;
  10439. /**
  10440. * Creates a new ValueCondition
  10441. * @param actionManager manager for the action the condition applies to
  10442. * @param target for the action
  10443. * @param propertyPath path to specify the property of the target the conditional operator uses
  10444. * @param value the value compared by the conditional operator against the current value of the property
  10445. * @param operator the conditional operator, default ValueCondition.IsEqual
  10446. */
  10447. constructor(actionManager: ActionManager, target: any,
  10448. /** path to specify the property of the target the conditional operator uses */
  10449. propertyPath: string,
  10450. /** the value compared by the conditional operator against the current value of the property */
  10451. value: any,
  10452. /** the conditional operator, default ValueCondition.IsEqual */
  10453. operator?: number);
  10454. /**
  10455. * Compares the given value with the property value for the specified conditional operator
  10456. * @returns the result of the comparison
  10457. */
  10458. isValid(): boolean;
  10459. /**
  10460. * Serialize the ValueCondition into a JSON compatible object
  10461. * @returns serialization object
  10462. */
  10463. serialize(): any;
  10464. /**
  10465. * Gets the name of the conditional operator for the ValueCondition
  10466. * @param operator the conditional operator
  10467. * @returns the name
  10468. */
  10469. static GetOperatorName(operator: number): string;
  10470. }
  10471. /**
  10472. * Defines a predicate condition as an extension of Condition
  10473. */
  10474. export class PredicateCondition extends Condition {
  10475. /** defines the predicate function used to validate the condition */
  10476. predicate: () => boolean;
  10477. /**
  10478. * Internal only - manager for action
  10479. * @hidden
  10480. */
  10481. _actionManager: ActionManager;
  10482. /**
  10483. * Creates a new PredicateCondition
  10484. * @param actionManager manager for the action the condition applies to
  10485. * @param predicate defines the predicate function used to validate the condition
  10486. */
  10487. constructor(actionManager: ActionManager,
  10488. /** defines the predicate function used to validate the condition */
  10489. predicate: () => boolean);
  10490. /**
  10491. * @returns the validity of the predicate condition
  10492. */
  10493. isValid(): boolean;
  10494. }
  10495. /**
  10496. * Defines a state condition as an extension of Condition
  10497. */
  10498. export class StateCondition extends Condition {
  10499. /** Value to compare with target state */
  10500. value: string;
  10501. /**
  10502. * Internal only - manager for action
  10503. * @hidden
  10504. */
  10505. _actionManager: ActionManager;
  10506. /**
  10507. * Internal only
  10508. * @hidden
  10509. */
  10510. private _target;
  10511. /**
  10512. * Creates a new StateCondition
  10513. * @param actionManager manager for the action the condition applies to
  10514. * @param target of the condition
  10515. * @param value to compare with target state
  10516. */
  10517. constructor(actionManager: ActionManager, target: any,
  10518. /** Value to compare with target state */
  10519. value: string);
  10520. /**
  10521. * Gets a boolean indicating if the current condition is met
  10522. * @returns the validity of the state
  10523. */
  10524. isValid(): boolean;
  10525. /**
  10526. * Serialize the StateCondition into a JSON compatible object
  10527. * @returns serialization object
  10528. */
  10529. serialize(): any;
  10530. }
  10531. }
  10532. declare module "babylonjs/Actions/directActions" {
  10533. import { Action } from "babylonjs/Actions/action";
  10534. import { Condition } from "babylonjs/Actions/condition";
  10535. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10536. /**
  10537. * This defines an action responsible to toggle a boolean once triggered.
  10538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10539. */
  10540. export class SwitchBooleanAction extends Action {
  10541. /**
  10542. * The path to the boolean property in the target object
  10543. */
  10544. propertyPath: string;
  10545. private _target;
  10546. private _effectiveTarget;
  10547. private _property;
  10548. /**
  10549. * Instantiate the action
  10550. * @param triggerOptions defines the trigger options
  10551. * @param target defines the object containing the boolean
  10552. * @param propertyPath defines the path to the boolean property in the target object
  10553. * @param condition defines the trigger related conditions
  10554. */
  10555. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10556. /** @hidden */
  10557. _prepare(): void;
  10558. /**
  10559. * Execute the action toggle the boolean value.
  10560. */
  10561. execute(): void;
  10562. /**
  10563. * Serializes the actions and its related information.
  10564. * @param parent defines the object to serialize in
  10565. * @returns the serialized object
  10566. */
  10567. serialize(parent: any): any;
  10568. }
  10569. /**
  10570. * This defines an action responsible to set a the state field of the target
  10571. * to a desired value once triggered.
  10572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10573. */
  10574. export class SetStateAction extends Action {
  10575. /**
  10576. * The value to store in the state field.
  10577. */
  10578. value: string;
  10579. private _target;
  10580. /**
  10581. * Instantiate the action
  10582. * @param triggerOptions defines the trigger options
  10583. * @param target defines the object containing the state property
  10584. * @param value defines the value to store in the state field
  10585. * @param condition defines the trigger related conditions
  10586. */
  10587. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10588. /**
  10589. * Execute the action and store the value on the target state property.
  10590. */
  10591. execute(): void;
  10592. /**
  10593. * Serializes the actions and its related information.
  10594. * @param parent defines the object to serialize in
  10595. * @returns the serialized object
  10596. */
  10597. serialize(parent: any): any;
  10598. }
  10599. /**
  10600. * This defines an action responsible to set a property of the target
  10601. * to a desired value once triggered.
  10602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10603. */
  10604. export class SetValueAction extends Action {
  10605. /**
  10606. * The path of the property to set in the target.
  10607. */
  10608. propertyPath: string;
  10609. /**
  10610. * The value to set in the property
  10611. */
  10612. value: any;
  10613. private _target;
  10614. private _effectiveTarget;
  10615. private _property;
  10616. /**
  10617. * Instantiate the action
  10618. * @param triggerOptions defines the trigger options
  10619. * @param target defines the object containing the property
  10620. * @param propertyPath defines the path of the property to set in the target
  10621. * @param value defines the value to set in the property
  10622. * @param condition defines the trigger related conditions
  10623. */
  10624. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10625. /** @hidden */
  10626. _prepare(): void;
  10627. /**
  10628. * Execute the action and set the targetted property to the desired value.
  10629. */
  10630. execute(): void;
  10631. /**
  10632. * Serializes the actions and its related information.
  10633. * @param parent defines the object to serialize in
  10634. * @returns the serialized object
  10635. */
  10636. serialize(parent: any): any;
  10637. }
  10638. /**
  10639. * This defines an action responsible to increment the target value
  10640. * to a desired value once triggered.
  10641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10642. */
  10643. export class IncrementValueAction extends Action {
  10644. /**
  10645. * The path of the property to increment in the target.
  10646. */
  10647. propertyPath: string;
  10648. /**
  10649. * The value we should increment the property by.
  10650. */
  10651. value: any;
  10652. private _target;
  10653. private _effectiveTarget;
  10654. private _property;
  10655. /**
  10656. * Instantiate the action
  10657. * @param triggerOptions defines the trigger options
  10658. * @param target defines the object containing the property
  10659. * @param propertyPath defines the path of the property to increment in the target
  10660. * @param value defines the value value we should increment the property by
  10661. * @param condition defines the trigger related conditions
  10662. */
  10663. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10664. /** @hidden */
  10665. _prepare(): void;
  10666. /**
  10667. * Execute the action and increment the target of the value amount.
  10668. */
  10669. execute(): void;
  10670. /**
  10671. * Serializes the actions and its related information.
  10672. * @param parent defines the object to serialize in
  10673. * @returns the serialized object
  10674. */
  10675. serialize(parent: any): any;
  10676. }
  10677. /**
  10678. * This defines an action responsible to start an animation once triggered.
  10679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10680. */
  10681. export class PlayAnimationAction extends Action {
  10682. /**
  10683. * Where the animation should start (animation frame)
  10684. */
  10685. from: number;
  10686. /**
  10687. * Where the animation should stop (animation frame)
  10688. */
  10689. to: number;
  10690. /**
  10691. * Define if the animation should loop or stop after the first play.
  10692. */
  10693. loop?: boolean;
  10694. private _target;
  10695. /**
  10696. * Instantiate the action
  10697. * @param triggerOptions defines the trigger options
  10698. * @param target defines the target animation or animation name
  10699. * @param from defines from where the animation should start (animation frame)
  10700. * @param end defines where the animation should stop (animation frame)
  10701. * @param loop defines if the animation should loop or stop after the first play
  10702. * @param condition defines the trigger related conditions
  10703. */
  10704. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10705. /** @hidden */
  10706. _prepare(): void;
  10707. /**
  10708. * Execute the action and play the animation.
  10709. */
  10710. execute(): void;
  10711. /**
  10712. * Serializes the actions and its related information.
  10713. * @param parent defines the object to serialize in
  10714. * @returns the serialized object
  10715. */
  10716. serialize(parent: any): any;
  10717. }
  10718. /**
  10719. * This defines an action responsible to stop an animation once triggered.
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10721. */
  10722. export class StopAnimationAction extends Action {
  10723. private _target;
  10724. /**
  10725. * Instantiate the action
  10726. * @param triggerOptions defines the trigger options
  10727. * @param target defines the target animation or animation name
  10728. * @param condition defines the trigger related conditions
  10729. */
  10730. constructor(triggerOptions: any, target: any, condition?: Condition);
  10731. /** @hidden */
  10732. _prepare(): void;
  10733. /**
  10734. * Execute the action and stop the animation.
  10735. */
  10736. execute(): void;
  10737. /**
  10738. * Serializes the actions and its related information.
  10739. * @param parent defines the object to serialize in
  10740. * @returns the serialized object
  10741. */
  10742. serialize(parent: any): any;
  10743. }
  10744. /**
  10745. * This defines an action responsible that does nothing once triggered.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class DoNothingAction extends Action {
  10749. /**
  10750. * Instantiate the action
  10751. * @param triggerOptions defines the trigger options
  10752. * @param condition defines the trigger related conditions
  10753. */
  10754. constructor(triggerOptions?: any, condition?: Condition);
  10755. /**
  10756. * Execute the action and do nothing.
  10757. */
  10758. execute(): void;
  10759. /**
  10760. * Serializes the actions and its related information.
  10761. * @param parent defines the object to serialize in
  10762. * @returns the serialized object
  10763. */
  10764. serialize(parent: any): any;
  10765. }
  10766. /**
  10767. * This defines an action responsible to trigger several actions once triggered.
  10768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10769. */
  10770. export class CombineAction extends Action {
  10771. /**
  10772. * The list of aggregated animations to run.
  10773. */
  10774. children: Action[];
  10775. /**
  10776. * Instantiate the action
  10777. * @param triggerOptions defines the trigger options
  10778. * @param children defines the list of aggregated animations to run
  10779. * @param condition defines the trigger related conditions
  10780. */
  10781. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10782. /** @hidden */
  10783. _prepare(): void;
  10784. /**
  10785. * Execute the action and executes all the aggregated actions.
  10786. */
  10787. execute(evt: ActionEvent): void;
  10788. /**
  10789. * Serializes the actions and its related information.
  10790. * @param parent defines the object to serialize in
  10791. * @returns the serialized object
  10792. */
  10793. serialize(parent: any): any;
  10794. }
  10795. /**
  10796. * This defines an action responsible to run code (external event) once triggered.
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10798. */
  10799. export class ExecuteCodeAction extends Action {
  10800. /**
  10801. * The callback function to run.
  10802. */
  10803. func: (evt: ActionEvent) => void;
  10804. /**
  10805. * Instantiate the action
  10806. * @param triggerOptions defines the trigger options
  10807. * @param func defines the callback function to run
  10808. * @param condition defines the trigger related conditions
  10809. */
  10810. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10811. /**
  10812. * Execute the action and run the attached code.
  10813. */
  10814. execute(evt: ActionEvent): void;
  10815. }
  10816. /**
  10817. * This defines an action responsible to set the parent property of the target once triggered.
  10818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10819. */
  10820. export class SetParentAction extends Action {
  10821. private _parent;
  10822. private _target;
  10823. /**
  10824. * Instantiate the action
  10825. * @param triggerOptions defines the trigger options
  10826. * @param target defines the target containing the parent property
  10827. * @param parent defines from where the animation should start (animation frame)
  10828. * @param condition defines the trigger related conditions
  10829. */
  10830. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10831. /** @hidden */
  10832. _prepare(): void;
  10833. /**
  10834. * Execute the action and set the parent property.
  10835. */
  10836. execute(): void;
  10837. /**
  10838. * Serializes the actions and its related information.
  10839. * @param parent defines the object to serialize in
  10840. * @returns the serialized object
  10841. */
  10842. serialize(parent: any): any;
  10843. }
  10844. }
  10845. declare module "babylonjs/Actions/actionManager" {
  10846. import { Nullable } from "babylonjs/types";
  10847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10848. import { Scene } from "babylonjs/scene";
  10849. import { IAction } from "babylonjs/Actions/action";
  10850. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10851. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10852. /**
  10853. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10854. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10856. */
  10857. export class ActionManager extends AbstractActionManager {
  10858. /**
  10859. * Nothing
  10860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10861. */
  10862. static readonly NothingTrigger: number;
  10863. /**
  10864. * On pick
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10866. */
  10867. static readonly OnPickTrigger: number;
  10868. /**
  10869. * On left pick
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10871. */
  10872. static readonly OnLeftPickTrigger: number;
  10873. /**
  10874. * On right pick
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10876. */
  10877. static readonly OnRightPickTrigger: number;
  10878. /**
  10879. * On center pick
  10880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10881. */
  10882. static readonly OnCenterPickTrigger: number;
  10883. /**
  10884. * On pick down
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10886. */
  10887. static readonly OnPickDownTrigger: number;
  10888. /**
  10889. * On double pick
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10891. */
  10892. static readonly OnDoublePickTrigger: number;
  10893. /**
  10894. * On pick up
  10895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10896. */
  10897. static readonly OnPickUpTrigger: number;
  10898. /**
  10899. * On pick out.
  10900. * This trigger will only be raised if you also declared a OnPickDown
  10901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10902. */
  10903. static readonly OnPickOutTrigger: number;
  10904. /**
  10905. * On long press
  10906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10907. */
  10908. static readonly OnLongPressTrigger: number;
  10909. /**
  10910. * On pointer over
  10911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10912. */
  10913. static readonly OnPointerOverTrigger: number;
  10914. /**
  10915. * On pointer out
  10916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10917. */
  10918. static readonly OnPointerOutTrigger: number;
  10919. /**
  10920. * On every frame
  10921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10922. */
  10923. static readonly OnEveryFrameTrigger: number;
  10924. /**
  10925. * On intersection enter
  10926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10927. */
  10928. static readonly OnIntersectionEnterTrigger: number;
  10929. /**
  10930. * On intersection exit
  10931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10932. */
  10933. static readonly OnIntersectionExitTrigger: number;
  10934. /**
  10935. * On key down
  10936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10937. */
  10938. static readonly OnKeyDownTrigger: number;
  10939. /**
  10940. * On key up
  10941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10942. */
  10943. static readonly OnKeyUpTrigger: number;
  10944. private _scene;
  10945. /**
  10946. * Creates a new action manager
  10947. * @param scene defines the hosting scene
  10948. */
  10949. constructor(scene: Scene);
  10950. /**
  10951. * Releases all associated resources
  10952. */
  10953. dispose(): void;
  10954. /**
  10955. * Gets hosting scene
  10956. * @returns the hosting scene
  10957. */
  10958. getScene(): Scene;
  10959. /**
  10960. * Does this action manager handles actions of any of the given triggers
  10961. * @param triggers defines the triggers to be tested
  10962. * @return a boolean indicating whether one (or more) of the triggers is handled
  10963. */
  10964. hasSpecificTriggers(triggers: number[]): boolean;
  10965. /**
  10966. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10967. * speed.
  10968. * @param triggerA defines the trigger to be tested
  10969. * @param triggerB defines the trigger to be tested
  10970. * @return a boolean indicating whether one (or more) of the triggers is handled
  10971. */
  10972. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10973. /**
  10974. * Does this action manager handles actions of a given trigger
  10975. * @param trigger defines the trigger to be tested
  10976. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10977. * @return whether the trigger is handled
  10978. */
  10979. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10980. /**
  10981. * Does this action manager has pointer triggers
  10982. */
  10983. readonly hasPointerTriggers: boolean;
  10984. /**
  10985. * Does this action manager has pick triggers
  10986. */
  10987. readonly hasPickTriggers: boolean;
  10988. /**
  10989. * Registers an action to this action manager
  10990. * @param action defines the action to be registered
  10991. * @return the action amended (prepared) after registration
  10992. */
  10993. registerAction(action: IAction): Nullable<IAction>;
  10994. /**
  10995. * Unregisters an action to this action manager
  10996. * @param action defines the action to be unregistered
  10997. * @return a boolean indicating whether the action has been unregistered
  10998. */
  10999. unregisterAction(action: IAction): Boolean;
  11000. /**
  11001. * Process a specific trigger
  11002. * @param trigger defines the trigger to process
  11003. * @param evt defines the event details to be processed
  11004. */
  11005. processTrigger(trigger: number, evt?: IActionEvent): void;
  11006. /** @hidden */
  11007. _getEffectiveTarget(target: any, propertyPath: string): any;
  11008. /** @hidden */
  11009. _getProperty(propertyPath: string): string;
  11010. /**
  11011. * Serialize this manager to a JSON object
  11012. * @param name defines the property name to store this manager
  11013. * @returns a JSON representation of this manager
  11014. */
  11015. serialize(name: string): any;
  11016. /**
  11017. * Creates a new ActionManager from a JSON data
  11018. * @param parsedActions defines the JSON data to read from
  11019. * @param object defines the hosting mesh
  11020. * @param scene defines the hosting scene
  11021. */
  11022. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11023. /**
  11024. * Get a trigger name by index
  11025. * @param trigger defines the trigger index
  11026. * @returns a trigger name
  11027. */
  11028. static GetTriggerName(trigger: number): string;
  11029. }
  11030. }
  11031. declare module "babylonjs/Culling/ray" {
  11032. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11033. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11035. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11036. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11037. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11038. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11039. import { Plane } from "babylonjs/Maths/math.plane";
  11040. /**
  11041. * Class representing a ray with position and direction
  11042. */
  11043. export class Ray {
  11044. /** origin point */
  11045. origin: Vector3;
  11046. /** direction */
  11047. direction: Vector3;
  11048. /** length of the ray */
  11049. length: number;
  11050. private static readonly TmpVector3;
  11051. private _tmpRay;
  11052. /**
  11053. * Creates a new ray
  11054. * @param origin origin point
  11055. * @param direction direction
  11056. * @param length length of the ray
  11057. */
  11058. constructor(
  11059. /** origin point */
  11060. origin: Vector3,
  11061. /** direction */
  11062. direction: Vector3,
  11063. /** length of the ray */
  11064. length?: number);
  11065. /**
  11066. * Checks if the ray intersects a box
  11067. * @param minimum bound of the box
  11068. * @param maximum bound of the box
  11069. * @param intersectionTreshold extra extend to be added to the box in all direction
  11070. * @returns if the box was hit
  11071. */
  11072. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11073. /**
  11074. * Checks if the ray intersects a box
  11075. * @param box the bounding box to check
  11076. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11077. * @returns if the box was hit
  11078. */
  11079. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11080. /**
  11081. * If the ray hits a sphere
  11082. * @param sphere the bounding sphere to check
  11083. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11084. * @returns true if it hits the sphere
  11085. */
  11086. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11087. /**
  11088. * If the ray hits a triange
  11089. * @param vertex0 triangle vertex
  11090. * @param vertex1 triangle vertex
  11091. * @param vertex2 triangle vertex
  11092. * @returns intersection information if hit
  11093. */
  11094. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11095. /**
  11096. * Checks if ray intersects a plane
  11097. * @param plane the plane to check
  11098. * @returns the distance away it was hit
  11099. */
  11100. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11101. /**
  11102. * Calculate the intercept of a ray on a given axis
  11103. * @param axis to check 'x' | 'y' | 'z'
  11104. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11105. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11106. */
  11107. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11108. /**
  11109. * Checks if ray intersects a mesh
  11110. * @param mesh the mesh to check
  11111. * @param fastCheck if only the bounding box should checked
  11112. * @returns picking info of the intersecton
  11113. */
  11114. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11115. /**
  11116. * Checks if ray intersects a mesh
  11117. * @param meshes the meshes to check
  11118. * @param fastCheck if only the bounding box should checked
  11119. * @param results array to store result in
  11120. * @returns Array of picking infos
  11121. */
  11122. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11123. private _comparePickingInfo;
  11124. private static smallnum;
  11125. private static rayl;
  11126. /**
  11127. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11128. * @param sega the first point of the segment to test the intersection against
  11129. * @param segb the second point of the segment to test the intersection against
  11130. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11131. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11132. */
  11133. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11134. /**
  11135. * Update the ray from viewport position
  11136. * @param x position
  11137. * @param y y position
  11138. * @param viewportWidth viewport width
  11139. * @param viewportHeight viewport height
  11140. * @param world world matrix
  11141. * @param view view matrix
  11142. * @param projection projection matrix
  11143. * @returns this ray updated
  11144. */
  11145. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11146. /**
  11147. * Creates a ray with origin and direction of 0,0,0
  11148. * @returns the new ray
  11149. */
  11150. static Zero(): Ray;
  11151. /**
  11152. * Creates a new ray from screen space and viewport
  11153. * @param x position
  11154. * @param y y position
  11155. * @param viewportWidth viewport width
  11156. * @param viewportHeight viewport height
  11157. * @param world world matrix
  11158. * @param view view matrix
  11159. * @param projection projection matrix
  11160. * @returns new ray
  11161. */
  11162. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11163. /**
  11164. * 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
  11165. * transformed to the given world matrix.
  11166. * @param origin The origin point
  11167. * @param end The end point
  11168. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11169. * @returns the new ray
  11170. */
  11171. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11172. /**
  11173. * Transforms a ray by a matrix
  11174. * @param ray ray to transform
  11175. * @param matrix matrix to apply
  11176. * @returns the resulting new ray
  11177. */
  11178. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11179. /**
  11180. * Transforms a ray by a matrix
  11181. * @param ray ray to transform
  11182. * @param matrix matrix to apply
  11183. * @param result ray to store result in
  11184. */
  11185. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11186. /**
  11187. * Unproject a ray from screen space to object space
  11188. * @param sourceX defines the screen space x coordinate to use
  11189. * @param sourceY defines the screen space y coordinate to use
  11190. * @param viewportWidth defines the current width of the viewport
  11191. * @param viewportHeight defines the current height of the viewport
  11192. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11193. * @param view defines the view matrix to use
  11194. * @param projection defines the projection matrix to use
  11195. */
  11196. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11197. }
  11198. /**
  11199. * Type used to define predicate used to select faces when a mesh intersection is detected
  11200. */
  11201. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11202. module "babylonjs/scene" {
  11203. interface Scene {
  11204. /** @hidden */
  11205. _tempPickingRay: Nullable<Ray>;
  11206. /** @hidden */
  11207. _cachedRayForTransform: Ray;
  11208. /** @hidden */
  11209. _pickWithRayInverseMatrix: Matrix;
  11210. /** @hidden */
  11211. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11212. /** @hidden */
  11213. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11214. }
  11215. }
  11216. }
  11217. declare module "babylonjs/sceneComponent" {
  11218. import { Scene } from "babylonjs/scene";
  11219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11220. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11221. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11222. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11223. import { Nullable } from "babylonjs/types";
  11224. import { Camera } from "babylonjs/Cameras/camera";
  11225. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11226. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11227. import { AbstractScene } from "babylonjs/abstractScene";
  11228. /**
  11229. * Groups all the scene component constants in one place to ease maintenance.
  11230. * @hidden
  11231. */
  11232. export class SceneComponentConstants {
  11233. static readonly NAME_EFFECTLAYER: string;
  11234. static readonly NAME_LAYER: string;
  11235. static readonly NAME_LENSFLARESYSTEM: string;
  11236. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11237. static readonly NAME_PARTICLESYSTEM: string;
  11238. static readonly NAME_GAMEPAD: string;
  11239. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11240. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11241. static readonly NAME_DEPTHRENDERER: string;
  11242. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11243. static readonly NAME_SPRITE: string;
  11244. static readonly NAME_OUTLINERENDERER: string;
  11245. static readonly NAME_PROCEDURALTEXTURE: string;
  11246. static readonly NAME_SHADOWGENERATOR: string;
  11247. static readonly NAME_OCTREE: string;
  11248. static readonly NAME_PHYSICSENGINE: string;
  11249. static readonly NAME_AUDIO: string;
  11250. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11251. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11252. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11253. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11254. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11255. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11256. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11257. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11258. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11259. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11260. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11261. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11262. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11263. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11264. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11265. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11266. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11267. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11268. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11269. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11270. static readonly STEP_AFTERRENDER_AUDIO: number;
  11271. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11272. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11273. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11274. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11275. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11276. static readonly STEP_POINTERMOVE_SPRITE: number;
  11277. static readonly STEP_POINTERDOWN_SPRITE: number;
  11278. static readonly STEP_POINTERUP_SPRITE: number;
  11279. }
  11280. /**
  11281. * This represents a scene component.
  11282. *
  11283. * This is used to decouple the dependency the scene is having on the different workloads like
  11284. * layers, post processes...
  11285. */
  11286. export interface ISceneComponent {
  11287. /**
  11288. * The name of the component. Each component must have a unique name.
  11289. */
  11290. name: string;
  11291. /**
  11292. * The scene the component belongs to.
  11293. */
  11294. scene: Scene;
  11295. /**
  11296. * Register the component to one instance of a scene.
  11297. */
  11298. register(): void;
  11299. /**
  11300. * Rebuilds the elements related to this component in case of
  11301. * context lost for instance.
  11302. */
  11303. rebuild(): void;
  11304. /**
  11305. * Disposes the component and the associated ressources.
  11306. */
  11307. dispose(): void;
  11308. }
  11309. /**
  11310. * This represents a SERIALIZABLE scene component.
  11311. *
  11312. * This extends Scene Component to add Serialization methods on top.
  11313. */
  11314. export interface ISceneSerializableComponent extends ISceneComponent {
  11315. /**
  11316. * Adds all the elements from the container to the scene
  11317. * @param container the container holding the elements
  11318. */
  11319. addFromContainer(container: AbstractScene): void;
  11320. /**
  11321. * Removes all the elements in the container from the scene
  11322. * @param container contains the elements to remove
  11323. * @param dispose if the removed element should be disposed (default: false)
  11324. */
  11325. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11326. /**
  11327. * Serializes the component data to the specified json object
  11328. * @param serializationObject The object to serialize to
  11329. */
  11330. serialize(serializationObject: any): void;
  11331. }
  11332. /**
  11333. * Strong typing of a Mesh related stage step action
  11334. */
  11335. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11336. /**
  11337. * Strong typing of a Evaluate Sub Mesh related stage step action
  11338. */
  11339. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11340. /**
  11341. * Strong typing of a Active Mesh related stage step action
  11342. */
  11343. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11344. /**
  11345. * Strong typing of a Camera related stage step action
  11346. */
  11347. export type CameraStageAction = (camera: Camera) => void;
  11348. /**
  11349. * Strong typing of a Camera Frame buffer related stage step action
  11350. */
  11351. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11352. /**
  11353. * Strong typing of a Render Target related stage step action
  11354. */
  11355. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11356. /**
  11357. * Strong typing of a RenderingGroup related stage step action
  11358. */
  11359. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11360. /**
  11361. * Strong typing of a Mesh Render related stage step action
  11362. */
  11363. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11364. /**
  11365. * Strong typing of a simple stage step action
  11366. */
  11367. export type SimpleStageAction = () => void;
  11368. /**
  11369. * Strong typing of a render target action.
  11370. */
  11371. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11372. /**
  11373. * Strong typing of a pointer move action.
  11374. */
  11375. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11376. /**
  11377. * Strong typing of a pointer up/down action.
  11378. */
  11379. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11380. /**
  11381. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11382. * @hidden
  11383. */
  11384. export class Stage<T extends Function> extends Array<{
  11385. index: number;
  11386. component: ISceneComponent;
  11387. action: T;
  11388. }> {
  11389. /**
  11390. * Hide ctor from the rest of the world.
  11391. * @param items The items to add.
  11392. */
  11393. private constructor();
  11394. /**
  11395. * Creates a new Stage.
  11396. * @returns A new instance of a Stage
  11397. */
  11398. static Create<T extends Function>(): Stage<T>;
  11399. /**
  11400. * Registers a step in an ordered way in the targeted stage.
  11401. * @param index Defines the position to register the step in
  11402. * @param component Defines the component attached to the step
  11403. * @param action Defines the action to launch during the step
  11404. */
  11405. registerStep(index: number, component: ISceneComponent, action: T): void;
  11406. /**
  11407. * Clears all the steps from the stage.
  11408. */
  11409. clear(): void;
  11410. }
  11411. }
  11412. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11413. import { Nullable } from "babylonjs/types";
  11414. import { Observable } from "babylonjs/Misc/observable";
  11415. import { Scene } from "babylonjs/scene";
  11416. import { Sprite } from "babylonjs/Sprites/sprite";
  11417. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11418. import { Ray } from "babylonjs/Culling/ray";
  11419. import { Camera } from "babylonjs/Cameras/camera";
  11420. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11421. import { ISceneComponent } from "babylonjs/sceneComponent";
  11422. module "babylonjs/scene" {
  11423. interface Scene {
  11424. /** @hidden */
  11425. _pointerOverSprite: Nullable<Sprite>;
  11426. /** @hidden */
  11427. _pickedDownSprite: Nullable<Sprite>;
  11428. /** @hidden */
  11429. _tempSpritePickingRay: Nullable<Ray>;
  11430. /**
  11431. * All of the sprite managers added to this scene
  11432. * @see http://doc.babylonjs.com/babylon101/sprites
  11433. */
  11434. spriteManagers: Array<ISpriteManager>;
  11435. /**
  11436. * An event triggered when sprites rendering is about to start
  11437. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11438. */
  11439. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11440. /**
  11441. * An event triggered when sprites rendering is done
  11442. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11443. */
  11444. onAfterSpritesRenderingObservable: Observable<Scene>;
  11445. /** @hidden */
  11446. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11447. /** Launch a ray to try to pick a sprite in the scene
  11448. * @param x position on screen
  11449. * @param y position on screen
  11450. * @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
  11451. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11452. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11453. * @returns a PickingInfo
  11454. */
  11455. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11456. /** Use the given ray to pick a sprite in the scene
  11457. * @param ray The ray (in world space) to use to pick meshes
  11458. * @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
  11459. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11460. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11461. * @returns a PickingInfo
  11462. */
  11463. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11464. /** @hidden */
  11465. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11466. /** Launch a ray to try to pick sprites in the scene
  11467. * @param x position on screen
  11468. * @param y position on screen
  11469. * @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
  11470. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11471. * @returns a PickingInfo array
  11472. */
  11473. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11474. /** Use the given ray to pick sprites in the scene
  11475. * @param ray The ray (in world space) to use to pick meshes
  11476. * @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
  11477. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11478. * @returns a PickingInfo array
  11479. */
  11480. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11481. /**
  11482. * Force the sprite under the pointer
  11483. * @param sprite defines the sprite to use
  11484. */
  11485. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11486. /**
  11487. * Gets the sprite under the pointer
  11488. * @returns a Sprite or null if no sprite is under the pointer
  11489. */
  11490. getPointerOverSprite(): Nullable<Sprite>;
  11491. }
  11492. }
  11493. /**
  11494. * Defines the sprite scene component responsible to manage sprites
  11495. * in a given scene.
  11496. */
  11497. export class SpriteSceneComponent implements ISceneComponent {
  11498. /**
  11499. * The component name helpfull to identify the component in the list of scene components.
  11500. */
  11501. readonly name: string;
  11502. /**
  11503. * The scene the component belongs to.
  11504. */
  11505. scene: Scene;
  11506. /** @hidden */
  11507. private _spritePredicate;
  11508. /**
  11509. * Creates a new instance of the component for the given scene
  11510. * @param scene Defines the scene to register the component in
  11511. */
  11512. constructor(scene: Scene);
  11513. /**
  11514. * Registers the component in a given scene
  11515. */
  11516. register(): void;
  11517. /**
  11518. * Rebuilds the elements related to this component in case of
  11519. * context lost for instance.
  11520. */
  11521. rebuild(): void;
  11522. /**
  11523. * Disposes the component and the associated ressources.
  11524. */
  11525. dispose(): void;
  11526. private _pickSpriteButKeepRay;
  11527. private _pointerMove;
  11528. private _pointerDown;
  11529. private _pointerUp;
  11530. }
  11531. }
  11532. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11533. /** @hidden */
  11534. export var fogFragmentDeclaration: {
  11535. name: string;
  11536. shader: string;
  11537. };
  11538. }
  11539. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11540. /** @hidden */
  11541. export var fogFragment: {
  11542. name: string;
  11543. shader: string;
  11544. };
  11545. }
  11546. declare module "babylonjs/Shaders/sprites.fragment" {
  11547. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11548. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11549. /** @hidden */
  11550. export var spritesPixelShader: {
  11551. name: string;
  11552. shader: string;
  11553. };
  11554. }
  11555. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11556. /** @hidden */
  11557. export var fogVertexDeclaration: {
  11558. name: string;
  11559. shader: string;
  11560. };
  11561. }
  11562. declare module "babylonjs/Shaders/sprites.vertex" {
  11563. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11564. /** @hidden */
  11565. export var spritesVertexShader: {
  11566. name: string;
  11567. shader: string;
  11568. };
  11569. }
  11570. declare module "babylonjs/Sprites/spriteManager" {
  11571. import { IDisposable, Scene } from "babylonjs/scene";
  11572. import { Nullable } from "babylonjs/types";
  11573. import { Observable } from "babylonjs/Misc/observable";
  11574. import { Sprite } from "babylonjs/Sprites/sprite";
  11575. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11576. import { Camera } from "babylonjs/Cameras/camera";
  11577. import { Texture } from "babylonjs/Materials/Textures/texture";
  11578. import "babylonjs/Shaders/sprites.fragment";
  11579. import "babylonjs/Shaders/sprites.vertex";
  11580. import { Ray } from "babylonjs/Culling/ray";
  11581. /**
  11582. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11583. */
  11584. export interface ISpriteManager extends IDisposable {
  11585. /**
  11586. * Restricts the camera to viewing objects with the same layerMask.
  11587. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11588. */
  11589. layerMask: number;
  11590. /**
  11591. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11592. */
  11593. isPickable: boolean;
  11594. /**
  11595. * Specifies the rendering group id for this mesh (0 by default)
  11596. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11597. */
  11598. renderingGroupId: number;
  11599. /**
  11600. * Defines the list of sprites managed by the manager.
  11601. */
  11602. sprites: Array<Sprite>;
  11603. /**
  11604. * Tests the intersection of a sprite with a specific ray.
  11605. * @param ray The ray we are sending to test the collision
  11606. * @param camera The camera space we are sending rays in
  11607. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11608. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11609. * @returns picking info or null.
  11610. */
  11611. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11612. /**
  11613. * Intersects the sprites with a ray
  11614. * @param ray defines the ray to intersect with
  11615. * @param camera defines the current active camera
  11616. * @param predicate defines a predicate used to select candidate sprites
  11617. * @returns null if no hit or a PickingInfo array
  11618. */
  11619. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11620. /**
  11621. * Renders the list of sprites on screen.
  11622. */
  11623. render(): void;
  11624. }
  11625. /**
  11626. * Class used to manage multiple sprites on the same spritesheet
  11627. * @see http://doc.babylonjs.com/babylon101/sprites
  11628. */
  11629. export class SpriteManager implements ISpriteManager {
  11630. /** defines the manager's name */
  11631. name: string;
  11632. /** Gets the list of sprites */
  11633. sprites: Sprite[];
  11634. /** Gets or sets the rendering group id (0 by default) */
  11635. renderingGroupId: number;
  11636. /** Gets or sets camera layer mask */
  11637. layerMask: number;
  11638. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11639. fogEnabled: boolean;
  11640. /** Gets or sets a boolean indicating if the sprites are pickable */
  11641. isPickable: boolean;
  11642. /** Defines the default width of a cell in the spritesheet */
  11643. cellWidth: number;
  11644. /** Defines the default height of a cell in the spritesheet */
  11645. cellHeight: number;
  11646. /** Associative array from JSON sprite data file */
  11647. private _cellData;
  11648. /** Array of sprite names from JSON sprite data file */
  11649. private _spriteMap;
  11650. /** True when packed cell data from JSON file is ready*/
  11651. private _packedAndReady;
  11652. /**
  11653. * An event triggered when the manager is disposed.
  11654. */
  11655. onDisposeObservable: Observable<SpriteManager>;
  11656. private _onDisposeObserver;
  11657. /**
  11658. * Callback called when the manager is disposed
  11659. */
  11660. onDispose: () => void;
  11661. private _capacity;
  11662. private _fromPacked;
  11663. private _spriteTexture;
  11664. private _epsilon;
  11665. private _scene;
  11666. private _vertexData;
  11667. private _buffer;
  11668. private _vertexBuffers;
  11669. private _indexBuffer;
  11670. private _effectBase;
  11671. private _effectFog;
  11672. /**
  11673. * Gets or sets the spritesheet texture
  11674. */
  11675. texture: Texture;
  11676. /**
  11677. * Creates a new sprite manager
  11678. * @param name defines the manager's name
  11679. * @param imgUrl defines the sprite sheet url
  11680. * @param capacity defines the maximum allowed number of sprites
  11681. * @param cellSize defines the size of a sprite cell
  11682. * @param scene defines the hosting scene
  11683. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11684. * @param samplingMode defines the smapling mode to use with spritesheet
  11685. * @param fromPacked set to false; do not alter
  11686. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11687. */
  11688. constructor(
  11689. /** defines the manager's name */
  11690. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11691. private _makePacked;
  11692. private _appendSpriteVertex;
  11693. /**
  11694. * Intersects the sprites with a ray
  11695. * @param ray defines the ray to intersect with
  11696. * @param camera defines the current active camera
  11697. * @param predicate defines a predicate used to select candidate sprites
  11698. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11699. * @returns null if no hit or a PickingInfo
  11700. */
  11701. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11702. /**
  11703. * Intersects the sprites with a ray
  11704. * @param ray defines the ray to intersect with
  11705. * @param camera defines the current active camera
  11706. * @param predicate defines a predicate used to select candidate sprites
  11707. * @returns null if no hit or a PickingInfo array
  11708. */
  11709. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11710. /**
  11711. * Render all child sprites
  11712. */
  11713. render(): void;
  11714. /**
  11715. * Release associated resources
  11716. */
  11717. dispose(): void;
  11718. }
  11719. }
  11720. declare module "babylonjs/Sprites/sprite" {
  11721. import { Vector3 } from "babylonjs/Maths/math.vector";
  11722. import { Nullable } from "babylonjs/types";
  11723. import { ActionManager } from "babylonjs/Actions/actionManager";
  11724. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11725. import { Color4 } from "babylonjs/Maths/math.color";
  11726. /**
  11727. * Class used to represent a sprite
  11728. * @see http://doc.babylonjs.com/babylon101/sprites
  11729. */
  11730. export class Sprite {
  11731. /** defines the name */
  11732. name: string;
  11733. /** Gets or sets the current world position */
  11734. position: Vector3;
  11735. /** Gets or sets the main color */
  11736. color: Color4;
  11737. /** Gets or sets the width */
  11738. width: number;
  11739. /** Gets or sets the height */
  11740. height: number;
  11741. /** Gets or sets rotation angle */
  11742. angle: number;
  11743. /** Gets or sets the cell index in the sprite sheet */
  11744. cellIndex: number;
  11745. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11746. cellRef: string;
  11747. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11748. invertU: number;
  11749. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11750. invertV: number;
  11751. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11752. disposeWhenFinishedAnimating: boolean;
  11753. /** Gets the list of attached animations */
  11754. animations: Animation[];
  11755. /** Gets or sets a boolean indicating if the sprite can be picked */
  11756. isPickable: boolean;
  11757. /**
  11758. * Gets or sets the associated action manager
  11759. */
  11760. actionManager: Nullable<ActionManager>;
  11761. private _animationStarted;
  11762. private _loopAnimation;
  11763. private _fromIndex;
  11764. private _toIndex;
  11765. private _delay;
  11766. private _direction;
  11767. private _manager;
  11768. private _time;
  11769. private _onAnimationEnd;
  11770. /**
  11771. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11772. */
  11773. isVisible: boolean;
  11774. /**
  11775. * Gets or sets the sprite size
  11776. */
  11777. size: number;
  11778. /**
  11779. * Creates a new Sprite
  11780. * @param name defines the name
  11781. * @param manager defines the manager
  11782. */
  11783. constructor(
  11784. /** defines the name */
  11785. name: string, manager: ISpriteManager);
  11786. /**
  11787. * Starts an animation
  11788. * @param from defines the initial key
  11789. * @param to defines the end key
  11790. * @param loop defines if the animation must loop
  11791. * @param delay defines the start delay (in ms)
  11792. * @param onAnimationEnd defines a callback to call when animation ends
  11793. */
  11794. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11795. /** Stops current animation (if any) */
  11796. stopAnimation(): void;
  11797. /** @hidden */
  11798. _animate(deltaTime: number): void;
  11799. /** Release associated resources */
  11800. dispose(): void;
  11801. }
  11802. }
  11803. declare module "babylonjs/Collisions/pickingInfo" {
  11804. import { Nullable } from "babylonjs/types";
  11805. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11807. import { Sprite } from "babylonjs/Sprites/sprite";
  11808. import { Ray } from "babylonjs/Culling/ray";
  11809. /**
  11810. * Information about the result of picking within a scene
  11811. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11812. */
  11813. export class PickingInfo {
  11814. /** @hidden */
  11815. _pickingUnavailable: boolean;
  11816. /**
  11817. * If the pick collided with an object
  11818. */
  11819. hit: boolean;
  11820. /**
  11821. * Distance away where the pick collided
  11822. */
  11823. distance: number;
  11824. /**
  11825. * The location of pick collision
  11826. */
  11827. pickedPoint: Nullable<Vector3>;
  11828. /**
  11829. * The mesh corresponding the the pick collision
  11830. */
  11831. pickedMesh: Nullable<AbstractMesh>;
  11832. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11833. bu: number;
  11834. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11835. bv: number;
  11836. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11837. faceId: number;
  11838. /** Id of the the submesh that was picked */
  11839. subMeshId: number;
  11840. /** If a sprite was picked, this will be the sprite the pick collided with */
  11841. pickedSprite: Nullable<Sprite>;
  11842. /**
  11843. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11844. */
  11845. originMesh: Nullable<AbstractMesh>;
  11846. /**
  11847. * The ray that was used to perform the picking.
  11848. */
  11849. ray: Nullable<Ray>;
  11850. /**
  11851. * Gets the normal correspodning to the face the pick collided with
  11852. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11853. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11854. * @returns The normal correspodning to the face the pick collided with
  11855. */
  11856. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11857. /**
  11858. * Gets the texture coordinates of where the pick occured
  11859. * @returns the vector containing the coordnates of the texture
  11860. */
  11861. getTextureCoordinates(): Nullable<Vector2>;
  11862. }
  11863. }
  11864. declare module "babylonjs/Events/pointerEvents" {
  11865. import { Nullable } from "babylonjs/types";
  11866. import { Vector2 } from "babylonjs/Maths/math.vector";
  11867. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11868. import { Ray } from "babylonjs/Culling/ray";
  11869. /**
  11870. * Gather the list of pointer event types as constants.
  11871. */
  11872. export class PointerEventTypes {
  11873. /**
  11874. * 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.
  11875. */
  11876. static readonly POINTERDOWN: number;
  11877. /**
  11878. * The pointerup event is fired when a pointer is no longer active.
  11879. */
  11880. static readonly POINTERUP: number;
  11881. /**
  11882. * The pointermove event is fired when a pointer changes coordinates.
  11883. */
  11884. static readonly POINTERMOVE: number;
  11885. /**
  11886. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11887. */
  11888. static readonly POINTERWHEEL: number;
  11889. /**
  11890. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11891. */
  11892. static readonly POINTERPICK: number;
  11893. /**
  11894. * The pointertap event is fired when a the object has been touched and released without drag.
  11895. */
  11896. static readonly POINTERTAP: number;
  11897. /**
  11898. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11899. */
  11900. static readonly POINTERDOUBLETAP: number;
  11901. }
  11902. /**
  11903. * Base class of pointer info types.
  11904. */
  11905. export class PointerInfoBase {
  11906. /**
  11907. * Defines the type of event (PointerEventTypes)
  11908. */
  11909. type: number;
  11910. /**
  11911. * Defines the related dom event
  11912. */
  11913. event: PointerEvent | MouseWheelEvent;
  11914. /**
  11915. * Instantiates the base class of pointers info.
  11916. * @param type Defines the type of event (PointerEventTypes)
  11917. * @param event Defines the related dom event
  11918. */
  11919. constructor(
  11920. /**
  11921. * Defines the type of event (PointerEventTypes)
  11922. */
  11923. type: number,
  11924. /**
  11925. * Defines the related dom event
  11926. */
  11927. event: PointerEvent | MouseWheelEvent);
  11928. }
  11929. /**
  11930. * This class is used to store pointer related info for the onPrePointerObservable event.
  11931. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11932. */
  11933. export class PointerInfoPre extends PointerInfoBase {
  11934. /**
  11935. * Ray from a pointer if availible (eg. 6dof controller)
  11936. */
  11937. ray: Nullable<Ray>;
  11938. /**
  11939. * Defines the local position of the pointer on the canvas.
  11940. */
  11941. localPosition: Vector2;
  11942. /**
  11943. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11944. */
  11945. skipOnPointerObservable: boolean;
  11946. /**
  11947. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11948. * @param type Defines the type of event (PointerEventTypes)
  11949. * @param event Defines the related dom event
  11950. * @param localX Defines the local x coordinates of the pointer when the event occured
  11951. * @param localY Defines the local y coordinates of the pointer when the event occured
  11952. */
  11953. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11954. }
  11955. /**
  11956. * This type contains all the data related to a pointer event in Babylon.js.
  11957. * 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.
  11958. */
  11959. export class PointerInfo extends PointerInfoBase {
  11960. /**
  11961. * Defines the picking info associated to the info (if any)\
  11962. */
  11963. pickInfo: Nullable<PickingInfo>;
  11964. /**
  11965. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11966. * @param type Defines the type of event (PointerEventTypes)
  11967. * @param event Defines the related dom event
  11968. * @param pickInfo Defines the picking info associated to the info (if any)\
  11969. */
  11970. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11971. /**
  11972. * Defines the picking info associated to the info (if any)\
  11973. */
  11974. pickInfo: Nullable<PickingInfo>);
  11975. }
  11976. /**
  11977. * Data relating to a touch event on the screen.
  11978. */
  11979. export interface PointerTouch {
  11980. /**
  11981. * X coordinate of touch.
  11982. */
  11983. x: number;
  11984. /**
  11985. * Y coordinate of touch.
  11986. */
  11987. y: number;
  11988. /**
  11989. * Id of touch. Unique for each finger.
  11990. */
  11991. pointerId: number;
  11992. /**
  11993. * Event type passed from DOM.
  11994. */
  11995. type: any;
  11996. }
  11997. }
  11998. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11999. import { Observable } from "babylonjs/Misc/observable";
  12000. import { Nullable } from "babylonjs/types";
  12001. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12002. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12003. /**
  12004. * Manage the mouse inputs to control the movement of a free camera.
  12005. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12006. */
  12007. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12008. /**
  12009. * Define if touch is enabled in the mouse input
  12010. */
  12011. touchEnabled: boolean;
  12012. /**
  12013. * Defines the camera the input is attached to.
  12014. */
  12015. camera: FreeCamera;
  12016. /**
  12017. * Defines the buttons associated with the input to handle camera move.
  12018. */
  12019. buttons: number[];
  12020. /**
  12021. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12022. */
  12023. angularSensibility: number;
  12024. private _pointerInput;
  12025. private _onMouseMove;
  12026. private _observer;
  12027. private previousPosition;
  12028. /**
  12029. * Observable for when a pointer move event occurs containing the move offset
  12030. */
  12031. onPointerMovedObservable: Observable<{
  12032. offsetX: number;
  12033. offsetY: number;
  12034. }>;
  12035. /**
  12036. * @hidden
  12037. * If the camera should be rotated automatically based on pointer movement
  12038. */
  12039. _allowCameraRotation: boolean;
  12040. /**
  12041. * Manage the mouse inputs to control the movement of a free camera.
  12042. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12043. * @param touchEnabled Defines if touch is enabled or not
  12044. */
  12045. constructor(
  12046. /**
  12047. * Define if touch is enabled in the mouse input
  12048. */
  12049. touchEnabled?: boolean);
  12050. /**
  12051. * Attach the input controls to a specific dom element to get the input from.
  12052. * @param element Defines the element the controls should be listened from
  12053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12054. */
  12055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12056. /**
  12057. * Called on JS contextmenu event.
  12058. * Override this method to provide functionality.
  12059. */
  12060. protected onContextMenu(evt: PointerEvent): void;
  12061. /**
  12062. * Detach the current controls from the specified dom element.
  12063. * @param element Defines the element to stop listening the inputs from
  12064. */
  12065. detachControl(element: Nullable<HTMLElement>): void;
  12066. /**
  12067. * Gets the class name of the current intput.
  12068. * @returns the class name
  12069. */
  12070. getClassName(): string;
  12071. /**
  12072. * Get the friendly name associated with the input class.
  12073. * @returns the input friendly name
  12074. */
  12075. getSimpleName(): string;
  12076. }
  12077. }
  12078. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12079. import { Nullable } from "babylonjs/types";
  12080. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12081. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12082. /**
  12083. * Manage the touch inputs to control the movement of a free camera.
  12084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12085. */
  12086. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12087. /**
  12088. * Defines the camera the input is attached to.
  12089. */
  12090. camera: FreeCamera;
  12091. /**
  12092. * Defines the touch sensibility for rotation.
  12093. * The higher the faster.
  12094. */
  12095. touchAngularSensibility: number;
  12096. /**
  12097. * Defines the touch sensibility for move.
  12098. * The higher the faster.
  12099. */
  12100. touchMoveSensibility: number;
  12101. private _offsetX;
  12102. private _offsetY;
  12103. private _pointerPressed;
  12104. private _pointerInput;
  12105. private _observer;
  12106. private _onLostFocus;
  12107. /**
  12108. * Attach the input controls to a specific dom element to get the input from.
  12109. * @param element Defines the element the controls should be listened from
  12110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12111. */
  12112. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12113. /**
  12114. * Detach the current controls from the specified dom element.
  12115. * @param element Defines the element to stop listening the inputs from
  12116. */
  12117. detachControl(element: Nullable<HTMLElement>): void;
  12118. /**
  12119. * Update the current camera state depending on the inputs that have been used this frame.
  12120. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12121. */
  12122. checkInputs(): void;
  12123. /**
  12124. * Gets the class name of the current intput.
  12125. * @returns the class name
  12126. */
  12127. getClassName(): string;
  12128. /**
  12129. * Get the friendly name associated with the input class.
  12130. * @returns the input friendly name
  12131. */
  12132. getSimpleName(): string;
  12133. }
  12134. }
  12135. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12136. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12137. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12138. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12139. import { Nullable } from "babylonjs/types";
  12140. /**
  12141. * Default Inputs manager for the FreeCamera.
  12142. * It groups all the default supported inputs for ease of use.
  12143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12144. */
  12145. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12146. /**
  12147. * @hidden
  12148. */
  12149. _mouseInput: Nullable<FreeCameraMouseInput>;
  12150. /**
  12151. * Instantiates a new FreeCameraInputsManager.
  12152. * @param camera Defines the camera the inputs belong to
  12153. */
  12154. constructor(camera: FreeCamera);
  12155. /**
  12156. * Add keyboard input support to the input manager.
  12157. * @returns the current input manager
  12158. */
  12159. addKeyboard(): FreeCameraInputsManager;
  12160. /**
  12161. * Add mouse input support to the input manager.
  12162. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12163. * @returns the current input manager
  12164. */
  12165. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12166. /**
  12167. * Removes the mouse input support from the manager
  12168. * @returns the current input manager
  12169. */
  12170. removeMouse(): FreeCameraInputsManager;
  12171. /**
  12172. * Add touch input support to the input manager.
  12173. * @returns the current input manager
  12174. */
  12175. addTouch(): FreeCameraInputsManager;
  12176. /**
  12177. * Remove all attached input methods from a camera
  12178. */
  12179. clear(): void;
  12180. }
  12181. }
  12182. declare module "babylonjs/Cameras/freeCamera" {
  12183. import { Vector3 } from "babylonjs/Maths/math.vector";
  12184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12185. import { Scene } from "babylonjs/scene";
  12186. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12187. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12188. /**
  12189. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12190. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12191. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12192. */
  12193. export class FreeCamera extends TargetCamera {
  12194. /**
  12195. * Define the collision ellipsoid of the camera.
  12196. * This is helpful to simulate a camera body like the player body around the camera
  12197. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12198. */
  12199. ellipsoid: Vector3;
  12200. /**
  12201. * Define an offset for the position of the ellipsoid around the camera.
  12202. * This can be helpful to determine the center of the body near the gravity center of the body
  12203. * instead of its head.
  12204. */
  12205. ellipsoidOffset: Vector3;
  12206. /**
  12207. * Enable or disable collisions of the camera with the rest of the scene objects.
  12208. */
  12209. checkCollisions: boolean;
  12210. /**
  12211. * Enable or disable gravity on the camera.
  12212. */
  12213. applyGravity: boolean;
  12214. /**
  12215. * Define the input manager associated to the camera.
  12216. */
  12217. inputs: FreeCameraInputsManager;
  12218. /**
  12219. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12220. * Higher values reduce sensitivity.
  12221. */
  12222. /**
  12223. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12224. * Higher values reduce sensitivity.
  12225. */
  12226. angularSensibility: number;
  12227. /**
  12228. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12229. */
  12230. keysUp: number[];
  12231. /**
  12232. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12233. */
  12234. keysDown: number[];
  12235. /**
  12236. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12237. */
  12238. keysLeft: number[];
  12239. /**
  12240. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12241. */
  12242. keysRight: number[];
  12243. /**
  12244. * Event raised when the camera collide with a mesh in the scene.
  12245. */
  12246. onCollide: (collidedMesh: AbstractMesh) => void;
  12247. private _collider;
  12248. private _needMoveForGravity;
  12249. private _oldPosition;
  12250. private _diffPosition;
  12251. private _newPosition;
  12252. /** @hidden */
  12253. _localDirection: Vector3;
  12254. /** @hidden */
  12255. _transformedDirection: Vector3;
  12256. /**
  12257. * Instantiates a Free Camera.
  12258. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12259. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12260. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12261. * @param name Define the name of the camera in the scene
  12262. * @param position Define the start position of the camera in the scene
  12263. * @param scene Define the scene the camera belongs to
  12264. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12265. */
  12266. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12267. /**
  12268. * Attached controls to the current camera.
  12269. * @param element Defines the element the controls should be listened from
  12270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12271. */
  12272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12273. /**
  12274. * Detach the current controls from the camera.
  12275. * The camera will stop reacting to inputs.
  12276. * @param element Defines the element to stop listening the inputs from
  12277. */
  12278. detachControl(element: HTMLElement): void;
  12279. private _collisionMask;
  12280. /**
  12281. * Define a collision mask to limit the list of object the camera can collide with
  12282. */
  12283. collisionMask: number;
  12284. /** @hidden */
  12285. _collideWithWorld(displacement: Vector3): void;
  12286. private _onCollisionPositionChange;
  12287. /** @hidden */
  12288. _checkInputs(): void;
  12289. /** @hidden */
  12290. _decideIfNeedsToMove(): boolean;
  12291. /** @hidden */
  12292. _updatePosition(): void;
  12293. /**
  12294. * Destroy the camera and release the current resources hold by it.
  12295. */
  12296. dispose(): void;
  12297. /**
  12298. * Gets the current object class name.
  12299. * @return the class name
  12300. */
  12301. getClassName(): string;
  12302. }
  12303. }
  12304. declare module "babylonjs/Gamepads/gamepad" {
  12305. import { Observable } from "babylonjs/Misc/observable";
  12306. /**
  12307. * Represents a gamepad control stick position
  12308. */
  12309. export class StickValues {
  12310. /**
  12311. * The x component of the control stick
  12312. */
  12313. x: number;
  12314. /**
  12315. * The y component of the control stick
  12316. */
  12317. y: number;
  12318. /**
  12319. * Initializes the gamepad x and y control stick values
  12320. * @param x The x component of the gamepad control stick value
  12321. * @param y The y component of the gamepad control stick value
  12322. */
  12323. constructor(
  12324. /**
  12325. * The x component of the control stick
  12326. */
  12327. x: number,
  12328. /**
  12329. * The y component of the control stick
  12330. */
  12331. y: number);
  12332. }
  12333. /**
  12334. * An interface which manages callbacks for gamepad button changes
  12335. */
  12336. export interface GamepadButtonChanges {
  12337. /**
  12338. * Called when a gamepad has been changed
  12339. */
  12340. changed: boolean;
  12341. /**
  12342. * Called when a gamepad press event has been triggered
  12343. */
  12344. pressChanged: boolean;
  12345. /**
  12346. * Called when a touch event has been triggered
  12347. */
  12348. touchChanged: boolean;
  12349. /**
  12350. * Called when a value has changed
  12351. */
  12352. valueChanged: boolean;
  12353. }
  12354. /**
  12355. * Represents a gamepad
  12356. */
  12357. export class Gamepad {
  12358. /**
  12359. * The id of the gamepad
  12360. */
  12361. id: string;
  12362. /**
  12363. * The index of the gamepad
  12364. */
  12365. index: number;
  12366. /**
  12367. * The browser gamepad
  12368. */
  12369. browserGamepad: any;
  12370. /**
  12371. * Specifies what type of gamepad this represents
  12372. */
  12373. type: number;
  12374. private _leftStick;
  12375. private _rightStick;
  12376. /** @hidden */
  12377. _isConnected: boolean;
  12378. private _leftStickAxisX;
  12379. private _leftStickAxisY;
  12380. private _rightStickAxisX;
  12381. private _rightStickAxisY;
  12382. /**
  12383. * Triggered when the left control stick has been changed
  12384. */
  12385. private _onleftstickchanged;
  12386. /**
  12387. * Triggered when the right control stick has been changed
  12388. */
  12389. private _onrightstickchanged;
  12390. /**
  12391. * Represents a gamepad controller
  12392. */
  12393. static GAMEPAD: number;
  12394. /**
  12395. * Represents a generic controller
  12396. */
  12397. static GENERIC: number;
  12398. /**
  12399. * Represents an XBox controller
  12400. */
  12401. static XBOX: number;
  12402. /**
  12403. * Represents a pose-enabled controller
  12404. */
  12405. static POSE_ENABLED: number;
  12406. /**
  12407. * Represents an Dual Shock controller
  12408. */
  12409. static DUALSHOCK: number;
  12410. /**
  12411. * Specifies whether the left control stick should be Y-inverted
  12412. */
  12413. protected _invertLeftStickY: boolean;
  12414. /**
  12415. * Specifies if the gamepad has been connected
  12416. */
  12417. readonly isConnected: boolean;
  12418. /**
  12419. * Initializes the gamepad
  12420. * @param id The id of the gamepad
  12421. * @param index The index of the gamepad
  12422. * @param browserGamepad The browser gamepad
  12423. * @param leftStickX The x component of the left joystick
  12424. * @param leftStickY The y component of the left joystick
  12425. * @param rightStickX The x component of the right joystick
  12426. * @param rightStickY The y component of the right joystick
  12427. */
  12428. constructor(
  12429. /**
  12430. * The id of the gamepad
  12431. */
  12432. id: string,
  12433. /**
  12434. * The index of the gamepad
  12435. */
  12436. index: number,
  12437. /**
  12438. * The browser gamepad
  12439. */
  12440. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12441. /**
  12442. * Callback triggered when the left joystick has changed
  12443. * @param callback
  12444. */
  12445. onleftstickchanged(callback: (values: StickValues) => void): void;
  12446. /**
  12447. * Callback triggered when the right joystick has changed
  12448. * @param callback
  12449. */
  12450. onrightstickchanged(callback: (values: StickValues) => void): void;
  12451. /**
  12452. * Gets the left joystick
  12453. */
  12454. /**
  12455. * Sets the left joystick values
  12456. */
  12457. leftStick: StickValues;
  12458. /**
  12459. * Gets the right joystick
  12460. */
  12461. /**
  12462. * Sets the right joystick value
  12463. */
  12464. rightStick: StickValues;
  12465. /**
  12466. * Updates the gamepad joystick positions
  12467. */
  12468. update(): void;
  12469. /**
  12470. * Disposes the gamepad
  12471. */
  12472. dispose(): void;
  12473. }
  12474. /**
  12475. * Represents a generic gamepad
  12476. */
  12477. export class GenericPad extends Gamepad {
  12478. private _buttons;
  12479. private _onbuttondown;
  12480. private _onbuttonup;
  12481. /**
  12482. * Observable triggered when a button has been pressed
  12483. */
  12484. onButtonDownObservable: Observable<number>;
  12485. /**
  12486. * Observable triggered when a button has been released
  12487. */
  12488. onButtonUpObservable: Observable<number>;
  12489. /**
  12490. * Callback triggered when a button has been pressed
  12491. * @param callback Called when a button has been pressed
  12492. */
  12493. onbuttondown(callback: (buttonPressed: number) => void): void;
  12494. /**
  12495. * Callback triggered when a button has been released
  12496. * @param callback Called when a button has been released
  12497. */
  12498. onbuttonup(callback: (buttonReleased: number) => void): void;
  12499. /**
  12500. * Initializes the generic gamepad
  12501. * @param id The id of the generic gamepad
  12502. * @param index The index of the generic gamepad
  12503. * @param browserGamepad The browser gamepad
  12504. */
  12505. constructor(id: string, index: number, browserGamepad: any);
  12506. private _setButtonValue;
  12507. /**
  12508. * Updates the generic gamepad
  12509. */
  12510. update(): void;
  12511. /**
  12512. * Disposes the generic gamepad
  12513. */
  12514. dispose(): void;
  12515. }
  12516. }
  12517. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12518. import { Nullable } from "babylonjs/types";
  12519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12520. import { Scene } from "babylonjs/scene";
  12521. module "babylonjs/Engines/engine" {
  12522. interface Engine {
  12523. /**
  12524. * Creates a raw texture
  12525. * @param data defines the data to store in the texture
  12526. * @param width defines the width of the texture
  12527. * @param height defines the height of the texture
  12528. * @param format defines the format of the data
  12529. * @param generateMipMaps defines if the engine should generate the mip levels
  12530. * @param invertY defines if data must be stored with Y axis inverted
  12531. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12532. * @param compression defines the compression used (null by default)
  12533. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12534. * @returns the raw texture inside an InternalTexture
  12535. */
  12536. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12537. /**
  12538. * Update a raw texture
  12539. * @param texture defines the texture to update
  12540. * @param data defines the data to store in the texture
  12541. * @param format defines the format of the data
  12542. * @param invertY defines if data must be stored with Y axis inverted
  12543. */
  12544. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12545. /**
  12546. * Update a raw texture
  12547. * @param texture defines the texture to update
  12548. * @param data defines the data to store in the texture
  12549. * @param format defines the format of the data
  12550. * @param invertY defines if data must be stored with Y axis inverted
  12551. * @param compression defines the compression used (null by default)
  12552. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12553. */
  12554. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12555. /**
  12556. * Creates a new raw cube texture
  12557. * @param data defines the array of data to use to create each face
  12558. * @param size defines the size of the textures
  12559. * @param format defines the format of the data
  12560. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12561. * @param generateMipMaps defines if the engine should generate the mip levels
  12562. * @param invertY defines if data must be stored with Y axis inverted
  12563. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12564. * @param compression defines the compression used (null by default)
  12565. * @returns the cube texture as an InternalTexture
  12566. */
  12567. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12568. /**
  12569. * Update a raw cube texture
  12570. * @param texture defines the texture to udpdate
  12571. * @param data defines the data to store
  12572. * @param format defines the data format
  12573. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12574. * @param invertY defines if data must be stored with Y axis inverted
  12575. */
  12576. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12577. /**
  12578. * Update a raw cube texture
  12579. * @param texture defines the texture to udpdate
  12580. * @param data defines the data to store
  12581. * @param format defines the data format
  12582. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12583. * @param invertY defines if data must be stored with Y axis inverted
  12584. * @param compression defines the compression used (null by default)
  12585. */
  12586. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12587. /**
  12588. * Update a raw cube texture
  12589. * @param texture defines the texture to udpdate
  12590. * @param data defines the data to store
  12591. * @param format defines the data format
  12592. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12593. * @param invertY defines if data must be stored with Y axis inverted
  12594. * @param compression defines the compression used (null by default)
  12595. * @param level defines which level of the texture to update
  12596. */
  12597. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12598. /**
  12599. * Creates a new raw cube texture from a specified url
  12600. * @param url defines the url where the data is located
  12601. * @param scene defines the current scene
  12602. * @param size defines the size of the textures
  12603. * @param format defines the format of the data
  12604. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12605. * @param noMipmap defines if the engine should avoid generating the mip levels
  12606. * @param callback defines a callback used to extract texture data from loaded data
  12607. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12608. * @param onLoad defines a callback called when texture is loaded
  12609. * @param onError defines a callback called if there is an error
  12610. * @returns the cube texture as an InternalTexture
  12611. */
  12612. 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;
  12613. /**
  12614. * Creates a new raw cube texture from a specified url
  12615. * @param url defines the url where the data is located
  12616. * @param scene defines the current scene
  12617. * @param size defines the size of the textures
  12618. * @param format defines the format of the data
  12619. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12620. * @param noMipmap defines if the engine should avoid generating the mip levels
  12621. * @param callback defines a callback used to extract texture data from loaded data
  12622. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12623. * @param onLoad defines a callback called when texture is loaded
  12624. * @param onError defines a callback called if there is an error
  12625. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12626. * @param invertY defines if data must be stored with Y axis inverted
  12627. * @returns the cube texture as an InternalTexture
  12628. */
  12629. 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;
  12630. /**
  12631. * Creates a new raw 3D texture
  12632. * @param data defines the data used to create the texture
  12633. * @param width defines the width of the texture
  12634. * @param height defines the height of the texture
  12635. * @param depth defines the depth of the texture
  12636. * @param format defines the format of the texture
  12637. * @param generateMipMaps defines if the engine must generate mip levels
  12638. * @param invertY defines if data must be stored with Y axis inverted
  12639. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12640. * @param compression defines the compressed used (can be null)
  12641. * @param textureType defines the compressed used (can be null)
  12642. * @returns a new raw 3D texture (stored in an InternalTexture)
  12643. */
  12644. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12645. /**
  12646. * Update a raw 3D texture
  12647. * @param texture defines the texture to update
  12648. * @param data defines the data to store
  12649. * @param format defines the data format
  12650. * @param invertY defines if data must be stored with Y axis inverted
  12651. */
  12652. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12653. /**
  12654. * Update a raw 3D texture
  12655. * @param texture defines the texture to update
  12656. * @param data defines the data to store
  12657. * @param format defines the data format
  12658. * @param invertY defines if data must be stored with Y axis inverted
  12659. * @param compression defines the used compression (can be null)
  12660. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12661. */
  12662. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12663. }
  12664. }
  12665. }
  12666. declare module "babylonjs/Materials/Textures/rawTexture" {
  12667. import { Scene } from "babylonjs/scene";
  12668. import { Texture } from "babylonjs/Materials/Textures/texture";
  12669. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12670. /**
  12671. * Raw texture can help creating a texture directly from an array of data.
  12672. * This can be super useful if you either get the data from an uncompressed source or
  12673. * if you wish to create your texture pixel by pixel.
  12674. */
  12675. export class RawTexture extends Texture {
  12676. /**
  12677. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12678. */
  12679. format: number;
  12680. private _engine;
  12681. /**
  12682. * Instantiates a new RawTexture.
  12683. * Raw texture can help creating a texture directly from an array of data.
  12684. * This can be super useful if you either get the data from an uncompressed source or
  12685. * if you wish to create your texture pixel by pixel.
  12686. * @param data define the array of data to use to create the texture
  12687. * @param width define the width of the texture
  12688. * @param height define the height of the texture
  12689. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12690. * @param scene define the scene the texture belongs to
  12691. * @param generateMipMaps define whether mip maps should be generated or not
  12692. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12693. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12694. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12695. */
  12696. constructor(data: ArrayBufferView, width: number, height: number,
  12697. /**
  12698. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12699. */
  12700. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12701. /**
  12702. * Updates the texture underlying data.
  12703. * @param data Define the new data of the texture
  12704. */
  12705. update(data: ArrayBufferView): void;
  12706. /**
  12707. * Creates a luminance texture from some data.
  12708. * @param data Define the texture data
  12709. * @param width Define the width of the texture
  12710. * @param height Define the height of the texture
  12711. * @param scene Define the scene the texture belongs to
  12712. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12713. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12714. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12715. * @returns the luminance texture
  12716. */
  12717. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12718. /**
  12719. * Creates a luminance alpha texture from some data.
  12720. * @param data Define the texture data
  12721. * @param width Define the width of the texture
  12722. * @param height Define the height of the texture
  12723. * @param scene Define the scene the texture belongs to
  12724. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12725. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12726. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12727. * @returns the luminance alpha texture
  12728. */
  12729. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12730. /**
  12731. * Creates an alpha texture from some data.
  12732. * @param data Define the texture data
  12733. * @param width Define the width of the texture
  12734. * @param height Define the height of the texture
  12735. * @param scene Define the scene the texture belongs to
  12736. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12737. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12738. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12739. * @returns the alpha texture
  12740. */
  12741. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12742. /**
  12743. * Creates a RGB texture from some data.
  12744. * @param data Define the texture data
  12745. * @param width Define the width of the texture
  12746. * @param height Define the height of the texture
  12747. * @param scene Define the scene the texture belongs to
  12748. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12749. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12750. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12751. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12752. * @returns the RGB alpha texture
  12753. */
  12754. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12755. /**
  12756. * Creates a RGBA texture from some data.
  12757. * @param data Define the texture data
  12758. * @param width Define the width of the texture
  12759. * @param height Define the height of the texture
  12760. * @param scene Define the scene the texture belongs to
  12761. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12762. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12763. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12764. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12765. * @returns the RGBA texture
  12766. */
  12767. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12768. /**
  12769. * Creates a R texture from some data.
  12770. * @param data Define the texture data
  12771. * @param width Define the width of the texture
  12772. * @param height Define the height of the texture
  12773. * @param scene Define the scene the texture belongs to
  12774. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12775. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12776. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12777. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12778. * @returns the R texture
  12779. */
  12780. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12781. }
  12782. }
  12783. declare module "babylonjs/Maths/math.size" {
  12784. /**
  12785. * Interface for the size containing width and height
  12786. */
  12787. export interface ISize {
  12788. /**
  12789. * Width
  12790. */
  12791. width: number;
  12792. /**
  12793. * Heighht
  12794. */
  12795. height: number;
  12796. }
  12797. /**
  12798. * Size containing widht and height
  12799. */
  12800. export class Size implements ISize {
  12801. /**
  12802. * Width
  12803. */
  12804. width: number;
  12805. /**
  12806. * Height
  12807. */
  12808. height: number;
  12809. /**
  12810. * Creates a Size object from the given width and height (floats).
  12811. * @param width width of the new size
  12812. * @param height height of the new size
  12813. */
  12814. constructor(width: number, height: number);
  12815. /**
  12816. * Returns a string with the Size width and height
  12817. * @returns a string with the Size width and height
  12818. */
  12819. toString(): string;
  12820. /**
  12821. * "Size"
  12822. * @returns the string "Size"
  12823. */
  12824. getClassName(): string;
  12825. /**
  12826. * Returns the Size hash code.
  12827. * @returns a hash code for a unique width and height
  12828. */
  12829. getHashCode(): number;
  12830. /**
  12831. * Updates the current size from the given one.
  12832. * @param src the given size
  12833. */
  12834. copyFrom(src: Size): void;
  12835. /**
  12836. * Updates in place the current Size from the given floats.
  12837. * @param width width of the new size
  12838. * @param height height of the new size
  12839. * @returns the updated Size.
  12840. */
  12841. copyFromFloats(width: number, height: number): Size;
  12842. /**
  12843. * Updates in place the current Size from the given floats.
  12844. * @param width width to set
  12845. * @param height height to set
  12846. * @returns the updated Size.
  12847. */
  12848. set(width: number, height: number): Size;
  12849. /**
  12850. * Multiplies the width and height by numbers
  12851. * @param w factor to multiple the width by
  12852. * @param h factor to multiple the height by
  12853. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12854. */
  12855. multiplyByFloats(w: number, h: number): Size;
  12856. /**
  12857. * Clones the size
  12858. * @returns a new Size copied from the given one.
  12859. */
  12860. clone(): Size;
  12861. /**
  12862. * True if the current Size and the given one width and height are strictly equal.
  12863. * @param other the other size to compare against
  12864. * @returns True if the current Size and the given one width and height are strictly equal.
  12865. */
  12866. equals(other: Size): boolean;
  12867. /**
  12868. * The surface of the Size : width * height (float).
  12869. */
  12870. readonly surface: number;
  12871. /**
  12872. * Create a new size of zero
  12873. * @returns a new Size set to (0.0, 0.0)
  12874. */
  12875. static Zero(): Size;
  12876. /**
  12877. * Sums the width and height of two sizes
  12878. * @param otherSize size to add to this size
  12879. * @returns a new Size set as the addition result of the current Size and the given one.
  12880. */
  12881. add(otherSize: Size): Size;
  12882. /**
  12883. * Subtracts the width and height of two
  12884. * @param otherSize size to subtract to this size
  12885. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12886. */
  12887. subtract(otherSize: Size): Size;
  12888. /**
  12889. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12890. * @param start starting size to lerp between
  12891. * @param end end size to lerp between
  12892. * @param amount amount to lerp between the start and end values
  12893. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12894. */
  12895. static Lerp(start: Size, end: Size, amount: number): Size;
  12896. }
  12897. }
  12898. declare module "babylonjs/Animations/runtimeAnimation" {
  12899. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12900. import { Animatable } from "babylonjs/Animations/animatable";
  12901. import { Scene } from "babylonjs/scene";
  12902. /**
  12903. * Defines a runtime animation
  12904. */
  12905. export class RuntimeAnimation {
  12906. private _events;
  12907. /**
  12908. * The current frame of the runtime animation
  12909. */
  12910. private _currentFrame;
  12911. /**
  12912. * The animation used by the runtime animation
  12913. */
  12914. private _animation;
  12915. /**
  12916. * The target of the runtime animation
  12917. */
  12918. private _target;
  12919. /**
  12920. * The initiating animatable
  12921. */
  12922. private _host;
  12923. /**
  12924. * The original value of the runtime animation
  12925. */
  12926. private _originalValue;
  12927. /**
  12928. * The original blend value of the runtime animation
  12929. */
  12930. private _originalBlendValue;
  12931. /**
  12932. * The offsets cache of the runtime animation
  12933. */
  12934. private _offsetsCache;
  12935. /**
  12936. * The high limits cache of the runtime animation
  12937. */
  12938. private _highLimitsCache;
  12939. /**
  12940. * Specifies if the runtime animation has been stopped
  12941. */
  12942. private _stopped;
  12943. /**
  12944. * The blending factor of the runtime animation
  12945. */
  12946. private _blendingFactor;
  12947. /**
  12948. * The BabylonJS scene
  12949. */
  12950. private _scene;
  12951. /**
  12952. * The current value of the runtime animation
  12953. */
  12954. private _currentValue;
  12955. /** @hidden */
  12956. _animationState: _IAnimationState;
  12957. /**
  12958. * The active target of the runtime animation
  12959. */
  12960. private _activeTargets;
  12961. private _currentActiveTarget;
  12962. private _directTarget;
  12963. /**
  12964. * The target path of the runtime animation
  12965. */
  12966. private _targetPath;
  12967. /**
  12968. * The weight of the runtime animation
  12969. */
  12970. private _weight;
  12971. /**
  12972. * The ratio offset of the runtime animation
  12973. */
  12974. private _ratioOffset;
  12975. /**
  12976. * The previous delay of the runtime animation
  12977. */
  12978. private _previousDelay;
  12979. /**
  12980. * The previous ratio of the runtime animation
  12981. */
  12982. private _previousRatio;
  12983. private _enableBlending;
  12984. private _keys;
  12985. private _minFrame;
  12986. private _maxFrame;
  12987. private _minValue;
  12988. private _maxValue;
  12989. private _targetIsArray;
  12990. /**
  12991. * Gets the current frame of the runtime animation
  12992. */
  12993. readonly currentFrame: number;
  12994. /**
  12995. * Gets the weight of the runtime animation
  12996. */
  12997. readonly weight: number;
  12998. /**
  12999. * Gets the current value of the runtime animation
  13000. */
  13001. readonly currentValue: any;
  13002. /**
  13003. * Gets the target path of the runtime animation
  13004. */
  13005. readonly targetPath: string;
  13006. /**
  13007. * Gets the actual target of the runtime animation
  13008. */
  13009. readonly target: any;
  13010. /** @hidden */
  13011. _onLoop: () => void;
  13012. /**
  13013. * Create a new RuntimeAnimation object
  13014. * @param target defines the target of the animation
  13015. * @param animation defines the source animation object
  13016. * @param scene defines the hosting scene
  13017. * @param host defines the initiating Animatable
  13018. */
  13019. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13020. private _preparePath;
  13021. /**
  13022. * Gets the animation from the runtime animation
  13023. */
  13024. readonly animation: Animation;
  13025. /**
  13026. * Resets the runtime animation to the beginning
  13027. * @param restoreOriginal defines whether to restore the target property to the original value
  13028. */
  13029. reset(restoreOriginal?: boolean): void;
  13030. /**
  13031. * Specifies if the runtime animation is stopped
  13032. * @returns Boolean specifying if the runtime animation is stopped
  13033. */
  13034. isStopped(): boolean;
  13035. /**
  13036. * Disposes of the runtime animation
  13037. */
  13038. dispose(): void;
  13039. /**
  13040. * Apply the interpolated value to the target
  13041. * @param currentValue defines the value computed by the animation
  13042. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13043. */
  13044. setValue(currentValue: any, weight: number): void;
  13045. private _getOriginalValues;
  13046. private _setValue;
  13047. /**
  13048. * Gets the loop pmode of the runtime animation
  13049. * @returns Loop Mode
  13050. */
  13051. private _getCorrectLoopMode;
  13052. /**
  13053. * Move the current animation to a given frame
  13054. * @param frame defines the frame to move to
  13055. */
  13056. goToFrame(frame: number): void;
  13057. /**
  13058. * @hidden Internal use only
  13059. */
  13060. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13061. /**
  13062. * Execute the current animation
  13063. * @param delay defines the delay to add to the current frame
  13064. * @param from defines the lower bound of the animation range
  13065. * @param to defines the upper bound of the animation range
  13066. * @param loop defines if the current animation must loop
  13067. * @param speedRatio defines the current speed ratio
  13068. * @param weight defines the weight of the animation (default is -1 so no weight)
  13069. * @param onLoop optional callback called when animation loops
  13070. * @returns a boolean indicating if the animation is running
  13071. */
  13072. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13073. }
  13074. }
  13075. declare module "babylonjs/Animations/animatable" {
  13076. import { Animation } from "babylonjs/Animations/animation";
  13077. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13078. import { Nullable } from "babylonjs/types";
  13079. import { Observable } from "babylonjs/Misc/observable";
  13080. import { Scene } from "babylonjs/scene";
  13081. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13082. import { Node } from "babylonjs/node";
  13083. /**
  13084. * Class used to store an actual running animation
  13085. */
  13086. export class Animatable {
  13087. /** defines the target object */
  13088. target: any;
  13089. /** defines the starting frame number (default is 0) */
  13090. fromFrame: number;
  13091. /** defines the ending frame number (default is 100) */
  13092. toFrame: number;
  13093. /** defines if the animation must loop (default is false) */
  13094. loopAnimation: boolean;
  13095. /** defines a callback to call when animation ends if it is not looping */
  13096. onAnimationEnd?: (() => void) | null | undefined;
  13097. /** defines a callback to call when animation loops */
  13098. onAnimationLoop?: (() => void) | null | undefined;
  13099. private _localDelayOffset;
  13100. private _pausedDelay;
  13101. private _runtimeAnimations;
  13102. private _paused;
  13103. private _scene;
  13104. private _speedRatio;
  13105. private _weight;
  13106. private _syncRoot;
  13107. /**
  13108. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13109. * This will only apply for non looping animation (default is true)
  13110. */
  13111. disposeOnEnd: boolean;
  13112. /**
  13113. * Gets a boolean indicating if the animation has started
  13114. */
  13115. animationStarted: boolean;
  13116. /**
  13117. * Observer raised when the animation ends
  13118. */
  13119. onAnimationEndObservable: Observable<Animatable>;
  13120. /**
  13121. * Observer raised when the animation loops
  13122. */
  13123. onAnimationLoopObservable: Observable<Animatable>;
  13124. /**
  13125. * Gets the root Animatable used to synchronize and normalize animations
  13126. */
  13127. readonly syncRoot: Nullable<Animatable>;
  13128. /**
  13129. * Gets the current frame of the first RuntimeAnimation
  13130. * Used to synchronize Animatables
  13131. */
  13132. readonly masterFrame: number;
  13133. /**
  13134. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13135. */
  13136. weight: number;
  13137. /**
  13138. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13139. */
  13140. speedRatio: number;
  13141. /**
  13142. * Creates a new Animatable
  13143. * @param scene defines the hosting scene
  13144. * @param target defines the target object
  13145. * @param fromFrame defines the starting frame number (default is 0)
  13146. * @param toFrame defines the ending frame number (default is 100)
  13147. * @param loopAnimation defines if the animation must loop (default is false)
  13148. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13149. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13150. * @param animations defines a group of animation to add to the new Animatable
  13151. * @param onAnimationLoop defines a callback to call when animation loops
  13152. */
  13153. constructor(scene: Scene,
  13154. /** defines the target object */
  13155. target: any,
  13156. /** defines the starting frame number (default is 0) */
  13157. fromFrame?: number,
  13158. /** defines the ending frame number (default is 100) */
  13159. toFrame?: number,
  13160. /** defines if the animation must loop (default is false) */
  13161. loopAnimation?: boolean, speedRatio?: number,
  13162. /** defines a callback to call when animation ends if it is not looping */
  13163. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13164. /** defines a callback to call when animation loops */
  13165. onAnimationLoop?: (() => void) | null | undefined);
  13166. /**
  13167. * Synchronize and normalize current Animatable with a source Animatable
  13168. * This is useful when using animation weights and when animations are not of the same length
  13169. * @param root defines the root Animatable to synchronize with
  13170. * @returns the current Animatable
  13171. */
  13172. syncWith(root: Animatable): Animatable;
  13173. /**
  13174. * Gets the list of runtime animations
  13175. * @returns an array of RuntimeAnimation
  13176. */
  13177. getAnimations(): RuntimeAnimation[];
  13178. /**
  13179. * Adds more animations to the current animatable
  13180. * @param target defines the target of the animations
  13181. * @param animations defines the new animations to add
  13182. */
  13183. appendAnimations(target: any, animations: Animation[]): void;
  13184. /**
  13185. * Gets the source animation for a specific property
  13186. * @param property defines the propertyu to look for
  13187. * @returns null or the source animation for the given property
  13188. */
  13189. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13190. /**
  13191. * Gets the runtime animation for a specific property
  13192. * @param property defines the propertyu to look for
  13193. * @returns null or the runtime animation for the given property
  13194. */
  13195. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13196. /**
  13197. * Resets the animatable to its original state
  13198. */
  13199. reset(): void;
  13200. /**
  13201. * Allows the animatable to blend with current running animations
  13202. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13203. * @param blendingSpeed defines the blending speed to use
  13204. */
  13205. enableBlending(blendingSpeed: number): void;
  13206. /**
  13207. * Disable animation blending
  13208. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13209. */
  13210. disableBlending(): void;
  13211. /**
  13212. * Jump directly to a given frame
  13213. * @param frame defines the frame to jump to
  13214. */
  13215. goToFrame(frame: number): void;
  13216. /**
  13217. * Pause the animation
  13218. */
  13219. pause(): void;
  13220. /**
  13221. * Restart the animation
  13222. */
  13223. restart(): void;
  13224. private _raiseOnAnimationEnd;
  13225. /**
  13226. * Stop and delete the current animation
  13227. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13228. * @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)
  13229. */
  13230. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13231. /**
  13232. * Wait asynchronously for the animation to end
  13233. * @returns a promise which will be fullfilled when the animation ends
  13234. */
  13235. waitAsync(): Promise<Animatable>;
  13236. /** @hidden */
  13237. _animate(delay: number): boolean;
  13238. }
  13239. module "babylonjs/scene" {
  13240. interface Scene {
  13241. /** @hidden */
  13242. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13243. /** @hidden */
  13244. _processLateAnimationBindingsForMatrices(holder: {
  13245. totalWeight: number;
  13246. animations: RuntimeAnimation[];
  13247. originalValue: Matrix;
  13248. }): any;
  13249. /** @hidden */
  13250. _processLateAnimationBindingsForQuaternions(holder: {
  13251. totalWeight: number;
  13252. animations: RuntimeAnimation[];
  13253. originalValue: Quaternion;
  13254. }, refQuaternion: Quaternion): Quaternion;
  13255. /** @hidden */
  13256. _processLateAnimationBindings(): void;
  13257. /**
  13258. * Will start the animation sequence of a given target
  13259. * @param target defines the target
  13260. * @param from defines from which frame should animation start
  13261. * @param to defines until which frame should animation run.
  13262. * @param weight defines the weight to apply to the animation (1.0 by default)
  13263. * @param loop defines if the animation loops
  13264. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13265. * @param onAnimationEnd defines the function to be executed when the animation ends
  13266. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13267. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13268. * @param onAnimationLoop defines the callback to call when an animation loops
  13269. * @returns the animatable object created for this animation
  13270. */
  13271. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13272. /**
  13273. * Will start the animation sequence of a given target
  13274. * @param target defines the target
  13275. * @param from defines from which frame should animation start
  13276. * @param to defines until which frame should animation run.
  13277. * @param loop defines if the animation loops
  13278. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13279. * @param onAnimationEnd defines the function to be executed when the animation ends
  13280. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13281. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13282. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13283. * @param onAnimationLoop defines the callback to call when an animation loops
  13284. * @returns the animatable object created for this animation
  13285. */
  13286. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13287. /**
  13288. * Will start the animation sequence of a given target and its hierarchy
  13289. * @param target defines the target
  13290. * @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.
  13291. * @param from defines from which frame should animation start
  13292. * @param to defines until which frame should animation run.
  13293. * @param loop defines if the animation loops
  13294. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13295. * @param onAnimationEnd defines the function to be executed when the animation ends
  13296. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13297. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13298. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13299. * @param onAnimationLoop defines the callback to call when an animation loops
  13300. * @returns the list of created animatables
  13301. */
  13302. 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[];
  13303. /**
  13304. * Begin a new animation on a given node
  13305. * @param target defines the target where the animation will take place
  13306. * @param animations defines the list of animations to start
  13307. * @param from defines the initial value
  13308. * @param to defines the final value
  13309. * @param loop defines if you want animation to loop (off by default)
  13310. * @param speedRatio defines the speed ratio to apply to all animations
  13311. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13312. * @param onAnimationLoop defines the callback to call when an animation loops
  13313. * @returns the list of created animatables
  13314. */
  13315. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13316. /**
  13317. * Begin a new animation on a given node and its hierarchy
  13318. * @param target defines the root node where the animation will take place
  13319. * @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.
  13320. * @param animations defines the list of animations to start
  13321. * @param from defines the initial value
  13322. * @param to defines the final value
  13323. * @param loop defines if you want animation to loop (off by default)
  13324. * @param speedRatio defines the speed ratio to apply to all animations
  13325. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13326. * @param onAnimationLoop defines the callback to call when an animation loops
  13327. * @returns the list of animatables created for all nodes
  13328. */
  13329. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13330. /**
  13331. * Gets the animatable associated with a specific target
  13332. * @param target defines the target of the animatable
  13333. * @returns the required animatable if found
  13334. */
  13335. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13336. /**
  13337. * Gets all animatables associated with a given target
  13338. * @param target defines the target to look animatables for
  13339. * @returns an array of Animatables
  13340. */
  13341. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13342. /**
  13343. * Stops and removes all animations that have been applied to the scene
  13344. */
  13345. stopAllAnimations(): void;
  13346. }
  13347. }
  13348. module "babylonjs/Bones/bone" {
  13349. interface Bone {
  13350. /**
  13351. * Copy an animation range from another bone
  13352. * @param source defines the source bone
  13353. * @param rangeName defines the range name to copy
  13354. * @param frameOffset defines the frame offset
  13355. * @param rescaleAsRequired defines if rescaling must be applied if required
  13356. * @param skelDimensionsRatio defines the scaling ratio
  13357. * @returns true if operation was successful
  13358. */
  13359. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13360. }
  13361. }
  13362. }
  13363. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13364. /**
  13365. * Class used to override all child animations of a given target
  13366. */
  13367. export class AnimationPropertiesOverride {
  13368. /**
  13369. * Gets or sets a value indicating if animation blending must be used
  13370. */
  13371. enableBlending: boolean;
  13372. /**
  13373. * Gets or sets the blending speed to use when enableBlending is true
  13374. */
  13375. blendingSpeed: number;
  13376. /**
  13377. * Gets or sets the default loop mode to use
  13378. */
  13379. loopMode: number;
  13380. }
  13381. }
  13382. declare module "babylonjs/Bones/skeleton" {
  13383. import { Bone } from "babylonjs/Bones/bone";
  13384. import { Observable } from "babylonjs/Misc/observable";
  13385. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13386. import { Scene } from "babylonjs/scene";
  13387. import { Nullable } from "babylonjs/types";
  13388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13389. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13390. import { Animatable } from "babylonjs/Animations/animatable";
  13391. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13392. import { Animation } from "babylonjs/Animations/animation";
  13393. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13394. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13395. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13396. /**
  13397. * Class used to handle skinning animations
  13398. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13399. */
  13400. export class Skeleton implements IAnimatable {
  13401. /** defines the skeleton name */
  13402. name: string;
  13403. /** defines the skeleton Id */
  13404. id: string;
  13405. /**
  13406. * Defines the list of child bones
  13407. */
  13408. bones: Bone[];
  13409. /**
  13410. * Defines an estimate of the dimension of the skeleton at rest
  13411. */
  13412. dimensionsAtRest: Vector3;
  13413. /**
  13414. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13415. */
  13416. needInitialSkinMatrix: boolean;
  13417. /**
  13418. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13419. */
  13420. overrideMesh: Nullable<AbstractMesh>;
  13421. /**
  13422. * Gets the list of animations attached to this skeleton
  13423. */
  13424. animations: Array<Animation>;
  13425. private _scene;
  13426. private _isDirty;
  13427. private _transformMatrices;
  13428. private _transformMatrixTexture;
  13429. private _meshesWithPoseMatrix;
  13430. private _animatables;
  13431. private _identity;
  13432. private _synchronizedWithMesh;
  13433. private _ranges;
  13434. private _lastAbsoluteTransformsUpdateId;
  13435. private _canUseTextureForBones;
  13436. private _uniqueId;
  13437. /** @hidden */
  13438. _numBonesWithLinkedTransformNode: number;
  13439. /** @hidden */
  13440. _hasWaitingData: Nullable<boolean>;
  13441. /**
  13442. * Specifies if the skeleton should be serialized
  13443. */
  13444. doNotSerialize: boolean;
  13445. private _useTextureToStoreBoneMatrices;
  13446. /**
  13447. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13448. * Please note that this option is not available if the hardware does not support it
  13449. */
  13450. useTextureToStoreBoneMatrices: boolean;
  13451. private _animationPropertiesOverride;
  13452. /**
  13453. * Gets or sets the animation properties override
  13454. */
  13455. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13456. /**
  13457. * List of inspectable custom properties (used by the Inspector)
  13458. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13459. */
  13460. inspectableCustomProperties: IInspectable[];
  13461. /**
  13462. * An observable triggered before computing the skeleton's matrices
  13463. */
  13464. onBeforeComputeObservable: Observable<Skeleton>;
  13465. /**
  13466. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13467. */
  13468. readonly isUsingTextureForMatrices: boolean;
  13469. /**
  13470. * Gets the unique ID of this skeleton
  13471. */
  13472. readonly uniqueId: number;
  13473. /**
  13474. * Creates a new skeleton
  13475. * @param name defines the skeleton name
  13476. * @param id defines the skeleton Id
  13477. * @param scene defines the hosting scene
  13478. */
  13479. constructor(
  13480. /** defines the skeleton name */
  13481. name: string,
  13482. /** defines the skeleton Id */
  13483. id: string, scene: Scene);
  13484. /**
  13485. * Gets the current object class name.
  13486. * @return the class name
  13487. */
  13488. getClassName(): string;
  13489. /**
  13490. * Returns an array containing the root bones
  13491. * @returns an array containing the root bones
  13492. */
  13493. getChildren(): Array<Bone>;
  13494. /**
  13495. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13496. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13497. * @returns a Float32Array containing matrices data
  13498. */
  13499. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13500. /**
  13501. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13502. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13503. * @returns a raw texture containing the data
  13504. */
  13505. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13506. /**
  13507. * Gets the current hosting scene
  13508. * @returns a scene object
  13509. */
  13510. getScene(): Scene;
  13511. /**
  13512. * Gets a string representing the current skeleton data
  13513. * @param fullDetails defines a boolean indicating if we want a verbose version
  13514. * @returns a string representing the current skeleton data
  13515. */
  13516. toString(fullDetails?: boolean): string;
  13517. /**
  13518. * Get bone's index searching by name
  13519. * @param name defines bone's name to search for
  13520. * @return the indice of the bone. Returns -1 if not found
  13521. */
  13522. getBoneIndexByName(name: string): number;
  13523. /**
  13524. * Creater a new animation range
  13525. * @param name defines the name of the range
  13526. * @param from defines the start key
  13527. * @param to defines the end key
  13528. */
  13529. createAnimationRange(name: string, from: number, to: number): void;
  13530. /**
  13531. * Delete a specific animation range
  13532. * @param name defines the name of the range
  13533. * @param deleteFrames defines if frames must be removed as well
  13534. */
  13535. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13536. /**
  13537. * Gets a specific animation range
  13538. * @param name defines the name of the range to look for
  13539. * @returns the requested animation range or null if not found
  13540. */
  13541. getAnimationRange(name: string): Nullable<AnimationRange>;
  13542. /**
  13543. * Gets the list of all animation ranges defined on this skeleton
  13544. * @returns an array
  13545. */
  13546. getAnimationRanges(): Nullable<AnimationRange>[];
  13547. /**
  13548. * Copy animation range from a source skeleton.
  13549. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13550. * @param source defines the source skeleton
  13551. * @param name defines the name of the range to copy
  13552. * @param rescaleAsRequired defines if rescaling must be applied if required
  13553. * @returns true if operation was successful
  13554. */
  13555. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13556. /**
  13557. * Forces the skeleton to go to rest pose
  13558. */
  13559. returnToRest(): void;
  13560. private _getHighestAnimationFrame;
  13561. /**
  13562. * Begin a specific animation range
  13563. * @param name defines the name of the range to start
  13564. * @param loop defines if looping must be turned on (false by default)
  13565. * @param speedRatio defines the speed ratio to apply (1 by default)
  13566. * @param onAnimationEnd defines a callback which will be called when animation will end
  13567. * @returns a new animatable
  13568. */
  13569. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13570. /** @hidden */
  13571. _markAsDirty(): void;
  13572. /** @hidden */
  13573. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13574. /** @hidden */
  13575. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13576. private _computeTransformMatrices;
  13577. /**
  13578. * Build all resources required to render a skeleton
  13579. */
  13580. prepare(): void;
  13581. /**
  13582. * Gets the list of animatables currently running for this skeleton
  13583. * @returns an array of animatables
  13584. */
  13585. getAnimatables(): IAnimatable[];
  13586. /**
  13587. * Clone the current skeleton
  13588. * @param name defines the name of the new skeleton
  13589. * @param id defines the id of the new skeleton
  13590. * @returns the new skeleton
  13591. */
  13592. clone(name: string, id: string): Skeleton;
  13593. /**
  13594. * Enable animation blending for this skeleton
  13595. * @param blendingSpeed defines the blending speed to apply
  13596. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13597. */
  13598. enableBlending(blendingSpeed?: number): void;
  13599. /**
  13600. * Releases all resources associated with the current skeleton
  13601. */
  13602. dispose(): void;
  13603. /**
  13604. * Serialize the skeleton in a JSON object
  13605. * @returns a JSON object
  13606. */
  13607. serialize(): any;
  13608. /**
  13609. * Creates a new skeleton from serialized data
  13610. * @param parsedSkeleton defines the serialized data
  13611. * @param scene defines the hosting scene
  13612. * @returns a new skeleton
  13613. */
  13614. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13615. /**
  13616. * Compute all node absolute transforms
  13617. * @param forceUpdate defines if computation must be done even if cache is up to date
  13618. */
  13619. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13620. /**
  13621. * Gets the root pose matrix
  13622. * @returns a matrix
  13623. */
  13624. getPoseMatrix(): Nullable<Matrix>;
  13625. /**
  13626. * Sorts bones per internal index
  13627. */
  13628. sortBones(): void;
  13629. private _sortBones;
  13630. }
  13631. }
  13632. declare module "babylonjs/Bones/bone" {
  13633. import { Skeleton } from "babylonjs/Bones/skeleton";
  13634. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13635. import { Nullable } from "babylonjs/types";
  13636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13637. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13638. import { Node } from "babylonjs/node";
  13639. import { Space } from "babylonjs/Maths/math.axis";
  13640. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13641. /**
  13642. * Class used to store bone information
  13643. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13644. */
  13645. export class Bone extends Node {
  13646. /**
  13647. * defines the bone name
  13648. */
  13649. name: string;
  13650. private static _tmpVecs;
  13651. private static _tmpQuat;
  13652. private static _tmpMats;
  13653. /**
  13654. * Gets the list of child bones
  13655. */
  13656. children: Bone[];
  13657. /** Gets the animations associated with this bone */
  13658. animations: import("babylonjs/Animations/animation").Animation[];
  13659. /**
  13660. * Gets or sets bone length
  13661. */
  13662. length: number;
  13663. /**
  13664. * @hidden Internal only
  13665. * Set this value to map this bone to a different index in the transform matrices
  13666. * Set this value to -1 to exclude the bone from the transform matrices
  13667. */
  13668. _index: Nullable<number>;
  13669. private _skeleton;
  13670. private _localMatrix;
  13671. private _restPose;
  13672. private _baseMatrix;
  13673. private _absoluteTransform;
  13674. private _invertedAbsoluteTransform;
  13675. private _parent;
  13676. private _scalingDeterminant;
  13677. private _worldTransform;
  13678. private _localScaling;
  13679. private _localRotation;
  13680. private _localPosition;
  13681. private _needToDecompose;
  13682. private _needToCompose;
  13683. /** @hidden */
  13684. _linkedTransformNode: Nullable<TransformNode>;
  13685. /** @hidden */
  13686. _waitingTransformNodeId: Nullable<string>;
  13687. /** @hidden */
  13688. /** @hidden */
  13689. _matrix: Matrix;
  13690. /**
  13691. * Create a new bone
  13692. * @param name defines the bone name
  13693. * @param skeleton defines the parent skeleton
  13694. * @param parentBone defines the parent (can be null if the bone is the root)
  13695. * @param localMatrix defines the local matrix
  13696. * @param restPose defines the rest pose matrix
  13697. * @param baseMatrix defines the base matrix
  13698. * @param index defines index of the bone in the hiearchy
  13699. */
  13700. constructor(
  13701. /**
  13702. * defines the bone name
  13703. */
  13704. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13705. /**
  13706. * Gets the current object class name.
  13707. * @return the class name
  13708. */
  13709. getClassName(): string;
  13710. /**
  13711. * Gets the parent skeleton
  13712. * @returns a skeleton
  13713. */
  13714. getSkeleton(): Skeleton;
  13715. /**
  13716. * Gets parent bone
  13717. * @returns a bone or null if the bone is the root of the bone hierarchy
  13718. */
  13719. getParent(): Nullable<Bone>;
  13720. /**
  13721. * Returns an array containing the root bones
  13722. * @returns an array containing the root bones
  13723. */
  13724. getChildren(): Array<Bone>;
  13725. /**
  13726. * Sets the parent bone
  13727. * @param parent defines the parent (can be null if the bone is the root)
  13728. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13729. */
  13730. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13731. /**
  13732. * Gets the local matrix
  13733. * @returns a matrix
  13734. */
  13735. getLocalMatrix(): Matrix;
  13736. /**
  13737. * Gets the base matrix (initial matrix which remains unchanged)
  13738. * @returns a matrix
  13739. */
  13740. getBaseMatrix(): Matrix;
  13741. /**
  13742. * Gets the rest pose matrix
  13743. * @returns a matrix
  13744. */
  13745. getRestPose(): Matrix;
  13746. /**
  13747. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13748. */
  13749. getWorldMatrix(): Matrix;
  13750. /**
  13751. * Sets the local matrix to rest pose matrix
  13752. */
  13753. returnToRest(): void;
  13754. /**
  13755. * Gets the inverse of the absolute transform matrix.
  13756. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13757. * @returns a matrix
  13758. */
  13759. getInvertedAbsoluteTransform(): Matrix;
  13760. /**
  13761. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13762. * @returns a matrix
  13763. */
  13764. getAbsoluteTransform(): Matrix;
  13765. /**
  13766. * Links with the given transform node.
  13767. * The local matrix of this bone is copied from the transform node every frame.
  13768. * @param transformNode defines the transform node to link to
  13769. */
  13770. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13771. /**
  13772. * Gets the node used to drive the bone's transformation
  13773. * @returns a transform node or null
  13774. */
  13775. getTransformNode(): Nullable<TransformNode>;
  13776. /** Gets or sets current position (in local space) */
  13777. position: Vector3;
  13778. /** Gets or sets current rotation (in local space) */
  13779. rotation: Vector3;
  13780. /** Gets or sets current rotation quaternion (in local space) */
  13781. rotationQuaternion: Quaternion;
  13782. /** Gets or sets current scaling (in local space) */
  13783. scaling: Vector3;
  13784. /**
  13785. * Gets the animation properties override
  13786. */
  13787. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13788. private _decompose;
  13789. private _compose;
  13790. /**
  13791. * Update the base and local matrices
  13792. * @param matrix defines the new base or local matrix
  13793. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13794. * @param updateLocalMatrix defines if the local matrix should be updated
  13795. */
  13796. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13797. /** @hidden */
  13798. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13799. /**
  13800. * Flag the bone as dirty (Forcing it to update everything)
  13801. */
  13802. markAsDirty(): void;
  13803. /** @hidden */
  13804. _markAsDirtyAndCompose(): void;
  13805. private _markAsDirtyAndDecompose;
  13806. /**
  13807. * Translate the bone in local or world space
  13808. * @param vec The amount to translate the bone
  13809. * @param space The space that the translation is in
  13810. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13811. */
  13812. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13813. /**
  13814. * Set the postion of the bone in local or world space
  13815. * @param position The position to set the bone
  13816. * @param space The space that the position is in
  13817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13818. */
  13819. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13820. /**
  13821. * Set the absolute position of the bone (world space)
  13822. * @param position The position to set the bone
  13823. * @param mesh The mesh that this bone is attached to
  13824. */
  13825. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13826. /**
  13827. * Scale the bone on the x, y and z axes (in local space)
  13828. * @param x The amount to scale the bone on the x axis
  13829. * @param y The amount to scale the bone on the y axis
  13830. * @param z The amount to scale the bone on the z axis
  13831. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13832. */
  13833. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13834. /**
  13835. * Set the bone scaling in local space
  13836. * @param scale defines the scaling vector
  13837. */
  13838. setScale(scale: Vector3): void;
  13839. /**
  13840. * Gets the current scaling in local space
  13841. * @returns the current scaling vector
  13842. */
  13843. getScale(): Vector3;
  13844. /**
  13845. * Gets the current scaling in local space and stores it in a target vector
  13846. * @param result defines the target vector
  13847. */
  13848. getScaleToRef(result: Vector3): void;
  13849. /**
  13850. * Set the yaw, pitch, and roll of the bone in local or world space
  13851. * @param yaw The rotation of the bone on the y axis
  13852. * @param pitch The rotation of the bone on the x axis
  13853. * @param roll The rotation of the bone on the z axis
  13854. * @param space The space that the axes of rotation are in
  13855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13856. */
  13857. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13858. /**
  13859. * Add a rotation to the bone on an axis in local or world space
  13860. * @param axis The axis to rotate the bone on
  13861. * @param amount The amount to rotate the bone
  13862. * @param space The space that the axis is in
  13863. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13864. */
  13865. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13866. /**
  13867. * Set the rotation of the bone to a particular axis angle in local or world space
  13868. * @param axis The axis to rotate the bone on
  13869. * @param angle The angle that the bone should be rotated to
  13870. * @param space The space that the axis is in
  13871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13872. */
  13873. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13874. /**
  13875. * Set the euler rotation of the bone in local of world space
  13876. * @param rotation The euler rotation that the bone should be set to
  13877. * @param space The space that the rotation is in
  13878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13879. */
  13880. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13881. /**
  13882. * Set the quaternion rotation of the bone in local of world space
  13883. * @param quat The quaternion rotation that the bone should be set to
  13884. * @param space The space that the rotation is in
  13885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13886. */
  13887. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13888. /**
  13889. * Set the rotation matrix of the bone in local of world space
  13890. * @param rotMat The rotation matrix that the bone should be set to
  13891. * @param space The space that the rotation is in
  13892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13893. */
  13894. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13895. private _rotateWithMatrix;
  13896. private _getNegativeRotationToRef;
  13897. /**
  13898. * Get the position of the bone in local or world space
  13899. * @param space The space that the returned position is in
  13900. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13901. * @returns The position of the bone
  13902. */
  13903. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13904. /**
  13905. * Copy the position of the bone to a vector3 in local or world space
  13906. * @param space The space that the returned position is in
  13907. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13908. * @param result The vector3 to copy the position to
  13909. */
  13910. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13911. /**
  13912. * Get the absolute position of the bone (world space)
  13913. * @param mesh The mesh that this bone is attached to
  13914. * @returns The absolute position of the bone
  13915. */
  13916. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13917. /**
  13918. * Copy the absolute position of the bone (world space) to the result param
  13919. * @param mesh The mesh that this bone is attached to
  13920. * @param result The vector3 to copy the absolute position to
  13921. */
  13922. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13923. /**
  13924. * Compute the absolute transforms of this bone and its children
  13925. */
  13926. computeAbsoluteTransforms(): void;
  13927. /**
  13928. * Get the world direction from an axis that is in the local space of the bone
  13929. * @param localAxis The local direction that is used to compute the world direction
  13930. * @param mesh The mesh that this bone is attached to
  13931. * @returns The world direction
  13932. */
  13933. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13934. /**
  13935. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13936. * @param localAxis The local direction that is used to compute the world direction
  13937. * @param mesh The mesh that this bone is attached to
  13938. * @param result The vector3 that the world direction will be copied to
  13939. */
  13940. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13941. /**
  13942. * Get the euler rotation of the bone in local or world space
  13943. * @param space The space that the rotation should be in
  13944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13945. * @returns The euler rotation
  13946. */
  13947. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13948. /**
  13949. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13950. * @param space The space that the rotation should be in
  13951. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13952. * @param result The vector3 that the rotation should be copied to
  13953. */
  13954. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13955. /**
  13956. * Get the quaternion rotation of the bone in either local or world space
  13957. * @param space The space that the rotation should be in
  13958. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13959. * @returns The quaternion rotation
  13960. */
  13961. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13962. /**
  13963. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13964. * @param space The space that the rotation should be in
  13965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13966. * @param result The quaternion that the rotation should be copied to
  13967. */
  13968. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13969. /**
  13970. * Get the rotation matrix of the bone in local or world space
  13971. * @param space The space that the rotation should be in
  13972. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13973. * @returns The rotation matrix
  13974. */
  13975. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13976. /**
  13977. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13978. * @param space The space that the rotation should be in
  13979. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13980. * @param result The quaternion that the rotation should be copied to
  13981. */
  13982. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13983. /**
  13984. * Get the world position of a point that is in the local space of the bone
  13985. * @param position The local position
  13986. * @param mesh The mesh that this bone is attached to
  13987. * @returns The world position
  13988. */
  13989. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13990. /**
  13991. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13992. * @param position The local position
  13993. * @param mesh The mesh that this bone is attached to
  13994. * @param result The vector3 that the world position should be copied to
  13995. */
  13996. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13997. /**
  13998. * Get the local position of a point that is in world space
  13999. * @param position The world position
  14000. * @param mesh The mesh that this bone is attached to
  14001. * @returns The local position
  14002. */
  14003. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14004. /**
  14005. * Get the local position of a point that is in world space and copy it to the result param
  14006. * @param position The world position
  14007. * @param mesh The mesh that this bone is attached to
  14008. * @param result The vector3 that the local position should be copied to
  14009. */
  14010. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14011. }
  14012. }
  14013. declare module "babylonjs/Meshes/transformNode" {
  14014. import { DeepImmutable } from "babylonjs/types";
  14015. import { Observable } from "babylonjs/Misc/observable";
  14016. import { Nullable } from "babylonjs/types";
  14017. import { Camera } from "babylonjs/Cameras/camera";
  14018. import { Scene } from "babylonjs/scene";
  14019. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14020. import { Node } from "babylonjs/node";
  14021. import { Bone } from "babylonjs/Bones/bone";
  14022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14023. import { Space } from "babylonjs/Maths/math.axis";
  14024. /**
  14025. * 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.
  14026. * @see https://doc.babylonjs.com/how_to/transformnode
  14027. */
  14028. export class TransformNode extends Node {
  14029. /**
  14030. * Object will not rotate to face the camera
  14031. */
  14032. static BILLBOARDMODE_NONE: number;
  14033. /**
  14034. * Object will rotate to face the camera but only on the x axis
  14035. */
  14036. static BILLBOARDMODE_X: number;
  14037. /**
  14038. * Object will rotate to face the camera but only on the y axis
  14039. */
  14040. static BILLBOARDMODE_Y: number;
  14041. /**
  14042. * Object will rotate to face the camera but only on the z axis
  14043. */
  14044. static BILLBOARDMODE_Z: number;
  14045. /**
  14046. * Object will rotate to face the camera
  14047. */
  14048. static BILLBOARDMODE_ALL: number;
  14049. /**
  14050. * Object will rotate to face the camera's position instead of orientation
  14051. */
  14052. static BILLBOARDMODE_USE_POSITION: number;
  14053. private _forward;
  14054. private _forwardInverted;
  14055. private _up;
  14056. private _right;
  14057. private _rightInverted;
  14058. private _position;
  14059. private _rotation;
  14060. private _rotationQuaternion;
  14061. protected _scaling: Vector3;
  14062. protected _isDirty: boolean;
  14063. private _transformToBoneReferal;
  14064. private _isAbsoluteSynced;
  14065. private _billboardMode;
  14066. /**
  14067. * Gets or sets the billboard mode. Default is 0.
  14068. *
  14069. * | Value | Type | Description |
  14070. * | --- | --- | --- |
  14071. * | 0 | BILLBOARDMODE_NONE | |
  14072. * | 1 | BILLBOARDMODE_X | |
  14073. * | 2 | BILLBOARDMODE_Y | |
  14074. * | 4 | BILLBOARDMODE_Z | |
  14075. * | 7 | BILLBOARDMODE_ALL | |
  14076. *
  14077. */
  14078. billboardMode: number;
  14079. private _preserveParentRotationForBillboard;
  14080. /**
  14081. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14082. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14083. */
  14084. preserveParentRotationForBillboard: boolean;
  14085. /**
  14086. * 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
  14087. */
  14088. scalingDeterminant: number;
  14089. private _infiniteDistance;
  14090. /**
  14091. * Gets or sets the distance of the object to max, often used by skybox
  14092. */
  14093. infiniteDistance: boolean;
  14094. /**
  14095. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14096. * By default the system will update normals to compensate
  14097. */
  14098. ignoreNonUniformScaling: boolean;
  14099. /**
  14100. * 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
  14101. */
  14102. reIntegrateRotationIntoRotationQuaternion: boolean;
  14103. /** @hidden */
  14104. _poseMatrix: Nullable<Matrix>;
  14105. /** @hidden */
  14106. _localMatrix: Matrix;
  14107. private _usePivotMatrix;
  14108. private _absolutePosition;
  14109. private _absoluteScaling;
  14110. private _absoluteRotationQuaternion;
  14111. private _pivotMatrix;
  14112. private _pivotMatrixInverse;
  14113. protected _postMultiplyPivotMatrix: boolean;
  14114. protected _isWorldMatrixFrozen: boolean;
  14115. /** @hidden */
  14116. _indexInSceneTransformNodesArray: number;
  14117. /**
  14118. * An event triggered after the world matrix is updated
  14119. */
  14120. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14121. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14122. /**
  14123. * Gets a string identifying the name of the class
  14124. * @returns "TransformNode" string
  14125. */
  14126. getClassName(): string;
  14127. /**
  14128. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14129. */
  14130. position: Vector3;
  14131. /**
  14132. * 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)).
  14133. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14134. */
  14135. rotation: Vector3;
  14136. /**
  14137. * 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)).
  14138. */
  14139. scaling: Vector3;
  14140. /**
  14141. * 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).
  14142. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14143. */
  14144. rotationQuaternion: Nullable<Quaternion>;
  14145. /**
  14146. * The forward direction of that transform in world space.
  14147. */
  14148. readonly forward: Vector3;
  14149. /**
  14150. * The up direction of that transform in world space.
  14151. */
  14152. readonly up: Vector3;
  14153. /**
  14154. * The right direction of that transform in world space.
  14155. */
  14156. readonly right: Vector3;
  14157. /**
  14158. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14159. * @param matrix the matrix to copy the pose from
  14160. * @returns this TransformNode.
  14161. */
  14162. updatePoseMatrix(matrix: Matrix): TransformNode;
  14163. /**
  14164. * Returns the mesh Pose matrix.
  14165. * @returns the pose matrix
  14166. */
  14167. getPoseMatrix(): Matrix;
  14168. /** @hidden */
  14169. _isSynchronized(): boolean;
  14170. /** @hidden */
  14171. _initCache(): void;
  14172. /**
  14173. * Flag the transform node as dirty (Forcing it to update everything)
  14174. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14175. * @returns this transform node
  14176. */
  14177. markAsDirty(property: string): TransformNode;
  14178. /**
  14179. * Returns the current mesh absolute position.
  14180. * Returns a Vector3.
  14181. */
  14182. readonly absolutePosition: Vector3;
  14183. /**
  14184. * Returns the current mesh absolute scaling.
  14185. * Returns a Vector3.
  14186. */
  14187. readonly absoluteScaling: Vector3;
  14188. /**
  14189. * Returns the current mesh absolute rotation.
  14190. * Returns a Quaternion.
  14191. */
  14192. readonly absoluteRotationQuaternion: Quaternion;
  14193. /**
  14194. * Sets a new matrix to apply before all other transformation
  14195. * @param matrix defines the transform matrix
  14196. * @returns the current TransformNode
  14197. */
  14198. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14199. /**
  14200. * Sets a new pivot matrix to the current node
  14201. * @param matrix defines the new pivot matrix to use
  14202. * @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
  14203. * @returns the current TransformNode
  14204. */
  14205. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14206. /**
  14207. * Returns the mesh pivot matrix.
  14208. * Default : Identity.
  14209. * @returns the matrix
  14210. */
  14211. getPivotMatrix(): Matrix;
  14212. /**
  14213. * Instantiate (when possible) or clone that node with its hierarchy
  14214. * @param newParent defines the new parent to use for the instance (or clone)
  14215. * @returns an instance (or a clone) of the current node with its hiearchy
  14216. */
  14217. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14218. /**
  14219. * Prevents the World matrix to be computed any longer
  14220. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14221. * @returns the TransformNode.
  14222. */
  14223. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14224. /**
  14225. * Allows back the World matrix computation.
  14226. * @returns the TransformNode.
  14227. */
  14228. unfreezeWorldMatrix(): this;
  14229. /**
  14230. * True if the World matrix has been frozen.
  14231. */
  14232. readonly isWorldMatrixFrozen: boolean;
  14233. /**
  14234. * Retuns the mesh absolute position in the World.
  14235. * @returns a Vector3.
  14236. */
  14237. getAbsolutePosition(): Vector3;
  14238. /**
  14239. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14240. * @param absolutePosition the absolute position to set
  14241. * @returns the TransformNode.
  14242. */
  14243. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14244. /**
  14245. * Sets the mesh position in its local space.
  14246. * @param vector3 the position to set in localspace
  14247. * @returns the TransformNode.
  14248. */
  14249. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14250. /**
  14251. * Returns the mesh position in the local space from the current World matrix values.
  14252. * @returns a new Vector3.
  14253. */
  14254. getPositionExpressedInLocalSpace(): Vector3;
  14255. /**
  14256. * Translates the mesh along the passed Vector3 in its local space.
  14257. * @param vector3 the distance to translate in localspace
  14258. * @returns the TransformNode.
  14259. */
  14260. locallyTranslate(vector3: Vector3): TransformNode;
  14261. private static _lookAtVectorCache;
  14262. /**
  14263. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14264. * @param targetPoint the position (must be in same space as current mesh) to look at
  14265. * @param yawCor optional yaw (y-axis) correction in radians
  14266. * @param pitchCor optional pitch (x-axis) correction in radians
  14267. * @param rollCor optional roll (z-axis) correction in radians
  14268. * @param space the choosen space of the target
  14269. * @returns the TransformNode.
  14270. */
  14271. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14272. /**
  14273. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14274. * This Vector3 is expressed in the World space.
  14275. * @param localAxis axis to rotate
  14276. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14277. */
  14278. getDirection(localAxis: Vector3): Vector3;
  14279. /**
  14280. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14281. * localAxis is expressed in the mesh local space.
  14282. * result is computed in the Wordl space from the mesh World matrix.
  14283. * @param localAxis axis to rotate
  14284. * @param result the resulting transformnode
  14285. * @returns this TransformNode.
  14286. */
  14287. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14288. /**
  14289. * Sets this transform node rotation to the given local axis.
  14290. * @param localAxis the axis in local space
  14291. * @param yawCor optional yaw (y-axis) correction in radians
  14292. * @param pitchCor optional pitch (x-axis) correction in radians
  14293. * @param rollCor optional roll (z-axis) correction in radians
  14294. * @returns this TransformNode
  14295. */
  14296. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14297. /**
  14298. * Sets a new pivot point to the current node
  14299. * @param point defines the new pivot point to use
  14300. * @param space defines if the point is in world or local space (local by default)
  14301. * @returns the current TransformNode
  14302. */
  14303. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14304. /**
  14305. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14306. * @returns the pivot point
  14307. */
  14308. getPivotPoint(): Vector3;
  14309. /**
  14310. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14311. * @param result the vector3 to store the result
  14312. * @returns this TransformNode.
  14313. */
  14314. getPivotPointToRef(result: Vector3): TransformNode;
  14315. /**
  14316. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14317. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14318. */
  14319. getAbsolutePivotPoint(): Vector3;
  14320. /**
  14321. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14322. * @param result vector3 to store the result
  14323. * @returns this TransformNode.
  14324. */
  14325. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14326. /**
  14327. * Defines the passed node as the parent of the current node.
  14328. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14329. * @see https://doc.babylonjs.com/how_to/parenting
  14330. * @param node the node ot set as the parent
  14331. * @returns this TransformNode.
  14332. */
  14333. setParent(node: Nullable<Node>): TransformNode;
  14334. private _nonUniformScaling;
  14335. /**
  14336. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14337. */
  14338. readonly nonUniformScaling: boolean;
  14339. /** @hidden */
  14340. _updateNonUniformScalingState(value: boolean): boolean;
  14341. /**
  14342. * Attach the current TransformNode to another TransformNode associated with a bone
  14343. * @param bone Bone affecting the TransformNode
  14344. * @param affectedTransformNode TransformNode associated with the bone
  14345. * @returns this object
  14346. */
  14347. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14348. /**
  14349. * Detach the transform node if its associated with a bone
  14350. * @returns this object
  14351. */
  14352. detachFromBone(): TransformNode;
  14353. private static _rotationAxisCache;
  14354. /**
  14355. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14356. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14357. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14358. * The passed axis is also normalized.
  14359. * @param axis the axis to rotate around
  14360. * @param amount the amount to rotate in radians
  14361. * @param space Space to rotate in (Default: local)
  14362. * @returns the TransformNode.
  14363. */
  14364. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14365. /**
  14366. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14367. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14368. * The passed axis is also normalized. .
  14369. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14370. * @param point the point to rotate around
  14371. * @param axis the axis to rotate around
  14372. * @param amount the amount to rotate in radians
  14373. * @returns the TransformNode
  14374. */
  14375. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14376. /**
  14377. * Translates the mesh along the axis vector for the passed distance in the given space.
  14378. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14379. * @param axis the axis to translate in
  14380. * @param distance the distance to translate
  14381. * @param space Space to rotate in (Default: local)
  14382. * @returns the TransformNode.
  14383. */
  14384. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14385. /**
  14386. * Adds a rotation step to the mesh current rotation.
  14387. * x, y, z are Euler angles expressed in radians.
  14388. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14389. * This means this rotation is made in the mesh local space only.
  14390. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14391. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14392. * ```javascript
  14393. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14394. * ```
  14395. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14396. * 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.
  14397. * @param x Rotation to add
  14398. * @param y Rotation to add
  14399. * @param z Rotation to add
  14400. * @returns the TransformNode.
  14401. */
  14402. addRotation(x: number, y: number, z: number): TransformNode;
  14403. /**
  14404. * @hidden
  14405. */
  14406. protected _getEffectiveParent(): Nullable<Node>;
  14407. /**
  14408. * Computes the world matrix of the node
  14409. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14410. * @returns the world matrix
  14411. */
  14412. computeWorldMatrix(force?: boolean): Matrix;
  14413. protected _afterComputeWorldMatrix(): void;
  14414. /**
  14415. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14416. * @param func callback function to add
  14417. *
  14418. * @returns the TransformNode.
  14419. */
  14420. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14421. /**
  14422. * Removes a registered callback function.
  14423. * @param func callback function to remove
  14424. * @returns the TransformNode.
  14425. */
  14426. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14427. /**
  14428. * Gets the position of the current mesh in camera space
  14429. * @param camera defines the camera to use
  14430. * @returns a position
  14431. */
  14432. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14433. /**
  14434. * Returns the distance from the mesh to the active camera
  14435. * @param camera defines the camera to use
  14436. * @returns the distance
  14437. */
  14438. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14439. /**
  14440. * Clone the current transform node
  14441. * @param name Name of the new clone
  14442. * @param newParent New parent for the clone
  14443. * @param doNotCloneChildren Do not clone children hierarchy
  14444. * @returns the new transform node
  14445. */
  14446. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14447. /**
  14448. * Serializes the objects information.
  14449. * @param currentSerializationObject defines the object to serialize in
  14450. * @returns the serialized object
  14451. */
  14452. serialize(currentSerializationObject?: any): any;
  14453. /**
  14454. * Returns a new TransformNode object parsed from the source provided.
  14455. * @param parsedTransformNode is the source.
  14456. * @param scene the scne the object belongs to
  14457. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14458. * @returns a new TransformNode object parsed from the source provided.
  14459. */
  14460. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14461. /**
  14462. * Get all child-transformNodes of this node
  14463. * @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
  14464. * @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
  14465. * @returns an array of TransformNode
  14466. */
  14467. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14468. /**
  14469. * Releases resources associated with this transform node.
  14470. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14471. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14472. */
  14473. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14474. /**
  14475. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14476. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14477. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14478. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14479. * @returns the current mesh
  14480. */
  14481. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14482. private _syncAbsoluteScalingAndRotation;
  14483. }
  14484. }
  14485. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14486. import { Observable } from "babylonjs/Misc/observable";
  14487. import { Nullable } from "babylonjs/types";
  14488. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14489. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14491. import { Ray } from "babylonjs/Culling/ray";
  14492. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14493. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14494. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14495. /**
  14496. * Defines the types of pose enabled controllers that are supported
  14497. */
  14498. export enum PoseEnabledControllerType {
  14499. /**
  14500. * HTC Vive
  14501. */
  14502. VIVE = 0,
  14503. /**
  14504. * Oculus Rift
  14505. */
  14506. OCULUS = 1,
  14507. /**
  14508. * Windows mixed reality
  14509. */
  14510. WINDOWS = 2,
  14511. /**
  14512. * Samsung gear VR
  14513. */
  14514. GEAR_VR = 3,
  14515. /**
  14516. * Google Daydream
  14517. */
  14518. DAYDREAM = 4,
  14519. /**
  14520. * Generic
  14521. */
  14522. GENERIC = 5
  14523. }
  14524. /**
  14525. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14526. */
  14527. export interface MutableGamepadButton {
  14528. /**
  14529. * Value of the button/trigger
  14530. */
  14531. value: number;
  14532. /**
  14533. * If the button/trigger is currently touched
  14534. */
  14535. touched: boolean;
  14536. /**
  14537. * If the button/trigger is currently pressed
  14538. */
  14539. pressed: boolean;
  14540. }
  14541. /**
  14542. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14543. * @hidden
  14544. */
  14545. export interface ExtendedGamepadButton extends GamepadButton {
  14546. /**
  14547. * If the button/trigger is currently pressed
  14548. */
  14549. readonly pressed: boolean;
  14550. /**
  14551. * If the button/trigger is currently touched
  14552. */
  14553. readonly touched: boolean;
  14554. /**
  14555. * Value of the button/trigger
  14556. */
  14557. readonly value: number;
  14558. }
  14559. /** @hidden */
  14560. export interface _GamePadFactory {
  14561. /**
  14562. * Returns wether or not the current gamepad can be created for this type of controller.
  14563. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14564. * @returns true if it can be created, otherwise false
  14565. */
  14566. canCreate(gamepadInfo: any): boolean;
  14567. /**
  14568. * Creates a new instance of the Gamepad.
  14569. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14570. * @returns the new gamepad instance
  14571. */
  14572. create(gamepadInfo: any): Gamepad;
  14573. }
  14574. /**
  14575. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14576. */
  14577. export class PoseEnabledControllerHelper {
  14578. /** @hidden */
  14579. static _ControllerFactories: _GamePadFactory[];
  14580. /** @hidden */
  14581. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14582. /**
  14583. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14584. * @param vrGamepad the gamepad to initialized
  14585. * @returns a vr controller of the type the gamepad identified as
  14586. */
  14587. static InitiateController(vrGamepad: any): Gamepad;
  14588. }
  14589. /**
  14590. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14591. */
  14592. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14593. /**
  14594. * If the controller is used in a webXR session
  14595. */
  14596. isXR: boolean;
  14597. private _deviceRoomPosition;
  14598. private _deviceRoomRotationQuaternion;
  14599. /**
  14600. * The device position in babylon space
  14601. */
  14602. devicePosition: Vector3;
  14603. /**
  14604. * The device rotation in babylon space
  14605. */
  14606. deviceRotationQuaternion: Quaternion;
  14607. /**
  14608. * The scale factor of the device in babylon space
  14609. */
  14610. deviceScaleFactor: number;
  14611. /**
  14612. * (Likely devicePosition should be used instead) The device position in its room space
  14613. */
  14614. position: Vector3;
  14615. /**
  14616. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14617. */
  14618. rotationQuaternion: Quaternion;
  14619. /**
  14620. * The type of controller (Eg. Windows mixed reality)
  14621. */
  14622. controllerType: PoseEnabledControllerType;
  14623. protected _calculatedPosition: Vector3;
  14624. private _calculatedRotation;
  14625. /**
  14626. * The raw pose from the device
  14627. */
  14628. rawPose: DevicePose;
  14629. private _trackPosition;
  14630. private _maxRotationDistFromHeadset;
  14631. private _draggedRoomRotation;
  14632. /**
  14633. * @hidden
  14634. */
  14635. _disableTrackPosition(fixedPosition: Vector3): void;
  14636. /**
  14637. * Internal, the mesh attached to the controller
  14638. * @hidden
  14639. */
  14640. _mesh: Nullable<AbstractMesh>;
  14641. private _poseControlledCamera;
  14642. private _leftHandSystemQuaternion;
  14643. /**
  14644. * Internal, matrix used to convert room space to babylon space
  14645. * @hidden
  14646. */
  14647. _deviceToWorld: Matrix;
  14648. /**
  14649. * Node to be used when casting a ray from the controller
  14650. * @hidden
  14651. */
  14652. _pointingPoseNode: Nullable<TransformNode>;
  14653. /**
  14654. * Name of the child mesh that can be used to cast a ray from the controller
  14655. */
  14656. static readonly POINTING_POSE: string;
  14657. /**
  14658. * Creates a new PoseEnabledController from a gamepad
  14659. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14660. */
  14661. constructor(browserGamepad: any);
  14662. private _workingMatrix;
  14663. /**
  14664. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14665. */
  14666. update(): void;
  14667. /**
  14668. * Updates only the pose device and mesh without doing any button event checking
  14669. */
  14670. protected _updatePoseAndMesh(): void;
  14671. /**
  14672. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14673. * @param poseData raw pose fromthe device
  14674. */
  14675. updateFromDevice(poseData: DevicePose): void;
  14676. /**
  14677. * @hidden
  14678. */
  14679. _meshAttachedObservable: Observable<AbstractMesh>;
  14680. /**
  14681. * Attaches a mesh to the controller
  14682. * @param mesh the mesh to be attached
  14683. */
  14684. attachToMesh(mesh: AbstractMesh): void;
  14685. /**
  14686. * Attaches the controllers mesh to a camera
  14687. * @param camera the camera the mesh should be attached to
  14688. */
  14689. attachToPoseControlledCamera(camera: TargetCamera): void;
  14690. /**
  14691. * Disposes of the controller
  14692. */
  14693. dispose(): void;
  14694. /**
  14695. * The mesh that is attached to the controller
  14696. */
  14697. readonly mesh: Nullable<AbstractMesh>;
  14698. /**
  14699. * Gets the ray of the controller in the direction the controller is pointing
  14700. * @param length the length the resulting ray should be
  14701. * @returns a ray in the direction the controller is pointing
  14702. */
  14703. getForwardRay(length?: number): Ray;
  14704. }
  14705. }
  14706. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14707. import { Observable } from "babylonjs/Misc/observable";
  14708. import { Scene } from "babylonjs/scene";
  14709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14710. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14711. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14712. import { Nullable } from "babylonjs/types";
  14713. /**
  14714. * Defines the WebVRController object that represents controllers tracked in 3D space
  14715. */
  14716. export abstract class WebVRController extends PoseEnabledController {
  14717. /**
  14718. * Internal, the default controller model for the controller
  14719. */
  14720. protected _defaultModel: Nullable<AbstractMesh>;
  14721. /**
  14722. * Fired when the trigger state has changed
  14723. */
  14724. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14725. /**
  14726. * Fired when the main button state has changed
  14727. */
  14728. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14729. /**
  14730. * Fired when the secondary button state has changed
  14731. */
  14732. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14733. /**
  14734. * Fired when the pad state has changed
  14735. */
  14736. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14737. /**
  14738. * Fired when controllers stick values have changed
  14739. */
  14740. onPadValuesChangedObservable: Observable<StickValues>;
  14741. /**
  14742. * Array of button availible on the controller
  14743. */
  14744. protected _buttons: Array<MutableGamepadButton>;
  14745. private _onButtonStateChange;
  14746. /**
  14747. * Fired when a controller button's state has changed
  14748. * @param callback the callback containing the button that was modified
  14749. */
  14750. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14751. /**
  14752. * X and Y axis corresponding to the controllers joystick
  14753. */
  14754. pad: StickValues;
  14755. /**
  14756. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14757. */
  14758. hand: string;
  14759. /**
  14760. * The default controller model for the controller
  14761. */
  14762. readonly defaultModel: Nullable<AbstractMesh>;
  14763. /**
  14764. * Creates a new WebVRController from a gamepad
  14765. * @param vrGamepad the gamepad that the WebVRController should be created from
  14766. */
  14767. constructor(vrGamepad: any);
  14768. /**
  14769. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14770. */
  14771. update(): void;
  14772. /**
  14773. * Function to be called when a button is modified
  14774. */
  14775. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14776. /**
  14777. * Loads a mesh and attaches it to the controller
  14778. * @param scene the scene the mesh should be added to
  14779. * @param meshLoaded callback for when the mesh has been loaded
  14780. */
  14781. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14782. private _setButtonValue;
  14783. private _changes;
  14784. private _checkChanges;
  14785. /**
  14786. * Disposes of th webVRCOntroller
  14787. */
  14788. dispose(): void;
  14789. }
  14790. }
  14791. declare module "babylonjs/Lights/hemisphericLight" {
  14792. import { Nullable } from "babylonjs/types";
  14793. import { Scene } from "babylonjs/scene";
  14794. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14795. import { Color3 } from "babylonjs/Maths/math.color";
  14796. import { Effect } from "babylonjs/Materials/effect";
  14797. import { Light } from "babylonjs/Lights/light";
  14798. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14799. /**
  14800. * The HemisphericLight simulates the ambient environment light,
  14801. * so the passed direction is the light reflection direction, not the incoming direction.
  14802. */
  14803. export class HemisphericLight extends Light {
  14804. /**
  14805. * The groundColor is the light in the opposite direction to the one specified during creation.
  14806. * 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.
  14807. */
  14808. groundColor: Color3;
  14809. /**
  14810. * The light reflection direction, not the incoming direction.
  14811. */
  14812. direction: Vector3;
  14813. /**
  14814. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14815. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14816. * The HemisphericLight can't cast shadows.
  14817. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14818. * @param name The friendly name of the light
  14819. * @param direction The direction of the light reflection
  14820. * @param scene The scene the light belongs to
  14821. */
  14822. constructor(name: string, direction: Vector3, scene: Scene);
  14823. protected _buildUniformLayout(): void;
  14824. /**
  14825. * Returns the string "HemisphericLight".
  14826. * @return The class name
  14827. */
  14828. getClassName(): string;
  14829. /**
  14830. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14831. * Returns the updated direction.
  14832. * @param target The target the direction should point to
  14833. * @return The computed direction
  14834. */
  14835. setDirectionToTarget(target: Vector3): Vector3;
  14836. /**
  14837. * Returns the shadow generator associated to the light.
  14838. * @returns Always null for hemispheric lights because it does not support shadows.
  14839. */
  14840. getShadowGenerator(): Nullable<IShadowGenerator>;
  14841. /**
  14842. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14843. * @param effect The effect to update
  14844. * @param lightIndex The index of the light in the effect to update
  14845. * @returns The hemispheric light
  14846. */
  14847. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14848. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14849. /**
  14850. * Computes the world matrix of the node
  14851. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14852. * @param useWasUpdatedFlag defines a reserved property
  14853. * @returns the world matrix
  14854. */
  14855. computeWorldMatrix(): Matrix;
  14856. /**
  14857. * Returns the integer 3.
  14858. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14859. */
  14860. getTypeID(): number;
  14861. /**
  14862. * Prepares the list of defines specific to the light type.
  14863. * @param defines the list of defines
  14864. * @param lightIndex defines the index of the light for the effect
  14865. */
  14866. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14867. }
  14868. }
  14869. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14870. /** @hidden */
  14871. export var vrMultiviewToSingleviewPixelShader: {
  14872. name: string;
  14873. shader: string;
  14874. };
  14875. }
  14876. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14877. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14878. import { Scene } from "babylonjs/scene";
  14879. /**
  14880. * Renders to multiple views with a single draw call
  14881. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14882. */
  14883. export class MultiviewRenderTarget extends RenderTargetTexture {
  14884. /**
  14885. * Creates a multiview render target
  14886. * @param scene scene used with the render target
  14887. * @param size the size of the render target (used for each view)
  14888. */
  14889. constructor(scene: Scene, size?: number | {
  14890. width: number;
  14891. height: number;
  14892. } | {
  14893. ratio: number;
  14894. });
  14895. /**
  14896. * @hidden
  14897. * @param faceIndex the face index, if its a cube texture
  14898. */
  14899. _bindFrameBuffer(faceIndex?: number): void;
  14900. /**
  14901. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14902. * @returns the view count
  14903. */
  14904. getViewCount(): number;
  14905. }
  14906. }
  14907. declare module "babylonjs/Maths/math.frustum" {
  14908. import { Matrix } from "babylonjs/Maths/math.vector";
  14909. import { DeepImmutable } from "babylonjs/types";
  14910. import { Plane } from "babylonjs/Maths/math.plane";
  14911. /**
  14912. * Represents a camera frustum
  14913. */
  14914. export class Frustum {
  14915. /**
  14916. * Gets the planes representing the frustum
  14917. * @param transform matrix to be applied to the returned planes
  14918. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14919. */
  14920. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14921. /**
  14922. * Gets the near frustum plane transformed by the transform matrix
  14923. * @param transform transformation matrix to be applied to the resulting frustum plane
  14924. * @param frustumPlane the resuling frustum plane
  14925. */
  14926. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14927. /**
  14928. * Gets the far frustum plane transformed by the transform matrix
  14929. * @param transform transformation matrix to be applied to the resulting frustum plane
  14930. * @param frustumPlane the resuling frustum plane
  14931. */
  14932. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14933. /**
  14934. * Gets the left frustum plane transformed by the transform matrix
  14935. * @param transform transformation matrix to be applied to the resulting frustum plane
  14936. * @param frustumPlane the resuling frustum plane
  14937. */
  14938. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14939. /**
  14940. * Gets the right frustum plane transformed by the transform matrix
  14941. * @param transform transformation matrix to be applied to the resulting frustum plane
  14942. * @param frustumPlane the resuling frustum plane
  14943. */
  14944. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14945. /**
  14946. * Gets the top frustum plane transformed by the transform matrix
  14947. * @param transform transformation matrix to be applied to the resulting frustum plane
  14948. * @param frustumPlane the resuling frustum plane
  14949. */
  14950. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14951. /**
  14952. * Gets the bottom frustum plane transformed by the transform matrix
  14953. * @param transform transformation matrix to be applied to the resulting frustum plane
  14954. * @param frustumPlane the resuling frustum plane
  14955. */
  14956. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14957. /**
  14958. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14959. * @param transform transformation matrix to be applied to the resulting frustum planes
  14960. * @param frustumPlanes the resuling frustum planes
  14961. */
  14962. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14963. }
  14964. }
  14965. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14966. import { Camera } from "babylonjs/Cameras/camera";
  14967. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14968. import { Nullable } from "babylonjs/types";
  14969. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14970. import { Matrix } from "babylonjs/Maths/math.vector";
  14971. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14972. module "babylonjs/Engines/engine" {
  14973. interface Engine {
  14974. /**
  14975. * Creates a new multiview render target
  14976. * @param width defines the width of the texture
  14977. * @param height defines the height of the texture
  14978. * @returns the created multiview texture
  14979. */
  14980. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14981. /**
  14982. * Binds a multiview framebuffer to be drawn to
  14983. * @param multiviewTexture texture to bind
  14984. */
  14985. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14986. }
  14987. }
  14988. module "babylonjs/Cameras/camera" {
  14989. interface Camera {
  14990. /**
  14991. * @hidden
  14992. * 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)
  14993. */
  14994. _useMultiviewToSingleView: boolean;
  14995. /**
  14996. * @hidden
  14997. * 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)
  14998. */
  14999. _multiviewTexture: Nullable<RenderTargetTexture>;
  15000. /**
  15001. * @hidden
  15002. * ensures the multiview texture of the camera exists and has the specified width/height
  15003. * @param width height to set on the multiview texture
  15004. * @param height width to set on the multiview texture
  15005. */
  15006. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15007. }
  15008. }
  15009. module "babylonjs/scene" {
  15010. interface Scene {
  15011. /** @hidden */
  15012. _transformMatrixR: Matrix;
  15013. /** @hidden */
  15014. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15015. /** @hidden */
  15016. _createMultiviewUbo(): void;
  15017. /** @hidden */
  15018. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15019. /** @hidden */
  15020. _renderMultiviewToSingleView(camera: Camera): void;
  15021. }
  15022. }
  15023. }
  15024. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15025. import { Camera } from "babylonjs/Cameras/camera";
  15026. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15027. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15028. import "babylonjs/Engines/Extensions/engine.multiview";
  15029. /**
  15030. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15031. * This will not be used for webXR as it supports displaying texture arrays directly
  15032. */
  15033. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15034. /**
  15035. * Initializes a VRMultiviewToSingleview
  15036. * @param name name of the post process
  15037. * @param camera camera to be applied to
  15038. * @param scaleFactor scaling factor to the size of the output texture
  15039. */
  15040. constructor(name: string, camera: Camera, scaleFactor: number);
  15041. }
  15042. }
  15043. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15044. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15045. import { Nullable } from "babylonjs/types";
  15046. import { Size } from "babylonjs/Maths/math.size";
  15047. import { Observable } from "babylonjs/Misc/observable";
  15048. module "babylonjs/Engines/engine" {
  15049. interface Engine {
  15050. /** @hidden */
  15051. _vrDisplay: any;
  15052. /** @hidden */
  15053. _vrSupported: boolean;
  15054. /** @hidden */
  15055. _oldSize: Size;
  15056. /** @hidden */
  15057. _oldHardwareScaleFactor: number;
  15058. /** @hidden */
  15059. _vrExclusivePointerMode: boolean;
  15060. /** @hidden */
  15061. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15062. /** @hidden */
  15063. _onVRDisplayPointerRestricted: () => void;
  15064. /** @hidden */
  15065. _onVRDisplayPointerUnrestricted: () => void;
  15066. /** @hidden */
  15067. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15068. /** @hidden */
  15069. _onVrDisplayDisconnect: Nullable<() => void>;
  15070. /** @hidden */
  15071. _onVrDisplayPresentChange: Nullable<() => void>;
  15072. /**
  15073. * Observable signaled when VR display mode changes
  15074. */
  15075. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15076. /**
  15077. * Observable signaled when VR request present is complete
  15078. */
  15079. onVRRequestPresentComplete: Observable<boolean>;
  15080. /**
  15081. * Observable signaled when VR request present starts
  15082. */
  15083. onVRRequestPresentStart: Observable<Engine>;
  15084. /**
  15085. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15086. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15087. */
  15088. isInVRExclusivePointerMode: boolean;
  15089. /**
  15090. * Gets a boolean indicating if a webVR device was detected
  15091. * @returns true if a webVR device was detected
  15092. */
  15093. isVRDevicePresent(): boolean;
  15094. /**
  15095. * Gets the current webVR device
  15096. * @returns the current webVR device (or null)
  15097. */
  15098. getVRDevice(): any;
  15099. /**
  15100. * Initializes a webVR display and starts listening to display change events
  15101. * The onVRDisplayChangedObservable will be notified upon these changes
  15102. * @returns A promise containing a VRDisplay and if vr is supported
  15103. */
  15104. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15105. /** @hidden */
  15106. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15107. /**
  15108. * Call this function to switch to webVR mode
  15109. * Will do nothing if webVR is not supported or if there is no webVR device
  15110. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15111. */
  15112. enableVR(): void;
  15113. /** @hidden */
  15114. _onVRFullScreenTriggered(): void;
  15115. }
  15116. }
  15117. }
  15118. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15119. import { Nullable } from "babylonjs/types";
  15120. import { Observable } from "babylonjs/Misc/observable";
  15121. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15122. import { Scene } from "babylonjs/scene";
  15123. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15124. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15125. import { Node } from "babylonjs/node";
  15126. import { Ray } from "babylonjs/Culling/ray";
  15127. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15128. import "babylonjs/Engines/Extensions/engine.webVR";
  15129. /**
  15130. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15131. * IMPORTANT!! The data is right-hand data.
  15132. * @export
  15133. * @interface DevicePose
  15134. */
  15135. export interface DevicePose {
  15136. /**
  15137. * The position of the device, values in array are [x,y,z].
  15138. */
  15139. readonly position: Nullable<Float32Array>;
  15140. /**
  15141. * The linearVelocity of the device, values in array are [x,y,z].
  15142. */
  15143. readonly linearVelocity: Nullable<Float32Array>;
  15144. /**
  15145. * The linearAcceleration of the device, values in array are [x,y,z].
  15146. */
  15147. readonly linearAcceleration: Nullable<Float32Array>;
  15148. /**
  15149. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15150. */
  15151. readonly orientation: Nullable<Float32Array>;
  15152. /**
  15153. * The angularVelocity of the device, values in array are [x,y,z].
  15154. */
  15155. readonly angularVelocity: Nullable<Float32Array>;
  15156. /**
  15157. * The angularAcceleration of the device, values in array are [x,y,z].
  15158. */
  15159. readonly angularAcceleration: Nullable<Float32Array>;
  15160. }
  15161. /**
  15162. * Interface representing a pose controlled object in Babylon.
  15163. * A pose controlled object has both regular pose values as well as pose values
  15164. * from an external device such as a VR head mounted display
  15165. */
  15166. export interface PoseControlled {
  15167. /**
  15168. * The position of the object in babylon space.
  15169. */
  15170. position: Vector3;
  15171. /**
  15172. * The rotation quaternion of the object in babylon space.
  15173. */
  15174. rotationQuaternion: Quaternion;
  15175. /**
  15176. * The position of the device in babylon space.
  15177. */
  15178. devicePosition?: Vector3;
  15179. /**
  15180. * The rotation quaternion of the device in babylon space.
  15181. */
  15182. deviceRotationQuaternion: Quaternion;
  15183. /**
  15184. * The raw pose coming from the device.
  15185. */
  15186. rawPose: Nullable<DevicePose>;
  15187. /**
  15188. * The scale of the device to be used when translating from device space to babylon space.
  15189. */
  15190. deviceScaleFactor: number;
  15191. /**
  15192. * Updates the poseControlled values based on the input device pose.
  15193. * @param poseData the pose data to update the object with
  15194. */
  15195. updateFromDevice(poseData: DevicePose): void;
  15196. }
  15197. /**
  15198. * Set of options to customize the webVRCamera
  15199. */
  15200. export interface WebVROptions {
  15201. /**
  15202. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15203. */
  15204. trackPosition?: boolean;
  15205. /**
  15206. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15207. */
  15208. positionScale?: number;
  15209. /**
  15210. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15211. */
  15212. displayName?: string;
  15213. /**
  15214. * Should the native controller meshes be initialized. (default: true)
  15215. */
  15216. controllerMeshes?: boolean;
  15217. /**
  15218. * Creating a default HemiLight only on controllers. (default: true)
  15219. */
  15220. defaultLightingOnControllers?: boolean;
  15221. /**
  15222. * If you don't want to use the default VR button of the helper. (default: false)
  15223. */
  15224. useCustomVRButton?: boolean;
  15225. /**
  15226. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15227. */
  15228. customVRButton?: HTMLButtonElement;
  15229. /**
  15230. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15231. */
  15232. rayLength?: number;
  15233. /**
  15234. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15235. */
  15236. defaultHeight?: number;
  15237. /**
  15238. * If multiview should be used if availible (default: false)
  15239. */
  15240. useMultiview?: boolean;
  15241. }
  15242. /**
  15243. * This represents a WebVR camera.
  15244. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15245. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15246. */
  15247. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15248. private webVROptions;
  15249. /**
  15250. * @hidden
  15251. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15252. */
  15253. _vrDevice: any;
  15254. /**
  15255. * The rawPose of the vrDevice.
  15256. */
  15257. rawPose: Nullable<DevicePose>;
  15258. private _onVREnabled;
  15259. private _specsVersion;
  15260. private _attached;
  15261. private _frameData;
  15262. protected _descendants: Array<Node>;
  15263. private _deviceRoomPosition;
  15264. /** @hidden */
  15265. _deviceRoomRotationQuaternion: Quaternion;
  15266. private _standingMatrix;
  15267. /**
  15268. * Represents device position in babylon space.
  15269. */
  15270. devicePosition: Vector3;
  15271. /**
  15272. * Represents device rotation in babylon space.
  15273. */
  15274. deviceRotationQuaternion: Quaternion;
  15275. /**
  15276. * The scale of the device to be used when translating from device space to babylon space.
  15277. */
  15278. deviceScaleFactor: number;
  15279. private _deviceToWorld;
  15280. private _worldToDevice;
  15281. /**
  15282. * References to the webVR controllers for the vrDevice.
  15283. */
  15284. controllers: Array<WebVRController>;
  15285. /**
  15286. * Emits an event when a controller is attached.
  15287. */
  15288. onControllersAttachedObservable: Observable<WebVRController[]>;
  15289. /**
  15290. * Emits an event when a controller's mesh has been loaded;
  15291. */
  15292. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15293. /**
  15294. * Emits an event when the HMD's pose has been updated.
  15295. */
  15296. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15297. private _poseSet;
  15298. /**
  15299. * If the rig cameras be used as parent instead of this camera.
  15300. */
  15301. rigParenting: boolean;
  15302. private _lightOnControllers;
  15303. private _defaultHeight?;
  15304. /**
  15305. * Instantiates a WebVRFreeCamera.
  15306. * @param name The name of the WebVRFreeCamera
  15307. * @param position The starting anchor position for the camera
  15308. * @param scene The scene the camera belongs to
  15309. * @param webVROptions a set of customizable options for the webVRCamera
  15310. */
  15311. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15312. /**
  15313. * Gets the device distance from the ground in meters.
  15314. * @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.
  15315. */
  15316. deviceDistanceToRoomGround(): number;
  15317. /**
  15318. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15319. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15320. */
  15321. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15322. /**
  15323. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15324. * @returns A promise with a boolean set to if the standing matrix is supported.
  15325. */
  15326. useStandingMatrixAsync(): Promise<boolean>;
  15327. /**
  15328. * Disposes the camera
  15329. */
  15330. dispose(): void;
  15331. /**
  15332. * Gets a vrController by name.
  15333. * @param name The name of the controller to retreive
  15334. * @returns the controller matching the name specified or null if not found
  15335. */
  15336. getControllerByName(name: string): Nullable<WebVRController>;
  15337. private _leftController;
  15338. /**
  15339. * The controller corresponding to the users left hand.
  15340. */
  15341. readonly leftController: Nullable<WebVRController>;
  15342. private _rightController;
  15343. /**
  15344. * The controller corresponding to the users right hand.
  15345. */
  15346. readonly rightController: Nullable<WebVRController>;
  15347. /**
  15348. * Casts a ray forward from the vrCamera's gaze.
  15349. * @param length Length of the ray (default: 100)
  15350. * @returns the ray corresponding to the gaze
  15351. */
  15352. getForwardRay(length?: number): Ray;
  15353. /**
  15354. * @hidden
  15355. * Updates the camera based on device's frame data
  15356. */
  15357. _checkInputs(): void;
  15358. /**
  15359. * Updates the poseControlled values based on the input device pose.
  15360. * @param poseData Pose coming from the device
  15361. */
  15362. updateFromDevice(poseData: DevicePose): void;
  15363. private _htmlElementAttached;
  15364. private _detachIfAttached;
  15365. /**
  15366. * WebVR's attach control will start broadcasting frames to the device.
  15367. * Note that in certain browsers (chrome for example) this function must be called
  15368. * within a user-interaction callback. Example:
  15369. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15370. *
  15371. * @param element html element to attach the vrDevice to
  15372. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15373. */
  15374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15375. /**
  15376. * Detaches the camera from the html element and disables VR
  15377. *
  15378. * @param element html element to detach from
  15379. */
  15380. detachControl(element: HTMLElement): void;
  15381. /**
  15382. * @returns the name of this class
  15383. */
  15384. getClassName(): string;
  15385. /**
  15386. * Calls resetPose on the vrDisplay
  15387. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15388. */
  15389. resetToCurrentRotation(): void;
  15390. /**
  15391. * @hidden
  15392. * Updates the rig cameras (left and right eye)
  15393. */
  15394. _updateRigCameras(): void;
  15395. private _workingVector;
  15396. private _oneVector;
  15397. private _workingMatrix;
  15398. private updateCacheCalled;
  15399. private _correctPositionIfNotTrackPosition;
  15400. /**
  15401. * @hidden
  15402. * Updates the cached values of the camera
  15403. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15404. */
  15405. _updateCache(ignoreParentClass?: boolean): void;
  15406. /**
  15407. * @hidden
  15408. * Get current device position in babylon world
  15409. */
  15410. _computeDevicePosition(): void;
  15411. /**
  15412. * Updates the current device position and rotation in the babylon world
  15413. */
  15414. update(): void;
  15415. /**
  15416. * @hidden
  15417. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15418. * @returns an identity matrix
  15419. */
  15420. _getViewMatrix(): Matrix;
  15421. private _tmpMatrix;
  15422. /**
  15423. * This function is called by the two RIG cameras.
  15424. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15425. * @hidden
  15426. */
  15427. _getWebVRViewMatrix(): Matrix;
  15428. /** @hidden */
  15429. _getWebVRProjectionMatrix(): Matrix;
  15430. private _onGamepadConnectedObserver;
  15431. private _onGamepadDisconnectedObserver;
  15432. private _updateCacheWhenTrackingDisabledObserver;
  15433. /**
  15434. * Initializes the controllers and their meshes
  15435. */
  15436. initControllers(): void;
  15437. }
  15438. }
  15439. declare module "babylonjs/PostProcesses/postProcess" {
  15440. import { Nullable } from "babylonjs/types";
  15441. import { SmartArray } from "babylonjs/Misc/smartArray";
  15442. import { Observable } from "babylonjs/Misc/observable";
  15443. import { Vector2 } from "babylonjs/Maths/math.vector";
  15444. import { Camera } from "babylonjs/Cameras/camera";
  15445. import { Effect } from "babylonjs/Materials/effect";
  15446. import "babylonjs/Shaders/postprocess.vertex";
  15447. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15448. import { Engine } from "babylonjs/Engines/engine";
  15449. import { Color4 } from "babylonjs/Maths/math.color";
  15450. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15451. /**
  15452. * Size options for a post process
  15453. */
  15454. export type PostProcessOptions = {
  15455. width: number;
  15456. height: number;
  15457. };
  15458. /**
  15459. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15460. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15461. */
  15462. export class PostProcess {
  15463. /** Name of the PostProcess. */
  15464. name: string;
  15465. /**
  15466. * Gets or sets the unique id of the post process
  15467. */
  15468. uniqueId: number;
  15469. /**
  15470. * Width of the texture to apply the post process on
  15471. */
  15472. width: number;
  15473. /**
  15474. * Height of the texture to apply the post process on
  15475. */
  15476. height: number;
  15477. /**
  15478. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15479. * @hidden
  15480. */
  15481. _outputTexture: Nullable<InternalTexture>;
  15482. /**
  15483. * Sampling mode used by the shader
  15484. * See https://doc.babylonjs.com/classes/3.1/texture
  15485. */
  15486. renderTargetSamplingMode: number;
  15487. /**
  15488. * Clear color to use when screen clearing
  15489. */
  15490. clearColor: Color4;
  15491. /**
  15492. * If the buffer needs to be cleared before applying the post process. (default: true)
  15493. * Should be set to false if shader will overwrite all previous pixels.
  15494. */
  15495. autoClear: boolean;
  15496. /**
  15497. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15498. */
  15499. alphaMode: number;
  15500. /**
  15501. * Sets the setAlphaBlendConstants of the babylon engine
  15502. */
  15503. alphaConstants: Color4;
  15504. /**
  15505. * Animations to be used for the post processing
  15506. */
  15507. animations: import("babylonjs/Animations/animation").Animation[];
  15508. /**
  15509. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15510. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15511. */
  15512. enablePixelPerfectMode: boolean;
  15513. /**
  15514. * Force the postprocess to be applied without taking in account viewport
  15515. */
  15516. forceFullscreenViewport: boolean;
  15517. /**
  15518. * List of inspectable custom properties (used by the Inspector)
  15519. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15520. */
  15521. inspectableCustomProperties: IInspectable[];
  15522. /**
  15523. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15524. *
  15525. * | Value | Type | Description |
  15526. * | ----- | ----------------------------------- | ----------- |
  15527. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15528. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15529. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15530. *
  15531. */
  15532. scaleMode: number;
  15533. /**
  15534. * Force textures to be a power of two (default: false)
  15535. */
  15536. alwaysForcePOT: boolean;
  15537. private _samples;
  15538. /**
  15539. * Number of sample textures (default: 1)
  15540. */
  15541. samples: number;
  15542. /**
  15543. * Modify the scale of the post process to be the same as the viewport (default: false)
  15544. */
  15545. adaptScaleToCurrentViewport: boolean;
  15546. private _camera;
  15547. private _scene;
  15548. private _engine;
  15549. private _options;
  15550. private _reusable;
  15551. private _textureType;
  15552. /**
  15553. * Smart array of input and output textures for the post process.
  15554. * @hidden
  15555. */
  15556. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15557. /**
  15558. * The index in _textures that corresponds to the output texture.
  15559. * @hidden
  15560. */
  15561. _currentRenderTextureInd: number;
  15562. private _effect;
  15563. private _samplers;
  15564. private _fragmentUrl;
  15565. private _vertexUrl;
  15566. private _parameters;
  15567. private _scaleRatio;
  15568. protected _indexParameters: any;
  15569. private _shareOutputWithPostProcess;
  15570. private _texelSize;
  15571. private _forcedOutputTexture;
  15572. /**
  15573. * Returns the fragment url or shader name used in the post process.
  15574. * @returns the fragment url or name in the shader store.
  15575. */
  15576. getEffectName(): string;
  15577. /**
  15578. * An event triggered when the postprocess is activated.
  15579. */
  15580. onActivateObservable: Observable<Camera>;
  15581. private _onActivateObserver;
  15582. /**
  15583. * A function that is added to the onActivateObservable
  15584. */
  15585. onActivate: Nullable<(camera: Camera) => void>;
  15586. /**
  15587. * An event triggered when the postprocess changes its size.
  15588. */
  15589. onSizeChangedObservable: Observable<PostProcess>;
  15590. private _onSizeChangedObserver;
  15591. /**
  15592. * A function that is added to the onSizeChangedObservable
  15593. */
  15594. onSizeChanged: (postProcess: PostProcess) => void;
  15595. /**
  15596. * An event triggered when the postprocess applies its effect.
  15597. */
  15598. onApplyObservable: Observable<Effect>;
  15599. private _onApplyObserver;
  15600. /**
  15601. * A function that is added to the onApplyObservable
  15602. */
  15603. onApply: (effect: Effect) => void;
  15604. /**
  15605. * An event triggered before rendering the postprocess
  15606. */
  15607. onBeforeRenderObservable: Observable<Effect>;
  15608. private _onBeforeRenderObserver;
  15609. /**
  15610. * A function that is added to the onBeforeRenderObservable
  15611. */
  15612. onBeforeRender: (effect: Effect) => void;
  15613. /**
  15614. * An event triggered after rendering the postprocess
  15615. */
  15616. onAfterRenderObservable: Observable<Effect>;
  15617. private _onAfterRenderObserver;
  15618. /**
  15619. * A function that is added to the onAfterRenderObservable
  15620. */
  15621. onAfterRender: (efect: Effect) => void;
  15622. /**
  15623. * 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
  15624. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15625. */
  15626. inputTexture: InternalTexture;
  15627. /**
  15628. * Gets the camera which post process is applied to.
  15629. * @returns The camera the post process is applied to.
  15630. */
  15631. getCamera(): Camera;
  15632. /**
  15633. * Gets the texel size of the postprocess.
  15634. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15635. */
  15636. readonly texelSize: Vector2;
  15637. /**
  15638. * Creates a new instance PostProcess
  15639. * @param name The name of the PostProcess.
  15640. * @param fragmentUrl The url of the fragment shader to be used.
  15641. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15642. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15643. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15644. * @param camera The camera to apply the render pass to.
  15645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15646. * @param engine The engine which the post process will be applied. (default: current engine)
  15647. * @param reusable If the post process can be reused on the same frame. (default: false)
  15648. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15649. * @param textureType Type of textures used when performing the post process. (default: 0)
  15650. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15651. * @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
  15652. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15653. */
  15654. constructor(
  15655. /** Name of the PostProcess. */
  15656. 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);
  15657. /**
  15658. * Gets a string idenfifying the name of the class
  15659. * @returns "PostProcess" string
  15660. */
  15661. getClassName(): string;
  15662. /**
  15663. * Gets the engine which this post process belongs to.
  15664. * @returns The engine the post process was enabled with.
  15665. */
  15666. getEngine(): Engine;
  15667. /**
  15668. * The effect that is created when initializing the post process.
  15669. * @returns The created effect corresponding the the postprocess.
  15670. */
  15671. getEffect(): Effect;
  15672. /**
  15673. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15674. * @param postProcess The post process to share the output with.
  15675. * @returns This post process.
  15676. */
  15677. shareOutputWith(postProcess: PostProcess): PostProcess;
  15678. /**
  15679. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15680. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15681. */
  15682. useOwnOutput(): void;
  15683. /**
  15684. * Updates the effect with the current post process compile time values and recompiles the shader.
  15685. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15686. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15687. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15688. * @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
  15689. * @param onCompiled Called when the shader has been compiled.
  15690. * @param onError Called if there is an error when compiling a shader.
  15691. */
  15692. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15693. /**
  15694. * The post process is reusable if it can be used multiple times within one frame.
  15695. * @returns If the post process is reusable
  15696. */
  15697. isReusable(): boolean;
  15698. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15699. markTextureDirty(): void;
  15700. /**
  15701. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15702. * 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.
  15703. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15704. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15705. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15706. * @returns The target texture that was bound to be written to.
  15707. */
  15708. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15709. /**
  15710. * If the post process is supported.
  15711. */
  15712. readonly isSupported: boolean;
  15713. /**
  15714. * The aspect ratio of the output texture.
  15715. */
  15716. readonly aspectRatio: number;
  15717. /**
  15718. * Get a value indicating if the post-process is ready to be used
  15719. * @returns true if the post-process is ready (shader is compiled)
  15720. */
  15721. isReady(): boolean;
  15722. /**
  15723. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15724. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15725. */
  15726. apply(): Nullable<Effect>;
  15727. private _disposeTextures;
  15728. /**
  15729. * Disposes the post process.
  15730. * @param camera The camera to dispose the post process on.
  15731. */
  15732. dispose(camera?: Camera): void;
  15733. }
  15734. }
  15735. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15736. /** @hidden */
  15737. export var kernelBlurVaryingDeclaration: {
  15738. name: string;
  15739. shader: string;
  15740. };
  15741. }
  15742. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15743. /** @hidden */
  15744. export var kernelBlurFragment: {
  15745. name: string;
  15746. shader: string;
  15747. };
  15748. }
  15749. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15750. /** @hidden */
  15751. export var kernelBlurFragment2: {
  15752. name: string;
  15753. shader: string;
  15754. };
  15755. }
  15756. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15757. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15758. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15759. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15760. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15761. /** @hidden */
  15762. export var kernelBlurPixelShader: {
  15763. name: string;
  15764. shader: string;
  15765. };
  15766. }
  15767. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15768. /** @hidden */
  15769. export var kernelBlurVertex: {
  15770. name: string;
  15771. shader: string;
  15772. };
  15773. }
  15774. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15775. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15776. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15777. /** @hidden */
  15778. export var kernelBlurVertexShader: {
  15779. name: string;
  15780. shader: string;
  15781. };
  15782. }
  15783. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15784. import { Vector2 } from "babylonjs/Maths/math.vector";
  15785. import { Nullable } from "babylonjs/types";
  15786. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15787. import { Camera } from "babylonjs/Cameras/camera";
  15788. import { Effect } from "babylonjs/Materials/effect";
  15789. import { Engine } from "babylonjs/Engines/engine";
  15790. import "babylonjs/Shaders/kernelBlur.fragment";
  15791. import "babylonjs/Shaders/kernelBlur.vertex";
  15792. /**
  15793. * The Blur Post Process which blurs an image based on a kernel and direction.
  15794. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15795. */
  15796. export class BlurPostProcess extends PostProcess {
  15797. /** The direction in which to blur the image. */
  15798. direction: Vector2;
  15799. private blockCompilation;
  15800. protected _kernel: number;
  15801. protected _idealKernel: number;
  15802. protected _packedFloat: boolean;
  15803. private _staticDefines;
  15804. /**
  15805. * Sets the length in pixels of the blur sample region
  15806. */
  15807. /**
  15808. * Gets the length in pixels of the blur sample region
  15809. */
  15810. kernel: number;
  15811. /**
  15812. * Sets wether or not the blur needs to unpack/repack floats
  15813. */
  15814. /**
  15815. * Gets wether or not the blur is unpacking/repacking floats
  15816. */
  15817. packedFloat: boolean;
  15818. /**
  15819. * Creates a new instance BlurPostProcess
  15820. * @param name The name of the effect.
  15821. * @param direction The direction in which to blur the image.
  15822. * @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.
  15823. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15824. * @param camera The camera to apply the render pass to.
  15825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15826. * @param engine The engine which the post process will be applied. (default: current engine)
  15827. * @param reusable If the post process can be reused on the same frame. (default: false)
  15828. * @param textureType Type of textures used when performing the post process. (default: 0)
  15829. * @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)
  15830. */
  15831. constructor(name: string,
  15832. /** The direction in which to blur the image. */
  15833. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15834. /**
  15835. * Updates the effect with the current post process compile time values and recompiles the shader.
  15836. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15837. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15838. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15839. * @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
  15840. * @param onCompiled Called when the shader has been compiled.
  15841. * @param onError Called if there is an error when compiling a shader.
  15842. */
  15843. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15844. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15845. /**
  15846. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15847. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15848. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15849. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15850. * The gaps between physical kernels are compensated for in the weighting of the samples
  15851. * @param idealKernel Ideal blur kernel.
  15852. * @return Nearest best kernel.
  15853. */
  15854. protected _nearestBestKernel(idealKernel: number): number;
  15855. /**
  15856. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15857. * @param x The point on the Gaussian distribution to sample.
  15858. * @return the value of the Gaussian function at x.
  15859. */
  15860. protected _gaussianWeight(x: number): number;
  15861. /**
  15862. * Generates a string that can be used as a floating point number in GLSL.
  15863. * @param x Value to print.
  15864. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15865. * @return GLSL float string.
  15866. */
  15867. protected _glslFloat(x: number, decimalFigures?: number): string;
  15868. }
  15869. }
  15870. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15871. import { Scene } from "babylonjs/scene";
  15872. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15873. import { Plane } from "babylonjs/Maths/math.plane";
  15874. /**
  15875. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15876. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15877. * You can then easily use it as a reflectionTexture on a flat surface.
  15878. * In case the surface is not a plane, please consider relying on reflection probes.
  15879. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15880. */
  15881. export class MirrorTexture extends RenderTargetTexture {
  15882. private scene;
  15883. /**
  15884. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15885. * 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.
  15886. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15887. */
  15888. mirrorPlane: Plane;
  15889. /**
  15890. * Define the blur ratio used to blur the reflection if needed.
  15891. */
  15892. blurRatio: number;
  15893. /**
  15894. * Define the adaptive blur kernel used to blur the reflection if needed.
  15895. * This will autocompute the closest best match for the `blurKernel`
  15896. */
  15897. adaptiveBlurKernel: number;
  15898. /**
  15899. * Define the blur kernel used to blur the reflection if needed.
  15900. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15901. */
  15902. blurKernel: number;
  15903. /**
  15904. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15905. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15906. */
  15907. blurKernelX: number;
  15908. /**
  15909. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15910. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15911. */
  15912. blurKernelY: number;
  15913. private _autoComputeBlurKernel;
  15914. protected _onRatioRescale(): void;
  15915. private _updateGammaSpace;
  15916. private _imageProcessingConfigChangeObserver;
  15917. private _transformMatrix;
  15918. private _mirrorMatrix;
  15919. private _savedViewMatrix;
  15920. private _blurX;
  15921. private _blurY;
  15922. private _adaptiveBlurKernel;
  15923. private _blurKernelX;
  15924. private _blurKernelY;
  15925. private _blurRatio;
  15926. /**
  15927. * Instantiates a Mirror Texture.
  15928. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15929. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15930. * You can then easily use it as a reflectionTexture on a flat surface.
  15931. * In case the surface is not a plane, please consider relying on reflection probes.
  15932. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15933. * @param name
  15934. * @param size
  15935. * @param scene
  15936. * @param generateMipMaps
  15937. * @param type
  15938. * @param samplingMode
  15939. * @param generateDepthBuffer
  15940. */
  15941. constructor(name: string, size: number | {
  15942. width: number;
  15943. height: number;
  15944. } | {
  15945. ratio: number;
  15946. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15947. private _preparePostProcesses;
  15948. /**
  15949. * Clone the mirror texture.
  15950. * @returns the cloned texture
  15951. */
  15952. clone(): MirrorTexture;
  15953. /**
  15954. * Serialize the texture to a JSON representation you could use in Parse later on
  15955. * @returns the serialized JSON representation
  15956. */
  15957. serialize(): any;
  15958. /**
  15959. * Dispose the texture and release its associated resources.
  15960. */
  15961. dispose(): void;
  15962. }
  15963. }
  15964. declare module "babylonjs/Materials/Textures/texture" {
  15965. import { Observable } from "babylonjs/Misc/observable";
  15966. import { Nullable } from "babylonjs/types";
  15967. import { Scene } from "babylonjs/scene";
  15968. import { Matrix } from "babylonjs/Maths/math.vector";
  15969. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15970. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15971. import { Engine } from "babylonjs/Engines/engine";
  15972. /**
  15973. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15974. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15975. */
  15976. export class Texture extends BaseTexture {
  15977. /**
  15978. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15979. */
  15980. static SerializeBuffers: boolean;
  15981. /** @hidden */
  15982. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15983. /** @hidden */
  15984. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15985. /** @hidden */
  15986. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15987. /** nearest is mag = nearest and min = nearest and mip = linear */
  15988. static readonly NEAREST_SAMPLINGMODE: number;
  15989. /** nearest is mag = nearest and min = nearest and mip = linear */
  15990. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15991. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15992. static readonly BILINEAR_SAMPLINGMODE: number;
  15993. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15994. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15995. /** Trilinear is mag = linear and min = linear and mip = linear */
  15996. static readonly TRILINEAR_SAMPLINGMODE: number;
  15997. /** Trilinear is mag = linear and min = linear and mip = linear */
  15998. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15999. /** mag = nearest and min = nearest and mip = nearest */
  16000. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16001. /** mag = nearest and min = linear and mip = nearest */
  16002. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16003. /** mag = nearest and min = linear and mip = linear */
  16004. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16005. /** mag = nearest and min = linear and mip = none */
  16006. static readonly NEAREST_LINEAR: number;
  16007. /** mag = nearest and min = nearest and mip = none */
  16008. static readonly NEAREST_NEAREST: number;
  16009. /** mag = linear and min = nearest and mip = nearest */
  16010. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16011. /** mag = linear and min = nearest and mip = linear */
  16012. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16013. /** mag = linear and min = linear and mip = none */
  16014. static readonly LINEAR_LINEAR: number;
  16015. /** mag = linear and min = nearest and mip = none */
  16016. static readonly LINEAR_NEAREST: number;
  16017. /** Explicit coordinates mode */
  16018. static readonly EXPLICIT_MODE: number;
  16019. /** Spherical coordinates mode */
  16020. static readonly SPHERICAL_MODE: number;
  16021. /** Planar coordinates mode */
  16022. static readonly PLANAR_MODE: number;
  16023. /** Cubic coordinates mode */
  16024. static readonly CUBIC_MODE: number;
  16025. /** Projection coordinates mode */
  16026. static readonly PROJECTION_MODE: number;
  16027. /** Inverse Cubic coordinates mode */
  16028. static readonly SKYBOX_MODE: number;
  16029. /** Inverse Cubic coordinates mode */
  16030. static readonly INVCUBIC_MODE: number;
  16031. /** Equirectangular coordinates mode */
  16032. static readonly EQUIRECTANGULAR_MODE: number;
  16033. /** Equirectangular Fixed coordinates mode */
  16034. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16035. /** Equirectangular Fixed Mirrored coordinates mode */
  16036. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16037. /** Texture is not repeating outside of 0..1 UVs */
  16038. static readonly CLAMP_ADDRESSMODE: number;
  16039. /** Texture is repeating outside of 0..1 UVs */
  16040. static readonly WRAP_ADDRESSMODE: number;
  16041. /** Texture is repeating and mirrored */
  16042. static readonly MIRROR_ADDRESSMODE: number;
  16043. /**
  16044. * 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
  16045. */
  16046. static UseSerializedUrlIfAny: boolean;
  16047. /**
  16048. * Define the url of the texture.
  16049. */
  16050. url: Nullable<string>;
  16051. /**
  16052. * Define an offset on the texture to offset the u coordinates of the UVs
  16053. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16054. */
  16055. uOffset: number;
  16056. /**
  16057. * Define an offset on the texture to offset the v coordinates of the UVs
  16058. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16059. */
  16060. vOffset: number;
  16061. /**
  16062. * Define an offset on the texture to scale the u coordinates of the UVs
  16063. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16064. */
  16065. uScale: number;
  16066. /**
  16067. * Define an offset on the texture to scale the v coordinates of the UVs
  16068. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16069. */
  16070. vScale: number;
  16071. /**
  16072. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16073. * @see http://doc.babylonjs.com/how_to/more_materials
  16074. */
  16075. uAng: number;
  16076. /**
  16077. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16078. * @see http://doc.babylonjs.com/how_to/more_materials
  16079. */
  16080. vAng: number;
  16081. /**
  16082. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16083. * @see http://doc.babylonjs.com/how_to/more_materials
  16084. */
  16085. wAng: number;
  16086. /**
  16087. * Defines the center of rotation (U)
  16088. */
  16089. uRotationCenter: number;
  16090. /**
  16091. * Defines the center of rotation (V)
  16092. */
  16093. vRotationCenter: number;
  16094. /**
  16095. * Defines the center of rotation (W)
  16096. */
  16097. wRotationCenter: number;
  16098. /**
  16099. * Are mip maps generated for this texture or not.
  16100. */
  16101. readonly noMipmap: boolean;
  16102. /**
  16103. * List of inspectable custom properties (used by the Inspector)
  16104. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16105. */
  16106. inspectableCustomProperties: Nullable<IInspectable[]>;
  16107. private _noMipmap;
  16108. /** @hidden */
  16109. _invertY: boolean;
  16110. private _rowGenerationMatrix;
  16111. private _cachedTextureMatrix;
  16112. private _projectionModeMatrix;
  16113. private _t0;
  16114. private _t1;
  16115. private _t2;
  16116. private _cachedUOffset;
  16117. private _cachedVOffset;
  16118. private _cachedUScale;
  16119. private _cachedVScale;
  16120. private _cachedUAng;
  16121. private _cachedVAng;
  16122. private _cachedWAng;
  16123. private _cachedProjectionMatrixId;
  16124. private _cachedCoordinatesMode;
  16125. /** @hidden */
  16126. protected _initialSamplingMode: number;
  16127. /** @hidden */
  16128. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16129. private _deleteBuffer;
  16130. protected _format: Nullable<number>;
  16131. private _delayedOnLoad;
  16132. private _delayedOnError;
  16133. /**
  16134. * Observable triggered once the texture has been loaded.
  16135. */
  16136. onLoadObservable: Observable<Texture>;
  16137. protected _isBlocking: boolean;
  16138. /**
  16139. * Is the texture preventing material to render while loading.
  16140. * If false, a default texture will be used instead of the loading one during the preparation step.
  16141. */
  16142. isBlocking: boolean;
  16143. /**
  16144. * Get the current sampling mode associated with the texture.
  16145. */
  16146. readonly samplingMode: number;
  16147. /**
  16148. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16149. */
  16150. readonly invertY: boolean;
  16151. /**
  16152. * Instantiates a new texture.
  16153. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16154. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16155. * @param url define the url of the picture to load as a texture
  16156. * @param scene define the scene or engine the texture will belong to
  16157. * @param noMipmap define if the texture will require mip maps or not
  16158. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16159. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16160. * @param onLoad define a callback triggered when the texture has been loaded
  16161. * @param onError define a callback triggered when an error occurred during the loading session
  16162. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16163. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16164. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16165. */
  16166. 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);
  16167. /**
  16168. * Update the url (and optional buffer) of this texture if url was null during construction.
  16169. * @param url the url of the texture
  16170. * @param buffer the buffer of the texture (defaults to null)
  16171. * @param onLoad callback called when the texture is loaded (defaults to null)
  16172. */
  16173. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16174. /**
  16175. * Finish the loading sequence of a texture flagged as delayed load.
  16176. * @hidden
  16177. */
  16178. delayLoad(): void;
  16179. private _prepareRowForTextureGeneration;
  16180. /**
  16181. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16182. * @returns the transform matrix of the texture.
  16183. */
  16184. getTextureMatrix(): Matrix;
  16185. /**
  16186. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16187. * @returns The reflection texture transform
  16188. */
  16189. getReflectionTextureMatrix(): Matrix;
  16190. /**
  16191. * Clones the texture.
  16192. * @returns the cloned texture
  16193. */
  16194. clone(): Texture;
  16195. /**
  16196. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16197. * @returns The JSON representation of the texture
  16198. */
  16199. serialize(): any;
  16200. /**
  16201. * Get the current class name of the texture useful for serialization or dynamic coding.
  16202. * @returns "Texture"
  16203. */
  16204. getClassName(): string;
  16205. /**
  16206. * Dispose the texture and release its associated resources.
  16207. */
  16208. dispose(): void;
  16209. /**
  16210. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16211. * @param parsedTexture Define the JSON representation of the texture
  16212. * @param scene Define the scene the parsed texture should be instantiated in
  16213. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16214. * @returns The parsed texture if successful
  16215. */
  16216. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16217. /**
  16218. * Creates a texture from its base 64 representation.
  16219. * @param data Define the base64 payload without the data: prefix
  16220. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16221. * @param scene Define the scene the texture should belong to
  16222. * @param noMipmap Forces the texture to not create mip map information if true
  16223. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16224. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16225. * @param onLoad define a callback triggered when the texture has been loaded
  16226. * @param onError define a callback triggered when an error occurred during the loading session
  16227. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16228. * @returns the created texture
  16229. */
  16230. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16231. /**
  16232. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16233. * @param data Define the base64 payload without the data: prefix
  16234. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16235. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16236. * @param scene Define the scene the texture should belong to
  16237. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16238. * @param noMipmap Forces the texture to not create mip map information if true
  16239. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16240. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16241. * @param onLoad define a callback triggered when the texture has been loaded
  16242. * @param onError define a callback triggered when an error occurred during the loading session
  16243. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16244. * @returns the created texture
  16245. */
  16246. 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;
  16247. }
  16248. }
  16249. declare module "babylonjs/PostProcesses/postProcessManager" {
  16250. import { Nullable } from "babylonjs/types";
  16251. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16252. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16253. import { Scene } from "babylonjs/scene";
  16254. /**
  16255. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16256. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16257. */
  16258. export class PostProcessManager {
  16259. private _scene;
  16260. private _indexBuffer;
  16261. private _vertexBuffers;
  16262. /**
  16263. * Creates a new instance PostProcess
  16264. * @param scene The scene that the post process is associated with.
  16265. */
  16266. constructor(scene: Scene);
  16267. private _prepareBuffers;
  16268. private _buildIndexBuffer;
  16269. /**
  16270. * Rebuilds the vertex buffers of the manager.
  16271. * @hidden
  16272. */
  16273. _rebuild(): void;
  16274. /**
  16275. * Prepares a frame to be run through a post process.
  16276. * @param sourceTexture The input texture to the post procesess. (default: null)
  16277. * @param postProcesses An array of post processes to be run. (default: null)
  16278. * @returns True if the post processes were able to be run.
  16279. * @hidden
  16280. */
  16281. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16282. /**
  16283. * Manually render a set of post processes to a texture.
  16284. * @param postProcesses An array of post processes to be run.
  16285. * @param targetTexture The target texture to render to.
  16286. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16287. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16288. * @param lodLevel defines which lod of the texture to render to
  16289. */
  16290. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16291. /**
  16292. * Finalize the result of the output of the postprocesses.
  16293. * @param doNotPresent If true the result will not be displayed to the screen.
  16294. * @param targetTexture The target texture to render to.
  16295. * @param faceIndex The index of the face to bind the target texture to.
  16296. * @param postProcesses The array of post processes to render.
  16297. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16298. * @hidden
  16299. */
  16300. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16301. /**
  16302. * Disposes of the post process manager.
  16303. */
  16304. dispose(): void;
  16305. }
  16306. }
  16307. declare module "babylonjs/Misc/gradients" {
  16308. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16309. /** Interface used by value gradients (color, factor, ...) */
  16310. export interface IValueGradient {
  16311. /**
  16312. * Gets or sets the gradient value (between 0 and 1)
  16313. */
  16314. gradient: number;
  16315. }
  16316. /** Class used to store color4 gradient */
  16317. export class ColorGradient implements IValueGradient {
  16318. /**
  16319. * Gets or sets the gradient value (between 0 and 1)
  16320. */
  16321. gradient: number;
  16322. /**
  16323. * Gets or sets first associated color
  16324. */
  16325. color1: Color4;
  16326. /**
  16327. * Gets or sets second associated color
  16328. */
  16329. color2?: Color4;
  16330. /**
  16331. * Will get a color picked randomly between color1 and color2.
  16332. * If color2 is undefined then color1 will be used
  16333. * @param result defines the target Color4 to store the result in
  16334. */
  16335. getColorToRef(result: Color4): void;
  16336. }
  16337. /** Class used to store color 3 gradient */
  16338. export class Color3Gradient implements IValueGradient {
  16339. /**
  16340. * Gets or sets the gradient value (between 0 and 1)
  16341. */
  16342. gradient: number;
  16343. /**
  16344. * Gets or sets the associated color
  16345. */
  16346. color: Color3;
  16347. }
  16348. /** Class used to store factor gradient */
  16349. export class FactorGradient implements IValueGradient {
  16350. /**
  16351. * Gets or sets the gradient value (between 0 and 1)
  16352. */
  16353. gradient: number;
  16354. /**
  16355. * Gets or sets first associated factor
  16356. */
  16357. factor1: number;
  16358. /**
  16359. * Gets or sets second associated factor
  16360. */
  16361. factor2?: number;
  16362. /**
  16363. * Will get a number picked randomly between factor1 and factor2.
  16364. * If factor2 is undefined then factor1 will be used
  16365. * @returns the picked number
  16366. */
  16367. getFactor(): number;
  16368. }
  16369. /**
  16370. * Helper used to simplify some generic gradient tasks
  16371. */
  16372. export class GradientHelper {
  16373. /**
  16374. * Gets the current gradient from an array of IValueGradient
  16375. * @param ratio defines the current ratio to get
  16376. * @param gradients defines the array of IValueGradient
  16377. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16378. */
  16379. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16380. }
  16381. }
  16382. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16383. import { Scene } from "babylonjs/scene";
  16384. import { Texture } from "babylonjs/Materials/Textures/texture";
  16385. /**
  16386. * A class extending Texture allowing drawing on a texture
  16387. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16388. */
  16389. export class DynamicTexture extends Texture {
  16390. private _generateMipMaps;
  16391. private _canvas;
  16392. private _context;
  16393. private _engine;
  16394. /**
  16395. * Creates a DynamicTexture
  16396. * @param name defines the name of the texture
  16397. * @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
  16398. * @param scene defines the scene where you want the texture
  16399. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16400. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16401. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16402. */
  16403. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16404. /**
  16405. * Get the current class name of the texture useful for serialization or dynamic coding.
  16406. * @returns "DynamicTexture"
  16407. */
  16408. getClassName(): string;
  16409. /**
  16410. * Gets the current state of canRescale
  16411. */
  16412. readonly canRescale: boolean;
  16413. private _recreate;
  16414. /**
  16415. * Scales the texture
  16416. * @param ratio the scale factor to apply to both width and height
  16417. */
  16418. scale(ratio: number): void;
  16419. /**
  16420. * Resizes the texture
  16421. * @param width the new width
  16422. * @param height the new height
  16423. */
  16424. scaleTo(width: number, height: number): void;
  16425. /**
  16426. * Gets the context of the canvas used by the texture
  16427. * @returns the canvas context of the dynamic texture
  16428. */
  16429. getContext(): CanvasRenderingContext2D;
  16430. /**
  16431. * Clears the texture
  16432. */
  16433. clear(): void;
  16434. /**
  16435. * Updates the texture
  16436. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16437. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16438. */
  16439. update(invertY?: boolean, premulAlpha?: boolean): void;
  16440. /**
  16441. * Draws text onto the texture
  16442. * @param text defines the text to be drawn
  16443. * @param x defines the placement of the text from the left
  16444. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16445. * @param font defines the font to be used with font-style, font-size, font-name
  16446. * @param color defines the color used for the text
  16447. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16448. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16449. * @param update defines whether texture is immediately update (default is true)
  16450. */
  16451. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16452. /**
  16453. * Clones the texture
  16454. * @returns the clone of the texture.
  16455. */
  16456. clone(): DynamicTexture;
  16457. /**
  16458. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16459. * @returns a serialized dynamic texture object
  16460. */
  16461. serialize(): any;
  16462. /** @hidden */
  16463. _rebuild(): void;
  16464. }
  16465. }
  16466. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16467. import { Scene } from "babylonjs/scene";
  16468. import { ISceneComponent } from "babylonjs/sceneComponent";
  16469. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16470. module "babylonjs/abstractScene" {
  16471. interface AbstractScene {
  16472. /**
  16473. * The list of procedural textures added to the scene
  16474. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16475. */
  16476. proceduralTextures: Array<ProceduralTexture>;
  16477. }
  16478. }
  16479. /**
  16480. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16481. * in a given scene.
  16482. */
  16483. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16484. /**
  16485. * The component name helpfull to identify the component in the list of scene components.
  16486. */
  16487. readonly name: string;
  16488. /**
  16489. * The scene the component belongs to.
  16490. */
  16491. scene: Scene;
  16492. /**
  16493. * Creates a new instance of the component for the given scene
  16494. * @param scene Defines the scene to register the component in
  16495. */
  16496. constructor(scene: Scene);
  16497. /**
  16498. * Registers the component in a given scene
  16499. */
  16500. register(): void;
  16501. /**
  16502. * Rebuilds the elements related to this component in case of
  16503. * context lost for instance.
  16504. */
  16505. rebuild(): void;
  16506. /**
  16507. * Disposes the component and the associated ressources.
  16508. */
  16509. dispose(): void;
  16510. private _beforeClear;
  16511. }
  16512. }
  16513. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16514. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16515. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16516. module "babylonjs/Engines/engine" {
  16517. interface Engine {
  16518. /**
  16519. * Creates a new render target cube texture
  16520. * @param size defines the size of the texture
  16521. * @param options defines the options used to create the texture
  16522. * @returns a new render target cube texture stored in an InternalTexture
  16523. */
  16524. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16525. }
  16526. }
  16527. }
  16528. declare module "babylonjs/Shaders/procedural.vertex" {
  16529. /** @hidden */
  16530. export var proceduralVertexShader: {
  16531. name: string;
  16532. shader: string;
  16533. };
  16534. }
  16535. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16536. import { Observable } from "babylonjs/Misc/observable";
  16537. import { Nullable } from "babylonjs/types";
  16538. import { Scene } from "babylonjs/scene";
  16539. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16540. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16541. import { Effect } from "babylonjs/Materials/effect";
  16542. import { Texture } from "babylonjs/Materials/Textures/texture";
  16543. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16544. import "babylonjs/Shaders/procedural.vertex";
  16545. /**
  16546. * 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.
  16547. * This is the base class of any Procedural texture and contains most of the shareable code.
  16548. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16549. */
  16550. export class ProceduralTexture extends Texture {
  16551. isCube: boolean;
  16552. /**
  16553. * Define if the texture is enabled or not (disabled texture will not render)
  16554. */
  16555. isEnabled: boolean;
  16556. /**
  16557. * Define if the texture must be cleared before rendering (default is true)
  16558. */
  16559. autoClear: boolean;
  16560. /**
  16561. * Callback called when the texture is generated
  16562. */
  16563. onGenerated: () => void;
  16564. /**
  16565. * Event raised when the texture is generated
  16566. */
  16567. onGeneratedObservable: Observable<ProceduralTexture>;
  16568. /** @hidden */
  16569. _generateMipMaps: boolean;
  16570. /** @hidden **/
  16571. _effect: Effect;
  16572. /** @hidden */
  16573. _textures: {
  16574. [key: string]: Texture;
  16575. };
  16576. private _size;
  16577. private _currentRefreshId;
  16578. private _refreshRate;
  16579. private _vertexBuffers;
  16580. private _indexBuffer;
  16581. private _uniforms;
  16582. private _samplers;
  16583. private _fragment;
  16584. private _floats;
  16585. private _ints;
  16586. private _floatsArrays;
  16587. private _colors3;
  16588. private _colors4;
  16589. private _vectors2;
  16590. private _vectors3;
  16591. private _matrices;
  16592. private _fallbackTexture;
  16593. private _fallbackTextureUsed;
  16594. private _engine;
  16595. private _cachedDefines;
  16596. private _contentUpdateId;
  16597. private _contentData;
  16598. /**
  16599. * Instantiates a new procedural texture.
  16600. * 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.
  16601. * This is the base class of any Procedural texture and contains most of the shareable code.
  16602. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16603. * @param name Define the name of the texture
  16604. * @param size Define the size of the texture to create
  16605. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16606. * @param scene Define the scene the texture belongs to
  16607. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16608. * @param generateMipMaps Define if the texture should creates mip maps or not
  16609. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16610. */
  16611. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16612. /**
  16613. * The effect that is created when initializing the post process.
  16614. * @returns The created effect corresponding the the postprocess.
  16615. */
  16616. getEffect(): Effect;
  16617. /**
  16618. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16619. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16620. */
  16621. getContent(): Nullable<ArrayBufferView>;
  16622. private _createIndexBuffer;
  16623. /** @hidden */
  16624. _rebuild(): void;
  16625. /**
  16626. * Resets the texture in order to recreate its associated resources.
  16627. * This can be called in case of context loss
  16628. */
  16629. reset(): void;
  16630. protected _getDefines(): string;
  16631. /**
  16632. * Is the texture ready to be used ? (rendered at least once)
  16633. * @returns true if ready, otherwise, false.
  16634. */
  16635. isReady(): boolean;
  16636. /**
  16637. * Resets the refresh counter of the texture and start bak from scratch.
  16638. * Could be useful to regenerate the texture if it is setup to render only once.
  16639. */
  16640. resetRefreshCounter(): void;
  16641. /**
  16642. * Set the fragment shader to use in order to render the texture.
  16643. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16644. */
  16645. setFragment(fragment: any): void;
  16646. /**
  16647. * Define the refresh rate of the texture or the rendering frequency.
  16648. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16649. */
  16650. refreshRate: number;
  16651. /** @hidden */
  16652. _shouldRender(): boolean;
  16653. /**
  16654. * Get the size the texture is rendering at.
  16655. * @returns the size (texture is always squared)
  16656. */
  16657. getRenderSize(): number;
  16658. /**
  16659. * Resize the texture to new value.
  16660. * @param size Define the new size the texture should have
  16661. * @param generateMipMaps Define whether the new texture should create mip maps
  16662. */
  16663. resize(size: number, generateMipMaps: boolean): void;
  16664. private _checkUniform;
  16665. /**
  16666. * Set a texture in the shader program used to render.
  16667. * @param name Define the name of the uniform samplers as defined in the shader
  16668. * @param texture Define the texture to bind to this sampler
  16669. * @return the texture itself allowing "fluent" like uniform updates
  16670. */
  16671. setTexture(name: string, texture: Texture): ProceduralTexture;
  16672. /**
  16673. * Set a float in the shader.
  16674. * @param name Define the name of the uniform as defined in the shader
  16675. * @param value Define the value to give to the uniform
  16676. * @return the texture itself allowing "fluent" like uniform updates
  16677. */
  16678. setFloat(name: string, value: number): ProceduralTexture;
  16679. /**
  16680. * Set a int in the shader.
  16681. * @param name Define the name of the uniform as defined in the shader
  16682. * @param value Define the value to give to the uniform
  16683. * @return the texture itself allowing "fluent" like uniform updates
  16684. */
  16685. setInt(name: string, value: number): ProceduralTexture;
  16686. /**
  16687. * Set an array of floats in the shader.
  16688. * @param name Define the name of the uniform as defined in the shader
  16689. * @param value Define the value to give to the uniform
  16690. * @return the texture itself allowing "fluent" like uniform updates
  16691. */
  16692. setFloats(name: string, value: number[]): ProceduralTexture;
  16693. /**
  16694. * Set a vec3 in the shader from a Color3.
  16695. * @param name Define the name of the uniform as defined in the shader
  16696. * @param value Define the value to give to the uniform
  16697. * @return the texture itself allowing "fluent" like uniform updates
  16698. */
  16699. setColor3(name: string, value: Color3): ProceduralTexture;
  16700. /**
  16701. * Set a vec4 in the shader from a Color4.
  16702. * @param name Define the name of the uniform as defined in the shader
  16703. * @param value Define the value to give to the uniform
  16704. * @return the texture itself allowing "fluent" like uniform updates
  16705. */
  16706. setColor4(name: string, value: Color4): ProceduralTexture;
  16707. /**
  16708. * Set a vec2 in the shader from a Vector2.
  16709. * @param name Define the name of the uniform as defined in the shader
  16710. * @param value Define the value to give to the uniform
  16711. * @return the texture itself allowing "fluent" like uniform updates
  16712. */
  16713. setVector2(name: string, value: Vector2): ProceduralTexture;
  16714. /**
  16715. * Set a vec3 in the shader from a Vector3.
  16716. * @param name Define the name of the uniform as defined in the shader
  16717. * @param value Define the value to give to the uniform
  16718. * @return the texture itself allowing "fluent" like uniform updates
  16719. */
  16720. setVector3(name: string, value: Vector3): ProceduralTexture;
  16721. /**
  16722. * Set a mat4 in the shader from a MAtrix.
  16723. * @param name Define the name of the uniform as defined in the shader
  16724. * @param value Define the value to give to the uniform
  16725. * @return the texture itself allowing "fluent" like uniform updates
  16726. */
  16727. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16728. /**
  16729. * Render the texture to its associated render target.
  16730. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16731. */
  16732. render(useCameraPostProcess?: boolean): void;
  16733. /**
  16734. * Clone the texture.
  16735. * @returns the cloned texture
  16736. */
  16737. clone(): ProceduralTexture;
  16738. /**
  16739. * Dispose the texture and release its asoociated resources.
  16740. */
  16741. dispose(): void;
  16742. }
  16743. }
  16744. declare module "babylonjs/Particles/baseParticleSystem" {
  16745. import { Nullable } from "babylonjs/types";
  16746. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16748. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16749. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16750. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16751. import { Scene } from "babylonjs/scene";
  16752. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16753. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16754. import { Texture } from "babylonjs/Materials/Textures/texture";
  16755. import { Color4 } from "babylonjs/Maths/math.color";
  16756. import { Animation } from "babylonjs/Animations/animation";
  16757. /**
  16758. * This represents the base class for particle system in Babylon.
  16759. * 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.
  16760. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16761. * @example https://doc.babylonjs.com/babylon101/particles
  16762. */
  16763. export class BaseParticleSystem {
  16764. /**
  16765. * Source color is added to the destination color without alpha affecting the result
  16766. */
  16767. static BLENDMODE_ONEONE: number;
  16768. /**
  16769. * Blend current color and particle color using particle’s alpha
  16770. */
  16771. static BLENDMODE_STANDARD: number;
  16772. /**
  16773. * Add current color and particle color multiplied by particle’s alpha
  16774. */
  16775. static BLENDMODE_ADD: number;
  16776. /**
  16777. * Multiply current color with particle color
  16778. */
  16779. static BLENDMODE_MULTIPLY: number;
  16780. /**
  16781. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16782. */
  16783. static BLENDMODE_MULTIPLYADD: number;
  16784. /**
  16785. * List of animations used by the particle system.
  16786. */
  16787. animations: Animation[];
  16788. /**
  16789. * The id of the Particle system.
  16790. */
  16791. id: string;
  16792. /**
  16793. * The friendly name of the Particle system.
  16794. */
  16795. name: string;
  16796. /**
  16797. * The rendering group used by the Particle system to chose when to render.
  16798. */
  16799. renderingGroupId: number;
  16800. /**
  16801. * The emitter represents the Mesh or position we are attaching the particle system to.
  16802. */
  16803. emitter: Nullable<AbstractMesh | Vector3>;
  16804. /**
  16805. * The maximum number of particles to emit per frame
  16806. */
  16807. emitRate: number;
  16808. /**
  16809. * If you want to launch only a few particles at once, that can be done, as well.
  16810. */
  16811. manualEmitCount: number;
  16812. /**
  16813. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16814. */
  16815. updateSpeed: number;
  16816. /**
  16817. * The amount of time the particle system is running (depends of the overall update speed).
  16818. */
  16819. targetStopDuration: number;
  16820. /**
  16821. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16822. */
  16823. disposeOnStop: boolean;
  16824. /**
  16825. * Minimum power of emitting particles.
  16826. */
  16827. minEmitPower: number;
  16828. /**
  16829. * Maximum power of emitting particles.
  16830. */
  16831. maxEmitPower: number;
  16832. /**
  16833. * Minimum life time of emitting particles.
  16834. */
  16835. minLifeTime: number;
  16836. /**
  16837. * Maximum life time of emitting particles.
  16838. */
  16839. maxLifeTime: number;
  16840. /**
  16841. * Minimum Size of emitting particles.
  16842. */
  16843. minSize: number;
  16844. /**
  16845. * Maximum Size of emitting particles.
  16846. */
  16847. maxSize: number;
  16848. /**
  16849. * Minimum scale of emitting particles on X axis.
  16850. */
  16851. minScaleX: number;
  16852. /**
  16853. * Maximum scale of emitting particles on X axis.
  16854. */
  16855. maxScaleX: number;
  16856. /**
  16857. * Minimum scale of emitting particles on Y axis.
  16858. */
  16859. minScaleY: number;
  16860. /**
  16861. * Maximum scale of emitting particles on Y axis.
  16862. */
  16863. maxScaleY: number;
  16864. /**
  16865. * Gets or sets the minimal initial rotation in radians.
  16866. */
  16867. minInitialRotation: number;
  16868. /**
  16869. * Gets or sets the maximal initial rotation in radians.
  16870. */
  16871. maxInitialRotation: number;
  16872. /**
  16873. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16874. */
  16875. minAngularSpeed: number;
  16876. /**
  16877. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16878. */
  16879. maxAngularSpeed: number;
  16880. /**
  16881. * The texture used to render each particle. (this can be a spritesheet)
  16882. */
  16883. particleTexture: Nullable<Texture>;
  16884. /**
  16885. * The layer mask we are rendering the particles through.
  16886. */
  16887. layerMask: number;
  16888. /**
  16889. * This can help using your own shader to render the particle system.
  16890. * The according effect will be created
  16891. */
  16892. customShader: any;
  16893. /**
  16894. * By default particle system starts as soon as they are created. This prevents the
  16895. * automatic start to happen and let you decide when to start emitting particles.
  16896. */
  16897. preventAutoStart: boolean;
  16898. private _noiseTexture;
  16899. /**
  16900. * Gets or sets a texture used to add random noise to particle positions
  16901. */
  16902. noiseTexture: Nullable<ProceduralTexture>;
  16903. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16904. noiseStrength: Vector3;
  16905. /**
  16906. * Callback triggered when the particle animation is ending.
  16907. */
  16908. onAnimationEnd: Nullable<() => void>;
  16909. /**
  16910. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16911. */
  16912. blendMode: number;
  16913. /**
  16914. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16915. * to override the particles.
  16916. */
  16917. forceDepthWrite: boolean;
  16918. /** 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 */
  16919. preWarmCycles: number;
  16920. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16921. preWarmStepOffset: number;
  16922. /**
  16923. * 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)
  16924. */
  16925. spriteCellChangeSpeed: number;
  16926. /**
  16927. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16928. */
  16929. startSpriteCellID: number;
  16930. /**
  16931. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16932. */
  16933. endSpriteCellID: number;
  16934. /**
  16935. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16936. */
  16937. spriteCellWidth: number;
  16938. /**
  16939. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16940. */
  16941. spriteCellHeight: number;
  16942. /**
  16943. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16944. */
  16945. spriteRandomStartCell: boolean;
  16946. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16947. translationPivot: Vector2;
  16948. /** @hidden */
  16949. protected _isAnimationSheetEnabled: boolean;
  16950. /**
  16951. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16952. */
  16953. beginAnimationOnStart: boolean;
  16954. /**
  16955. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16956. */
  16957. beginAnimationFrom: number;
  16958. /**
  16959. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16960. */
  16961. beginAnimationTo: number;
  16962. /**
  16963. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16964. */
  16965. beginAnimationLoop: boolean;
  16966. /**
  16967. * Gets or sets a world offset applied to all particles
  16968. */
  16969. worldOffset: Vector3;
  16970. /**
  16971. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16972. */
  16973. isAnimationSheetEnabled: boolean;
  16974. /**
  16975. * Get hosting scene
  16976. * @returns the scene
  16977. */
  16978. getScene(): Scene;
  16979. /**
  16980. * You can use gravity if you want to give an orientation to your particles.
  16981. */
  16982. gravity: Vector3;
  16983. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16984. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16985. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16986. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16987. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16988. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16989. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16990. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16991. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16992. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16993. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16994. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16995. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16996. /**
  16997. * Defines the delay in milliseconds before starting the system (0 by default)
  16998. */
  16999. startDelay: number;
  17000. /**
  17001. * Gets the current list of drag gradients.
  17002. * You must use addDragGradient and removeDragGradient to udpate this list
  17003. * @returns the list of drag gradients
  17004. */
  17005. getDragGradients(): Nullable<Array<FactorGradient>>;
  17006. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17007. limitVelocityDamping: number;
  17008. /**
  17009. * Gets the current list of limit velocity gradients.
  17010. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17011. * @returns the list of limit velocity gradients
  17012. */
  17013. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17014. /**
  17015. * Gets the current list of color gradients.
  17016. * You must use addColorGradient and removeColorGradient to udpate this list
  17017. * @returns the list of color gradients
  17018. */
  17019. getColorGradients(): Nullable<Array<ColorGradient>>;
  17020. /**
  17021. * Gets the current list of size gradients.
  17022. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17023. * @returns the list of size gradients
  17024. */
  17025. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17026. /**
  17027. * Gets the current list of color remap gradients.
  17028. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17029. * @returns the list of color remap gradients
  17030. */
  17031. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17032. /**
  17033. * Gets the current list of alpha remap gradients.
  17034. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17035. * @returns the list of alpha remap gradients
  17036. */
  17037. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17038. /**
  17039. * Gets the current list of life time gradients.
  17040. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17041. * @returns the list of life time gradients
  17042. */
  17043. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17044. /**
  17045. * Gets the current list of angular speed gradients.
  17046. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17047. * @returns the list of angular speed gradients
  17048. */
  17049. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17050. /**
  17051. * Gets the current list of velocity gradients.
  17052. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17053. * @returns the list of velocity gradients
  17054. */
  17055. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17056. /**
  17057. * Gets the current list of start size gradients.
  17058. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17059. * @returns the list of start size gradients
  17060. */
  17061. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17062. /**
  17063. * Gets the current list of emit rate gradients.
  17064. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17065. * @returns the list of emit rate gradients
  17066. */
  17067. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17068. /**
  17069. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17070. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17071. */
  17072. direction1: Vector3;
  17073. /**
  17074. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17075. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17076. */
  17077. direction2: Vector3;
  17078. /**
  17079. * 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.
  17080. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17081. */
  17082. minEmitBox: Vector3;
  17083. /**
  17084. * 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.
  17085. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17086. */
  17087. maxEmitBox: Vector3;
  17088. /**
  17089. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17090. */
  17091. color1: Color4;
  17092. /**
  17093. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17094. */
  17095. color2: Color4;
  17096. /**
  17097. * Color the particle will have at the end of its lifetime
  17098. */
  17099. colorDead: Color4;
  17100. /**
  17101. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17102. */
  17103. textureMask: Color4;
  17104. /**
  17105. * The particle emitter type defines the emitter used by the particle system.
  17106. * It can be for example box, sphere, or cone...
  17107. */
  17108. particleEmitterType: IParticleEmitterType;
  17109. /** @hidden */
  17110. _isSubEmitter: boolean;
  17111. /**
  17112. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17113. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17114. */
  17115. billboardMode: number;
  17116. protected _isBillboardBased: boolean;
  17117. /**
  17118. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17119. */
  17120. isBillboardBased: boolean;
  17121. /**
  17122. * The scene the particle system belongs to.
  17123. */
  17124. protected _scene: Scene;
  17125. /**
  17126. * Local cache of defines for image processing.
  17127. */
  17128. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17129. /**
  17130. * Default configuration related to image processing available in the standard Material.
  17131. */
  17132. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17133. /**
  17134. * Gets the image processing configuration used either in this material.
  17135. */
  17136. /**
  17137. * Sets the Default image processing configuration used either in the this material.
  17138. *
  17139. * If sets to null, the scene one is in use.
  17140. */
  17141. imageProcessingConfiguration: ImageProcessingConfiguration;
  17142. /**
  17143. * Attaches a new image processing configuration to the Standard Material.
  17144. * @param configuration
  17145. */
  17146. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17147. /** @hidden */
  17148. protected _reset(): void;
  17149. /** @hidden */
  17150. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17151. /**
  17152. * Instantiates a particle system.
  17153. * 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.
  17154. * @param name The name of the particle system
  17155. */
  17156. constructor(name: string);
  17157. /**
  17158. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17159. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17160. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17161. * @returns the emitter
  17162. */
  17163. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17164. /**
  17165. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17166. * @param radius The radius of the hemisphere to emit from
  17167. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17168. * @returns the emitter
  17169. */
  17170. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17171. /**
  17172. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17173. * @param radius The radius of the sphere to emit from
  17174. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17175. * @returns the emitter
  17176. */
  17177. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17178. /**
  17179. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17180. * @param radius The radius of the sphere to emit from
  17181. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17182. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17183. * @returns the emitter
  17184. */
  17185. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17186. /**
  17187. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17188. * @param radius The radius of the emission cylinder
  17189. * @param height The height of the emission cylinder
  17190. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17191. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17192. * @returns the emitter
  17193. */
  17194. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17195. /**
  17196. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17197. * @param radius The radius of the cylinder to emit from
  17198. * @param height The height of the emission cylinder
  17199. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17200. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17201. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17202. * @returns the emitter
  17203. */
  17204. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17205. /**
  17206. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17207. * @param radius The radius of the cone to emit from
  17208. * @param angle The base angle of the cone
  17209. * @returns the emitter
  17210. */
  17211. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17212. /**
  17213. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17214. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17215. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17216. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17217. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17218. * @returns the emitter
  17219. */
  17220. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17221. }
  17222. }
  17223. declare module "babylonjs/Particles/subEmitter" {
  17224. import { Scene } from "babylonjs/scene";
  17225. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17226. /**
  17227. * Type of sub emitter
  17228. */
  17229. export enum SubEmitterType {
  17230. /**
  17231. * Attached to the particle over it's lifetime
  17232. */
  17233. ATTACHED = 0,
  17234. /**
  17235. * Created when the particle dies
  17236. */
  17237. END = 1
  17238. }
  17239. /**
  17240. * Sub emitter class used to emit particles from an existing particle
  17241. */
  17242. export class SubEmitter {
  17243. /**
  17244. * the particle system to be used by the sub emitter
  17245. */
  17246. particleSystem: ParticleSystem;
  17247. /**
  17248. * Type of the submitter (Default: END)
  17249. */
  17250. type: SubEmitterType;
  17251. /**
  17252. * 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)
  17253. * Note: This only is supported when using an emitter of type Mesh
  17254. */
  17255. inheritDirection: boolean;
  17256. /**
  17257. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17258. */
  17259. inheritedVelocityAmount: number;
  17260. /**
  17261. * Creates a sub emitter
  17262. * @param particleSystem the particle system to be used by the sub emitter
  17263. */
  17264. constructor(
  17265. /**
  17266. * the particle system to be used by the sub emitter
  17267. */
  17268. particleSystem: ParticleSystem);
  17269. /**
  17270. * Clones the sub emitter
  17271. * @returns the cloned sub emitter
  17272. */
  17273. clone(): SubEmitter;
  17274. /**
  17275. * Serialize current object to a JSON object
  17276. * @returns the serialized object
  17277. */
  17278. serialize(): any;
  17279. /** @hidden */
  17280. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17281. /**
  17282. * Creates a new SubEmitter from a serialized JSON version
  17283. * @param serializationObject defines the JSON object to read from
  17284. * @param scene defines the hosting scene
  17285. * @param rootUrl defines the rootUrl for data loading
  17286. * @returns a new SubEmitter
  17287. */
  17288. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17289. /** Release associated resources */
  17290. dispose(): void;
  17291. }
  17292. }
  17293. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17294. /** @hidden */
  17295. export var clipPlaneFragmentDeclaration: {
  17296. name: string;
  17297. shader: string;
  17298. };
  17299. }
  17300. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17301. /** @hidden */
  17302. export var imageProcessingDeclaration: {
  17303. name: string;
  17304. shader: string;
  17305. };
  17306. }
  17307. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17308. /** @hidden */
  17309. export var imageProcessingFunctions: {
  17310. name: string;
  17311. shader: string;
  17312. };
  17313. }
  17314. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17315. /** @hidden */
  17316. export var clipPlaneFragment: {
  17317. name: string;
  17318. shader: string;
  17319. };
  17320. }
  17321. declare module "babylonjs/Shaders/particles.fragment" {
  17322. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17323. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17324. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17325. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17326. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17327. /** @hidden */
  17328. export var particlesPixelShader: {
  17329. name: string;
  17330. shader: string;
  17331. };
  17332. }
  17333. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17334. /** @hidden */
  17335. export var clipPlaneVertexDeclaration: {
  17336. name: string;
  17337. shader: string;
  17338. };
  17339. }
  17340. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17341. /** @hidden */
  17342. export var clipPlaneVertex: {
  17343. name: string;
  17344. shader: string;
  17345. };
  17346. }
  17347. declare module "babylonjs/Shaders/particles.vertex" {
  17348. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17349. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17350. /** @hidden */
  17351. export var particlesVertexShader: {
  17352. name: string;
  17353. shader: string;
  17354. };
  17355. }
  17356. declare module "babylonjs/Particles/particleSystem" {
  17357. import { Nullable } from "babylonjs/types";
  17358. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17359. import { Observable } from "babylonjs/Misc/observable";
  17360. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17361. import { Effect } from "babylonjs/Materials/effect";
  17362. import { Scene, IDisposable } from "babylonjs/scene";
  17363. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17364. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17365. import { Particle } from "babylonjs/Particles/particle";
  17366. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17367. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17368. import "babylonjs/Shaders/particles.fragment";
  17369. import "babylonjs/Shaders/particles.vertex";
  17370. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17371. /**
  17372. * This represents a particle system in Babylon.
  17373. * 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.
  17374. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17375. * @example https://doc.babylonjs.com/babylon101/particles
  17376. */
  17377. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17378. /**
  17379. * Billboard mode will only apply to Y axis
  17380. */
  17381. static readonly BILLBOARDMODE_Y: number;
  17382. /**
  17383. * Billboard mode will apply to all axes
  17384. */
  17385. static readonly BILLBOARDMODE_ALL: number;
  17386. /**
  17387. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17388. */
  17389. static readonly BILLBOARDMODE_STRETCHED: number;
  17390. /**
  17391. * This function can be defined to provide custom update for active particles.
  17392. * This function will be called instead of regular update (age, position, color, etc.).
  17393. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17394. */
  17395. updateFunction: (particles: Particle[]) => void;
  17396. private _emitterWorldMatrix;
  17397. /**
  17398. * This function can be defined to specify initial direction for every new particle.
  17399. * It by default use the emitterType defined function
  17400. */
  17401. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17402. /**
  17403. * This function can be defined to specify initial position for every new particle.
  17404. * It by default use the emitterType defined function
  17405. */
  17406. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17407. /**
  17408. * @hidden
  17409. */
  17410. _inheritedVelocityOffset: Vector3;
  17411. /**
  17412. * An event triggered when the system is disposed
  17413. */
  17414. onDisposeObservable: Observable<ParticleSystem>;
  17415. private _onDisposeObserver;
  17416. /**
  17417. * Sets a callback that will be triggered when the system is disposed
  17418. */
  17419. onDispose: () => void;
  17420. private _particles;
  17421. private _epsilon;
  17422. private _capacity;
  17423. private _stockParticles;
  17424. private _newPartsExcess;
  17425. private _vertexData;
  17426. private _vertexBuffer;
  17427. private _vertexBuffers;
  17428. private _spriteBuffer;
  17429. private _indexBuffer;
  17430. private _effect;
  17431. private _customEffect;
  17432. private _cachedDefines;
  17433. private _scaledColorStep;
  17434. private _colorDiff;
  17435. private _scaledDirection;
  17436. private _scaledGravity;
  17437. private _currentRenderId;
  17438. private _alive;
  17439. private _useInstancing;
  17440. private _started;
  17441. private _stopped;
  17442. private _actualFrame;
  17443. private _scaledUpdateSpeed;
  17444. private _vertexBufferSize;
  17445. /** @hidden */
  17446. _currentEmitRateGradient: Nullable<FactorGradient>;
  17447. /** @hidden */
  17448. _currentEmitRate1: number;
  17449. /** @hidden */
  17450. _currentEmitRate2: number;
  17451. /** @hidden */
  17452. _currentStartSizeGradient: Nullable<FactorGradient>;
  17453. /** @hidden */
  17454. _currentStartSize1: number;
  17455. /** @hidden */
  17456. _currentStartSize2: number;
  17457. private readonly _rawTextureWidth;
  17458. private _rampGradientsTexture;
  17459. private _useRampGradients;
  17460. /** Gets or sets a boolean indicating that ramp gradients must be used
  17461. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17462. */
  17463. useRampGradients: boolean;
  17464. /**
  17465. * 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.
  17466. * 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: [])
  17467. */
  17468. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17469. private _subEmitters;
  17470. /**
  17471. * @hidden
  17472. * If the particle systems emitter should be disposed when the particle system is disposed
  17473. */
  17474. _disposeEmitterOnDispose: boolean;
  17475. /**
  17476. * The current active Sub-systems, this property is used by the root particle system only.
  17477. */
  17478. activeSubSystems: Array<ParticleSystem>;
  17479. private _rootParticleSystem;
  17480. /**
  17481. * Gets the current list of active particles
  17482. */
  17483. readonly particles: Particle[];
  17484. /**
  17485. * Returns the string "ParticleSystem"
  17486. * @returns a string containing the class name
  17487. */
  17488. getClassName(): string;
  17489. /**
  17490. * Instantiates a particle system.
  17491. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17492. * @param name The name of the particle system
  17493. * @param capacity The max number of particles alive at the same time
  17494. * @param scene The scene the particle system belongs to
  17495. * @param customEffect a custom effect used to change the way particles are rendered by default
  17496. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17497. * @param epsilon Offset used to render the particles
  17498. */
  17499. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17500. private _addFactorGradient;
  17501. private _removeFactorGradient;
  17502. /**
  17503. * Adds a new life time gradient
  17504. * @param gradient defines the gradient to use (between 0 and 1)
  17505. * @param factor defines the life time factor to affect to the specified gradient
  17506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17507. * @returns the current particle system
  17508. */
  17509. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17510. /**
  17511. * Remove a specific life time gradient
  17512. * @param gradient defines the gradient to remove
  17513. * @returns the current particle system
  17514. */
  17515. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17516. /**
  17517. * Adds a new size gradient
  17518. * @param gradient defines the gradient to use (between 0 and 1)
  17519. * @param factor defines the size factor to affect to the specified gradient
  17520. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17521. * @returns the current particle system
  17522. */
  17523. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17524. /**
  17525. * Remove a specific size gradient
  17526. * @param gradient defines the gradient to remove
  17527. * @returns the current particle system
  17528. */
  17529. removeSizeGradient(gradient: number): IParticleSystem;
  17530. /**
  17531. * Adds a new color remap gradient
  17532. * @param gradient defines the gradient to use (between 0 and 1)
  17533. * @param min defines the color remap minimal range
  17534. * @param max defines the color remap maximal range
  17535. * @returns the current particle system
  17536. */
  17537. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17538. /**
  17539. * Remove a specific color remap gradient
  17540. * @param gradient defines the gradient to remove
  17541. * @returns the current particle system
  17542. */
  17543. removeColorRemapGradient(gradient: number): IParticleSystem;
  17544. /**
  17545. * Adds a new alpha remap gradient
  17546. * @param gradient defines the gradient to use (between 0 and 1)
  17547. * @param min defines the alpha remap minimal range
  17548. * @param max defines the alpha remap maximal range
  17549. * @returns the current particle system
  17550. */
  17551. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17552. /**
  17553. * Remove a specific alpha remap gradient
  17554. * @param gradient defines the gradient to remove
  17555. * @returns the current particle system
  17556. */
  17557. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17558. /**
  17559. * Adds a new angular speed gradient
  17560. * @param gradient defines the gradient to use (between 0 and 1)
  17561. * @param factor defines the angular speed to affect to the specified gradient
  17562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17563. * @returns the current particle system
  17564. */
  17565. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17566. /**
  17567. * Remove a specific angular speed gradient
  17568. * @param gradient defines the gradient to remove
  17569. * @returns the current particle system
  17570. */
  17571. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17572. /**
  17573. * Adds a new velocity gradient
  17574. * @param gradient defines the gradient to use (between 0 and 1)
  17575. * @param factor defines the velocity to affect to the specified gradient
  17576. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17577. * @returns the current particle system
  17578. */
  17579. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17580. /**
  17581. * Remove a specific velocity gradient
  17582. * @param gradient defines the gradient to remove
  17583. * @returns the current particle system
  17584. */
  17585. removeVelocityGradient(gradient: number): IParticleSystem;
  17586. /**
  17587. * Adds a new limit velocity gradient
  17588. * @param gradient defines the gradient to use (between 0 and 1)
  17589. * @param factor defines the limit velocity value to affect to the specified gradient
  17590. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17591. * @returns the current particle system
  17592. */
  17593. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17594. /**
  17595. * Remove a specific limit velocity gradient
  17596. * @param gradient defines the gradient to remove
  17597. * @returns the current particle system
  17598. */
  17599. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17600. /**
  17601. * Adds a new drag gradient
  17602. * @param gradient defines the gradient to use (between 0 and 1)
  17603. * @param factor defines the drag value to affect to the specified gradient
  17604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17605. * @returns the current particle system
  17606. */
  17607. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17608. /**
  17609. * Remove a specific drag gradient
  17610. * @param gradient defines the gradient to remove
  17611. * @returns the current particle system
  17612. */
  17613. removeDragGradient(gradient: number): IParticleSystem;
  17614. /**
  17615. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17616. * @param gradient defines the gradient to use (between 0 and 1)
  17617. * @param factor defines the emit rate value to affect to the specified gradient
  17618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17619. * @returns the current particle system
  17620. */
  17621. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17622. /**
  17623. * Remove a specific emit rate gradient
  17624. * @param gradient defines the gradient to remove
  17625. * @returns the current particle system
  17626. */
  17627. removeEmitRateGradient(gradient: number): IParticleSystem;
  17628. /**
  17629. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17630. * @param gradient defines the gradient to use (between 0 and 1)
  17631. * @param factor defines the start size value to affect to the specified gradient
  17632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17633. * @returns the current particle system
  17634. */
  17635. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17636. /**
  17637. * Remove a specific start size gradient
  17638. * @param gradient defines the gradient to remove
  17639. * @returns the current particle system
  17640. */
  17641. removeStartSizeGradient(gradient: number): IParticleSystem;
  17642. private _createRampGradientTexture;
  17643. /**
  17644. * Gets the current list of ramp gradients.
  17645. * You must use addRampGradient and removeRampGradient to udpate this list
  17646. * @returns the list of ramp gradients
  17647. */
  17648. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17649. /**
  17650. * Adds a new ramp gradient used to remap particle colors
  17651. * @param gradient defines the gradient to use (between 0 and 1)
  17652. * @param color defines the color to affect to the specified gradient
  17653. * @returns the current particle system
  17654. */
  17655. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17656. /**
  17657. * Remove a specific ramp gradient
  17658. * @param gradient defines the gradient to remove
  17659. * @returns the current particle system
  17660. */
  17661. removeRampGradient(gradient: number): ParticleSystem;
  17662. /**
  17663. * Adds a new color gradient
  17664. * @param gradient defines the gradient to use (between 0 and 1)
  17665. * @param color1 defines the color to affect to the specified gradient
  17666. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17667. * @returns this particle system
  17668. */
  17669. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17670. /**
  17671. * Remove a specific color gradient
  17672. * @param gradient defines the gradient to remove
  17673. * @returns this particle system
  17674. */
  17675. removeColorGradient(gradient: number): IParticleSystem;
  17676. private _fetchR;
  17677. protected _reset(): void;
  17678. private _resetEffect;
  17679. private _createVertexBuffers;
  17680. private _createIndexBuffer;
  17681. /**
  17682. * Gets the maximum number of particles active at the same time.
  17683. * @returns The max number of active particles.
  17684. */
  17685. getCapacity(): number;
  17686. /**
  17687. * Gets whether there are still active particles in the system.
  17688. * @returns True if it is alive, otherwise false.
  17689. */
  17690. isAlive(): boolean;
  17691. /**
  17692. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17693. * @returns True if it has been started, otherwise false.
  17694. */
  17695. isStarted(): boolean;
  17696. private _prepareSubEmitterInternalArray;
  17697. /**
  17698. * Starts the particle system and begins to emit
  17699. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17700. */
  17701. start(delay?: number): void;
  17702. /**
  17703. * Stops the particle system.
  17704. * @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.
  17705. */
  17706. stop(stopSubEmitters?: boolean): void;
  17707. /**
  17708. * Remove all active particles
  17709. */
  17710. reset(): void;
  17711. /**
  17712. * @hidden (for internal use only)
  17713. */
  17714. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17715. /**
  17716. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17717. * Its lifetime will start back at 0.
  17718. */
  17719. recycleParticle: (particle: Particle) => void;
  17720. private _stopSubEmitters;
  17721. private _createParticle;
  17722. private _removeFromRoot;
  17723. private _emitFromParticle;
  17724. private _update;
  17725. /** @hidden */
  17726. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17727. /** @hidden */
  17728. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17729. /** @hidden */
  17730. private _getEffect;
  17731. /**
  17732. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17733. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17734. */
  17735. animate(preWarmOnly?: boolean): void;
  17736. private _appendParticleVertices;
  17737. /**
  17738. * Rebuilds the particle system.
  17739. */
  17740. rebuild(): void;
  17741. /**
  17742. * Is this system ready to be used/rendered
  17743. * @return true if the system is ready
  17744. */
  17745. isReady(): boolean;
  17746. private _render;
  17747. /**
  17748. * Renders the particle system in its current state.
  17749. * @returns the current number of particles
  17750. */
  17751. render(): number;
  17752. /**
  17753. * Disposes the particle system and free the associated resources
  17754. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17755. */
  17756. dispose(disposeTexture?: boolean): void;
  17757. /**
  17758. * Clones the particle system.
  17759. * @param name The name of the cloned object
  17760. * @param newEmitter The new emitter to use
  17761. * @returns the cloned particle system
  17762. */
  17763. clone(name: string, newEmitter: any): ParticleSystem;
  17764. /**
  17765. * Serializes the particle system to a JSON object.
  17766. * @returns the JSON object
  17767. */
  17768. serialize(): any;
  17769. /** @hidden */
  17770. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17771. /** @hidden */
  17772. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17773. /**
  17774. * Parses a JSON object to create a particle system.
  17775. * @param parsedParticleSystem The JSON object to parse
  17776. * @param scene The scene to create the particle system in
  17777. * @param rootUrl The root url to use to load external dependencies like texture
  17778. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17779. * @returns the Parsed particle system
  17780. */
  17781. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17782. }
  17783. }
  17784. declare module "babylonjs/Particles/particle" {
  17785. import { Nullable } from "babylonjs/types";
  17786. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17787. import { Color4 } from "babylonjs/Maths/math.color";
  17788. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17789. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17790. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17791. /**
  17792. * A particle represents one of the element emitted by a particle system.
  17793. * This is mainly define by its coordinates, direction, velocity and age.
  17794. */
  17795. export class Particle {
  17796. /**
  17797. * The particle system the particle belongs to.
  17798. */
  17799. particleSystem: ParticleSystem;
  17800. private static _Count;
  17801. /**
  17802. * Unique ID of the particle
  17803. */
  17804. id: number;
  17805. /**
  17806. * The world position of the particle in the scene.
  17807. */
  17808. position: Vector3;
  17809. /**
  17810. * The world direction of the particle in the scene.
  17811. */
  17812. direction: Vector3;
  17813. /**
  17814. * The color of the particle.
  17815. */
  17816. color: Color4;
  17817. /**
  17818. * The color change of the particle per step.
  17819. */
  17820. colorStep: Color4;
  17821. /**
  17822. * Defines how long will the life of the particle be.
  17823. */
  17824. lifeTime: number;
  17825. /**
  17826. * The current age of the particle.
  17827. */
  17828. age: number;
  17829. /**
  17830. * The current size of the particle.
  17831. */
  17832. size: number;
  17833. /**
  17834. * The current scale of the particle.
  17835. */
  17836. scale: Vector2;
  17837. /**
  17838. * The current angle of the particle.
  17839. */
  17840. angle: number;
  17841. /**
  17842. * Defines how fast is the angle changing.
  17843. */
  17844. angularSpeed: number;
  17845. /**
  17846. * Defines the cell index used by the particle to be rendered from a sprite.
  17847. */
  17848. cellIndex: number;
  17849. /**
  17850. * The information required to support color remapping
  17851. */
  17852. remapData: Vector4;
  17853. /** @hidden */
  17854. _randomCellOffset?: number;
  17855. /** @hidden */
  17856. _initialDirection: Nullable<Vector3>;
  17857. /** @hidden */
  17858. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17859. /** @hidden */
  17860. _initialStartSpriteCellID: number;
  17861. /** @hidden */
  17862. _initialEndSpriteCellID: number;
  17863. /** @hidden */
  17864. _currentColorGradient: Nullable<ColorGradient>;
  17865. /** @hidden */
  17866. _currentColor1: Color4;
  17867. /** @hidden */
  17868. _currentColor2: Color4;
  17869. /** @hidden */
  17870. _currentSizeGradient: Nullable<FactorGradient>;
  17871. /** @hidden */
  17872. _currentSize1: number;
  17873. /** @hidden */
  17874. _currentSize2: number;
  17875. /** @hidden */
  17876. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17877. /** @hidden */
  17878. _currentAngularSpeed1: number;
  17879. /** @hidden */
  17880. _currentAngularSpeed2: number;
  17881. /** @hidden */
  17882. _currentVelocityGradient: Nullable<FactorGradient>;
  17883. /** @hidden */
  17884. _currentVelocity1: number;
  17885. /** @hidden */
  17886. _currentVelocity2: number;
  17887. /** @hidden */
  17888. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17889. /** @hidden */
  17890. _currentLimitVelocity1: number;
  17891. /** @hidden */
  17892. _currentLimitVelocity2: number;
  17893. /** @hidden */
  17894. _currentDragGradient: Nullable<FactorGradient>;
  17895. /** @hidden */
  17896. _currentDrag1: number;
  17897. /** @hidden */
  17898. _currentDrag2: number;
  17899. /** @hidden */
  17900. _randomNoiseCoordinates1: Vector3;
  17901. /** @hidden */
  17902. _randomNoiseCoordinates2: Vector3;
  17903. /**
  17904. * Creates a new instance Particle
  17905. * @param particleSystem the particle system the particle belongs to
  17906. */
  17907. constructor(
  17908. /**
  17909. * The particle system the particle belongs to.
  17910. */
  17911. particleSystem: ParticleSystem);
  17912. private updateCellInfoFromSystem;
  17913. /**
  17914. * Defines how the sprite cell index is updated for the particle
  17915. */
  17916. updateCellIndex(): void;
  17917. /** @hidden */
  17918. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17919. /** @hidden */
  17920. _inheritParticleInfoToSubEmitters(): void;
  17921. /** @hidden */
  17922. _reset(): void;
  17923. /**
  17924. * Copy the properties of particle to another one.
  17925. * @param other the particle to copy the information to.
  17926. */
  17927. copyTo(other: Particle): void;
  17928. }
  17929. }
  17930. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17931. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17932. import { Effect } from "babylonjs/Materials/effect";
  17933. import { Particle } from "babylonjs/Particles/particle";
  17934. /**
  17935. * Particle emitter represents a volume emitting particles.
  17936. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17937. */
  17938. export interface IParticleEmitterType {
  17939. /**
  17940. * Called by the particle System when the direction is computed for the created particle.
  17941. * @param worldMatrix is the world matrix of the particle system
  17942. * @param directionToUpdate is the direction vector to update with the result
  17943. * @param particle is the particle we are computed the direction for
  17944. */
  17945. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17946. /**
  17947. * Called by the particle System when the position is computed for the created particle.
  17948. * @param worldMatrix is the world matrix of the particle system
  17949. * @param positionToUpdate is the position vector to update with the result
  17950. * @param particle is the particle we are computed the position for
  17951. */
  17952. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17953. /**
  17954. * Clones the current emitter and returns a copy of it
  17955. * @returns the new emitter
  17956. */
  17957. clone(): IParticleEmitterType;
  17958. /**
  17959. * Called by the GPUParticleSystem to setup the update shader
  17960. * @param effect defines the update shader
  17961. */
  17962. applyToShader(effect: Effect): void;
  17963. /**
  17964. * Returns a string to use to update the GPU particles update shader
  17965. * @returns the effect defines string
  17966. */
  17967. getEffectDefines(): string;
  17968. /**
  17969. * Returns a string representing the class name
  17970. * @returns a string containing the class name
  17971. */
  17972. getClassName(): string;
  17973. /**
  17974. * Serializes the particle system to a JSON object.
  17975. * @returns the JSON object
  17976. */
  17977. serialize(): any;
  17978. /**
  17979. * Parse properties from a JSON object
  17980. * @param serializationObject defines the JSON object
  17981. */
  17982. parse(serializationObject: any): void;
  17983. }
  17984. }
  17985. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17986. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17987. import { Effect } from "babylonjs/Materials/effect";
  17988. import { Particle } from "babylonjs/Particles/particle";
  17989. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17990. /**
  17991. * Particle emitter emitting particles from the inside of a box.
  17992. * It emits the particles randomly between 2 given directions.
  17993. */
  17994. export class BoxParticleEmitter implements IParticleEmitterType {
  17995. /**
  17996. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17997. */
  17998. direction1: Vector3;
  17999. /**
  18000. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18001. */
  18002. direction2: Vector3;
  18003. /**
  18004. * 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.
  18005. */
  18006. minEmitBox: Vector3;
  18007. /**
  18008. * 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.
  18009. */
  18010. maxEmitBox: Vector3;
  18011. /**
  18012. * Creates a new instance BoxParticleEmitter
  18013. */
  18014. constructor();
  18015. /**
  18016. * Called by the particle System when the direction is computed for the created particle.
  18017. * @param worldMatrix is the world matrix of the particle system
  18018. * @param directionToUpdate is the direction vector to update with the result
  18019. * @param particle is the particle we are computed the direction for
  18020. */
  18021. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18022. /**
  18023. * Called by the particle System when the position is computed for the created particle.
  18024. * @param worldMatrix is the world matrix of the particle system
  18025. * @param positionToUpdate is the position vector to update with the result
  18026. * @param particle is the particle we are computed the position for
  18027. */
  18028. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18029. /**
  18030. * Clones the current emitter and returns a copy of it
  18031. * @returns the new emitter
  18032. */
  18033. clone(): BoxParticleEmitter;
  18034. /**
  18035. * Called by the GPUParticleSystem to setup the update shader
  18036. * @param effect defines the update shader
  18037. */
  18038. applyToShader(effect: Effect): void;
  18039. /**
  18040. * Returns a string to use to update the GPU particles update shader
  18041. * @returns a string containng the defines string
  18042. */
  18043. getEffectDefines(): string;
  18044. /**
  18045. * Returns the string "BoxParticleEmitter"
  18046. * @returns a string containing the class name
  18047. */
  18048. getClassName(): string;
  18049. /**
  18050. * Serializes the particle system to a JSON object.
  18051. * @returns the JSON object
  18052. */
  18053. serialize(): any;
  18054. /**
  18055. * Parse properties from a JSON object
  18056. * @param serializationObject defines the JSON object
  18057. */
  18058. parse(serializationObject: any): void;
  18059. }
  18060. }
  18061. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18062. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18063. import { Effect } from "babylonjs/Materials/effect";
  18064. import { Particle } from "babylonjs/Particles/particle";
  18065. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18066. /**
  18067. * Particle emitter emitting particles from the inside of a cone.
  18068. * It emits the particles alongside the cone volume from the base to the particle.
  18069. * The emission direction might be randomized.
  18070. */
  18071. export class ConeParticleEmitter implements IParticleEmitterType {
  18072. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18073. directionRandomizer: number;
  18074. private _radius;
  18075. private _angle;
  18076. private _height;
  18077. /**
  18078. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18079. */
  18080. radiusRange: number;
  18081. /**
  18082. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18083. */
  18084. heightRange: number;
  18085. /**
  18086. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18087. */
  18088. emitFromSpawnPointOnly: boolean;
  18089. /**
  18090. * Gets or sets the radius of the emission cone
  18091. */
  18092. radius: number;
  18093. /**
  18094. * Gets or sets the angle of the emission cone
  18095. */
  18096. angle: number;
  18097. private _buildHeight;
  18098. /**
  18099. * Creates a new instance ConeParticleEmitter
  18100. * @param radius the radius of the emission cone (1 by default)
  18101. * @param angle the cone base angle (PI by default)
  18102. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18103. */
  18104. constructor(radius?: number, angle?: number,
  18105. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18106. directionRandomizer?: number);
  18107. /**
  18108. * Called by the particle System when the direction is computed for the created particle.
  18109. * @param worldMatrix is the world matrix of the particle system
  18110. * @param directionToUpdate is the direction vector to update with the result
  18111. * @param particle is the particle we are computed the direction for
  18112. */
  18113. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18114. /**
  18115. * Called by the particle System when the position is computed for the created particle.
  18116. * @param worldMatrix is the world matrix of the particle system
  18117. * @param positionToUpdate is the position vector to update with the result
  18118. * @param particle is the particle we are computed the position for
  18119. */
  18120. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18121. /**
  18122. * Clones the current emitter and returns a copy of it
  18123. * @returns the new emitter
  18124. */
  18125. clone(): ConeParticleEmitter;
  18126. /**
  18127. * Called by the GPUParticleSystem to setup the update shader
  18128. * @param effect defines the update shader
  18129. */
  18130. applyToShader(effect: Effect): void;
  18131. /**
  18132. * Returns a string to use to update the GPU particles update shader
  18133. * @returns a string containng the defines string
  18134. */
  18135. getEffectDefines(): string;
  18136. /**
  18137. * Returns the string "ConeParticleEmitter"
  18138. * @returns a string containing the class name
  18139. */
  18140. getClassName(): string;
  18141. /**
  18142. * Serializes the particle system to a JSON object.
  18143. * @returns the JSON object
  18144. */
  18145. serialize(): any;
  18146. /**
  18147. * Parse properties from a JSON object
  18148. * @param serializationObject defines the JSON object
  18149. */
  18150. parse(serializationObject: any): void;
  18151. }
  18152. }
  18153. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18154. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18155. import { Effect } from "babylonjs/Materials/effect";
  18156. import { Particle } from "babylonjs/Particles/particle";
  18157. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18158. /**
  18159. * Particle emitter emitting particles from the inside of a cylinder.
  18160. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18161. */
  18162. export class CylinderParticleEmitter implements IParticleEmitterType {
  18163. /**
  18164. * The radius of the emission cylinder.
  18165. */
  18166. radius: number;
  18167. /**
  18168. * The height of the emission cylinder.
  18169. */
  18170. height: number;
  18171. /**
  18172. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18173. */
  18174. radiusRange: number;
  18175. /**
  18176. * How much to randomize the particle direction [0-1].
  18177. */
  18178. directionRandomizer: number;
  18179. /**
  18180. * Creates a new instance CylinderParticleEmitter
  18181. * @param radius the radius of the emission cylinder (1 by default)
  18182. * @param height the height of the emission cylinder (1 by default)
  18183. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18184. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18185. */
  18186. constructor(
  18187. /**
  18188. * The radius of the emission cylinder.
  18189. */
  18190. radius?: number,
  18191. /**
  18192. * The height of the emission cylinder.
  18193. */
  18194. height?: number,
  18195. /**
  18196. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18197. */
  18198. radiusRange?: number,
  18199. /**
  18200. * How much to randomize the particle direction [0-1].
  18201. */
  18202. directionRandomizer?: number);
  18203. /**
  18204. * Called by the particle System when the direction is computed for the created particle.
  18205. * @param worldMatrix is the world matrix of the particle system
  18206. * @param directionToUpdate is the direction vector to update with the result
  18207. * @param particle is the particle we are computed the direction for
  18208. */
  18209. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18210. /**
  18211. * Called by the particle System when the position is computed for the created particle.
  18212. * @param worldMatrix is the world matrix of the particle system
  18213. * @param positionToUpdate is the position vector to update with the result
  18214. * @param particle is the particle we are computed the position for
  18215. */
  18216. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18217. /**
  18218. * Clones the current emitter and returns a copy of it
  18219. * @returns the new emitter
  18220. */
  18221. clone(): CylinderParticleEmitter;
  18222. /**
  18223. * Called by the GPUParticleSystem to setup the update shader
  18224. * @param effect defines the update shader
  18225. */
  18226. applyToShader(effect: Effect): void;
  18227. /**
  18228. * Returns a string to use to update the GPU particles update shader
  18229. * @returns a string containng the defines string
  18230. */
  18231. getEffectDefines(): string;
  18232. /**
  18233. * Returns the string "CylinderParticleEmitter"
  18234. * @returns a string containing the class name
  18235. */
  18236. getClassName(): string;
  18237. /**
  18238. * Serializes the particle system to a JSON object.
  18239. * @returns the JSON object
  18240. */
  18241. serialize(): any;
  18242. /**
  18243. * Parse properties from a JSON object
  18244. * @param serializationObject defines the JSON object
  18245. */
  18246. parse(serializationObject: any): void;
  18247. }
  18248. /**
  18249. * Particle emitter emitting particles from the inside of a cylinder.
  18250. * It emits the particles randomly between two vectors.
  18251. */
  18252. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18253. /**
  18254. * The min limit of the emission direction.
  18255. */
  18256. direction1: Vector3;
  18257. /**
  18258. * The max limit of the emission direction.
  18259. */
  18260. direction2: Vector3;
  18261. /**
  18262. * Creates a new instance CylinderDirectedParticleEmitter
  18263. * @param radius the radius of the emission cylinder (1 by default)
  18264. * @param height the height of the emission cylinder (1 by default)
  18265. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18266. * @param direction1 the min limit of the emission direction (up vector by default)
  18267. * @param direction2 the max limit of the emission direction (up vector by default)
  18268. */
  18269. constructor(radius?: number, height?: number, radiusRange?: number,
  18270. /**
  18271. * The min limit of the emission direction.
  18272. */
  18273. direction1?: Vector3,
  18274. /**
  18275. * The max limit of the emission direction.
  18276. */
  18277. direction2?: Vector3);
  18278. /**
  18279. * Called by the particle System when the direction is computed for the created particle.
  18280. * @param worldMatrix is the world matrix of the particle system
  18281. * @param directionToUpdate is the direction vector to update with the result
  18282. * @param particle is the particle we are computed the direction for
  18283. */
  18284. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18285. /**
  18286. * Clones the current emitter and returns a copy of it
  18287. * @returns the new emitter
  18288. */
  18289. clone(): CylinderDirectedParticleEmitter;
  18290. /**
  18291. * Called by the GPUParticleSystem to setup the update shader
  18292. * @param effect defines the update shader
  18293. */
  18294. applyToShader(effect: Effect): void;
  18295. /**
  18296. * Returns a string to use to update the GPU particles update shader
  18297. * @returns a string containng the defines string
  18298. */
  18299. getEffectDefines(): string;
  18300. /**
  18301. * Returns the string "CylinderDirectedParticleEmitter"
  18302. * @returns a string containing the class name
  18303. */
  18304. getClassName(): string;
  18305. /**
  18306. * Serializes the particle system to a JSON object.
  18307. * @returns the JSON object
  18308. */
  18309. serialize(): any;
  18310. /**
  18311. * Parse properties from a JSON object
  18312. * @param serializationObject defines the JSON object
  18313. */
  18314. parse(serializationObject: any): void;
  18315. }
  18316. }
  18317. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18318. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18319. import { Effect } from "babylonjs/Materials/effect";
  18320. import { Particle } from "babylonjs/Particles/particle";
  18321. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18322. /**
  18323. * Particle emitter emitting particles from the inside of a hemisphere.
  18324. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18325. */
  18326. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18327. /**
  18328. * The radius of the emission hemisphere.
  18329. */
  18330. radius: number;
  18331. /**
  18332. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18333. */
  18334. radiusRange: number;
  18335. /**
  18336. * How much to randomize the particle direction [0-1].
  18337. */
  18338. directionRandomizer: number;
  18339. /**
  18340. * Creates a new instance HemisphericParticleEmitter
  18341. * @param radius the radius of the emission hemisphere (1 by default)
  18342. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18343. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18344. */
  18345. constructor(
  18346. /**
  18347. * The radius of the emission hemisphere.
  18348. */
  18349. radius?: number,
  18350. /**
  18351. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18352. */
  18353. radiusRange?: number,
  18354. /**
  18355. * How much to randomize the particle direction [0-1].
  18356. */
  18357. directionRandomizer?: number);
  18358. /**
  18359. * Called by the particle System when the direction is computed for the created particle.
  18360. * @param worldMatrix is the world matrix of the particle system
  18361. * @param directionToUpdate is the direction vector to update with the result
  18362. * @param particle is the particle we are computed the direction for
  18363. */
  18364. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18365. /**
  18366. * Called by the particle System when the position is computed for the created particle.
  18367. * @param worldMatrix is the world matrix of the particle system
  18368. * @param positionToUpdate is the position vector to update with the result
  18369. * @param particle is the particle we are computed the position for
  18370. */
  18371. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18372. /**
  18373. * Clones the current emitter and returns a copy of it
  18374. * @returns the new emitter
  18375. */
  18376. clone(): HemisphericParticleEmitter;
  18377. /**
  18378. * Called by the GPUParticleSystem to setup the update shader
  18379. * @param effect defines the update shader
  18380. */
  18381. applyToShader(effect: Effect): void;
  18382. /**
  18383. * Returns a string to use to update the GPU particles update shader
  18384. * @returns a string containng the defines string
  18385. */
  18386. getEffectDefines(): string;
  18387. /**
  18388. * Returns the string "HemisphericParticleEmitter"
  18389. * @returns a string containing the class name
  18390. */
  18391. getClassName(): string;
  18392. /**
  18393. * Serializes the particle system to a JSON object.
  18394. * @returns the JSON object
  18395. */
  18396. serialize(): any;
  18397. /**
  18398. * Parse properties from a JSON object
  18399. * @param serializationObject defines the JSON object
  18400. */
  18401. parse(serializationObject: any): void;
  18402. }
  18403. }
  18404. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18405. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18406. import { Effect } from "babylonjs/Materials/effect";
  18407. import { Particle } from "babylonjs/Particles/particle";
  18408. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18409. /**
  18410. * Particle emitter emitting particles from a point.
  18411. * It emits the particles randomly between 2 given directions.
  18412. */
  18413. export class PointParticleEmitter implements IParticleEmitterType {
  18414. /**
  18415. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18416. */
  18417. direction1: Vector3;
  18418. /**
  18419. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18420. */
  18421. direction2: Vector3;
  18422. /**
  18423. * Creates a new instance PointParticleEmitter
  18424. */
  18425. constructor();
  18426. /**
  18427. * Called by the particle System when the direction is computed for the created particle.
  18428. * @param worldMatrix is the world matrix of the particle system
  18429. * @param directionToUpdate is the direction vector to update with the result
  18430. * @param particle is the particle we are computed the direction for
  18431. */
  18432. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18433. /**
  18434. * Called by the particle System when the position is computed for the created particle.
  18435. * @param worldMatrix is the world matrix of the particle system
  18436. * @param positionToUpdate is the position vector to update with the result
  18437. * @param particle is the particle we are computed the position for
  18438. */
  18439. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18440. /**
  18441. * Clones the current emitter and returns a copy of it
  18442. * @returns the new emitter
  18443. */
  18444. clone(): PointParticleEmitter;
  18445. /**
  18446. * Called by the GPUParticleSystem to setup the update shader
  18447. * @param effect defines the update shader
  18448. */
  18449. applyToShader(effect: Effect): void;
  18450. /**
  18451. * Returns a string to use to update the GPU particles update shader
  18452. * @returns a string containng the defines string
  18453. */
  18454. getEffectDefines(): string;
  18455. /**
  18456. * Returns the string "PointParticleEmitter"
  18457. * @returns a string containing the class name
  18458. */
  18459. getClassName(): string;
  18460. /**
  18461. * Serializes the particle system to a JSON object.
  18462. * @returns the JSON object
  18463. */
  18464. serialize(): any;
  18465. /**
  18466. * Parse properties from a JSON object
  18467. * @param serializationObject defines the JSON object
  18468. */
  18469. parse(serializationObject: any): void;
  18470. }
  18471. }
  18472. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18473. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18474. import { Effect } from "babylonjs/Materials/effect";
  18475. import { Particle } from "babylonjs/Particles/particle";
  18476. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18477. /**
  18478. * Particle emitter emitting particles from the inside of a sphere.
  18479. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18480. */
  18481. export class SphereParticleEmitter implements IParticleEmitterType {
  18482. /**
  18483. * The radius of the emission sphere.
  18484. */
  18485. radius: number;
  18486. /**
  18487. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18488. */
  18489. radiusRange: number;
  18490. /**
  18491. * How much to randomize the particle direction [0-1].
  18492. */
  18493. directionRandomizer: number;
  18494. /**
  18495. * Creates a new instance SphereParticleEmitter
  18496. * @param radius the radius of the emission sphere (1 by default)
  18497. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18498. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18499. */
  18500. constructor(
  18501. /**
  18502. * The radius of the emission sphere.
  18503. */
  18504. radius?: number,
  18505. /**
  18506. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18507. */
  18508. radiusRange?: number,
  18509. /**
  18510. * How much to randomize the particle direction [0-1].
  18511. */
  18512. directionRandomizer?: number);
  18513. /**
  18514. * Called by the particle System when the direction is computed for the created particle.
  18515. * @param worldMatrix is the world matrix of the particle system
  18516. * @param directionToUpdate is the direction vector to update with the result
  18517. * @param particle is the particle we are computed the direction for
  18518. */
  18519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18520. /**
  18521. * Called by the particle System when the position is computed for the created particle.
  18522. * @param worldMatrix is the world matrix of the particle system
  18523. * @param positionToUpdate is the position vector to update with the result
  18524. * @param particle is the particle we are computed the position for
  18525. */
  18526. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18527. /**
  18528. * Clones the current emitter and returns a copy of it
  18529. * @returns the new emitter
  18530. */
  18531. clone(): SphereParticleEmitter;
  18532. /**
  18533. * Called by the GPUParticleSystem to setup the update shader
  18534. * @param effect defines the update shader
  18535. */
  18536. applyToShader(effect: Effect): void;
  18537. /**
  18538. * Returns a string to use to update the GPU particles update shader
  18539. * @returns a string containng the defines string
  18540. */
  18541. getEffectDefines(): string;
  18542. /**
  18543. * Returns the string "SphereParticleEmitter"
  18544. * @returns a string containing the class name
  18545. */
  18546. getClassName(): string;
  18547. /**
  18548. * Serializes the particle system to a JSON object.
  18549. * @returns the JSON object
  18550. */
  18551. serialize(): any;
  18552. /**
  18553. * Parse properties from a JSON object
  18554. * @param serializationObject defines the JSON object
  18555. */
  18556. parse(serializationObject: any): void;
  18557. }
  18558. /**
  18559. * Particle emitter emitting particles from the inside of a sphere.
  18560. * It emits the particles randomly between two vectors.
  18561. */
  18562. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18563. /**
  18564. * The min limit of the emission direction.
  18565. */
  18566. direction1: Vector3;
  18567. /**
  18568. * The max limit of the emission direction.
  18569. */
  18570. direction2: Vector3;
  18571. /**
  18572. * Creates a new instance SphereDirectedParticleEmitter
  18573. * @param radius the radius of the emission sphere (1 by default)
  18574. * @param direction1 the min limit of the emission direction (up vector by default)
  18575. * @param direction2 the max limit of the emission direction (up vector by default)
  18576. */
  18577. constructor(radius?: number,
  18578. /**
  18579. * The min limit of the emission direction.
  18580. */
  18581. direction1?: Vector3,
  18582. /**
  18583. * The max limit of the emission direction.
  18584. */
  18585. direction2?: Vector3);
  18586. /**
  18587. * Called by the particle System when the direction is computed for the created particle.
  18588. * @param worldMatrix is the world matrix of the particle system
  18589. * @param directionToUpdate is the direction vector to update with the result
  18590. * @param particle is the particle we are computed the direction for
  18591. */
  18592. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18593. /**
  18594. * Clones the current emitter and returns a copy of it
  18595. * @returns the new emitter
  18596. */
  18597. clone(): SphereDirectedParticleEmitter;
  18598. /**
  18599. * Called by the GPUParticleSystem to setup the update shader
  18600. * @param effect defines the update shader
  18601. */
  18602. applyToShader(effect: Effect): void;
  18603. /**
  18604. * Returns a string to use to update the GPU particles update shader
  18605. * @returns a string containng the defines string
  18606. */
  18607. getEffectDefines(): string;
  18608. /**
  18609. * Returns the string "SphereDirectedParticleEmitter"
  18610. * @returns a string containing the class name
  18611. */
  18612. getClassName(): string;
  18613. /**
  18614. * Serializes the particle system to a JSON object.
  18615. * @returns the JSON object
  18616. */
  18617. serialize(): any;
  18618. /**
  18619. * Parse properties from a JSON object
  18620. * @param serializationObject defines the JSON object
  18621. */
  18622. parse(serializationObject: any): void;
  18623. }
  18624. }
  18625. declare module "babylonjs/Particles/EmitterTypes/index" {
  18626. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18627. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18628. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18629. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18630. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18631. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18632. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18633. }
  18634. declare module "babylonjs/Particles/IParticleSystem" {
  18635. import { Nullable } from "babylonjs/types";
  18636. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18637. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18639. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18640. import { Texture } from "babylonjs/Materials/Textures/texture";
  18641. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18642. import { Scene } from "babylonjs/scene";
  18643. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18644. import { Animation } from "babylonjs/Animations/animation";
  18645. /**
  18646. * Interface representing a particle system in Babylon.js.
  18647. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18648. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18649. */
  18650. export interface IParticleSystem {
  18651. /**
  18652. * List of animations used by the particle system.
  18653. */
  18654. animations: Animation[];
  18655. /**
  18656. * The id of the Particle system.
  18657. */
  18658. id: string;
  18659. /**
  18660. * The name of the Particle system.
  18661. */
  18662. name: string;
  18663. /**
  18664. * The emitter represents the Mesh or position we are attaching the particle system to.
  18665. */
  18666. emitter: Nullable<AbstractMesh | Vector3>;
  18667. /**
  18668. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18669. */
  18670. isBillboardBased: boolean;
  18671. /**
  18672. * The rendering group used by the Particle system to chose when to render.
  18673. */
  18674. renderingGroupId: number;
  18675. /**
  18676. * The layer mask we are rendering the particles through.
  18677. */
  18678. layerMask: number;
  18679. /**
  18680. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18681. */
  18682. updateSpeed: number;
  18683. /**
  18684. * The amount of time the particle system is running (depends of the overall update speed).
  18685. */
  18686. targetStopDuration: number;
  18687. /**
  18688. * The texture used to render each particle. (this can be a spritesheet)
  18689. */
  18690. particleTexture: Nullable<Texture>;
  18691. /**
  18692. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18693. */
  18694. blendMode: number;
  18695. /**
  18696. * Minimum life time of emitting particles.
  18697. */
  18698. minLifeTime: number;
  18699. /**
  18700. * Maximum life time of emitting particles.
  18701. */
  18702. maxLifeTime: number;
  18703. /**
  18704. * Minimum Size of emitting particles.
  18705. */
  18706. minSize: number;
  18707. /**
  18708. * Maximum Size of emitting particles.
  18709. */
  18710. maxSize: number;
  18711. /**
  18712. * Minimum scale of emitting particles on X axis.
  18713. */
  18714. minScaleX: number;
  18715. /**
  18716. * Maximum scale of emitting particles on X axis.
  18717. */
  18718. maxScaleX: number;
  18719. /**
  18720. * Minimum scale of emitting particles on Y axis.
  18721. */
  18722. minScaleY: number;
  18723. /**
  18724. * Maximum scale of emitting particles on Y axis.
  18725. */
  18726. maxScaleY: number;
  18727. /**
  18728. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18729. */
  18730. color1: Color4;
  18731. /**
  18732. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18733. */
  18734. color2: Color4;
  18735. /**
  18736. * Color the particle will have at the end of its lifetime.
  18737. */
  18738. colorDead: Color4;
  18739. /**
  18740. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18741. */
  18742. emitRate: number;
  18743. /**
  18744. * You can use gravity if you want to give an orientation to your particles.
  18745. */
  18746. gravity: Vector3;
  18747. /**
  18748. * Minimum power of emitting particles.
  18749. */
  18750. minEmitPower: number;
  18751. /**
  18752. * Maximum power of emitting particles.
  18753. */
  18754. maxEmitPower: number;
  18755. /**
  18756. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18757. */
  18758. minAngularSpeed: number;
  18759. /**
  18760. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18761. */
  18762. maxAngularSpeed: number;
  18763. /**
  18764. * Gets or sets the minimal initial rotation in radians.
  18765. */
  18766. minInitialRotation: number;
  18767. /**
  18768. * Gets or sets the maximal initial rotation in radians.
  18769. */
  18770. maxInitialRotation: number;
  18771. /**
  18772. * The particle emitter type defines the emitter used by the particle system.
  18773. * It can be for example box, sphere, or cone...
  18774. */
  18775. particleEmitterType: Nullable<IParticleEmitterType>;
  18776. /**
  18777. * Defines the delay in milliseconds before starting the system (0 by default)
  18778. */
  18779. startDelay: number;
  18780. /**
  18781. * 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
  18782. */
  18783. preWarmCycles: number;
  18784. /**
  18785. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18786. */
  18787. preWarmStepOffset: number;
  18788. /**
  18789. * 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)
  18790. */
  18791. spriteCellChangeSpeed: number;
  18792. /**
  18793. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18794. */
  18795. startSpriteCellID: number;
  18796. /**
  18797. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18798. */
  18799. endSpriteCellID: number;
  18800. /**
  18801. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18802. */
  18803. spriteCellWidth: number;
  18804. /**
  18805. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18806. */
  18807. spriteCellHeight: number;
  18808. /**
  18809. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18810. */
  18811. spriteRandomStartCell: boolean;
  18812. /**
  18813. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18814. */
  18815. isAnimationSheetEnabled: boolean;
  18816. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18817. translationPivot: Vector2;
  18818. /**
  18819. * Gets or sets a texture used to add random noise to particle positions
  18820. */
  18821. noiseTexture: Nullable<BaseTexture>;
  18822. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18823. noiseStrength: Vector3;
  18824. /**
  18825. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18826. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18827. */
  18828. billboardMode: number;
  18829. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18830. limitVelocityDamping: number;
  18831. /**
  18832. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18833. */
  18834. beginAnimationOnStart: boolean;
  18835. /**
  18836. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18837. */
  18838. beginAnimationFrom: number;
  18839. /**
  18840. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18841. */
  18842. beginAnimationTo: number;
  18843. /**
  18844. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18845. */
  18846. beginAnimationLoop: boolean;
  18847. /**
  18848. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18849. */
  18850. disposeOnStop: boolean;
  18851. /**
  18852. * Gets the maximum number of particles active at the same time.
  18853. * @returns The max number of active particles.
  18854. */
  18855. getCapacity(): number;
  18856. /**
  18857. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18858. * @returns True if it has been started, otherwise false.
  18859. */
  18860. isStarted(): boolean;
  18861. /**
  18862. * Animates the particle system for this frame.
  18863. */
  18864. animate(): void;
  18865. /**
  18866. * Renders the particle system in its current state.
  18867. * @returns the current number of particles
  18868. */
  18869. render(): number;
  18870. /**
  18871. * Dispose the particle system and frees its associated resources.
  18872. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18873. */
  18874. dispose(disposeTexture?: boolean): void;
  18875. /**
  18876. * Clones the particle system.
  18877. * @param name The name of the cloned object
  18878. * @param newEmitter The new emitter to use
  18879. * @returns the cloned particle system
  18880. */
  18881. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18882. /**
  18883. * Serializes the particle system to a JSON object.
  18884. * @returns the JSON object
  18885. */
  18886. serialize(): any;
  18887. /**
  18888. * Rebuild the particle system
  18889. */
  18890. rebuild(): void;
  18891. /**
  18892. * Starts the particle system and begins to emit
  18893. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18894. */
  18895. start(delay?: number): void;
  18896. /**
  18897. * Stops the particle system.
  18898. */
  18899. stop(): void;
  18900. /**
  18901. * Remove all active particles
  18902. */
  18903. reset(): void;
  18904. /**
  18905. * Is this system ready to be used/rendered
  18906. * @return true if the system is ready
  18907. */
  18908. isReady(): boolean;
  18909. /**
  18910. * Adds a new color gradient
  18911. * @param gradient defines the gradient to use (between 0 and 1)
  18912. * @param color1 defines the color to affect to the specified gradient
  18913. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18914. * @returns the current particle system
  18915. */
  18916. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18917. /**
  18918. * Remove a specific color gradient
  18919. * @param gradient defines the gradient to remove
  18920. * @returns the current particle system
  18921. */
  18922. removeColorGradient(gradient: number): IParticleSystem;
  18923. /**
  18924. * Adds a new size gradient
  18925. * @param gradient defines the gradient to use (between 0 and 1)
  18926. * @param factor defines the size factor to affect to the specified gradient
  18927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18928. * @returns the current particle system
  18929. */
  18930. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18931. /**
  18932. * Remove a specific size gradient
  18933. * @param gradient defines the gradient to remove
  18934. * @returns the current particle system
  18935. */
  18936. removeSizeGradient(gradient: number): IParticleSystem;
  18937. /**
  18938. * Gets the current list of color gradients.
  18939. * You must use addColorGradient and removeColorGradient to udpate this list
  18940. * @returns the list of color gradients
  18941. */
  18942. getColorGradients(): Nullable<Array<ColorGradient>>;
  18943. /**
  18944. * Gets the current list of size gradients.
  18945. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18946. * @returns the list of size gradients
  18947. */
  18948. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18949. /**
  18950. * Gets the current list of angular speed gradients.
  18951. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18952. * @returns the list of angular speed gradients
  18953. */
  18954. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18955. /**
  18956. * Adds a new angular speed gradient
  18957. * @param gradient defines the gradient to use (between 0 and 1)
  18958. * @param factor defines the angular speed to affect to the specified gradient
  18959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18960. * @returns the current particle system
  18961. */
  18962. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18963. /**
  18964. * Remove a specific angular speed gradient
  18965. * @param gradient defines the gradient to remove
  18966. * @returns the current particle system
  18967. */
  18968. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18969. /**
  18970. * Gets the current list of velocity gradients.
  18971. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18972. * @returns the list of velocity gradients
  18973. */
  18974. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18975. /**
  18976. * Adds a new velocity gradient
  18977. * @param gradient defines the gradient to use (between 0 and 1)
  18978. * @param factor defines the velocity to affect to the specified gradient
  18979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18980. * @returns the current particle system
  18981. */
  18982. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18983. /**
  18984. * Remove a specific velocity gradient
  18985. * @param gradient defines the gradient to remove
  18986. * @returns the current particle system
  18987. */
  18988. removeVelocityGradient(gradient: number): IParticleSystem;
  18989. /**
  18990. * Gets the current list of limit velocity gradients.
  18991. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18992. * @returns the list of limit velocity gradients
  18993. */
  18994. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18995. /**
  18996. * Adds a new limit velocity gradient
  18997. * @param gradient defines the gradient to use (between 0 and 1)
  18998. * @param factor defines the limit velocity to affect to the specified gradient
  18999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19000. * @returns the current particle system
  19001. */
  19002. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19003. /**
  19004. * Remove a specific limit velocity gradient
  19005. * @param gradient defines the gradient to remove
  19006. * @returns the current particle system
  19007. */
  19008. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19009. /**
  19010. * Adds a new drag gradient
  19011. * @param gradient defines the gradient to use (between 0 and 1)
  19012. * @param factor defines the drag to affect to the specified gradient
  19013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19014. * @returns the current particle system
  19015. */
  19016. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19017. /**
  19018. * Remove a specific drag gradient
  19019. * @param gradient defines the gradient to remove
  19020. * @returns the current particle system
  19021. */
  19022. removeDragGradient(gradient: number): IParticleSystem;
  19023. /**
  19024. * Gets the current list of drag gradients.
  19025. * You must use addDragGradient and removeDragGradient to udpate this list
  19026. * @returns the list of drag gradients
  19027. */
  19028. getDragGradients(): Nullable<Array<FactorGradient>>;
  19029. /**
  19030. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19031. * @param gradient defines the gradient to use (between 0 and 1)
  19032. * @param factor defines the emit rate to affect to the specified gradient
  19033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19034. * @returns the current particle system
  19035. */
  19036. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19037. /**
  19038. * Remove a specific emit rate gradient
  19039. * @param gradient defines the gradient to remove
  19040. * @returns the current particle system
  19041. */
  19042. removeEmitRateGradient(gradient: number): IParticleSystem;
  19043. /**
  19044. * Gets the current list of emit rate gradients.
  19045. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19046. * @returns the list of emit rate gradients
  19047. */
  19048. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19049. /**
  19050. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19051. * @param gradient defines the gradient to use (between 0 and 1)
  19052. * @param factor defines the start size to affect to the specified gradient
  19053. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19054. * @returns the current particle system
  19055. */
  19056. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19057. /**
  19058. * Remove a specific start size gradient
  19059. * @param gradient defines the gradient to remove
  19060. * @returns the current particle system
  19061. */
  19062. removeStartSizeGradient(gradient: number): IParticleSystem;
  19063. /**
  19064. * Gets the current list of start size gradients.
  19065. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19066. * @returns the list of start size gradients
  19067. */
  19068. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19069. /**
  19070. * Adds a new life time gradient
  19071. * @param gradient defines the gradient to use (between 0 and 1)
  19072. * @param factor defines the life time factor to affect to the specified gradient
  19073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19074. * @returns the current particle system
  19075. */
  19076. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19077. /**
  19078. * Remove a specific life time gradient
  19079. * @param gradient defines the gradient to remove
  19080. * @returns the current particle system
  19081. */
  19082. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19083. /**
  19084. * Gets the current list of life time gradients.
  19085. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19086. * @returns the list of life time gradients
  19087. */
  19088. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19089. /**
  19090. * Gets the current list of color gradients.
  19091. * You must use addColorGradient and removeColorGradient to udpate this list
  19092. * @returns the list of color gradients
  19093. */
  19094. getColorGradients(): Nullable<Array<ColorGradient>>;
  19095. /**
  19096. * Adds a new ramp gradient used to remap particle colors
  19097. * @param gradient defines the gradient to use (between 0 and 1)
  19098. * @param color defines the color to affect to the specified gradient
  19099. * @returns the current particle system
  19100. */
  19101. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19102. /**
  19103. * Gets the current list of ramp gradients.
  19104. * You must use addRampGradient and removeRampGradient to udpate this list
  19105. * @returns the list of ramp gradients
  19106. */
  19107. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19108. /** Gets or sets a boolean indicating that ramp gradients must be used
  19109. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19110. */
  19111. useRampGradients: boolean;
  19112. /**
  19113. * Adds a new color remap gradient
  19114. * @param gradient defines the gradient to use (between 0 and 1)
  19115. * @param min defines the color remap minimal range
  19116. * @param max defines the color remap maximal range
  19117. * @returns the current particle system
  19118. */
  19119. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19120. /**
  19121. * Gets the current list of color remap gradients.
  19122. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19123. * @returns the list of color remap gradients
  19124. */
  19125. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19126. /**
  19127. * Adds a new alpha remap gradient
  19128. * @param gradient defines the gradient to use (between 0 and 1)
  19129. * @param min defines the alpha remap minimal range
  19130. * @param max defines the alpha remap maximal range
  19131. * @returns the current particle system
  19132. */
  19133. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19134. /**
  19135. * Gets the current list of alpha remap gradients.
  19136. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19137. * @returns the list of alpha remap gradients
  19138. */
  19139. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19140. /**
  19141. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19142. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19143. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19144. * @returns the emitter
  19145. */
  19146. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19147. /**
  19148. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19149. * @param radius The radius of the hemisphere to emit from
  19150. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19151. * @returns the emitter
  19152. */
  19153. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19154. /**
  19155. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19156. * @param radius The radius of the sphere to emit from
  19157. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19158. * @returns the emitter
  19159. */
  19160. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19161. /**
  19162. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19163. * @param radius The radius of the sphere to emit from
  19164. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19165. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19166. * @returns the emitter
  19167. */
  19168. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19169. /**
  19170. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19171. * @param radius The radius of the emission cylinder
  19172. * @param height The height of the emission cylinder
  19173. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19174. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19175. * @returns the emitter
  19176. */
  19177. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19178. /**
  19179. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19180. * @param radius The radius of the cylinder to emit from
  19181. * @param height The height of the emission cylinder
  19182. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19183. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19184. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19185. * @returns the emitter
  19186. */
  19187. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19188. /**
  19189. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19190. * @param radius The radius of the cone to emit from
  19191. * @param angle The base angle of the cone
  19192. * @returns the emitter
  19193. */
  19194. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19195. /**
  19196. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19197. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19198. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19199. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19200. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19201. * @returns the emitter
  19202. */
  19203. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19204. /**
  19205. * Get hosting scene
  19206. * @returns the scene
  19207. */
  19208. getScene(): Scene;
  19209. }
  19210. }
  19211. declare module "babylonjs/Meshes/instancedMesh" {
  19212. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19213. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19214. import { Camera } from "babylonjs/Cameras/camera";
  19215. import { Node } from "babylonjs/node";
  19216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19217. import { Mesh } from "babylonjs/Meshes/mesh";
  19218. import { Material } from "babylonjs/Materials/material";
  19219. import { Skeleton } from "babylonjs/Bones/skeleton";
  19220. import { Light } from "babylonjs/Lights/light";
  19221. /**
  19222. * Creates an instance based on a source mesh.
  19223. */
  19224. export class InstancedMesh extends AbstractMesh {
  19225. private _sourceMesh;
  19226. private _currentLOD;
  19227. /** @hidden */
  19228. _indexInSourceMeshInstanceArray: number;
  19229. constructor(name: string, source: Mesh);
  19230. /**
  19231. * Returns the string "InstancedMesh".
  19232. */
  19233. getClassName(): string;
  19234. /** Gets the list of lights affecting that mesh */
  19235. readonly lightSources: Light[];
  19236. _resyncLightSources(): void;
  19237. _resyncLighSource(light: Light): void;
  19238. _removeLightSource(light: Light, dispose: boolean): void;
  19239. /**
  19240. * If the source mesh receives shadows
  19241. */
  19242. readonly receiveShadows: boolean;
  19243. /**
  19244. * The material of the source mesh
  19245. */
  19246. readonly material: Nullable<Material>;
  19247. /**
  19248. * Visibility of the source mesh
  19249. */
  19250. readonly visibility: number;
  19251. /**
  19252. * Skeleton of the source mesh
  19253. */
  19254. readonly skeleton: Nullable<Skeleton>;
  19255. /**
  19256. * Rendering ground id of the source mesh
  19257. */
  19258. renderingGroupId: number;
  19259. /**
  19260. * Returns the total number of vertices (integer).
  19261. */
  19262. getTotalVertices(): number;
  19263. /**
  19264. * Returns a positive integer : the total number of indices in this mesh geometry.
  19265. * @returns the numner of indices or zero if the mesh has no geometry.
  19266. */
  19267. getTotalIndices(): number;
  19268. /**
  19269. * The source mesh of the instance
  19270. */
  19271. readonly sourceMesh: Mesh;
  19272. /**
  19273. * Is this node ready to be used/rendered
  19274. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19275. * @return {boolean} is it ready
  19276. */
  19277. isReady(completeCheck?: boolean): boolean;
  19278. /**
  19279. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19280. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19281. * @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.
  19282. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19283. */
  19284. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19285. /**
  19286. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19287. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19288. * The `data` are either a numeric array either a Float32Array.
  19289. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19290. * 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).
  19291. * Note that a new underlying VertexBuffer object is created each call.
  19292. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19293. *
  19294. * Possible `kind` values :
  19295. * - VertexBuffer.PositionKind
  19296. * - VertexBuffer.UVKind
  19297. * - VertexBuffer.UV2Kind
  19298. * - VertexBuffer.UV3Kind
  19299. * - VertexBuffer.UV4Kind
  19300. * - VertexBuffer.UV5Kind
  19301. * - VertexBuffer.UV6Kind
  19302. * - VertexBuffer.ColorKind
  19303. * - VertexBuffer.MatricesIndicesKind
  19304. * - VertexBuffer.MatricesIndicesExtraKind
  19305. * - VertexBuffer.MatricesWeightsKind
  19306. * - VertexBuffer.MatricesWeightsExtraKind
  19307. *
  19308. * Returns the Mesh.
  19309. */
  19310. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19311. /**
  19312. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19313. * If the mesh has no geometry, it is simply returned as it is.
  19314. * The `data` are either a numeric array either a Float32Array.
  19315. * No new underlying VertexBuffer object is created.
  19316. * 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.
  19317. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19318. *
  19319. * Possible `kind` values :
  19320. * - VertexBuffer.PositionKind
  19321. * - VertexBuffer.UVKind
  19322. * - VertexBuffer.UV2Kind
  19323. * - VertexBuffer.UV3Kind
  19324. * - VertexBuffer.UV4Kind
  19325. * - VertexBuffer.UV5Kind
  19326. * - VertexBuffer.UV6Kind
  19327. * - VertexBuffer.ColorKind
  19328. * - VertexBuffer.MatricesIndicesKind
  19329. * - VertexBuffer.MatricesIndicesExtraKind
  19330. * - VertexBuffer.MatricesWeightsKind
  19331. * - VertexBuffer.MatricesWeightsExtraKind
  19332. *
  19333. * Returns the Mesh.
  19334. */
  19335. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19336. /**
  19337. * Sets the mesh indices.
  19338. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19339. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19340. * This method creates a new index buffer each call.
  19341. * Returns the Mesh.
  19342. */
  19343. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19344. /**
  19345. * Boolean : True if the mesh owns the requested kind of data.
  19346. */
  19347. isVerticesDataPresent(kind: string): boolean;
  19348. /**
  19349. * Returns an array of indices (IndicesArray).
  19350. */
  19351. getIndices(): Nullable<IndicesArray>;
  19352. readonly _positions: Nullable<Vector3[]>;
  19353. /**
  19354. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19355. * This means the mesh underlying bounding box and sphere are recomputed.
  19356. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19357. * @returns the current mesh
  19358. */
  19359. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19360. /** @hidden */
  19361. _preActivate(): InstancedMesh;
  19362. /** @hidden */
  19363. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19364. /** @hidden */
  19365. _postActivate(): void;
  19366. getWorldMatrix(): Matrix;
  19367. readonly isAnInstance: boolean;
  19368. /**
  19369. * Returns the current associated LOD AbstractMesh.
  19370. */
  19371. getLOD(camera: Camera): AbstractMesh;
  19372. /** @hidden */
  19373. _syncSubMeshes(): InstancedMesh;
  19374. /** @hidden */
  19375. _generatePointsArray(): boolean;
  19376. /**
  19377. * Creates a new InstancedMesh from the current mesh.
  19378. * - name (string) : the cloned mesh name
  19379. * - newParent (optional Node) : the optional Node to parent the clone to.
  19380. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19381. *
  19382. * Returns the clone.
  19383. */
  19384. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19385. /**
  19386. * Disposes the InstancedMesh.
  19387. * Returns nothing.
  19388. */
  19389. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19390. }
  19391. }
  19392. declare module "babylonjs/Materials/shaderMaterial" {
  19393. import { Scene } from "babylonjs/scene";
  19394. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19396. import { Mesh } from "babylonjs/Meshes/mesh";
  19397. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19398. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19399. import { Texture } from "babylonjs/Materials/Textures/texture";
  19400. import { Material } from "babylonjs/Materials/material";
  19401. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19402. /**
  19403. * Defines the options associated with the creation of a shader material.
  19404. */
  19405. export interface IShaderMaterialOptions {
  19406. /**
  19407. * Does the material work in alpha blend mode
  19408. */
  19409. needAlphaBlending: boolean;
  19410. /**
  19411. * Does the material work in alpha test mode
  19412. */
  19413. needAlphaTesting: boolean;
  19414. /**
  19415. * The list of attribute names used in the shader
  19416. */
  19417. attributes: string[];
  19418. /**
  19419. * The list of unifrom names used in the shader
  19420. */
  19421. uniforms: string[];
  19422. /**
  19423. * The list of UBO names used in the shader
  19424. */
  19425. uniformBuffers: string[];
  19426. /**
  19427. * The list of sampler names used in the shader
  19428. */
  19429. samplers: string[];
  19430. /**
  19431. * The list of defines used in the shader
  19432. */
  19433. defines: string[];
  19434. }
  19435. /**
  19436. * 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.
  19437. *
  19438. * This returned material effects how the mesh will look based on the code in the shaders.
  19439. *
  19440. * @see http://doc.babylonjs.com/how_to/shader_material
  19441. */
  19442. export class ShaderMaterial extends Material {
  19443. private _shaderPath;
  19444. private _options;
  19445. private _textures;
  19446. private _textureArrays;
  19447. private _floats;
  19448. private _ints;
  19449. private _floatsArrays;
  19450. private _colors3;
  19451. private _colors3Arrays;
  19452. private _colors4;
  19453. private _colors4Arrays;
  19454. private _vectors2;
  19455. private _vectors3;
  19456. private _vectors4;
  19457. private _matrices;
  19458. private _matrices3x3;
  19459. private _matrices2x2;
  19460. private _vectors2Arrays;
  19461. private _vectors3Arrays;
  19462. private _vectors4Arrays;
  19463. private _cachedWorldViewMatrix;
  19464. private _cachedWorldViewProjectionMatrix;
  19465. private _renderId;
  19466. /**
  19467. * Instantiate a new shader material.
  19468. * 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.
  19469. * This returned material effects how the mesh will look based on the code in the shaders.
  19470. * @see http://doc.babylonjs.com/how_to/shader_material
  19471. * @param name Define the name of the material in the scene
  19472. * @param scene Define the scene the material belongs to
  19473. * @param shaderPath Defines the route to the shader code in one of three ways:
  19474. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19475. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19476. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19477. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19478. * @param options Define the options used to create the shader
  19479. */
  19480. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19481. /**
  19482. * Gets the options used to compile the shader.
  19483. * They can be modified to trigger a new compilation
  19484. */
  19485. readonly options: IShaderMaterialOptions;
  19486. /**
  19487. * Gets the current class name of the material e.g. "ShaderMaterial"
  19488. * Mainly use in serialization.
  19489. * @returns the class name
  19490. */
  19491. getClassName(): string;
  19492. /**
  19493. * Specifies if the material will require alpha blending
  19494. * @returns a boolean specifying if alpha blending is needed
  19495. */
  19496. needAlphaBlending(): boolean;
  19497. /**
  19498. * Specifies if this material should be rendered in alpha test mode
  19499. * @returns a boolean specifying if an alpha test is needed.
  19500. */
  19501. needAlphaTesting(): boolean;
  19502. private _checkUniform;
  19503. /**
  19504. * Set a texture in the shader.
  19505. * @param name Define the name of the uniform samplers as defined in the shader
  19506. * @param texture Define the texture to bind to this sampler
  19507. * @return the material itself allowing "fluent" like uniform updates
  19508. */
  19509. setTexture(name: string, texture: Texture): ShaderMaterial;
  19510. /**
  19511. * Set a texture array in the shader.
  19512. * @param name Define the name of the uniform sampler array as defined in the shader
  19513. * @param textures Define the list of textures to bind to this sampler
  19514. * @return the material itself allowing "fluent" like uniform updates
  19515. */
  19516. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19517. /**
  19518. * Set a float in the shader.
  19519. * @param name Define the name of the uniform as defined in the shader
  19520. * @param value Define the value to give to the uniform
  19521. * @return the material itself allowing "fluent" like uniform updates
  19522. */
  19523. setFloat(name: string, value: number): ShaderMaterial;
  19524. /**
  19525. * Set a int in the shader.
  19526. * @param name Define the name of the uniform as defined in the shader
  19527. * @param value Define the value to give to the uniform
  19528. * @return the material itself allowing "fluent" like uniform updates
  19529. */
  19530. setInt(name: string, value: number): ShaderMaterial;
  19531. /**
  19532. * Set an array of floats in the shader.
  19533. * @param name Define the name of the uniform as defined in the shader
  19534. * @param value Define the value to give to the uniform
  19535. * @return the material itself allowing "fluent" like uniform updates
  19536. */
  19537. setFloats(name: string, value: number[]): ShaderMaterial;
  19538. /**
  19539. * Set a vec3 in the shader from a Color3.
  19540. * @param name Define the name of the uniform as defined in the shader
  19541. * @param value Define the value to give to the uniform
  19542. * @return the material itself allowing "fluent" like uniform updates
  19543. */
  19544. setColor3(name: string, value: Color3): ShaderMaterial;
  19545. /**
  19546. * Set a vec3 array in the shader from a Color3 array.
  19547. * @param name Define the name of the uniform as defined in the shader
  19548. * @param value Define the value to give to the uniform
  19549. * @return the material itself allowing "fluent" like uniform updates
  19550. */
  19551. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19552. /**
  19553. * Set a vec4 in the shader from a Color4.
  19554. * @param name Define the name of the uniform as defined in the shader
  19555. * @param value Define the value to give to the uniform
  19556. * @return the material itself allowing "fluent" like uniform updates
  19557. */
  19558. setColor4(name: string, value: Color4): ShaderMaterial;
  19559. /**
  19560. * Set a vec4 array in the shader from a Color4 array.
  19561. * @param name Define the name of the uniform as defined in the shader
  19562. * @param value Define the value to give to the uniform
  19563. * @return the material itself allowing "fluent" like uniform updates
  19564. */
  19565. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19566. /**
  19567. * Set a vec2 in the shader from a Vector2.
  19568. * @param name Define the name of the uniform as defined in the shader
  19569. * @param value Define the value to give to the uniform
  19570. * @return the material itself allowing "fluent" like uniform updates
  19571. */
  19572. setVector2(name: string, value: Vector2): ShaderMaterial;
  19573. /**
  19574. * Set a vec3 in the shader from a Vector3.
  19575. * @param name Define the name of the uniform as defined in the shader
  19576. * @param value Define the value to give to the uniform
  19577. * @return the material itself allowing "fluent" like uniform updates
  19578. */
  19579. setVector3(name: string, value: Vector3): ShaderMaterial;
  19580. /**
  19581. * Set a vec4 in the shader from a Vector4.
  19582. * @param name Define the name of the uniform as defined in the shader
  19583. * @param value Define the value to give to the uniform
  19584. * @return the material itself allowing "fluent" like uniform updates
  19585. */
  19586. setVector4(name: string, value: Vector4): ShaderMaterial;
  19587. /**
  19588. * Set a mat4 in the shader from a Matrix.
  19589. * @param name Define the name of the uniform as defined in the shader
  19590. * @param value Define the value to give to the uniform
  19591. * @return the material itself allowing "fluent" like uniform updates
  19592. */
  19593. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19594. /**
  19595. * Set a mat3 in the shader from a Float32Array.
  19596. * @param name Define the name of the uniform as defined in the shader
  19597. * @param value Define the value to give to the uniform
  19598. * @return the material itself allowing "fluent" like uniform updates
  19599. */
  19600. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19601. /**
  19602. * Set a mat2 in the shader from a Float32Array.
  19603. * @param name Define the name of the uniform as defined in the shader
  19604. * @param value Define the value to give to the uniform
  19605. * @return the material itself allowing "fluent" like uniform updates
  19606. */
  19607. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19608. /**
  19609. * Set a vec2 array in the shader from a number array.
  19610. * @param name Define the name of the uniform as defined in the shader
  19611. * @param value Define the value to give to the uniform
  19612. * @return the material itself allowing "fluent" like uniform updates
  19613. */
  19614. setArray2(name: string, value: number[]): ShaderMaterial;
  19615. /**
  19616. * Set a vec3 array in the shader from a number array.
  19617. * @param name Define the name of the uniform as defined in the shader
  19618. * @param value Define the value to give to the uniform
  19619. * @return the material itself allowing "fluent" like uniform updates
  19620. */
  19621. setArray3(name: string, value: number[]): ShaderMaterial;
  19622. /**
  19623. * Set a vec4 array in the shader from a number array.
  19624. * @param name Define the name of the uniform as defined in the shader
  19625. * @param value Define the value to give to the uniform
  19626. * @return the material itself allowing "fluent" like uniform updates
  19627. */
  19628. setArray4(name: string, value: number[]): ShaderMaterial;
  19629. private _checkCache;
  19630. /**
  19631. * Specifies that the submesh is ready to be used
  19632. * @param mesh defines the mesh to check
  19633. * @param subMesh defines which submesh to check
  19634. * @param useInstances specifies that instances should be used
  19635. * @returns a boolean indicating that the submesh is ready or not
  19636. */
  19637. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19638. /**
  19639. * Checks if the material is ready to render the requested mesh
  19640. * @param mesh Define the mesh to render
  19641. * @param useInstances Define whether or not the material is used with instances
  19642. * @returns true if ready, otherwise false
  19643. */
  19644. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19645. /**
  19646. * Binds the world matrix to the material
  19647. * @param world defines the world transformation matrix
  19648. */
  19649. bindOnlyWorldMatrix(world: Matrix): void;
  19650. /**
  19651. * Binds the material to the mesh
  19652. * @param world defines the world transformation matrix
  19653. * @param mesh defines the mesh to bind the material to
  19654. */
  19655. bind(world: Matrix, mesh?: Mesh): void;
  19656. /**
  19657. * Gets the active textures from the material
  19658. * @returns an array of textures
  19659. */
  19660. getActiveTextures(): BaseTexture[];
  19661. /**
  19662. * Specifies if the material uses a texture
  19663. * @param texture defines the texture to check against the material
  19664. * @returns a boolean specifying if the material uses the texture
  19665. */
  19666. hasTexture(texture: BaseTexture): boolean;
  19667. /**
  19668. * Makes a duplicate of the material, and gives it a new name
  19669. * @param name defines the new name for the duplicated material
  19670. * @returns the cloned material
  19671. */
  19672. clone(name: string): ShaderMaterial;
  19673. /**
  19674. * Disposes the material
  19675. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19676. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19677. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19678. */
  19679. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19680. /**
  19681. * Serializes this material in a JSON representation
  19682. * @returns the serialized material object
  19683. */
  19684. serialize(): any;
  19685. /**
  19686. * Creates a shader material from parsed shader material data
  19687. * @param source defines the JSON represnetation of the material
  19688. * @param scene defines the hosting scene
  19689. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19690. * @returns a new material
  19691. */
  19692. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19693. }
  19694. }
  19695. declare module "babylonjs/Shaders/color.fragment" {
  19696. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19697. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19698. /** @hidden */
  19699. export var colorPixelShader: {
  19700. name: string;
  19701. shader: string;
  19702. };
  19703. }
  19704. declare module "babylonjs/Shaders/color.vertex" {
  19705. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19706. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19707. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19708. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19709. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19710. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19711. /** @hidden */
  19712. export var colorVertexShader: {
  19713. name: string;
  19714. shader: string;
  19715. };
  19716. }
  19717. declare module "babylonjs/Meshes/linesMesh" {
  19718. import { Nullable } from "babylonjs/types";
  19719. import { Scene } from "babylonjs/scene";
  19720. import { Color3 } from "babylonjs/Maths/math.color";
  19721. import { Node } from "babylonjs/node";
  19722. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19723. import { Mesh } from "babylonjs/Meshes/mesh";
  19724. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19725. import { Effect } from "babylonjs/Materials/effect";
  19726. import { Material } from "babylonjs/Materials/material";
  19727. import "babylonjs/Shaders/color.fragment";
  19728. import "babylonjs/Shaders/color.vertex";
  19729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19730. /**
  19731. * Line mesh
  19732. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19733. */
  19734. export class LinesMesh extends Mesh {
  19735. /**
  19736. * If vertex color should be applied to the mesh
  19737. */
  19738. readonly useVertexColor?: boolean | undefined;
  19739. /**
  19740. * If vertex alpha should be applied to the mesh
  19741. */
  19742. readonly useVertexAlpha?: boolean | undefined;
  19743. /**
  19744. * Color of the line (Default: White)
  19745. */
  19746. color: Color3;
  19747. /**
  19748. * Alpha of the line (Default: 1)
  19749. */
  19750. alpha: number;
  19751. /**
  19752. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19753. * This margin is expressed in world space coordinates, so its value may vary.
  19754. * Default value is 0.1
  19755. */
  19756. intersectionThreshold: number;
  19757. private _colorShader;
  19758. private color4;
  19759. /**
  19760. * Creates a new LinesMesh
  19761. * @param name defines the name
  19762. * @param scene defines the hosting scene
  19763. * @param parent defines the parent mesh if any
  19764. * @param source defines the optional source LinesMesh used to clone data from
  19765. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19766. * When false, achieved by calling a clone(), also passing False.
  19767. * This will make creation of children, recursive.
  19768. * @param useVertexColor defines if this LinesMesh supports vertex color
  19769. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19770. */
  19771. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19772. /**
  19773. * If vertex color should be applied to the mesh
  19774. */
  19775. useVertexColor?: boolean | undefined,
  19776. /**
  19777. * If vertex alpha should be applied to the mesh
  19778. */
  19779. useVertexAlpha?: boolean | undefined);
  19780. private _addClipPlaneDefine;
  19781. private _removeClipPlaneDefine;
  19782. isReady(): boolean;
  19783. /**
  19784. * Returns the string "LineMesh"
  19785. */
  19786. getClassName(): string;
  19787. /**
  19788. * @hidden
  19789. */
  19790. /**
  19791. * @hidden
  19792. */
  19793. material: Material;
  19794. /**
  19795. * @hidden
  19796. */
  19797. readonly checkCollisions: boolean;
  19798. /** @hidden */
  19799. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19800. /** @hidden */
  19801. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19802. /**
  19803. * Disposes of the line mesh
  19804. * @param doNotRecurse If children should be disposed
  19805. */
  19806. dispose(doNotRecurse?: boolean): void;
  19807. /**
  19808. * Returns a new LineMesh object cloned from the current one.
  19809. */
  19810. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19811. /**
  19812. * Creates a new InstancedLinesMesh object from the mesh model.
  19813. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19814. * @param name defines the name of the new instance
  19815. * @returns a new InstancedLinesMesh
  19816. */
  19817. createInstance(name: string): InstancedLinesMesh;
  19818. }
  19819. /**
  19820. * Creates an instance based on a source LinesMesh
  19821. */
  19822. export class InstancedLinesMesh extends InstancedMesh {
  19823. /**
  19824. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19825. * This margin is expressed in world space coordinates, so its value may vary.
  19826. * Initilized with the intersectionThreshold value of the source LinesMesh
  19827. */
  19828. intersectionThreshold: number;
  19829. constructor(name: string, source: LinesMesh);
  19830. /**
  19831. * Returns the string "InstancedLinesMesh".
  19832. */
  19833. getClassName(): string;
  19834. }
  19835. }
  19836. declare module "babylonjs/Shaders/line.fragment" {
  19837. /** @hidden */
  19838. export var linePixelShader: {
  19839. name: string;
  19840. shader: string;
  19841. };
  19842. }
  19843. declare module "babylonjs/Shaders/line.vertex" {
  19844. /** @hidden */
  19845. export var lineVertexShader: {
  19846. name: string;
  19847. shader: string;
  19848. };
  19849. }
  19850. declare module "babylonjs/Rendering/edgesRenderer" {
  19851. import { Nullable } from "babylonjs/types";
  19852. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19854. import { Vector3 } from "babylonjs/Maths/math.vector";
  19855. import { IDisposable } from "babylonjs/scene";
  19856. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19857. import "babylonjs/Shaders/line.fragment";
  19858. import "babylonjs/Shaders/line.vertex";
  19859. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19860. module "babylonjs/Meshes/abstractMesh" {
  19861. interface AbstractMesh {
  19862. /**
  19863. * Gets the edgesRenderer associated with the mesh
  19864. */
  19865. edgesRenderer: Nullable<EdgesRenderer>;
  19866. }
  19867. }
  19868. module "babylonjs/Meshes/linesMesh" {
  19869. interface LinesMesh {
  19870. /**
  19871. * Enables the edge rendering mode on the mesh.
  19872. * This mode makes the mesh edges visible
  19873. * @param epsilon defines the maximal distance between two angles to detect a face
  19874. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19875. * @returns the currentAbstractMesh
  19876. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19877. */
  19878. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19879. }
  19880. }
  19881. module "babylonjs/Meshes/linesMesh" {
  19882. interface InstancedLinesMesh {
  19883. /**
  19884. * Enables the edge rendering mode on the mesh.
  19885. * This mode makes the mesh edges visible
  19886. * @param epsilon defines the maximal distance between two angles to detect a face
  19887. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19888. * @returns the current InstancedLinesMesh
  19889. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19890. */
  19891. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19892. }
  19893. }
  19894. /**
  19895. * Defines the minimum contract an Edges renderer should follow.
  19896. */
  19897. export interface IEdgesRenderer extends IDisposable {
  19898. /**
  19899. * Gets or sets a boolean indicating if the edgesRenderer is active
  19900. */
  19901. isEnabled: boolean;
  19902. /**
  19903. * Renders the edges of the attached mesh,
  19904. */
  19905. render(): void;
  19906. /**
  19907. * Checks wether or not the edges renderer is ready to render.
  19908. * @return true if ready, otherwise false.
  19909. */
  19910. isReady(): boolean;
  19911. }
  19912. /**
  19913. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19914. */
  19915. export class EdgesRenderer implements IEdgesRenderer {
  19916. /**
  19917. * Define the size of the edges with an orthographic camera
  19918. */
  19919. edgesWidthScalerForOrthographic: number;
  19920. /**
  19921. * Define the size of the edges with a perspective camera
  19922. */
  19923. edgesWidthScalerForPerspective: number;
  19924. protected _source: AbstractMesh;
  19925. protected _linesPositions: number[];
  19926. protected _linesNormals: number[];
  19927. protected _linesIndices: number[];
  19928. protected _epsilon: number;
  19929. protected _indicesCount: number;
  19930. protected _lineShader: ShaderMaterial;
  19931. protected _ib: DataBuffer;
  19932. protected _buffers: {
  19933. [key: string]: Nullable<VertexBuffer>;
  19934. };
  19935. protected _checkVerticesInsteadOfIndices: boolean;
  19936. private _meshRebuildObserver;
  19937. private _meshDisposeObserver;
  19938. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19939. isEnabled: boolean;
  19940. /**
  19941. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19942. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19943. * @param source Mesh used to create edges
  19944. * @param epsilon sum of angles in adjacency to check for edge
  19945. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19946. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19947. */
  19948. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19949. protected _prepareRessources(): void;
  19950. /** @hidden */
  19951. _rebuild(): void;
  19952. /**
  19953. * Releases the required resources for the edges renderer
  19954. */
  19955. dispose(): void;
  19956. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19957. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19958. /**
  19959. * Checks if the pair of p0 and p1 is en edge
  19960. * @param faceIndex
  19961. * @param edge
  19962. * @param faceNormals
  19963. * @param p0
  19964. * @param p1
  19965. * @private
  19966. */
  19967. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19968. /**
  19969. * push line into the position, normal and index buffer
  19970. * @protected
  19971. */
  19972. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19973. /**
  19974. * Generates lines edges from adjacencjes
  19975. * @private
  19976. */
  19977. _generateEdgesLines(): void;
  19978. /**
  19979. * Checks wether or not the edges renderer is ready to render.
  19980. * @return true if ready, otherwise false.
  19981. */
  19982. isReady(): boolean;
  19983. /**
  19984. * Renders the edges of the attached mesh,
  19985. */
  19986. render(): void;
  19987. }
  19988. /**
  19989. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19990. */
  19991. export class LineEdgesRenderer extends EdgesRenderer {
  19992. /**
  19993. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19994. * @param source LineMesh used to generate edges
  19995. * @param epsilon not important (specified angle for edge detection)
  19996. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19997. */
  19998. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19999. /**
  20000. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20001. */
  20002. _generateEdgesLines(): void;
  20003. }
  20004. }
  20005. declare module "babylonjs/Rendering/renderingGroup" {
  20006. import { SmartArray } from "babylonjs/Misc/smartArray";
  20007. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20009. import { Nullable } from "babylonjs/types";
  20010. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20011. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20012. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20013. import { Material } from "babylonjs/Materials/material";
  20014. import { Scene } from "babylonjs/scene";
  20015. /**
  20016. * This represents the object necessary to create a rendering group.
  20017. * This is exclusively used and created by the rendering manager.
  20018. * To modify the behavior, you use the available helpers in your scene or meshes.
  20019. * @hidden
  20020. */
  20021. export class RenderingGroup {
  20022. index: number;
  20023. private static _zeroVector;
  20024. private _scene;
  20025. private _opaqueSubMeshes;
  20026. private _transparentSubMeshes;
  20027. private _alphaTestSubMeshes;
  20028. private _depthOnlySubMeshes;
  20029. private _particleSystems;
  20030. private _spriteManagers;
  20031. private _opaqueSortCompareFn;
  20032. private _alphaTestSortCompareFn;
  20033. private _transparentSortCompareFn;
  20034. private _renderOpaque;
  20035. private _renderAlphaTest;
  20036. private _renderTransparent;
  20037. /** @hidden */
  20038. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20039. onBeforeTransparentRendering: () => void;
  20040. /**
  20041. * Set the opaque sort comparison function.
  20042. * If null the sub meshes will be render in the order they were created
  20043. */
  20044. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20045. /**
  20046. * Set the alpha test sort comparison function.
  20047. * If null the sub meshes will be render in the order they were created
  20048. */
  20049. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20050. /**
  20051. * Set the transparent sort comparison function.
  20052. * If null the sub meshes will be render in the order they were created
  20053. */
  20054. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20055. /**
  20056. * Creates a new rendering group.
  20057. * @param index The rendering group index
  20058. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20059. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20060. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20061. */
  20062. 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>);
  20063. /**
  20064. * Render all the sub meshes contained in the group.
  20065. * @param customRenderFunction Used to override the default render behaviour of the group.
  20066. * @returns true if rendered some submeshes.
  20067. */
  20068. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20069. /**
  20070. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20071. * @param subMeshes The submeshes to render
  20072. */
  20073. private renderOpaqueSorted;
  20074. /**
  20075. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20076. * @param subMeshes The submeshes to render
  20077. */
  20078. private renderAlphaTestSorted;
  20079. /**
  20080. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20081. * @param subMeshes The submeshes to render
  20082. */
  20083. private renderTransparentSorted;
  20084. /**
  20085. * Renders the submeshes in a specified order.
  20086. * @param subMeshes The submeshes to sort before render
  20087. * @param sortCompareFn The comparison function use to sort
  20088. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20089. * @param transparent Specifies to activate blending if true
  20090. */
  20091. private static renderSorted;
  20092. /**
  20093. * Renders the submeshes in the order they were dispatched (no sort applied).
  20094. * @param subMeshes The submeshes to render
  20095. */
  20096. private static renderUnsorted;
  20097. /**
  20098. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20099. * are rendered back to front if in the same alpha index.
  20100. *
  20101. * @param a The first submesh
  20102. * @param b The second submesh
  20103. * @returns The result of the comparison
  20104. */
  20105. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20106. /**
  20107. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20108. * are rendered back to front.
  20109. *
  20110. * @param a The first submesh
  20111. * @param b The second submesh
  20112. * @returns The result of the comparison
  20113. */
  20114. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20115. /**
  20116. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20117. * are rendered front to back (prevent overdraw).
  20118. *
  20119. * @param a The first submesh
  20120. * @param b The second submesh
  20121. * @returns The result of the comparison
  20122. */
  20123. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20124. /**
  20125. * Resets the different lists of submeshes to prepare a new frame.
  20126. */
  20127. prepare(): void;
  20128. dispose(): void;
  20129. /**
  20130. * Inserts the submesh in its correct queue depending on its material.
  20131. * @param subMesh The submesh to dispatch
  20132. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20133. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20134. */
  20135. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20136. dispatchSprites(spriteManager: ISpriteManager): void;
  20137. dispatchParticles(particleSystem: IParticleSystem): void;
  20138. private _renderParticles;
  20139. private _renderSprites;
  20140. }
  20141. }
  20142. declare module "babylonjs/Rendering/renderingManager" {
  20143. import { Nullable } from "babylonjs/types";
  20144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20145. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20146. import { SmartArray } from "babylonjs/Misc/smartArray";
  20147. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20148. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20149. import { Material } from "babylonjs/Materials/material";
  20150. import { Scene } from "babylonjs/scene";
  20151. import { Camera } from "babylonjs/Cameras/camera";
  20152. /**
  20153. * Interface describing the different options available in the rendering manager
  20154. * regarding Auto Clear between groups.
  20155. */
  20156. export interface IRenderingManagerAutoClearSetup {
  20157. /**
  20158. * Defines whether or not autoclear is enable.
  20159. */
  20160. autoClear: boolean;
  20161. /**
  20162. * Defines whether or not to autoclear the depth buffer.
  20163. */
  20164. depth: boolean;
  20165. /**
  20166. * Defines whether or not to autoclear the stencil buffer.
  20167. */
  20168. stencil: boolean;
  20169. }
  20170. /**
  20171. * This class is used by the onRenderingGroupObservable
  20172. */
  20173. export class RenderingGroupInfo {
  20174. /**
  20175. * The Scene that being rendered
  20176. */
  20177. scene: Scene;
  20178. /**
  20179. * The camera currently used for the rendering pass
  20180. */
  20181. camera: Nullable<Camera>;
  20182. /**
  20183. * The ID of the renderingGroup being processed
  20184. */
  20185. renderingGroupId: number;
  20186. }
  20187. /**
  20188. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20189. * It is enable to manage the different groups as well as the different necessary sort functions.
  20190. * This should not be used directly aside of the few static configurations
  20191. */
  20192. export class RenderingManager {
  20193. /**
  20194. * The max id used for rendering groups (not included)
  20195. */
  20196. static MAX_RENDERINGGROUPS: number;
  20197. /**
  20198. * The min id used for rendering groups (included)
  20199. */
  20200. static MIN_RENDERINGGROUPS: number;
  20201. /**
  20202. * Used to globally prevent autoclearing scenes.
  20203. */
  20204. static AUTOCLEAR: boolean;
  20205. /**
  20206. * @hidden
  20207. */
  20208. _useSceneAutoClearSetup: boolean;
  20209. private _scene;
  20210. private _renderingGroups;
  20211. private _depthStencilBufferAlreadyCleaned;
  20212. private _autoClearDepthStencil;
  20213. private _customOpaqueSortCompareFn;
  20214. private _customAlphaTestSortCompareFn;
  20215. private _customTransparentSortCompareFn;
  20216. private _renderingGroupInfo;
  20217. /**
  20218. * Instantiates a new rendering group for a particular scene
  20219. * @param scene Defines the scene the groups belongs to
  20220. */
  20221. constructor(scene: Scene);
  20222. private _clearDepthStencilBuffer;
  20223. /**
  20224. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20225. * @hidden
  20226. */
  20227. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20228. /**
  20229. * Resets the different information of the group to prepare a new frame
  20230. * @hidden
  20231. */
  20232. reset(): void;
  20233. /**
  20234. * Dispose and release the group and its associated resources.
  20235. * @hidden
  20236. */
  20237. dispose(): void;
  20238. /**
  20239. * Clear the info related to rendering groups preventing retention points during dispose.
  20240. */
  20241. freeRenderingGroups(): void;
  20242. private _prepareRenderingGroup;
  20243. /**
  20244. * Add a sprite manager to the rendering manager in order to render it this frame.
  20245. * @param spriteManager Define the sprite manager to render
  20246. */
  20247. dispatchSprites(spriteManager: ISpriteManager): void;
  20248. /**
  20249. * Add a particle system to the rendering manager in order to render it this frame.
  20250. * @param particleSystem Define the particle system to render
  20251. */
  20252. dispatchParticles(particleSystem: IParticleSystem): void;
  20253. /**
  20254. * Add a submesh to the manager in order to render it this frame
  20255. * @param subMesh The submesh to dispatch
  20256. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20257. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20258. */
  20259. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20260. /**
  20261. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20262. * This allowed control for front to back rendering or reversly depending of the special needs.
  20263. *
  20264. * @param renderingGroupId The rendering group id corresponding to its index
  20265. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20266. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20267. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20268. */
  20269. 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;
  20270. /**
  20271. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20272. *
  20273. * @param renderingGroupId The rendering group id corresponding to its index
  20274. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20275. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20276. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20277. */
  20278. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20279. /**
  20280. * Gets the current auto clear configuration for one rendering group of the rendering
  20281. * manager.
  20282. * @param index the rendering group index to get the information for
  20283. * @returns The auto clear setup for the requested rendering group
  20284. */
  20285. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20286. }
  20287. }
  20288. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20289. import { Observable } from "babylonjs/Misc/observable";
  20290. import { SmartArray } from "babylonjs/Misc/smartArray";
  20291. import { Nullable } from "babylonjs/types";
  20292. import { Camera } from "babylonjs/Cameras/camera";
  20293. import { Scene } from "babylonjs/scene";
  20294. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20295. import { Color4 } from "babylonjs/Maths/math.color";
  20296. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20298. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20299. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20300. import { Texture } from "babylonjs/Materials/Textures/texture";
  20301. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20302. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20303. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20304. import { Engine } from "babylonjs/Engines/engine";
  20305. /**
  20306. * This Helps creating a texture that will be created from a camera in your scene.
  20307. * It is basically a dynamic texture that could be used to create special effects for instance.
  20308. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20309. */
  20310. export class RenderTargetTexture extends Texture {
  20311. isCube: boolean;
  20312. /**
  20313. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20314. */
  20315. static readonly REFRESHRATE_RENDER_ONCE: number;
  20316. /**
  20317. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20318. */
  20319. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20320. /**
  20321. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20322. * the central point of your effect and can save a lot of performances.
  20323. */
  20324. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20325. /**
  20326. * Use this predicate to dynamically define the list of mesh you want to render.
  20327. * If set, the renderList property will be overwritten.
  20328. */
  20329. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20330. private _renderList;
  20331. /**
  20332. * Use this list to define the list of mesh you want to render.
  20333. */
  20334. renderList: Nullable<Array<AbstractMesh>>;
  20335. private _hookArray;
  20336. /**
  20337. * Define if particles should be rendered in your texture.
  20338. */
  20339. renderParticles: boolean;
  20340. /**
  20341. * Define if sprites should be rendered in your texture.
  20342. */
  20343. renderSprites: boolean;
  20344. /**
  20345. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20346. */
  20347. coordinatesMode: number;
  20348. /**
  20349. * Define the camera used to render the texture.
  20350. */
  20351. activeCamera: Nullable<Camera>;
  20352. /**
  20353. * Override the render function of the texture with your own one.
  20354. */
  20355. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20356. /**
  20357. * Define if camera post processes should be use while rendering the texture.
  20358. */
  20359. useCameraPostProcesses: boolean;
  20360. /**
  20361. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20362. */
  20363. ignoreCameraViewport: boolean;
  20364. private _postProcessManager;
  20365. private _postProcesses;
  20366. private _resizeObserver;
  20367. /**
  20368. * An event triggered when the texture is unbind.
  20369. */
  20370. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20371. /**
  20372. * An event triggered when the texture is unbind.
  20373. */
  20374. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20375. private _onAfterUnbindObserver;
  20376. /**
  20377. * Set a after unbind callback in the texture.
  20378. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20379. */
  20380. onAfterUnbind: () => void;
  20381. /**
  20382. * An event triggered before rendering the texture
  20383. */
  20384. onBeforeRenderObservable: Observable<number>;
  20385. private _onBeforeRenderObserver;
  20386. /**
  20387. * Set a before render callback in the texture.
  20388. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20389. */
  20390. onBeforeRender: (faceIndex: number) => void;
  20391. /**
  20392. * An event triggered after rendering the texture
  20393. */
  20394. onAfterRenderObservable: Observable<number>;
  20395. private _onAfterRenderObserver;
  20396. /**
  20397. * Set a after render callback in the texture.
  20398. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20399. */
  20400. onAfterRender: (faceIndex: number) => void;
  20401. /**
  20402. * An event triggered after the texture clear
  20403. */
  20404. onClearObservable: Observable<Engine>;
  20405. private _onClearObserver;
  20406. /**
  20407. * Set a clear callback in the texture.
  20408. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20409. */
  20410. onClear: (Engine: Engine) => void;
  20411. /**
  20412. * An event triggered when the texture is resized.
  20413. */
  20414. onResizeObservable: Observable<RenderTargetTexture>;
  20415. /**
  20416. * Define the clear color of the Render Target if it should be different from the scene.
  20417. */
  20418. clearColor: Color4;
  20419. protected _size: number | {
  20420. width: number;
  20421. height: number;
  20422. };
  20423. protected _initialSizeParameter: number | {
  20424. width: number;
  20425. height: number;
  20426. } | {
  20427. ratio: number;
  20428. };
  20429. protected _sizeRatio: Nullable<number>;
  20430. /** @hidden */
  20431. _generateMipMaps: boolean;
  20432. protected _renderingManager: RenderingManager;
  20433. /** @hidden */
  20434. _waitingRenderList: string[];
  20435. protected _doNotChangeAspectRatio: boolean;
  20436. protected _currentRefreshId: number;
  20437. protected _refreshRate: number;
  20438. protected _textureMatrix: Matrix;
  20439. protected _samples: number;
  20440. protected _renderTargetOptions: RenderTargetCreationOptions;
  20441. /**
  20442. * Gets render target creation options that were used.
  20443. */
  20444. readonly renderTargetOptions: RenderTargetCreationOptions;
  20445. protected _engine: Engine;
  20446. protected _onRatioRescale(): void;
  20447. /**
  20448. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20449. * It must define where the camera used to render the texture is set
  20450. */
  20451. boundingBoxPosition: Vector3;
  20452. private _boundingBoxSize;
  20453. /**
  20454. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20455. * When defined, the cubemap will switch to local mode
  20456. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20457. * @example https://www.babylonjs-playground.com/#RNASML
  20458. */
  20459. boundingBoxSize: Vector3;
  20460. /**
  20461. * In case the RTT has been created with a depth texture, get the associated
  20462. * depth texture.
  20463. * Otherwise, return null.
  20464. */
  20465. depthStencilTexture: Nullable<InternalTexture>;
  20466. /**
  20467. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20468. * or used a shadow, depth texture...
  20469. * @param name The friendly name of the texture
  20470. * @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)
  20471. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20472. * @param generateMipMaps True if mip maps need to be generated after render.
  20473. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20474. * @param type The type of the buffer in the RTT (int, half float, float...)
  20475. * @param isCube True if a cube texture needs to be created
  20476. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20477. * @param generateDepthBuffer True to generate a depth buffer
  20478. * @param generateStencilBuffer True to generate a stencil buffer
  20479. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20480. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20481. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20482. */
  20483. constructor(name: string, size: number | {
  20484. width: number;
  20485. height: number;
  20486. } | {
  20487. ratio: number;
  20488. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20489. /**
  20490. * Creates a depth stencil texture.
  20491. * This is only available in WebGL 2 or with the depth texture extension available.
  20492. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20493. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20494. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20495. */
  20496. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20497. private _processSizeParameter;
  20498. /**
  20499. * Define the number of samples to use in case of MSAA.
  20500. * It defaults to one meaning no MSAA has been enabled.
  20501. */
  20502. samples: number;
  20503. /**
  20504. * Resets the refresh counter of the texture and start bak from scratch.
  20505. * Could be useful to regenerate the texture if it is setup to render only once.
  20506. */
  20507. resetRefreshCounter(): void;
  20508. /**
  20509. * Define the refresh rate of the texture or the rendering frequency.
  20510. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20511. */
  20512. refreshRate: number;
  20513. /**
  20514. * Adds a post process to the render target rendering passes.
  20515. * @param postProcess define the post process to add
  20516. */
  20517. addPostProcess(postProcess: PostProcess): void;
  20518. /**
  20519. * Clear all the post processes attached to the render target
  20520. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20521. */
  20522. clearPostProcesses(dispose?: boolean): void;
  20523. /**
  20524. * Remove one of the post process from the list of attached post processes to the texture
  20525. * @param postProcess define the post process to remove from the list
  20526. */
  20527. removePostProcess(postProcess: PostProcess): void;
  20528. /** @hidden */
  20529. _shouldRender(): boolean;
  20530. /**
  20531. * Gets the actual render size of the texture.
  20532. * @returns the width of the render size
  20533. */
  20534. getRenderSize(): number;
  20535. /**
  20536. * Gets the actual render width of the texture.
  20537. * @returns the width of the render size
  20538. */
  20539. getRenderWidth(): number;
  20540. /**
  20541. * Gets the actual render height of the texture.
  20542. * @returns the height of the render size
  20543. */
  20544. getRenderHeight(): number;
  20545. /**
  20546. * Get if the texture can be rescaled or not.
  20547. */
  20548. readonly canRescale: boolean;
  20549. /**
  20550. * Resize the texture using a ratio.
  20551. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20552. */
  20553. scale(ratio: number): void;
  20554. /**
  20555. * Get the texture reflection matrix used to rotate/transform the reflection.
  20556. * @returns the reflection matrix
  20557. */
  20558. getReflectionTextureMatrix(): Matrix;
  20559. /**
  20560. * Resize the texture to a new desired size.
  20561. * Be carrefull as it will recreate all the data in the new texture.
  20562. * @param size Define the new size. It can be:
  20563. * - a number for squared texture,
  20564. * - an object containing { width: number, height: number }
  20565. * - or an object containing a ratio { ratio: number }
  20566. */
  20567. resize(size: number | {
  20568. width: number;
  20569. height: number;
  20570. } | {
  20571. ratio: number;
  20572. }): void;
  20573. /**
  20574. * Renders all the objects from the render list into the texture.
  20575. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20576. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20577. */
  20578. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20579. private _bestReflectionRenderTargetDimension;
  20580. /**
  20581. * @hidden
  20582. * @param faceIndex face index to bind to if this is a cubetexture
  20583. */
  20584. _bindFrameBuffer(faceIndex?: number): void;
  20585. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20586. private renderToTarget;
  20587. /**
  20588. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20589. * This allowed control for front to back rendering or reversly depending of the special needs.
  20590. *
  20591. * @param renderingGroupId The rendering group id corresponding to its index
  20592. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20593. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20594. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20595. */
  20596. 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;
  20597. /**
  20598. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20599. *
  20600. * @param renderingGroupId The rendering group id corresponding to its index
  20601. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20602. */
  20603. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20604. /**
  20605. * Clones the texture.
  20606. * @returns the cloned texture
  20607. */
  20608. clone(): RenderTargetTexture;
  20609. /**
  20610. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20611. * @returns The JSON representation of the texture
  20612. */
  20613. serialize(): any;
  20614. /**
  20615. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20616. */
  20617. disposeFramebufferObjects(): void;
  20618. /**
  20619. * Dispose the texture and release its associated resources.
  20620. */
  20621. dispose(): void;
  20622. /** @hidden */
  20623. _rebuild(): void;
  20624. /**
  20625. * Clear the info related to rendering groups preventing retention point in material dispose.
  20626. */
  20627. freeRenderingGroups(): void;
  20628. /**
  20629. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20630. * @returns the view count
  20631. */
  20632. getViewCount(): number;
  20633. }
  20634. }
  20635. declare module "babylonjs/Materials/material" {
  20636. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20637. import { SmartArray } from "babylonjs/Misc/smartArray";
  20638. import { Observable } from "babylonjs/Misc/observable";
  20639. import { Nullable } from "babylonjs/types";
  20640. import { Scene } from "babylonjs/scene";
  20641. import { Matrix } from "babylonjs/Maths/math.vector";
  20642. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20644. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20645. import { Effect } from "babylonjs/Materials/effect";
  20646. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20647. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20648. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20649. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20650. import { Mesh } from "babylonjs/Meshes/mesh";
  20651. import { Animation } from "babylonjs/Animations/animation";
  20652. /**
  20653. * Base class for the main features of a material in Babylon.js
  20654. */
  20655. export class Material implements IAnimatable {
  20656. /**
  20657. * Returns the triangle fill mode
  20658. */
  20659. static readonly TriangleFillMode: number;
  20660. /**
  20661. * Returns the wireframe mode
  20662. */
  20663. static readonly WireFrameFillMode: number;
  20664. /**
  20665. * Returns the point fill mode
  20666. */
  20667. static readonly PointFillMode: number;
  20668. /**
  20669. * Returns the point list draw mode
  20670. */
  20671. static readonly PointListDrawMode: number;
  20672. /**
  20673. * Returns the line list draw mode
  20674. */
  20675. static readonly LineListDrawMode: number;
  20676. /**
  20677. * Returns the line loop draw mode
  20678. */
  20679. static readonly LineLoopDrawMode: number;
  20680. /**
  20681. * Returns the line strip draw mode
  20682. */
  20683. static readonly LineStripDrawMode: number;
  20684. /**
  20685. * Returns the triangle strip draw mode
  20686. */
  20687. static readonly TriangleStripDrawMode: number;
  20688. /**
  20689. * Returns the triangle fan draw mode
  20690. */
  20691. static readonly TriangleFanDrawMode: number;
  20692. /**
  20693. * Stores the clock-wise side orientation
  20694. */
  20695. static readonly ClockWiseSideOrientation: number;
  20696. /**
  20697. * Stores the counter clock-wise side orientation
  20698. */
  20699. static readonly CounterClockWiseSideOrientation: number;
  20700. /**
  20701. * The dirty texture flag value
  20702. */
  20703. static readonly TextureDirtyFlag: number;
  20704. /**
  20705. * The dirty light flag value
  20706. */
  20707. static readonly LightDirtyFlag: number;
  20708. /**
  20709. * The dirty fresnel flag value
  20710. */
  20711. static readonly FresnelDirtyFlag: number;
  20712. /**
  20713. * The dirty attribute flag value
  20714. */
  20715. static readonly AttributesDirtyFlag: number;
  20716. /**
  20717. * The dirty misc flag value
  20718. */
  20719. static readonly MiscDirtyFlag: number;
  20720. /**
  20721. * The all dirty flag value
  20722. */
  20723. static readonly AllDirtyFlag: number;
  20724. /**
  20725. * The ID of the material
  20726. */
  20727. id: string;
  20728. /**
  20729. * Gets or sets the unique id of the material
  20730. */
  20731. uniqueId: number;
  20732. /**
  20733. * The name of the material
  20734. */
  20735. name: string;
  20736. /**
  20737. * Gets or sets user defined metadata
  20738. */
  20739. metadata: any;
  20740. /**
  20741. * For internal use only. Please do not use.
  20742. */
  20743. reservedDataStore: any;
  20744. /**
  20745. * Specifies if the ready state should be checked on each call
  20746. */
  20747. checkReadyOnEveryCall: boolean;
  20748. /**
  20749. * Specifies if the ready state should be checked once
  20750. */
  20751. checkReadyOnlyOnce: boolean;
  20752. /**
  20753. * The state of the material
  20754. */
  20755. state: string;
  20756. /**
  20757. * The alpha value of the material
  20758. */
  20759. protected _alpha: number;
  20760. /**
  20761. * List of inspectable custom properties (used by the Inspector)
  20762. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20763. */
  20764. inspectableCustomProperties: IInspectable[];
  20765. /**
  20766. * Sets the alpha value of the material
  20767. */
  20768. /**
  20769. * Gets the alpha value of the material
  20770. */
  20771. alpha: number;
  20772. /**
  20773. * Specifies if back face culling is enabled
  20774. */
  20775. protected _backFaceCulling: boolean;
  20776. /**
  20777. * Sets the back-face culling state
  20778. */
  20779. /**
  20780. * Gets the back-face culling state
  20781. */
  20782. backFaceCulling: boolean;
  20783. /**
  20784. * Stores the value for side orientation
  20785. */
  20786. sideOrientation: number;
  20787. /**
  20788. * Callback triggered when the material is compiled
  20789. */
  20790. onCompiled: Nullable<(effect: Effect) => void>;
  20791. /**
  20792. * Callback triggered when an error occurs
  20793. */
  20794. onError: Nullable<(effect: Effect, errors: string) => void>;
  20795. /**
  20796. * Callback triggered to get the render target textures
  20797. */
  20798. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20799. /**
  20800. * Gets a boolean indicating that current material needs to register RTT
  20801. */
  20802. readonly hasRenderTargetTextures: boolean;
  20803. /**
  20804. * Specifies if the material should be serialized
  20805. */
  20806. doNotSerialize: boolean;
  20807. /**
  20808. * @hidden
  20809. */
  20810. _storeEffectOnSubMeshes: boolean;
  20811. /**
  20812. * Stores the animations for the material
  20813. */
  20814. animations: Nullable<Array<Animation>>;
  20815. /**
  20816. * An event triggered when the material is disposed
  20817. */
  20818. onDisposeObservable: Observable<Material>;
  20819. /**
  20820. * An observer which watches for dispose events
  20821. */
  20822. private _onDisposeObserver;
  20823. private _onUnBindObservable;
  20824. /**
  20825. * Called during a dispose event
  20826. */
  20827. onDispose: () => void;
  20828. private _onBindObservable;
  20829. /**
  20830. * An event triggered when the material is bound
  20831. */
  20832. readonly onBindObservable: Observable<AbstractMesh>;
  20833. /**
  20834. * An observer which watches for bind events
  20835. */
  20836. private _onBindObserver;
  20837. /**
  20838. * Called during a bind event
  20839. */
  20840. onBind: (Mesh: AbstractMesh) => void;
  20841. /**
  20842. * An event triggered when the material is unbound
  20843. */
  20844. readonly onUnBindObservable: Observable<Material>;
  20845. /**
  20846. * Stores the value of the alpha mode
  20847. */
  20848. private _alphaMode;
  20849. /**
  20850. * Sets the value of the alpha mode.
  20851. *
  20852. * | Value | Type | Description |
  20853. * | --- | --- | --- |
  20854. * | 0 | ALPHA_DISABLE | |
  20855. * | 1 | ALPHA_ADD | |
  20856. * | 2 | ALPHA_COMBINE | |
  20857. * | 3 | ALPHA_SUBTRACT | |
  20858. * | 4 | ALPHA_MULTIPLY | |
  20859. * | 5 | ALPHA_MAXIMIZED | |
  20860. * | 6 | ALPHA_ONEONE | |
  20861. * | 7 | ALPHA_PREMULTIPLIED | |
  20862. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20863. * | 9 | ALPHA_INTERPOLATE | |
  20864. * | 10 | ALPHA_SCREENMODE | |
  20865. *
  20866. */
  20867. /**
  20868. * Gets the value of the alpha mode
  20869. */
  20870. alphaMode: number;
  20871. /**
  20872. * Stores the state of the need depth pre-pass value
  20873. */
  20874. private _needDepthPrePass;
  20875. /**
  20876. * Sets the need depth pre-pass value
  20877. */
  20878. /**
  20879. * Gets the depth pre-pass value
  20880. */
  20881. needDepthPrePass: boolean;
  20882. /**
  20883. * Specifies if depth writing should be disabled
  20884. */
  20885. disableDepthWrite: boolean;
  20886. /**
  20887. * Specifies if depth writing should be forced
  20888. */
  20889. forceDepthWrite: boolean;
  20890. /**
  20891. * Specifies if there should be a separate pass for culling
  20892. */
  20893. separateCullingPass: boolean;
  20894. /**
  20895. * Stores the state specifing if fog should be enabled
  20896. */
  20897. private _fogEnabled;
  20898. /**
  20899. * Sets the state for enabling fog
  20900. */
  20901. /**
  20902. * Gets the value of the fog enabled state
  20903. */
  20904. fogEnabled: boolean;
  20905. /**
  20906. * Stores the size of points
  20907. */
  20908. pointSize: number;
  20909. /**
  20910. * Stores the z offset value
  20911. */
  20912. zOffset: number;
  20913. /**
  20914. * Gets a value specifying if wireframe mode is enabled
  20915. */
  20916. /**
  20917. * Sets the state of wireframe mode
  20918. */
  20919. wireframe: boolean;
  20920. /**
  20921. * Gets the value specifying if point clouds are enabled
  20922. */
  20923. /**
  20924. * Sets the state of point cloud mode
  20925. */
  20926. pointsCloud: boolean;
  20927. /**
  20928. * Gets the material fill mode
  20929. */
  20930. /**
  20931. * Sets the material fill mode
  20932. */
  20933. fillMode: number;
  20934. /**
  20935. * @hidden
  20936. * Stores the effects for the material
  20937. */
  20938. _effect: Nullable<Effect>;
  20939. /**
  20940. * @hidden
  20941. * Specifies if the material was previously ready
  20942. */
  20943. _wasPreviouslyReady: boolean;
  20944. /**
  20945. * Specifies if uniform buffers should be used
  20946. */
  20947. private _useUBO;
  20948. /**
  20949. * Stores a reference to the scene
  20950. */
  20951. private _scene;
  20952. /**
  20953. * Stores the fill mode state
  20954. */
  20955. private _fillMode;
  20956. /**
  20957. * Specifies if the depth write state should be cached
  20958. */
  20959. private _cachedDepthWriteState;
  20960. /**
  20961. * Stores the uniform buffer
  20962. */
  20963. protected _uniformBuffer: UniformBuffer;
  20964. /** @hidden */
  20965. _indexInSceneMaterialArray: number;
  20966. /** @hidden */
  20967. meshMap: Nullable<{
  20968. [id: string]: AbstractMesh | undefined;
  20969. }>;
  20970. /**
  20971. * Creates a material instance
  20972. * @param name defines the name of the material
  20973. * @param scene defines the scene to reference
  20974. * @param doNotAdd specifies if the material should be added to the scene
  20975. */
  20976. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20977. /**
  20978. * Returns a string representation of the current material
  20979. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20980. * @returns a string with material information
  20981. */
  20982. toString(fullDetails?: boolean): string;
  20983. /**
  20984. * Gets the class name of the material
  20985. * @returns a string with the class name of the material
  20986. */
  20987. getClassName(): string;
  20988. /**
  20989. * Specifies if updates for the material been locked
  20990. */
  20991. readonly isFrozen: boolean;
  20992. /**
  20993. * Locks updates for the material
  20994. */
  20995. freeze(): void;
  20996. /**
  20997. * Unlocks updates for the material
  20998. */
  20999. unfreeze(): void;
  21000. /**
  21001. * Specifies if the material is ready to be used
  21002. * @param mesh defines the mesh to check
  21003. * @param useInstances specifies if instances should be used
  21004. * @returns a boolean indicating if the material is ready to be used
  21005. */
  21006. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21007. /**
  21008. * Specifies that the submesh is ready to be used
  21009. * @param mesh defines the mesh to check
  21010. * @param subMesh defines which submesh to check
  21011. * @param useInstances specifies that instances should be used
  21012. * @returns a boolean indicating that the submesh is ready or not
  21013. */
  21014. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21015. /**
  21016. * Returns the material effect
  21017. * @returns the effect associated with the material
  21018. */
  21019. getEffect(): Nullable<Effect>;
  21020. /**
  21021. * Returns the current scene
  21022. * @returns a Scene
  21023. */
  21024. getScene(): Scene;
  21025. /**
  21026. * Specifies if the material will require alpha blending
  21027. * @returns a boolean specifying if alpha blending is needed
  21028. */
  21029. needAlphaBlending(): boolean;
  21030. /**
  21031. * Specifies if the mesh will require alpha blending
  21032. * @param mesh defines the mesh to check
  21033. * @returns a boolean specifying if alpha blending is needed for the mesh
  21034. */
  21035. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21036. /**
  21037. * Specifies if this material should be rendered in alpha test mode
  21038. * @returns a boolean specifying if an alpha test is needed.
  21039. */
  21040. needAlphaTesting(): boolean;
  21041. /**
  21042. * Gets the texture used for the alpha test
  21043. * @returns the texture to use for alpha testing
  21044. */
  21045. getAlphaTestTexture(): Nullable<BaseTexture>;
  21046. /**
  21047. * Marks the material to indicate that it needs to be re-calculated
  21048. */
  21049. markDirty(): void;
  21050. /** @hidden */
  21051. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21052. /**
  21053. * Binds the material to the mesh
  21054. * @param world defines the world transformation matrix
  21055. * @param mesh defines the mesh to bind the material to
  21056. */
  21057. bind(world: Matrix, mesh?: Mesh): void;
  21058. /**
  21059. * Binds the submesh to the material
  21060. * @param world defines the world transformation matrix
  21061. * @param mesh defines the mesh containing the submesh
  21062. * @param subMesh defines the submesh to bind the material to
  21063. */
  21064. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21065. /**
  21066. * Binds the world matrix to the material
  21067. * @param world defines the world transformation matrix
  21068. */
  21069. bindOnlyWorldMatrix(world: Matrix): void;
  21070. /**
  21071. * Binds the scene's uniform buffer to the effect.
  21072. * @param effect defines the effect to bind to the scene uniform buffer
  21073. * @param sceneUbo defines the uniform buffer storing scene data
  21074. */
  21075. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21076. /**
  21077. * Binds the view matrix to the effect
  21078. * @param effect defines the effect to bind the view matrix to
  21079. */
  21080. bindView(effect: Effect): void;
  21081. /**
  21082. * Binds the view projection matrix to the effect
  21083. * @param effect defines the effect to bind the view projection matrix to
  21084. */
  21085. bindViewProjection(effect: Effect): void;
  21086. /**
  21087. * Specifies if material alpha testing should be turned on for the mesh
  21088. * @param mesh defines the mesh to check
  21089. */
  21090. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21091. /**
  21092. * Processes to execute after binding the material to a mesh
  21093. * @param mesh defines the rendered mesh
  21094. */
  21095. protected _afterBind(mesh?: Mesh): void;
  21096. /**
  21097. * Unbinds the material from the mesh
  21098. */
  21099. unbind(): void;
  21100. /**
  21101. * Gets the active textures from the material
  21102. * @returns an array of textures
  21103. */
  21104. getActiveTextures(): BaseTexture[];
  21105. /**
  21106. * Specifies if the material uses a texture
  21107. * @param texture defines the texture to check against the material
  21108. * @returns a boolean specifying if the material uses the texture
  21109. */
  21110. hasTexture(texture: BaseTexture): boolean;
  21111. /**
  21112. * Makes a duplicate of the material, and gives it a new name
  21113. * @param name defines the new name for the duplicated material
  21114. * @returns the cloned material
  21115. */
  21116. clone(name: string): Nullable<Material>;
  21117. /**
  21118. * Gets the meshes bound to the material
  21119. * @returns an array of meshes bound to the material
  21120. */
  21121. getBindedMeshes(): AbstractMesh[];
  21122. /**
  21123. * Force shader compilation
  21124. * @param mesh defines the mesh associated with this material
  21125. * @param onCompiled defines a function to execute once the material is compiled
  21126. * @param options defines the options to configure the compilation
  21127. */
  21128. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21129. clipPlane: boolean;
  21130. }>): void;
  21131. /**
  21132. * Force shader compilation
  21133. * @param mesh defines the mesh that will use this material
  21134. * @param options defines additional options for compiling the shaders
  21135. * @returns a promise that resolves when the compilation completes
  21136. */
  21137. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21138. clipPlane: boolean;
  21139. }>): Promise<void>;
  21140. private static readonly _AllDirtyCallBack;
  21141. private static readonly _ImageProcessingDirtyCallBack;
  21142. private static readonly _TextureDirtyCallBack;
  21143. private static readonly _FresnelDirtyCallBack;
  21144. private static readonly _MiscDirtyCallBack;
  21145. private static readonly _LightsDirtyCallBack;
  21146. private static readonly _AttributeDirtyCallBack;
  21147. private static _FresnelAndMiscDirtyCallBack;
  21148. private static _TextureAndMiscDirtyCallBack;
  21149. private static readonly _DirtyCallbackArray;
  21150. private static readonly _RunDirtyCallBacks;
  21151. /**
  21152. * Marks a define in the material to indicate that it needs to be re-computed
  21153. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21154. */
  21155. markAsDirty(flag: number): void;
  21156. /**
  21157. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21158. * @param func defines a function which checks material defines against the submeshes
  21159. */
  21160. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21161. /**
  21162. * Indicates that we need to re-calculated for all submeshes
  21163. */
  21164. protected _markAllSubMeshesAsAllDirty(): void;
  21165. /**
  21166. * Indicates that image processing needs to be re-calculated for all submeshes
  21167. */
  21168. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21169. /**
  21170. * Indicates that textures need to be re-calculated for all submeshes
  21171. */
  21172. protected _markAllSubMeshesAsTexturesDirty(): void;
  21173. /**
  21174. * Indicates that fresnel needs to be re-calculated for all submeshes
  21175. */
  21176. protected _markAllSubMeshesAsFresnelDirty(): void;
  21177. /**
  21178. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21179. */
  21180. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21181. /**
  21182. * Indicates that lights need to be re-calculated for all submeshes
  21183. */
  21184. protected _markAllSubMeshesAsLightsDirty(): void;
  21185. /**
  21186. * Indicates that attributes need to be re-calculated for all submeshes
  21187. */
  21188. protected _markAllSubMeshesAsAttributesDirty(): void;
  21189. /**
  21190. * Indicates that misc needs to be re-calculated for all submeshes
  21191. */
  21192. protected _markAllSubMeshesAsMiscDirty(): void;
  21193. /**
  21194. * Indicates that textures and misc need to be re-calculated for all submeshes
  21195. */
  21196. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21197. /**
  21198. * Disposes the material
  21199. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21200. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21201. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21202. */
  21203. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21204. /** @hidden */
  21205. private releaseVertexArrayObject;
  21206. /**
  21207. * Serializes this material
  21208. * @returns the serialized material object
  21209. */
  21210. serialize(): any;
  21211. /**
  21212. * Creates a material from parsed material data
  21213. * @param parsedMaterial defines parsed material data
  21214. * @param scene defines the hosting scene
  21215. * @param rootUrl defines the root URL to use to load textures
  21216. * @returns a new material
  21217. */
  21218. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21219. }
  21220. }
  21221. declare module "babylonjs/Materials/multiMaterial" {
  21222. import { Nullable } from "babylonjs/types";
  21223. import { Scene } from "babylonjs/scene";
  21224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21225. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21226. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21227. import { Material } from "babylonjs/Materials/material";
  21228. /**
  21229. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21230. * separate meshes. This can be use to improve performances.
  21231. * @see http://doc.babylonjs.com/how_to/multi_materials
  21232. */
  21233. export class MultiMaterial extends Material {
  21234. private _subMaterials;
  21235. /**
  21236. * Gets or Sets the list of Materials used within the multi material.
  21237. * They need to be ordered according to the submeshes order in the associated mesh
  21238. */
  21239. subMaterials: Nullable<Material>[];
  21240. /**
  21241. * Function used to align with Node.getChildren()
  21242. * @returns the list of Materials used within the multi material
  21243. */
  21244. getChildren(): Nullable<Material>[];
  21245. /**
  21246. * Instantiates a new Multi Material
  21247. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21248. * separate meshes. This can be use to improve performances.
  21249. * @see http://doc.babylonjs.com/how_to/multi_materials
  21250. * @param name Define the name in the scene
  21251. * @param scene Define the scene the material belongs to
  21252. */
  21253. constructor(name: string, scene: Scene);
  21254. private _hookArray;
  21255. /**
  21256. * Get one of the submaterial by its index in the submaterials array
  21257. * @param index The index to look the sub material at
  21258. * @returns The Material if the index has been defined
  21259. */
  21260. getSubMaterial(index: number): Nullable<Material>;
  21261. /**
  21262. * Get the list of active textures for the whole sub materials list.
  21263. * @returns All the textures that will be used during the rendering
  21264. */
  21265. getActiveTextures(): BaseTexture[];
  21266. /**
  21267. * Gets the current class name of the material e.g. "MultiMaterial"
  21268. * Mainly use in serialization.
  21269. * @returns the class name
  21270. */
  21271. getClassName(): string;
  21272. /**
  21273. * Checks if the material is ready to render the requested sub mesh
  21274. * @param mesh Define the mesh the submesh belongs to
  21275. * @param subMesh Define the sub mesh to look readyness for
  21276. * @param useInstances Define whether or not the material is used with instances
  21277. * @returns true if ready, otherwise false
  21278. */
  21279. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21280. /**
  21281. * Clones the current material and its related sub materials
  21282. * @param name Define the name of the newly cloned material
  21283. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21284. * @returns the cloned material
  21285. */
  21286. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21287. /**
  21288. * Serializes the materials into a JSON representation.
  21289. * @returns the JSON representation
  21290. */
  21291. serialize(): any;
  21292. /**
  21293. * Dispose the material and release its associated resources
  21294. * @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)
  21295. * @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)
  21296. * @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)
  21297. */
  21298. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21299. /**
  21300. * Creates a MultiMaterial from parsed MultiMaterial data.
  21301. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21302. * @param scene defines the hosting scene
  21303. * @returns a new MultiMaterial
  21304. */
  21305. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21306. }
  21307. }
  21308. declare module "babylonjs/Meshes/subMesh" {
  21309. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21310. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21311. import { Engine } from "babylonjs/Engines/engine";
  21312. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21313. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21314. import { Effect } from "babylonjs/Materials/effect";
  21315. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21316. import { Plane } from "babylonjs/Maths/math.plane";
  21317. import { Collider } from "babylonjs/Collisions/collider";
  21318. import { Material } from "babylonjs/Materials/material";
  21319. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21321. import { Mesh } from "babylonjs/Meshes/mesh";
  21322. import { Ray } from "babylonjs/Culling/ray";
  21323. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21324. /**
  21325. * Base class for submeshes
  21326. */
  21327. export class BaseSubMesh {
  21328. /** @hidden */
  21329. _materialDefines: Nullable<MaterialDefines>;
  21330. /** @hidden */
  21331. _materialEffect: Nullable<Effect>;
  21332. /**
  21333. * Gets associated effect
  21334. */
  21335. readonly effect: Nullable<Effect>;
  21336. /**
  21337. * Sets associated effect (effect used to render this submesh)
  21338. * @param effect defines the effect to associate with
  21339. * @param defines defines the set of defines used to compile this effect
  21340. */
  21341. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21342. }
  21343. /**
  21344. * Defines a subdivision inside a mesh
  21345. */
  21346. export class SubMesh extends BaseSubMesh implements ICullable {
  21347. /** the material index to use */
  21348. materialIndex: number;
  21349. /** vertex index start */
  21350. verticesStart: number;
  21351. /** vertices count */
  21352. verticesCount: number;
  21353. /** index start */
  21354. indexStart: number;
  21355. /** indices count */
  21356. indexCount: number;
  21357. /** @hidden */
  21358. _linesIndexCount: number;
  21359. private _mesh;
  21360. private _renderingMesh;
  21361. private _boundingInfo;
  21362. private _linesIndexBuffer;
  21363. /** @hidden */
  21364. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21365. /** @hidden */
  21366. _trianglePlanes: Plane[];
  21367. /** @hidden */
  21368. _lastColliderTransformMatrix: Nullable<Matrix>;
  21369. /** @hidden */
  21370. _renderId: number;
  21371. /** @hidden */
  21372. _alphaIndex: number;
  21373. /** @hidden */
  21374. _distanceToCamera: number;
  21375. /** @hidden */
  21376. _id: number;
  21377. private _currentMaterial;
  21378. /**
  21379. * Add a new submesh to a mesh
  21380. * @param materialIndex defines the material index to use
  21381. * @param verticesStart defines vertex index start
  21382. * @param verticesCount defines vertices count
  21383. * @param indexStart defines index start
  21384. * @param indexCount defines indices count
  21385. * @param mesh defines the parent mesh
  21386. * @param renderingMesh defines an optional rendering mesh
  21387. * @param createBoundingBox defines if bounding box should be created for this submesh
  21388. * @returns the new submesh
  21389. */
  21390. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21391. /**
  21392. * Creates a new submesh
  21393. * @param materialIndex defines the material index to use
  21394. * @param verticesStart defines vertex index start
  21395. * @param verticesCount defines vertices count
  21396. * @param indexStart defines index start
  21397. * @param indexCount defines indices count
  21398. * @param mesh defines the parent mesh
  21399. * @param renderingMesh defines an optional rendering mesh
  21400. * @param createBoundingBox defines if bounding box should be created for this submesh
  21401. */
  21402. constructor(
  21403. /** the material index to use */
  21404. materialIndex: number,
  21405. /** vertex index start */
  21406. verticesStart: number,
  21407. /** vertices count */
  21408. verticesCount: number,
  21409. /** index start */
  21410. indexStart: number,
  21411. /** indices count */
  21412. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21413. /**
  21414. * Returns true if this submesh covers the entire parent mesh
  21415. * @ignorenaming
  21416. */
  21417. readonly IsGlobal: boolean;
  21418. /**
  21419. * Returns the submesh BoudingInfo object
  21420. * @returns current bounding info (or mesh's one if the submesh is global)
  21421. */
  21422. getBoundingInfo(): BoundingInfo;
  21423. /**
  21424. * Sets the submesh BoundingInfo
  21425. * @param boundingInfo defines the new bounding info to use
  21426. * @returns the SubMesh
  21427. */
  21428. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21429. /**
  21430. * Returns the mesh of the current submesh
  21431. * @return the parent mesh
  21432. */
  21433. getMesh(): AbstractMesh;
  21434. /**
  21435. * Returns the rendering mesh of the submesh
  21436. * @returns the rendering mesh (could be different from parent mesh)
  21437. */
  21438. getRenderingMesh(): Mesh;
  21439. /**
  21440. * Returns the submesh material
  21441. * @returns null or the current material
  21442. */
  21443. getMaterial(): Nullable<Material>;
  21444. /**
  21445. * Sets a new updated BoundingInfo object to the submesh
  21446. * @param data defines an optional position array to use to determine the bounding info
  21447. * @returns the SubMesh
  21448. */
  21449. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21450. /** @hidden */
  21451. _checkCollision(collider: Collider): boolean;
  21452. /**
  21453. * Updates the submesh BoundingInfo
  21454. * @param world defines the world matrix to use to update the bounding info
  21455. * @returns the submesh
  21456. */
  21457. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21458. /**
  21459. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21460. * @param frustumPlanes defines the frustum planes
  21461. * @returns true if the submesh is intersecting with the frustum
  21462. */
  21463. isInFrustum(frustumPlanes: Plane[]): boolean;
  21464. /**
  21465. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21466. * @param frustumPlanes defines the frustum planes
  21467. * @returns true if the submesh is inside the frustum
  21468. */
  21469. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21470. /**
  21471. * Renders the submesh
  21472. * @param enableAlphaMode defines if alpha needs to be used
  21473. * @returns the submesh
  21474. */
  21475. render(enableAlphaMode: boolean): SubMesh;
  21476. /**
  21477. * @hidden
  21478. */
  21479. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21480. /**
  21481. * Checks if the submesh intersects with a ray
  21482. * @param ray defines the ray to test
  21483. * @returns true is the passed ray intersects the submesh bounding box
  21484. */
  21485. canIntersects(ray: Ray): boolean;
  21486. /**
  21487. * Intersects current submesh with a ray
  21488. * @param ray defines the ray to test
  21489. * @param positions defines mesh's positions array
  21490. * @param indices defines mesh's indices array
  21491. * @param fastCheck defines if only bounding info should be used
  21492. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21493. * @returns intersection info or null if no intersection
  21494. */
  21495. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21496. /** @hidden */
  21497. private _intersectLines;
  21498. /** @hidden */
  21499. private _intersectUnIndexedLines;
  21500. /** @hidden */
  21501. private _intersectTriangles;
  21502. /** @hidden */
  21503. private _intersectUnIndexedTriangles;
  21504. /** @hidden */
  21505. _rebuild(): void;
  21506. /**
  21507. * Creates a new submesh from the passed mesh
  21508. * @param newMesh defines the new hosting mesh
  21509. * @param newRenderingMesh defines an optional rendering mesh
  21510. * @returns the new submesh
  21511. */
  21512. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21513. /**
  21514. * Release associated resources
  21515. */
  21516. dispose(): void;
  21517. /**
  21518. * Gets the class name
  21519. * @returns the string "SubMesh".
  21520. */
  21521. getClassName(): string;
  21522. /**
  21523. * Creates a new submesh from indices data
  21524. * @param materialIndex the index of the main mesh material
  21525. * @param startIndex the index where to start the copy in the mesh indices array
  21526. * @param indexCount the number of indices to copy then from the startIndex
  21527. * @param mesh the main mesh to create the submesh from
  21528. * @param renderingMesh the optional rendering mesh
  21529. * @returns a new submesh
  21530. */
  21531. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21532. }
  21533. }
  21534. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21535. /**
  21536. * Class used to represent data loading progression
  21537. */
  21538. export class SceneLoaderFlags {
  21539. private static _ForceFullSceneLoadingForIncremental;
  21540. private static _ShowLoadingScreen;
  21541. private static _CleanBoneMatrixWeights;
  21542. private static _loggingLevel;
  21543. /**
  21544. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21545. */
  21546. static ForceFullSceneLoadingForIncremental: boolean;
  21547. /**
  21548. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21549. */
  21550. static ShowLoadingScreen: boolean;
  21551. /**
  21552. * Defines the current logging level (while loading the scene)
  21553. * @ignorenaming
  21554. */
  21555. static loggingLevel: number;
  21556. /**
  21557. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21558. */
  21559. static CleanBoneMatrixWeights: boolean;
  21560. }
  21561. }
  21562. declare module "babylonjs/Meshes/geometry" {
  21563. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21564. import { Scene } from "babylonjs/scene";
  21565. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21566. import { Engine } from "babylonjs/Engines/engine";
  21567. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21568. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21569. import { Effect } from "babylonjs/Materials/effect";
  21570. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21571. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21572. import { Mesh } from "babylonjs/Meshes/mesh";
  21573. /**
  21574. * Class used to store geometry data (vertex buffers + index buffer)
  21575. */
  21576. export class Geometry implements IGetSetVerticesData {
  21577. /**
  21578. * Gets or sets the ID of the geometry
  21579. */
  21580. id: string;
  21581. /**
  21582. * Gets or sets the unique ID of the geometry
  21583. */
  21584. uniqueId: number;
  21585. /**
  21586. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21587. */
  21588. delayLoadState: number;
  21589. /**
  21590. * Gets the file containing the data to load when running in delay load state
  21591. */
  21592. delayLoadingFile: Nullable<string>;
  21593. /**
  21594. * Callback called when the geometry is updated
  21595. */
  21596. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21597. private _scene;
  21598. private _engine;
  21599. private _meshes;
  21600. private _totalVertices;
  21601. /** @hidden */
  21602. _indices: IndicesArray;
  21603. /** @hidden */
  21604. _vertexBuffers: {
  21605. [key: string]: VertexBuffer;
  21606. };
  21607. private _isDisposed;
  21608. private _extend;
  21609. private _boundingBias;
  21610. /** @hidden */
  21611. _delayInfo: Array<string>;
  21612. private _indexBuffer;
  21613. private _indexBufferIsUpdatable;
  21614. /** @hidden */
  21615. _boundingInfo: Nullable<BoundingInfo>;
  21616. /** @hidden */
  21617. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21618. /** @hidden */
  21619. _softwareSkinningFrameId: number;
  21620. private _vertexArrayObjects;
  21621. private _updatable;
  21622. /** @hidden */
  21623. _positions: Nullable<Vector3[]>;
  21624. /**
  21625. * 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
  21626. */
  21627. /**
  21628. * 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
  21629. */
  21630. boundingBias: Vector2;
  21631. /**
  21632. * Static function used to attach a new empty geometry to a mesh
  21633. * @param mesh defines the mesh to attach the geometry to
  21634. * @returns the new Geometry
  21635. */
  21636. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21637. /**
  21638. * Creates a new geometry
  21639. * @param id defines the unique ID
  21640. * @param scene defines the hosting scene
  21641. * @param vertexData defines the VertexData used to get geometry data
  21642. * @param updatable defines if geometry must be updatable (false by default)
  21643. * @param mesh defines the mesh that will be associated with the geometry
  21644. */
  21645. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21646. /**
  21647. * Gets the current extend of the geometry
  21648. */
  21649. readonly extend: {
  21650. minimum: Vector3;
  21651. maximum: Vector3;
  21652. };
  21653. /**
  21654. * Gets the hosting scene
  21655. * @returns the hosting Scene
  21656. */
  21657. getScene(): Scene;
  21658. /**
  21659. * Gets the hosting engine
  21660. * @returns the hosting Engine
  21661. */
  21662. getEngine(): Engine;
  21663. /**
  21664. * Defines if the geometry is ready to use
  21665. * @returns true if the geometry is ready to be used
  21666. */
  21667. isReady(): boolean;
  21668. /**
  21669. * Gets a value indicating that the geometry should not be serialized
  21670. */
  21671. readonly doNotSerialize: boolean;
  21672. /** @hidden */
  21673. _rebuild(): void;
  21674. /**
  21675. * Affects all geometry data in one call
  21676. * @param vertexData defines the geometry data
  21677. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21678. */
  21679. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21680. /**
  21681. * Set specific vertex data
  21682. * @param kind defines the data kind (Position, normal, etc...)
  21683. * @param data defines the vertex data to use
  21684. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21685. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21686. */
  21687. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21688. /**
  21689. * Removes a specific vertex data
  21690. * @param kind defines the data kind (Position, normal, etc...)
  21691. */
  21692. removeVerticesData(kind: string): void;
  21693. /**
  21694. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21695. * @param buffer defines the vertex buffer to use
  21696. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21697. */
  21698. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21699. /**
  21700. * Update a specific vertex buffer
  21701. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21702. * It will do nothing if the buffer is not updatable
  21703. * @param kind defines the data kind (Position, normal, etc...)
  21704. * @param data defines the data to use
  21705. * @param offset defines the offset in the target buffer where to store the data
  21706. * @param useBytes set to true if the offset is in bytes
  21707. */
  21708. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21709. /**
  21710. * Update a specific vertex buffer
  21711. * This function will create a new buffer if the current one is not updatable
  21712. * @param kind defines the data kind (Position, normal, etc...)
  21713. * @param data defines the data to use
  21714. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21715. */
  21716. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21717. private _updateBoundingInfo;
  21718. /** @hidden */
  21719. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21720. /**
  21721. * Gets total number of vertices
  21722. * @returns the total number of vertices
  21723. */
  21724. getTotalVertices(): number;
  21725. /**
  21726. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21727. * @param kind defines the data kind (Position, normal, etc...)
  21728. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21729. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21730. * @returns a float array containing vertex data
  21731. */
  21732. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21733. /**
  21734. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21735. * @param kind defines the data kind (Position, normal, etc...)
  21736. * @returns true if the vertex buffer with the specified kind is updatable
  21737. */
  21738. isVertexBufferUpdatable(kind: string): boolean;
  21739. /**
  21740. * Gets a specific vertex buffer
  21741. * @param kind defines the data kind (Position, normal, etc...)
  21742. * @returns a VertexBuffer
  21743. */
  21744. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21745. /**
  21746. * Returns all vertex buffers
  21747. * @return an object holding all vertex buffers indexed by kind
  21748. */
  21749. getVertexBuffers(): Nullable<{
  21750. [key: string]: VertexBuffer;
  21751. }>;
  21752. /**
  21753. * Gets a boolean indicating if specific vertex buffer is present
  21754. * @param kind defines the data kind (Position, normal, etc...)
  21755. * @returns true if data is present
  21756. */
  21757. isVerticesDataPresent(kind: string): boolean;
  21758. /**
  21759. * Gets a list of all attached data kinds (Position, normal, etc...)
  21760. * @returns a list of string containing all kinds
  21761. */
  21762. getVerticesDataKinds(): string[];
  21763. /**
  21764. * Update index buffer
  21765. * @param indices defines the indices to store in the index buffer
  21766. * @param offset defines the offset in the target buffer where to store the data
  21767. * @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)
  21768. */
  21769. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21770. /**
  21771. * Creates a new index buffer
  21772. * @param indices defines the indices to store in the index buffer
  21773. * @param totalVertices defines the total number of vertices (could be null)
  21774. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21775. */
  21776. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21777. /**
  21778. * Return the total number of indices
  21779. * @returns the total number of indices
  21780. */
  21781. getTotalIndices(): number;
  21782. /**
  21783. * Gets the index buffer array
  21784. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21785. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21786. * @returns the index buffer array
  21787. */
  21788. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21789. /**
  21790. * Gets the index buffer
  21791. * @return the index buffer
  21792. */
  21793. getIndexBuffer(): Nullable<DataBuffer>;
  21794. /** @hidden */
  21795. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21796. /**
  21797. * Release the associated resources for a specific mesh
  21798. * @param mesh defines the source mesh
  21799. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21800. */
  21801. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21802. /**
  21803. * Apply current geometry to a given mesh
  21804. * @param mesh defines the mesh to apply geometry to
  21805. */
  21806. applyToMesh(mesh: Mesh): void;
  21807. private _updateExtend;
  21808. private _applyToMesh;
  21809. private notifyUpdate;
  21810. /**
  21811. * Load the geometry if it was flagged as delay loaded
  21812. * @param scene defines the hosting scene
  21813. * @param onLoaded defines a callback called when the geometry is loaded
  21814. */
  21815. load(scene: Scene, onLoaded?: () => void): void;
  21816. private _queueLoad;
  21817. /**
  21818. * Invert the geometry to move from a right handed system to a left handed one.
  21819. */
  21820. toLeftHanded(): void;
  21821. /** @hidden */
  21822. _resetPointsArrayCache(): void;
  21823. /** @hidden */
  21824. _generatePointsArray(): boolean;
  21825. /**
  21826. * Gets a value indicating if the geometry is disposed
  21827. * @returns true if the geometry was disposed
  21828. */
  21829. isDisposed(): boolean;
  21830. private _disposeVertexArrayObjects;
  21831. /**
  21832. * Free all associated resources
  21833. */
  21834. dispose(): void;
  21835. /**
  21836. * Clone the current geometry into a new geometry
  21837. * @param id defines the unique ID of the new geometry
  21838. * @returns a new geometry object
  21839. */
  21840. copy(id: string): Geometry;
  21841. /**
  21842. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21843. * @return a JSON representation of the current geometry data (without the vertices data)
  21844. */
  21845. serialize(): any;
  21846. private toNumberArray;
  21847. /**
  21848. * Serialize all vertices data into a JSON oject
  21849. * @returns a JSON representation of the current geometry data
  21850. */
  21851. serializeVerticeData(): any;
  21852. /**
  21853. * Extracts a clone of a mesh geometry
  21854. * @param mesh defines the source mesh
  21855. * @param id defines the unique ID of the new geometry object
  21856. * @returns the new geometry object
  21857. */
  21858. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21859. /**
  21860. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21861. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21862. * Be aware Math.random() could cause collisions, but:
  21863. * "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"
  21864. * @returns a string containing a new GUID
  21865. */
  21866. static RandomId(): string;
  21867. /** @hidden */
  21868. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21869. private static _CleanMatricesWeights;
  21870. /**
  21871. * Create a new geometry from persisted data (Using .babylon file format)
  21872. * @param parsedVertexData defines the persisted data
  21873. * @param scene defines the hosting scene
  21874. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21875. * @returns the new geometry object
  21876. */
  21877. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21878. }
  21879. }
  21880. declare module "babylonjs/Meshes/mesh.vertexData" {
  21881. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21882. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21883. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21884. import { Geometry } from "babylonjs/Meshes/geometry";
  21885. import { Mesh } from "babylonjs/Meshes/mesh";
  21886. /**
  21887. * Define an interface for all classes that will get and set the data on vertices
  21888. */
  21889. export interface IGetSetVerticesData {
  21890. /**
  21891. * Gets a boolean indicating if specific vertex data is present
  21892. * @param kind defines the vertex data kind to use
  21893. * @returns true is data kind is present
  21894. */
  21895. isVerticesDataPresent(kind: string): boolean;
  21896. /**
  21897. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21898. * @param kind defines the data kind (Position, normal, etc...)
  21899. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21900. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21901. * @returns a float array containing vertex data
  21902. */
  21903. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21904. /**
  21905. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21906. * @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.
  21907. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21908. * @returns the indices array or an empty array if the mesh has no geometry
  21909. */
  21910. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21911. /**
  21912. * Set specific vertex data
  21913. * @param kind defines the data kind (Position, normal, etc...)
  21914. * @param data defines the vertex data to use
  21915. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21916. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21917. */
  21918. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21919. /**
  21920. * Update a specific associated vertex buffer
  21921. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21922. * - VertexBuffer.PositionKind
  21923. * - VertexBuffer.UVKind
  21924. * - VertexBuffer.UV2Kind
  21925. * - VertexBuffer.UV3Kind
  21926. * - VertexBuffer.UV4Kind
  21927. * - VertexBuffer.UV5Kind
  21928. * - VertexBuffer.UV6Kind
  21929. * - VertexBuffer.ColorKind
  21930. * - VertexBuffer.MatricesIndicesKind
  21931. * - VertexBuffer.MatricesIndicesExtraKind
  21932. * - VertexBuffer.MatricesWeightsKind
  21933. * - VertexBuffer.MatricesWeightsExtraKind
  21934. * @param data defines the data source
  21935. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21936. * @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)
  21937. */
  21938. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21939. /**
  21940. * Creates a new index buffer
  21941. * @param indices defines the indices to store in the index buffer
  21942. * @param totalVertices defines the total number of vertices (could be null)
  21943. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21944. */
  21945. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21946. }
  21947. /**
  21948. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21949. */
  21950. export class VertexData {
  21951. /**
  21952. * Mesh side orientation : usually the external or front surface
  21953. */
  21954. static readonly FRONTSIDE: number;
  21955. /**
  21956. * Mesh side orientation : usually the internal or back surface
  21957. */
  21958. static readonly BACKSIDE: number;
  21959. /**
  21960. * Mesh side orientation : both internal and external or front and back surfaces
  21961. */
  21962. static readonly DOUBLESIDE: number;
  21963. /**
  21964. * Mesh side orientation : by default, `FRONTSIDE`
  21965. */
  21966. static readonly DEFAULTSIDE: number;
  21967. /**
  21968. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21969. */
  21970. positions: Nullable<FloatArray>;
  21971. /**
  21972. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21973. */
  21974. normals: Nullable<FloatArray>;
  21975. /**
  21976. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21977. */
  21978. tangents: Nullable<FloatArray>;
  21979. /**
  21980. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21981. */
  21982. uvs: Nullable<FloatArray>;
  21983. /**
  21984. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21985. */
  21986. uvs2: Nullable<FloatArray>;
  21987. /**
  21988. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21989. */
  21990. uvs3: Nullable<FloatArray>;
  21991. /**
  21992. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21993. */
  21994. uvs4: Nullable<FloatArray>;
  21995. /**
  21996. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21997. */
  21998. uvs5: Nullable<FloatArray>;
  21999. /**
  22000. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22001. */
  22002. uvs6: Nullable<FloatArray>;
  22003. /**
  22004. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22005. */
  22006. colors: Nullable<FloatArray>;
  22007. /**
  22008. * 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).
  22009. */
  22010. matricesIndices: Nullable<FloatArray>;
  22011. /**
  22012. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22013. */
  22014. matricesWeights: Nullable<FloatArray>;
  22015. /**
  22016. * An array extending the number of possible indices
  22017. */
  22018. matricesIndicesExtra: Nullable<FloatArray>;
  22019. /**
  22020. * An array extending the number of possible weights when the number of indices is extended
  22021. */
  22022. matricesWeightsExtra: Nullable<FloatArray>;
  22023. /**
  22024. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22025. */
  22026. indices: Nullable<IndicesArray>;
  22027. /**
  22028. * Uses the passed data array to set the set the values for the specified kind of data
  22029. * @param data a linear array of floating numbers
  22030. * @param kind the type of data that is being set, eg positions, colors etc
  22031. */
  22032. set(data: FloatArray, kind: string): void;
  22033. /**
  22034. * Associates the vertexData to the passed Mesh.
  22035. * Sets it as updatable or not (default `false`)
  22036. * @param mesh the mesh the vertexData is applied to
  22037. * @param updatable when used and having the value true allows new data to update the vertexData
  22038. * @returns the VertexData
  22039. */
  22040. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22041. /**
  22042. * Associates the vertexData to the passed Geometry.
  22043. * Sets it as updatable or not (default `false`)
  22044. * @param geometry the geometry the vertexData is applied to
  22045. * @param updatable when used and having the value true allows new data to update the vertexData
  22046. * @returns VertexData
  22047. */
  22048. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22049. /**
  22050. * Updates the associated mesh
  22051. * @param mesh the mesh to be updated
  22052. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22053. * @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
  22054. * @returns VertexData
  22055. */
  22056. updateMesh(mesh: Mesh): VertexData;
  22057. /**
  22058. * Updates the associated geometry
  22059. * @param geometry the geometry to be updated
  22060. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22061. * @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
  22062. * @returns VertexData.
  22063. */
  22064. updateGeometry(geometry: Geometry): VertexData;
  22065. private _applyTo;
  22066. private _update;
  22067. /**
  22068. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22069. * @param matrix the transforming matrix
  22070. * @returns the VertexData
  22071. */
  22072. transform(matrix: Matrix): VertexData;
  22073. /**
  22074. * Merges the passed VertexData into the current one
  22075. * @param other the VertexData to be merged into the current one
  22076. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22077. * @returns the modified VertexData
  22078. */
  22079. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22080. private _mergeElement;
  22081. private _validate;
  22082. /**
  22083. * Serializes the VertexData
  22084. * @returns a serialized object
  22085. */
  22086. serialize(): any;
  22087. /**
  22088. * Extracts the vertexData from a mesh
  22089. * @param mesh the mesh from which to extract the VertexData
  22090. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22091. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22092. * @returns the object VertexData associated to the passed mesh
  22093. */
  22094. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22095. /**
  22096. * Extracts the vertexData from the geometry
  22097. * @param geometry the geometry from which to extract the VertexData
  22098. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22099. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22100. * @returns the object VertexData associated to the passed mesh
  22101. */
  22102. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22103. private static _ExtractFrom;
  22104. /**
  22105. * Creates the VertexData for a Ribbon
  22106. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22107. * * pathArray array of paths, each of which an array of successive Vector3
  22108. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22109. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22110. * * 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
  22111. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22112. * * 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)
  22113. * * 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)
  22114. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22115. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22116. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22117. * @returns the VertexData of the ribbon
  22118. */
  22119. static CreateRibbon(options: {
  22120. pathArray: Vector3[][];
  22121. closeArray?: boolean;
  22122. closePath?: boolean;
  22123. offset?: number;
  22124. sideOrientation?: number;
  22125. frontUVs?: Vector4;
  22126. backUVs?: Vector4;
  22127. invertUV?: boolean;
  22128. uvs?: Vector2[];
  22129. colors?: Color4[];
  22130. }): VertexData;
  22131. /**
  22132. * Creates the VertexData for a box
  22133. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22134. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22135. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22136. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22137. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22138. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22139. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22140. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22141. * * 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)
  22142. * * 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)
  22143. * @returns the VertexData of the box
  22144. */
  22145. static CreateBox(options: {
  22146. size?: number;
  22147. width?: number;
  22148. height?: number;
  22149. depth?: number;
  22150. faceUV?: Vector4[];
  22151. faceColors?: Color4[];
  22152. sideOrientation?: number;
  22153. frontUVs?: Vector4;
  22154. backUVs?: Vector4;
  22155. }): VertexData;
  22156. /**
  22157. * Creates the VertexData for a tiled box
  22158. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22159. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22160. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22161. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22162. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22163. * @returns the VertexData of the box
  22164. */
  22165. static CreateTiledBox(options: {
  22166. pattern?: number;
  22167. width?: number;
  22168. height?: number;
  22169. depth?: number;
  22170. tileSize?: number;
  22171. tileWidth?: number;
  22172. tileHeight?: number;
  22173. alignHorizontal?: number;
  22174. alignVertical?: number;
  22175. faceUV?: Vector4[];
  22176. faceColors?: Color4[];
  22177. sideOrientation?: number;
  22178. }): VertexData;
  22179. /**
  22180. * Creates the VertexData for a tiled plane
  22181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22182. * * pattern a limited pattern arrangement depending on the number
  22183. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22184. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22185. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22186. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22187. * * 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)
  22188. * * 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)
  22189. * @returns the VertexData of the tiled plane
  22190. */
  22191. static CreateTiledPlane(options: {
  22192. pattern?: number;
  22193. tileSize?: number;
  22194. tileWidth?: number;
  22195. tileHeight?: number;
  22196. size?: number;
  22197. width?: number;
  22198. height?: number;
  22199. alignHorizontal?: number;
  22200. alignVertical?: number;
  22201. sideOrientation?: number;
  22202. frontUVs?: Vector4;
  22203. backUVs?: Vector4;
  22204. }): VertexData;
  22205. /**
  22206. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22207. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22208. * * segments sets the number of horizontal strips optional, default 32
  22209. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22210. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22211. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22212. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22213. * * 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
  22214. * * 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
  22215. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22216. * * 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)
  22217. * * 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)
  22218. * @returns the VertexData of the ellipsoid
  22219. */
  22220. static CreateSphere(options: {
  22221. segments?: number;
  22222. diameter?: number;
  22223. diameterX?: number;
  22224. diameterY?: number;
  22225. diameterZ?: number;
  22226. arc?: number;
  22227. slice?: number;
  22228. sideOrientation?: number;
  22229. frontUVs?: Vector4;
  22230. backUVs?: Vector4;
  22231. }): VertexData;
  22232. /**
  22233. * Creates the VertexData for a cylinder, cone or prism
  22234. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22235. * * height sets the height (y direction) of the cylinder, optional, default 2
  22236. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22237. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22238. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22239. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22240. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22241. * * 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
  22242. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22243. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22244. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22245. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22247. * * 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)
  22248. * * 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)
  22249. * @returns the VertexData of the cylinder, cone or prism
  22250. */
  22251. static CreateCylinder(options: {
  22252. height?: number;
  22253. diameterTop?: number;
  22254. diameterBottom?: number;
  22255. diameter?: number;
  22256. tessellation?: number;
  22257. subdivisions?: number;
  22258. arc?: number;
  22259. faceColors?: Color4[];
  22260. faceUV?: Vector4[];
  22261. hasRings?: boolean;
  22262. enclose?: boolean;
  22263. sideOrientation?: number;
  22264. frontUVs?: Vector4;
  22265. backUVs?: Vector4;
  22266. }): VertexData;
  22267. /**
  22268. * Creates the VertexData for a torus
  22269. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22270. * * diameter the diameter of the torus, optional default 1
  22271. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22272. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22273. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22274. * * 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)
  22275. * * 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)
  22276. * @returns the VertexData of the torus
  22277. */
  22278. static CreateTorus(options: {
  22279. diameter?: number;
  22280. thickness?: number;
  22281. tessellation?: number;
  22282. sideOrientation?: number;
  22283. frontUVs?: Vector4;
  22284. backUVs?: Vector4;
  22285. }): VertexData;
  22286. /**
  22287. * Creates the VertexData of the LineSystem
  22288. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22289. * - lines an array of lines, each line being an array of successive Vector3
  22290. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22291. * @returns the VertexData of the LineSystem
  22292. */
  22293. static CreateLineSystem(options: {
  22294. lines: Vector3[][];
  22295. colors?: Nullable<Color4[][]>;
  22296. }): VertexData;
  22297. /**
  22298. * Create the VertexData for a DashedLines
  22299. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22300. * - points an array successive Vector3
  22301. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22302. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22303. * - dashNb the intended total number of dashes, optional, default 200
  22304. * @returns the VertexData for the DashedLines
  22305. */
  22306. static CreateDashedLines(options: {
  22307. points: Vector3[];
  22308. dashSize?: number;
  22309. gapSize?: number;
  22310. dashNb?: number;
  22311. }): VertexData;
  22312. /**
  22313. * Creates the VertexData for a Ground
  22314. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22315. * - width the width (x direction) of the ground, optional, default 1
  22316. * - height the height (z direction) of the ground, optional, default 1
  22317. * - subdivisions the number of subdivisions per side, optional, default 1
  22318. * @returns the VertexData of the Ground
  22319. */
  22320. static CreateGround(options: {
  22321. width?: number;
  22322. height?: number;
  22323. subdivisions?: number;
  22324. subdivisionsX?: number;
  22325. subdivisionsY?: number;
  22326. }): VertexData;
  22327. /**
  22328. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22329. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22330. * * xmin the ground minimum X coordinate, optional, default -1
  22331. * * zmin the ground minimum Z coordinate, optional, default -1
  22332. * * xmax the ground maximum X coordinate, optional, default 1
  22333. * * zmax the ground maximum Z coordinate, optional, default 1
  22334. * * 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}
  22335. * * 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}
  22336. * @returns the VertexData of the TiledGround
  22337. */
  22338. static CreateTiledGround(options: {
  22339. xmin: number;
  22340. zmin: number;
  22341. xmax: number;
  22342. zmax: number;
  22343. subdivisions?: {
  22344. w: number;
  22345. h: number;
  22346. };
  22347. precision?: {
  22348. w: number;
  22349. h: number;
  22350. };
  22351. }): VertexData;
  22352. /**
  22353. * Creates the VertexData of the Ground designed from a heightmap
  22354. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22355. * * width the width (x direction) of the ground
  22356. * * height the height (z direction) of the ground
  22357. * * subdivisions the number of subdivisions per side
  22358. * * minHeight the minimum altitude on the ground, optional, default 0
  22359. * * maxHeight the maximum altitude on the ground, optional default 1
  22360. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22361. * * buffer the array holding the image color data
  22362. * * bufferWidth the width of image
  22363. * * bufferHeight the height of image
  22364. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22365. * @returns the VertexData of the Ground designed from a heightmap
  22366. */
  22367. static CreateGroundFromHeightMap(options: {
  22368. width: number;
  22369. height: number;
  22370. subdivisions: number;
  22371. minHeight: number;
  22372. maxHeight: number;
  22373. colorFilter: Color3;
  22374. buffer: Uint8Array;
  22375. bufferWidth: number;
  22376. bufferHeight: number;
  22377. alphaFilter: number;
  22378. }): VertexData;
  22379. /**
  22380. * Creates the VertexData for a Plane
  22381. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22382. * * size sets the width and height of the plane to the value of size, optional default 1
  22383. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22384. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22385. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22386. * * 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)
  22387. * * 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)
  22388. * @returns the VertexData of the box
  22389. */
  22390. static CreatePlane(options: {
  22391. size?: number;
  22392. width?: number;
  22393. height?: number;
  22394. sideOrientation?: number;
  22395. frontUVs?: Vector4;
  22396. backUVs?: Vector4;
  22397. }): VertexData;
  22398. /**
  22399. * Creates the VertexData of the Disc or regular Polygon
  22400. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22401. * * radius the radius of the disc, optional default 0.5
  22402. * * tessellation the number of polygon sides, optional, default 64
  22403. * * 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
  22404. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22405. * * 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)
  22406. * * 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)
  22407. * @returns the VertexData of the box
  22408. */
  22409. static CreateDisc(options: {
  22410. radius?: number;
  22411. tessellation?: number;
  22412. arc?: number;
  22413. sideOrientation?: number;
  22414. frontUVs?: Vector4;
  22415. backUVs?: Vector4;
  22416. }): VertexData;
  22417. /**
  22418. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22419. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22420. * @param polygon a mesh built from polygonTriangulation.build()
  22421. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22422. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22423. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22424. * @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)
  22425. * @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)
  22426. * @returns the VertexData of the Polygon
  22427. */
  22428. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22429. /**
  22430. * Creates the VertexData of the IcoSphere
  22431. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22432. * * radius the radius of the IcoSphere, optional default 1
  22433. * * radiusX allows stretching in the x direction, optional, default radius
  22434. * * radiusY allows stretching in the y direction, optional, default radius
  22435. * * radiusZ allows stretching in the z direction, optional, default radius
  22436. * * flat when true creates a flat shaded mesh, optional, default true
  22437. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22438. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22439. * * 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)
  22440. * * 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)
  22441. * @returns the VertexData of the IcoSphere
  22442. */
  22443. static CreateIcoSphere(options: {
  22444. radius?: number;
  22445. radiusX?: number;
  22446. radiusY?: number;
  22447. radiusZ?: number;
  22448. flat?: boolean;
  22449. subdivisions?: number;
  22450. sideOrientation?: number;
  22451. frontUVs?: Vector4;
  22452. backUVs?: Vector4;
  22453. }): VertexData;
  22454. /**
  22455. * Creates the VertexData for a Polyhedron
  22456. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22457. * * type provided types are:
  22458. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22459. * * 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)
  22460. * * size the size of the IcoSphere, optional default 1
  22461. * * sizeX allows stretching in the x direction, optional, default size
  22462. * * sizeY allows stretching in the y direction, optional, default size
  22463. * * sizeZ allows stretching in the z direction, optional, default size
  22464. * * 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
  22465. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22466. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22467. * * flat when true creates a flat shaded mesh, optional, default true
  22468. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22469. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22470. * * 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)
  22471. * * 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)
  22472. * @returns the VertexData of the Polyhedron
  22473. */
  22474. static CreatePolyhedron(options: {
  22475. type?: number;
  22476. size?: number;
  22477. sizeX?: number;
  22478. sizeY?: number;
  22479. sizeZ?: number;
  22480. custom?: any;
  22481. faceUV?: Vector4[];
  22482. faceColors?: Color4[];
  22483. flat?: boolean;
  22484. sideOrientation?: number;
  22485. frontUVs?: Vector4;
  22486. backUVs?: Vector4;
  22487. }): VertexData;
  22488. /**
  22489. * Creates the VertexData for a TorusKnot
  22490. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22491. * * radius the radius of the torus knot, optional, default 2
  22492. * * tube the thickness of the tube, optional, default 0.5
  22493. * * radialSegments the number of sides on each tube segments, optional, default 32
  22494. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22495. * * p the number of windings around the z axis, optional, default 2
  22496. * * q the number of windings around the x axis, optional, default 3
  22497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22498. * * 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)
  22499. * * 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)
  22500. * @returns the VertexData of the Torus Knot
  22501. */
  22502. static CreateTorusKnot(options: {
  22503. radius?: number;
  22504. tube?: number;
  22505. radialSegments?: number;
  22506. tubularSegments?: number;
  22507. p?: number;
  22508. q?: number;
  22509. sideOrientation?: number;
  22510. frontUVs?: Vector4;
  22511. backUVs?: Vector4;
  22512. }): VertexData;
  22513. /**
  22514. * Compute normals for given positions and indices
  22515. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22516. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22517. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22518. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22519. * * facetNormals : optional array of facet normals (vector3)
  22520. * * facetPositions : optional array of facet positions (vector3)
  22521. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22522. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22523. * * bInfo : optional bounding info, required for facetPartitioning computation
  22524. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22525. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22526. * * useRightHandedSystem: optional boolean to for right handed system computation
  22527. * * depthSort : optional boolean to enable the facet depth sort computation
  22528. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22529. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22530. */
  22531. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22532. facetNormals?: any;
  22533. facetPositions?: any;
  22534. facetPartitioning?: any;
  22535. ratio?: number;
  22536. bInfo?: any;
  22537. bbSize?: Vector3;
  22538. subDiv?: any;
  22539. useRightHandedSystem?: boolean;
  22540. depthSort?: boolean;
  22541. distanceTo?: Vector3;
  22542. depthSortedFacets?: any;
  22543. }): void;
  22544. /** @hidden */
  22545. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22546. /**
  22547. * Applies VertexData created from the imported parameters to the geometry
  22548. * @param parsedVertexData the parsed data from an imported file
  22549. * @param geometry the geometry to apply the VertexData to
  22550. */
  22551. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22552. }
  22553. }
  22554. declare module "babylonjs/Morph/morphTarget" {
  22555. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22556. import { Observable } from "babylonjs/Misc/observable";
  22557. import { Nullable, FloatArray } from "babylonjs/types";
  22558. import { Scene } from "babylonjs/scene";
  22559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22560. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22561. /**
  22562. * Defines a target to use with MorphTargetManager
  22563. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22564. */
  22565. export class MorphTarget implements IAnimatable {
  22566. /** defines the name of the target */
  22567. name: string;
  22568. /**
  22569. * Gets or sets the list of animations
  22570. */
  22571. animations: import("babylonjs/Animations/animation").Animation[];
  22572. private _scene;
  22573. private _positions;
  22574. private _normals;
  22575. private _tangents;
  22576. private _uvs;
  22577. private _influence;
  22578. /**
  22579. * Observable raised when the influence changes
  22580. */
  22581. onInfluenceChanged: Observable<boolean>;
  22582. /** @hidden */
  22583. _onDataLayoutChanged: Observable<void>;
  22584. /**
  22585. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22586. */
  22587. influence: number;
  22588. /**
  22589. * Gets or sets the id of the morph Target
  22590. */
  22591. id: string;
  22592. private _animationPropertiesOverride;
  22593. /**
  22594. * Gets or sets the animation properties override
  22595. */
  22596. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22597. /**
  22598. * Creates a new MorphTarget
  22599. * @param name defines the name of the target
  22600. * @param influence defines the influence to use
  22601. * @param scene defines the scene the morphtarget belongs to
  22602. */
  22603. constructor(
  22604. /** defines the name of the target */
  22605. name: string, influence?: number, scene?: Nullable<Scene>);
  22606. /**
  22607. * Gets a boolean defining if the target contains position data
  22608. */
  22609. readonly hasPositions: boolean;
  22610. /**
  22611. * Gets a boolean defining if the target contains normal data
  22612. */
  22613. readonly hasNormals: boolean;
  22614. /**
  22615. * Gets a boolean defining if the target contains tangent data
  22616. */
  22617. readonly hasTangents: boolean;
  22618. /**
  22619. * Gets a boolean defining if the target contains texture coordinates data
  22620. */
  22621. readonly hasUVs: boolean;
  22622. /**
  22623. * Affects position data to this target
  22624. * @param data defines the position data to use
  22625. */
  22626. setPositions(data: Nullable<FloatArray>): void;
  22627. /**
  22628. * Gets the position data stored in this target
  22629. * @returns a FloatArray containing the position data (or null if not present)
  22630. */
  22631. getPositions(): Nullable<FloatArray>;
  22632. /**
  22633. * Affects normal data to this target
  22634. * @param data defines the normal data to use
  22635. */
  22636. setNormals(data: Nullable<FloatArray>): void;
  22637. /**
  22638. * Gets the normal data stored in this target
  22639. * @returns a FloatArray containing the normal data (or null if not present)
  22640. */
  22641. getNormals(): Nullable<FloatArray>;
  22642. /**
  22643. * Affects tangent data to this target
  22644. * @param data defines the tangent data to use
  22645. */
  22646. setTangents(data: Nullable<FloatArray>): void;
  22647. /**
  22648. * Gets the tangent data stored in this target
  22649. * @returns a FloatArray containing the tangent data (or null if not present)
  22650. */
  22651. getTangents(): Nullable<FloatArray>;
  22652. /**
  22653. * Affects texture coordinates data to this target
  22654. * @param data defines the texture coordinates data to use
  22655. */
  22656. setUVs(data: Nullable<FloatArray>): void;
  22657. /**
  22658. * Gets the texture coordinates data stored in this target
  22659. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22660. */
  22661. getUVs(): Nullable<FloatArray>;
  22662. /**
  22663. * Serializes the current target into a Serialization object
  22664. * @returns the serialized object
  22665. */
  22666. serialize(): any;
  22667. /**
  22668. * Returns the string "MorphTarget"
  22669. * @returns "MorphTarget"
  22670. */
  22671. getClassName(): string;
  22672. /**
  22673. * Creates a new target from serialized data
  22674. * @param serializationObject defines the serialized data to use
  22675. * @returns a new MorphTarget
  22676. */
  22677. static Parse(serializationObject: any): MorphTarget;
  22678. /**
  22679. * Creates a MorphTarget from mesh data
  22680. * @param mesh defines the source mesh
  22681. * @param name defines the name to use for the new target
  22682. * @param influence defines the influence to attach to the target
  22683. * @returns a new MorphTarget
  22684. */
  22685. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22686. }
  22687. }
  22688. declare module "babylonjs/Morph/morphTargetManager" {
  22689. import { Nullable } from "babylonjs/types";
  22690. import { Scene } from "babylonjs/scene";
  22691. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22692. /**
  22693. * This class is used to deform meshes using morphing between different targets
  22694. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22695. */
  22696. export class MorphTargetManager {
  22697. private _targets;
  22698. private _targetInfluenceChangedObservers;
  22699. private _targetDataLayoutChangedObservers;
  22700. private _activeTargets;
  22701. private _scene;
  22702. private _influences;
  22703. private _supportsNormals;
  22704. private _supportsTangents;
  22705. private _supportsUVs;
  22706. private _vertexCount;
  22707. private _uniqueId;
  22708. private _tempInfluences;
  22709. /**
  22710. * Gets or sets a boolean indicating if normals must be morphed
  22711. */
  22712. enableNormalMorphing: boolean;
  22713. /**
  22714. * Gets or sets a boolean indicating if tangents must be morphed
  22715. */
  22716. enableTangentMorphing: boolean;
  22717. /**
  22718. * Gets or sets a boolean indicating if UV must be morphed
  22719. */
  22720. enableUVMorphing: boolean;
  22721. /**
  22722. * Creates a new MorphTargetManager
  22723. * @param scene defines the current scene
  22724. */
  22725. constructor(scene?: Nullable<Scene>);
  22726. /**
  22727. * Gets the unique ID of this manager
  22728. */
  22729. readonly uniqueId: number;
  22730. /**
  22731. * Gets the number of vertices handled by this manager
  22732. */
  22733. readonly vertexCount: number;
  22734. /**
  22735. * Gets a boolean indicating if this manager supports morphing of normals
  22736. */
  22737. readonly supportsNormals: boolean;
  22738. /**
  22739. * Gets a boolean indicating if this manager supports morphing of tangents
  22740. */
  22741. readonly supportsTangents: boolean;
  22742. /**
  22743. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22744. */
  22745. readonly supportsUVs: boolean;
  22746. /**
  22747. * Gets the number of targets stored in this manager
  22748. */
  22749. readonly numTargets: number;
  22750. /**
  22751. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22752. */
  22753. readonly numInfluencers: number;
  22754. /**
  22755. * Gets the list of influences (one per target)
  22756. */
  22757. readonly influences: Float32Array;
  22758. /**
  22759. * Gets the active target at specified index. An active target is a target with an influence > 0
  22760. * @param index defines the index to check
  22761. * @returns the requested target
  22762. */
  22763. getActiveTarget(index: number): MorphTarget;
  22764. /**
  22765. * Gets the target at specified index
  22766. * @param index defines the index to check
  22767. * @returns the requested target
  22768. */
  22769. getTarget(index: number): MorphTarget;
  22770. /**
  22771. * Add a new target to this manager
  22772. * @param target defines the target to add
  22773. */
  22774. addTarget(target: MorphTarget): void;
  22775. /**
  22776. * Removes a target from the manager
  22777. * @param target defines the target to remove
  22778. */
  22779. removeTarget(target: MorphTarget): void;
  22780. /**
  22781. * Serializes the current manager into a Serialization object
  22782. * @returns the serialized object
  22783. */
  22784. serialize(): any;
  22785. private _syncActiveTargets;
  22786. /**
  22787. * Syncrhonize the targets with all the meshes using this morph target manager
  22788. */
  22789. synchronize(): void;
  22790. /**
  22791. * Creates a new MorphTargetManager from serialized data
  22792. * @param serializationObject defines the serialized data
  22793. * @param scene defines the hosting scene
  22794. * @returns the new MorphTargetManager
  22795. */
  22796. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22797. }
  22798. }
  22799. declare module "babylonjs/Meshes/meshLODLevel" {
  22800. import { Mesh } from "babylonjs/Meshes/mesh";
  22801. import { Nullable } from "babylonjs/types";
  22802. /**
  22803. * Class used to represent a specific level of detail of a mesh
  22804. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22805. */
  22806. export class MeshLODLevel {
  22807. /** Defines the distance where this level should start being displayed */
  22808. distance: number;
  22809. /** Defines the mesh to use to render this level */
  22810. mesh: Nullable<Mesh>;
  22811. /**
  22812. * Creates a new LOD level
  22813. * @param distance defines the distance where this level should star being displayed
  22814. * @param mesh defines the mesh to use to render this level
  22815. */
  22816. constructor(
  22817. /** Defines the distance where this level should start being displayed */
  22818. distance: number,
  22819. /** Defines the mesh to use to render this level */
  22820. mesh: Nullable<Mesh>);
  22821. }
  22822. }
  22823. declare module "babylonjs/Meshes/groundMesh" {
  22824. import { Scene } from "babylonjs/scene";
  22825. import { Vector3 } from "babylonjs/Maths/math.vector";
  22826. import { Mesh } from "babylonjs/Meshes/mesh";
  22827. /**
  22828. * Mesh representing the gorund
  22829. */
  22830. export class GroundMesh extends Mesh {
  22831. /** If octree should be generated */
  22832. generateOctree: boolean;
  22833. private _heightQuads;
  22834. /** @hidden */
  22835. _subdivisionsX: number;
  22836. /** @hidden */
  22837. _subdivisionsY: number;
  22838. /** @hidden */
  22839. _width: number;
  22840. /** @hidden */
  22841. _height: number;
  22842. /** @hidden */
  22843. _minX: number;
  22844. /** @hidden */
  22845. _maxX: number;
  22846. /** @hidden */
  22847. _minZ: number;
  22848. /** @hidden */
  22849. _maxZ: number;
  22850. constructor(name: string, scene: Scene);
  22851. /**
  22852. * "GroundMesh"
  22853. * @returns "GroundMesh"
  22854. */
  22855. getClassName(): string;
  22856. /**
  22857. * The minimum of x and y subdivisions
  22858. */
  22859. readonly subdivisions: number;
  22860. /**
  22861. * X subdivisions
  22862. */
  22863. readonly subdivisionsX: number;
  22864. /**
  22865. * Y subdivisions
  22866. */
  22867. readonly subdivisionsY: number;
  22868. /**
  22869. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22870. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22871. * @param chunksCount the number of subdivisions for x and y
  22872. * @param octreeBlocksSize (Default: 32)
  22873. */
  22874. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22875. /**
  22876. * Returns a height (y) value in the Worl system :
  22877. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22878. * @param x x coordinate
  22879. * @param z z coordinate
  22880. * @returns the ground y position if (x, z) are outside the ground surface.
  22881. */
  22882. getHeightAtCoordinates(x: number, z: number): number;
  22883. /**
  22884. * Returns a normalized vector (Vector3) orthogonal to the ground
  22885. * at the ground coordinates (x, z) expressed in the World system.
  22886. * @param x x coordinate
  22887. * @param z z coordinate
  22888. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22889. */
  22890. getNormalAtCoordinates(x: number, z: number): Vector3;
  22891. /**
  22892. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22893. * at the ground coordinates (x, z) expressed in the World system.
  22894. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22895. * @param x x coordinate
  22896. * @param z z coordinate
  22897. * @param ref vector to store the result
  22898. * @returns the GroundMesh.
  22899. */
  22900. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22901. /**
  22902. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22903. * if the ground has been updated.
  22904. * This can be used in the render loop.
  22905. * @returns the GroundMesh.
  22906. */
  22907. updateCoordinateHeights(): GroundMesh;
  22908. private _getFacetAt;
  22909. private _initHeightQuads;
  22910. private _computeHeightQuads;
  22911. /**
  22912. * Serializes this ground mesh
  22913. * @param serializationObject object to write serialization to
  22914. */
  22915. serialize(serializationObject: any): void;
  22916. /**
  22917. * Parses a serialized ground mesh
  22918. * @param parsedMesh the serialized mesh
  22919. * @param scene the scene to create the ground mesh in
  22920. * @returns the created ground mesh
  22921. */
  22922. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22923. }
  22924. }
  22925. declare module "babylonjs/Physics/physicsJoint" {
  22926. import { Vector3 } from "babylonjs/Maths/math.vector";
  22927. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22928. /**
  22929. * Interface for Physics-Joint data
  22930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22931. */
  22932. export interface PhysicsJointData {
  22933. /**
  22934. * The main pivot of the joint
  22935. */
  22936. mainPivot?: Vector3;
  22937. /**
  22938. * The connected pivot of the joint
  22939. */
  22940. connectedPivot?: Vector3;
  22941. /**
  22942. * The main axis of the joint
  22943. */
  22944. mainAxis?: Vector3;
  22945. /**
  22946. * The connected axis of the joint
  22947. */
  22948. connectedAxis?: Vector3;
  22949. /**
  22950. * The collision of the joint
  22951. */
  22952. collision?: boolean;
  22953. /**
  22954. * Native Oimo/Cannon/Energy data
  22955. */
  22956. nativeParams?: any;
  22957. }
  22958. /**
  22959. * This is a holder class for the physics joint created by the physics plugin
  22960. * It holds a set of functions to control the underlying joint
  22961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22962. */
  22963. export class PhysicsJoint {
  22964. /**
  22965. * The type of the physics joint
  22966. */
  22967. type: number;
  22968. /**
  22969. * The data for the physics joint
  22970. */
  22971. jointData: PhysicsJointData;
  22972. private _physicsJoint;
  22973. protected _physicsPlugin: IPhysicsEnginePlugin;
  22974. /**
  22975. * Initializes the physics joint
  22976. * @param type The type of the physics joint
  22977. * @param jointData The data for the physics joint
  22978. */
  22979. constructor(
  22980. /**
  22981. * The type of the physics joint
  22982. */
  22983. type: number,
  22984. /**
  22985. * The data for the physics joint
  22986. */
  22987. jointData: PhysicsJointData);
  22988. /**
  22989. * Gets the physics joint
  22990. */
  22991. /**
  22992. * Sets the physics joint
  22993. */
  22994. physicsJoint: any;
  22995. /**
  22996. * Sets the physics plugin
  22997. */
  22998. physicsPlugin: IPhysicsEnginePlugin;
  22999. /**
  23000. * Execute a function that is physics-plugin specific.
  23001. * @param {Function} func the function that will be executed.
  23002. * It accepts two parameters: the physics world and the physics joint
  23003. */
  23004. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23005. /**
  23006. * Distance-Joint type
  23007. */
  23008. static DistanceJoint: number;
  23009. /**
  23010. * Hinge-Joint type
  23011. */
  23012. static HingeJoint: number;
  23013. /**
  23014. * Ball-and-Socket joint type
  23015. */
  23016. static BallAndSocketJoint: number;
  23017. /**
  23018. * Wheel-Joint type
  23019. */
  23020. static WheelJoint: number;
  23021. /**
  23022. * Slider-Joint type
  23023. */
  23024. static SliderJoint: number;
  23025. /**
  23026. * Prismatic-Joint type
  23027. */
  23028. static PrismaticJoint: number;
  23029. /**
  23030. * Universal-Joint type
  23031. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23032. */
  23033. static UniversalJoint: number;
  23034. /**
  23035. * Hinge-Joint 2 type
  23036. */
  23037. static Hinge2Joint: number;
  23038. /**
  23039. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23040. */
  23041. static PointToPointJoint: number;
  23042. /**
  23043. * Spring-Joint type
  23044. */
  23045. static SpringJoint: number;
  23046. /**
  23047. * Lock-Joint type
  23048. */
  23049. static LockJoint: number;
  23050. }
  23051. /**
  23052. * A class representing a physics distance joint
  23053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23054. */
  23055. export class DistanceJoint extends PhysicsJoint {
  23056. /**
  23057. *
  23058. * @param jointData The data for the Distance-Joint
  23059. */
  23060. constructor(jointData: DistanceJointData);
  23061. /**
  23062. * Update the predefined distance.
  23063. * @param maxDistance The maximum preferred distance
  23064. * @param minDistance The minimum preferred distance
  23065. */
  23066. updateDistance(maxDistance: number, minDistance?: number): void;
  23067. }
  23068. /**
  23069. * Represents a Motor-Enabled Joint
  23070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23071. */
  23072. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23073. /**
  23074. * Initializes the Motor-Enabled Joint
  23075. * @param type The type of the joint
  23076. * @param jointData The physica joint data for the joint
  23077. */
  23078. constructor(type: number, jointData: PhysicsJointData);
  23079. /**
  23080. * Set the motor values.
  23081. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23082. * @param force the force to apply
  23083. * @param maxForce max force for this motor.
  23084. */
  23085. setMotor(force?: number, maxForce?: number): void;
  23086. /**
  23087. * Set the motor's limits.
  23088. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23089. * @param upperLimit The upper limit of the motor
  23090. * @param lowerLimit The lower limit of the motor
  23091. */
  23092. setLimit(upperLimit: number, lowerLimit?: number): void;
  23093. }
  23094. /**
  23095. * This class represents a single physics Hinge-Joint
  23096. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23097. */
  23098. export class HingeJoint extends MotorEnabledJoint {
  23099. /**
  23100. * Initializes the Hinge-Joint
  23101. * @param jointData The joint data for the Hinge-Joint
  23102. */
  23103. constructor(jointData: PhysicsJointData);
  23104. /**
  23105. * Set the motor values.
  23106. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23107. * @param {number} force the force to apply
  23108. * @param {number} maxForce max force for this motor.
  23109. */
  23110. setMotor(force?: number, maxForce?: number): void;
  23111. /**
  23112. * Set the motor's limits.
  23113. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23114. * @param upperLimit The upper limit of the motor
  23115. * @param lowerLimit The lower limit of the motor
  23116. */
  23117. setLimit(upperLimit: number, lowerLimit?: number): void;
  23118. }
  23119. /**
  23120. * This class represents a dual hinge physics joint (same as wheel joint)
  23121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23122. */
  23123. export class Hinge2Joint extends MotorEnabledJoint {
  23124. /**
  23125. * Initializes the Hinge2-Joint
  23126. * @param jointData The joint data for the Hinge2-Joint
  23127. */
  23128. constructor(jointData: PhysicsJointData);
  23129. /**
  23130. * Set the motor values.
  23131. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23132. * @param {number} targetSpeed the speed the motor is to reach
  23133. * @param {number} maxForce max force for this motor.
  23134. * @param {motorIndex} the motor's index, 0 or 1.
  23135. */
  23136. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23137. /**
  23138. * Set the motor limits.
  23139. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23140. * @param {number} upperLimit the upper limit
  23141. * @param {number} lowerLimit lower limit
  23142. * @param {motorIndex} the motor's index, 0 or 1.
  23143. */
  23144. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23145. }
  23146. /**
  23147. * Interface for a motor enabled joint
  23148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23149. */
  23150. export interface IMotorEnabledJoint {
  23151. /**
  23152. * Physics joint
  23153. */
  23154. physicsJoint: any;
  23155. /**
  23156. * Sets the motor of the motor-enabled joint
  23157. * @param force The force of the motor
  23158. * @param maxForce The maximum force of the motor
  23159. * @param motorIndex The index of the motor
  23160. */
  23161. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23162. /**
  23163. * Sets the limit of the motor
  23164. * @param upperLimit The upper limit of the motor
  23165. * @param lowerLimit The lower limit of the motor
  23166. * @param motorIndex The index of the motor
  23167. */
  23168. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23169. }
  23170. /**
  23171. * Joint data for a Distance-Joint
  23172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23173. */
  23174. export interface DistanceJointData extends PhysicsJointData {
  23175. /**
  23176. * Max distance the 2 joint objects can be apart
  23177. */
  23178. maxDistance: number;
  23179. }
  23180. /**
  23181. * Joint data from a spring joint
  23182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23183. */
  23184. export interface SpringJointData extends PhysicsJointData {
  23185. /**
  23186. * Length of the spring
  23187. */
  23188. length: number;
  23189. /**
  23190. * Stiffness of the spring
  23191. */
  23192. stiffness: number;
  23193. /**
  23194. * Damping of the spring
  23195. */
  23196. damping: number;
  23197. /** this callback will be called when applying the force to the impostors. */
  23198. forceApplicationCallback: () => void;
  23199. }
  23200. }
  23201. declare module "babylonjs/Physics/physicsRaycastResult" {
  23202. import { Vector3 } from "babylonjs/Maths/math.vector";
  23203. /**
  23204. * Holds the data for the raycast result
  23205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23206. */
  23207. export class PhysicsRaycastResult {
  23208. private _hasHit;
  23209. private _hitDistance;
  23210. private _hitNormalWorld;
  23211. private _hitPointWorld;
  23212. private _rayFromWorld;
  23213. private _rayToWorld;
  23214. /**
  23215. * Gets if there was a hit
  23216. */
  23217. readonly hasHit: boolean;
  23218. /**
  23219. * Gets the distance from the hit
  23220. */
  23221. readonly hitDistance: number;
  23222. /**
  23223. * Gets the hit normal/direction in the world
  23224. */
  23225. readonly hitNormalWorld: Vector3;
  23226. /**
  23227. * Gets the hit point in the world
  23228. */
  23229. readonly hitPointWorld: Vector3;
  23230. /**
  23231. * Gets the ray "start point" of the ray in the world
  23232. */
  23233. readonly rayFromWorld: Vector3;
  23234. /**
  23235. * Gets the ray "end point" of the ray in the world
  23236. */
  23237. readonly rayToWorld: Vector3;
  23238. /**
  23239. * Sets the hit data (normal & point in world space)
  23240. * @param hitNormalWorld defines the normal in world space
  23241. * @param hitPointWorld defines the point in world space
  23242. */
  23243. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23244. /**
  23245. * Sets the distance from the start point to the hit point
  23246. * @param distance
  23247. */
  23248. setHitDistance(distance: number): void;
  23249. /**
  23250. * Calculates the distance manually
  23251. */
  23252. calculateHitDistance(): void;
  23253. /**
  23254. * Resets all the values to default
  23255. * @param from The from point on world space
  23256. * @param to The to point on world space
  23257. */
  23258. reset(from?: Vector3, to?: Vector3): void;
  23259. }
  23260. /**
  23261. * Interface for the size containing width and height
  23262. */
  23263. interface IXYZ {
  23264. /**
  23265. * X
  23266. */
  23267. x: number;
  23268. /**
  23269. * Y
  23270. */
  23271. y: number;
  23272. /**
  23273. * Z
  23274. */
  23275. z: number;
  23276. }
  23277. }
  23278. declare module "babylonjs/Physics/IPhysicsEngine" {
  23279. import { Nullable } from "babylonjs/types";
  23280. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23282. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23283. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23284. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23285. /**
  23286. * Interface used to describe a physics joint
  23287. */
  23288. export interface PhysicsImpostorJoint {
  23289. /** Defines the main impostor to which the joint is linked */
  23290. mainImpostor: PhysicsImpostor;
  23291. /** Defines the impostor that is connected to the main impostor using this joint */
  23292. connectedImpostor: PhysicsImpostor;
  23293. /** Defines the joint itself */
  23294. joint: PhysicsJoint;
  23295. }
  23296. /** @hidden */
  23297. export interface IPhysicsEnginePlugin {
  23298. world: any;
  23299. name: string;
  23300. setGravity(gravity: Vector3): void;
  23301. setTimeStep(timeStep: number): void;
  23302. getTimeStep(): number;
  23303. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23304. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23305. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23306. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23307. removePhysicsBody(impostor: PhysicsImpostor): void;
  23308. generateJoint(joint: PhysicsImpostorJoint): void;
  23309. removeJoint(joint: PhysicsImpostorJoint): void;
  23310. isSupported(): boolean;
  23311. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23312. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23313. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23314. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23315. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23316. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23317. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23318. getBodyMass(impostor: PhysicsImpostor): number;
  23319. getBodyFriction(impostor: PhysicsImpostor): number;
  23320. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23321. getBodyRestitution(impostor: PhysicsImpostor): number;
  23322. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23323. getBodyPressure?(impostor: PhysicsImpostor): number;
  23324. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23325. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23326. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23327. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23328. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23329. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23330. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23331. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23332. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23333. sleepBody(impostor: PhysicsImpostor): void;
  23334. wakeUpBody(impostor: PhysicsImpostor): void;
  23335. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23336. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23337. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23338. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23339. getRadius(impostor: PhysicsImpostor): number;
  23340. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23341. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23342. dispose(): void;
  23343. }
  23344. /**
  23345. * Interface used to define a physics engine
  23346. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23347. */
  23348. export interface IPhysicsEngine {
  23349. /**
  23350. * Gets the gravity vector used by the simulation
  23351. */
  23352. gravity: Vector3;
  23353. /**
  23354. * Sets the gravity vector used by the simulation
  23355. * @param gravity defines the gravity vector to use
  23356. */
  23357. setGravity(gravity: Vector3): void;
  23358. /**
  23359. * Set the time step of the physics engine.
  23360. * Default is 1/60.
  23361. * To slow it down, enter 1/600 for example.
  23362. * To speed it up, 1/30
  23363. * @param newTimeStep the new timestep to apply to this world.
  23364. */
  23365. setTimeStep(newTimeStep: number): void;
  23366. /**
  23367. * Get the time step of the physics engine.
  23368. * @returns the current time step
  23369. */
  23370. getTimeStep(): number;
  23371. /**
  23372. * Release all resources
  23373. */
  23374. dispose(): void;
  23375. /**
  23376. * Gets the name of the current physics plugin
  23377. * @returns the name of the plugin
  23378. */
  23379. getPhysicsPluginName(): string;
  23380. /**
  23381. * Adding a new impostor for the impostor tracking.
  23382. * This will be done by the impostor itself.
  23383. * @param impostor the impostor to add
  23384. */
  23385. addImpostor(impostor: PhysicsImpostor): void;
  23386. /**
  23387. * Remove an impostor from the engine.
  23388. * This impostor and its mesh will not longer be updated by the physics engine.
  23389. * @param impostor the impostor to remove
  23390. */
  23391. removeImpostor(impostor: PhysicsImpostor): void;
  23392. /**
  23393. * Add a joint to the physics engine
  23394. * @param mainImpostor defines the main impostor to which the joint is added.
  23395. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23396. * @param joint defines the joint that will connect both impostors.
  23397. */
  23398. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23399. /**
  23400. * Removes a joint from the simulation
  23401. * @param mainImpostor defines the impostor used with the joint
  23402. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23403. * @param joint defines the joint to remove
  23404. */
  23405. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23406. /**
  23407. * Gets the current plugin used to run the simulation
  23408. * @returns current plugin
  23409. */
  23410. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23411. /**
  23412. * Gets the list of physic impostors
  23413. * @returns an array of PhysicsImpostor
  23414. */
  23415. getImpostors(): Array<PhysicsImpostor>;
  23416. /**
  23417. * Gets the impostor for a physics enabled object
  23418. * @param object defines the object impersonated by the impostor
  23419. * @returns the PhysicsImpostor or null if not found
  23420. */
  23421. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23422. /**
  23423. * Gets the impostor for a physics body object
  23424. * @param body defines physics body used by the impostor
  23425. * @returns the PhysicsImpostor or null if not found
  23426. */
  23427. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23428. /**
  23429. * Does a raycast in the physics world
  23430. * @param from when should the ray start?
  23431. * @param to when should the ray end?
  23432. * @returns PhysicsRaycastResult
  23433. */
  23434. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23435. /**
  23436. * Called by the scene. No need to call it.
  23437. * @param delta defines the timespam between frames
  23438. */
  23439. _step(delta: number): void;
  23440. }
  23441. }
  23442. declare module "babylonjs/Physics/physicsImpostor" {
  23443. import { Nullable, IndicesArray } from "babylonjs/types";
  23444. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23445. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23447. import { Scene } from "babylonjs/scene";
  23448. import { Bone } from "babylonjs/Bones/bone";
  23449. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23450. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23451. import { Space } from "babylonjs/Maths/math.axis";
  23452. /**
  23453. * The interface for the physics imposter parameters
  23454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23455. */
  23456. export interface PhysicsImpostorParameters {
  23457. /**
  23458. * The mass of the physics imposter
  23459. */
  23460. mass: number;
  23461. /**
  23462. * The friction of the physics imposter
  23463. */
  23464. friction?: number;
  23465. /**
  23466. * The coefficient of restitution of the physics imposter
  23467. */
  23468. restitution?: number;
  23469. /**
  23470. * The native options of the physics imposter
  23471. */
  23472. nativeOptions?: any;
  23473. /**
  23474. * Specifies if the parent should be ignored
  23475. */
  23476. ignoreParent?: boolean;
  23477. /**
  23478. * Specifies if bi-directional transformations should be disabled
  23479. */
  23480. disableBidirectionalTransformation?: boolean;
  23481. /**
  23482. * The pressure inside the physics imposter, soft object only
  23483. */
  23484. pressure?: number;
  23485. /**
  23486. * The stiffness the physics imposter, soft object only
  23487. */
  23488. stiffness?: number;
  23489. /**
  23490. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23491. */
  23492. velocityIterations?: number;
  23493. /**
  23494. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23495. */
  23496. positionIterations?: number;
  23497. /**
  23498. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23499. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23500. * Add to fix multiple points
  23501. */
  23502. fixedPoints?: number;
  23503. /**
  23504. * The collision margin around a soft object
  23505. */
  23506. margin?: number;
  23507. /**
  23508. * The collision margin around a soft object
  23509. */
  23510. damping?: number;
  23511. /**
  23512. * The path for a rope based on an extrusion
  23513. */
  23514. path?: any;
  23515. /**
  23516. * The shape of an extrusion used for a rope based on an extrusion
  23517. */
  23518. shape?: any;
  23519. }
  23520. /**
  23521. * Interface for a physics-enabled object
  23522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23523. */
  23524. export interface IPhysicsEnabledObject {
  23525. /**
  23526. * The position of the physics-enabled object
  23527. */
  23528. position: Vector3;
  23529. /**
  23530. * The rotation of the physics-enabled object
  23531. */
  23532. rotationQuaternion: Nullable<Quaternion>;
  23533. /**
  23534. * The scale of the physics-enabled object
  23535. */
  23536. scaling: Vector3;
  23537. /**
  23538. * The rotation of the physics-enabled object
  23539. */
  23540. rotation?: Vector3;
  23541. /**
  23542. * The parent of the physics-enabled object
  23543. */
  23544. parent?: any;
  23545. /**
  23546. * The bounding info of the physics-enabled object
  23547. * @returns The bounding info of the physics-enabled object
  23548. */
  23549. getBoundingInfo(): BoundingInfo;
  23550. /**
  23551. * Computes the world matrix
  23552. * @param force Specifies if the world matrix should be computed by force
  23553. * @returns A world matrix
  23554. */
  23555. computeWorldMatrix(force: boolean): Matrix;
  23556. /**
  23557. * Gets the world matrix
  23558. * @returns A world matrix
  23559. */
  23560. getWorldMatrix?(): Matrix;
  23561. /**
  23562. * Gets the child meshes
  23563. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23564. * @returns An array of abstract meshes
  23565. */
  23566. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23567. /**
  23568. * Gets the vertex data
  23569. * @param kind The type of vertex data
  23570. * @returns A nullable array of numbers, or a float32 array
  23571. */
  23572. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23573. /**
  23574. * Gets the indices from the mesh
  23575. * @returns A nullable array of index arrays
  23576. */
  23577. getIndices?(): Nullable<IndicesArray>;
  23578. /**
  23579. * Gets the scene from the mesh
  23580. * @returns the indices array or null
  23581. */
  23582. getScene?(): Scene;
  23583. /**
  23584. * Gets the absolute position from the mesh
  23585. * @returns the absolute position
  23586. */
  23587. getAbsolutePosition(): Vector3;
  23588. /**
  23589. * Gets the absolute pivot point from the mesh
  23590. * @returns the absolute pivot point
  23591. */
  23592. getAbsolutePivotPoint(): Vector3;
  23593. /**
  23594. * Rotates the mesh
  23595. * @param axis The axis of rotation
  23596. * @param amount The amount of rotation
  23597. * @param space The space of the rotation
  23598. * @returns The rotation transform node
  23599. */
  23600. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23601. /**
  23602. * Translates the mesh
  23603. * @param axis The axis of translation
  23604. * @param distance The distance of translation
  23605. * @param space The space of the translation
  23606. * @returns The transform node
  23607. */
  23608. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23609. /**
  23610. * Sets the absolute position of the mesh
  23611. * @param absolutePosition The absolute position of the mesh
  23612. * @returns The transform node
  23613. */
  23614. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23615. /**
  23616. * Gets the class name of the mesh
  23617. * @returns The class name
  23618. */
  23619. getClassName(): string;
  23620. }
  23621. /**
  23622. * Represents a physics imposter
  23623. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23624. */
  23625. export class PhysicsImpostor {
  23626. /**
  23627. * The physics-enabled object used as the physics imposter
  23628. */
  23629. object: IPhysicsEnabledObject;
  23630. /**
  23631. * The type of the physics imposter
  23632. */
  23633. type: number;
  23634. private _options;
  23635. private _scene?;
  23636. /**
  23637. * The default object size of the imposter
  23638. */
  23639. static DEFAULT_OBJECT_SIZE: Vector3;
  23640. /**
  23641. * The identity quaternion of the imposter
  23642. */
  23643. static IDENTITY_QUATERNION: Quaternion;
  23644. /** @hidden */
  23645. _pluginData: any;
  23646. private _physicsEngine;
  23647. private _physicsBody;
  23648. private _bodyUpdateRequired;
  23649. private _onBeforePhysicsStepCallbacks;
  23650. private _onAfterPhysicsStepCallbacks;
  23651. /** @hidden */
  23652. _onPhysicsCollideCallbacks: Array<{
  23653. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23654. otherImpostors: Array<PhysicsImpostor>;
  23655. }>;
  23656. private _deltaPosition;
  23657. private _deltaRotation;
  23658. private _deltaRotationConjugated;
  23659. /** @hidden */
  23660. _isFromLine: boolean;
  23661. private _parent;
  23662. private _isDisposed;
  23663. private static _tmpVecs;
  23664. private static _tmpQuat;
  23665. /**
  23666. * Specifies if the physics imposter is disposed
  23667. */
  23668. readonly isDisposed: boolean;
  23669. /**
  23670. * Gets the mass of the physics imposter
  23671. */
  23672. mass: number;
  23673. /**
  23674. * Gets the coefficient of friction
  23675. */
  23676. /**
  23677. * Sets the coefficient of friction
  23678. */
  23679. friction: number;
  23680. /**
  23681. * Gets the coefficient of restitution
  23682. */
  23683. /**
  23684. * Sets the coefficient of restitution
  23685. */
  23686. restitution: number;
  23687. /**
  23688. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23689. */
  23690. /**
  23691. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23692. */
  23693. pressure: number;
  23694. /**
  23695. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23696. */
  23697. /**
  23698. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23699. */
  23700. stiffness: number;
  23701. /**
  23702. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23703. */
  23704. /**
  23705. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23706. */
  23707. velocityIterations: number;
  23708. /**
  23709. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23710. */
  23711. /**
  23712. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23713. */
  23714. positionIterations: number;
  23715. /**
  23716. * The unique id of the physics imposter
  23717. * set by the physics engine when adding this impostor to the array
  23718. */
  23719. uniqueId: number;
  23720. /**
  23721. * @hidden
  23722. */
  23723. soft: boolean;
  23724. /**
  23725. * @hidden
  23726. */
  23727. segments: number;
  23728. private _joints;
  23729. /**
  23730. * Initializes the physics imposter
  23731. * @param object The physics-enabled object used as the physics imposter
  23732. * @param type The type of the physics imposter
  23733. * @param _options The options for the physics imposter
  23734. * @param _scene The Babylon scene
  23735. */
  23736. constructor(
  23737. /**
  23738. * The physics-enabled object used as the physics imposter
  23739. */
  23740. object: IPhysicsEnabledObject,
  23741. /**
  23742. * The type of the physics imposter
  23743. */
  23744. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23745. /**
  23746. * This function will completly initialize this impostor.
  23747. * It will create a new body - but only if this mesh has no parent.
  23748. * If it has, this impostor will not be used other than to define the impostor
  23749. * of the child mesh.
  23750. * @hidden
  23751. */
  23752. _init(): void;
  23753. private _getPhysicsParent;
  23754. /**
  23755. * Should a new body be generated.
  23756. * @returns boolean specifying if body initialization is required
  23757. */
  23758. isBodyInitRequired(): boolean;
  23759. /**
  23760. * Sets the updated scaling
  23761. * @param updated Specifies if the scaling is updated
  23762. */
  23763. setScalingUpdated(): void;
  23764. /**
  23765. * Force a regeneration of this or the parent's impostor's body.
  23766. * Use under cautious - This will remove all joints already implemented.
  23767. */
  23768. forceUpdate(): void;
  23769. /**
  23770. * Gets the body that holds this impostor. Either its own, or its parent.
  23771. */
  23772. /**
  23773. * Set the physics body. Used mainly by the physics engine/plugin
  23774. */
  23775. physicsBody: any;
  23776. /**
  23777. * Get the parent of the physics imposter
  23778. * @returns Physics imposter or null
  23779. */
  23780. /**
  23781. * Sets the parent of the physics imposter
  23782. */
  23783. parent: Nullable<PhysicsImpostor>;
  23784. /**
  23785. * Resets the update flags
  23786. */
  23787. resetUpdateFlags(): void;
  23788. /**
  23789. * Gets the object extend size
  23790. * @returns the object extend size
  23791. */
  23792. getObjectExtendSize(): Vector3;
  23793. /**
  23794. * Gets the object center
  23795. * @returns The object center
  23796. */
  23797. getObjectCenter(): Vector3;
  23798. /**
  23799. * Get a specific parametes from the options parameter
  23800. * @param paramName The object parameter name
  23801. * @returns The object parameter
  23802. */
  23803. getParam(paramName: string): any;
  23804. /**
  23805. * Sets a specific parameter in the options given to the physics plugin
  23806. * @param paramName The parameter name
  23807. * @param value The value of the parameter
  23808. */
  23809. setParam(paramName: string, value: number): void;
  23810. /**
  23811. * Specifically change the body's mass option. Won't recreate the physics body object
  23812. * @param mass The mass of the physics imposter
  23813. */
  23814. setMass(mass: number): void;
  23815. /**
  23816. * Gets the linear velocity
  23817. * @returns linear velocity or null
  23818. */
  23819. getLinearVelocity(): Nullable<Vector3>;
  23820. /**
  23821. * Sets the linear velocity
  23822. * @param velocity linear velocity or null
  23823. */
  23824. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23825. /**
  23826. * Gets the angular velocity
  23827. * @returns angular velocity or null
  23828. */
  23829. getAngularVelocity(): Nullable<Vector3>;
  23830. /**
  23831. * Sets the angular velocity
  23832. * @param velocity The velocity or null
  23833. */
  23834. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23835. /**
  23836. * Execute a function with the physics plugin native code
  23837. * Provide a function the will have two variables - the world object and the physics body object
  23838. * @param func The function to execute with the physics plugin native code
  23839. */
  23840. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23841. /**
  23842. * Register a function that will be executed before the physics world is stepping forward
  23843. * @param func The function to execute before the physics world is stepped forward
  23844. */
  23845. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23846. /**
  23847. * Unregister a function that will be executed before the physics world is stepping forward
  23848. * @param func The function to execute before the physics world is stepped forward
  23849. */
  23850. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23851. /**
  23852. * Register a function that will be executed after the physics step
  23853. * @param func The function to execute after physics step
  23854. */
  23855. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23856. /**
  23857. * Unregisters a function that will be executed after the physics step
  23858. * @param func The function to execute after physics step
  23859. */
  23860. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23861. /**
  23862. * register a function that will be executed when this impostor collides against a different body
  23863. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23864. * @param func Callback that is executed on collision
  23865. */
  23866. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23867. /**
  23868. * Unregisters the physics imposter on contact
  23869. * @param collideAgainst The physics object to collide against
  23870. * @param func Callback to execute on collision
  23871. */
  23872. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23873. private _tmpQuat;
  23874. private _tmpQuat2;
  23875. /**
  23876. * Get the parent rotation
  23877. * @returns The parent rotation
  23878. */
  23879. getParentsRotation(): Quaternion;
  23880. /**
  23881. * this function is executed by the physics engine.
  23882. */
  23883. beforeStep: () => void;
  23884. /**
  23885. * this function is executed by the physics engine
  23886. */
  23887. afterStep: () => void;
  23888. /**
  23889. * Legacy collision detection event support
  23890. */
  23891. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23892. /**
  23893. * event and body object due to cannon's event-based architecture.
  23894. */
  23895. onCollide: (e: {
  23896. body: any;
  23897. }) => void;
  23898. /**
  23899. * Apply a force
  23900. * @param force The force to apply
  23901. * @param contactPoint The contact point for the force
  23902. * @returns The physics imposter
  23903. */
  23904. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23905. /**
  23906. * Apply an impulse
  23907. * @param force The impulse force
  23908. * @param contactPoint The contact point for the impulse force
  23909. * @returns The physics imposter
  23910. */
  23911. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23912. /**
  23913. * A help function to create a joint
  23914. * @param otherImpostor A physics imposter used to create a joint
  23915. * @param jointType The type of joint
  23916. * @param jointData The data for the joint
  23917. * @returns The physics imposter
  23918. */
  23919. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23920. /**
  23921. * Add a joint to this impostor with a different impostor
  23922. * @param otherImpostor A physics imposter used to add a joint
  23923. * @param joint The joint to add
  23924. * @returns The physics imposter
  23925. */
  23926. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23927. /**
  23928. * Add an anchor to a cloth impostor
  23929. * @param otherImpostor rigid impostor to anchor to
  23930. * @param width ratio across width from 0 to 1
  23931. * @param height ratio up height from 0 to 1
  23932. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23933. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23934. * @returns impostor the soft imposter
  23935. */
  23936. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23937. /**
  23938. * Add a hook to a rope impostor
  23939. * @param otherImpostor rigid impostor to anchor to
  23940. * @param length ratio across rope from 0 to 1
  23941. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23942. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23943. * @returns impostor the rope imposter
  23944. */
  23945. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23946. /**
  23947. * Will keep this body still, in a sleep mode.
  23948. * @returns the physics imposter
  23949. */
  23950. sleep(): PhysicsImpostor;
  23951. /**
  23952. * Wake the body up.
  23953. * @returns The physics imposter
  23954. */
  23955. wakeUp(): PhysicsImpostor;
  23956. /**
  23957. * Clones the physics imposter
  23958. * @param newObject The physics imposter clones to this physics-enabled object
  23959. * @returns A nullable physics imposter
  23960. */
  23961. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23962. /**
  23963. * Disposes the physics imposter
  23964. */
  23965. dispose(): void;
  23966. /**
  23967. * Sets the delta position
  23968. * @param position The delta position amount
  23969. */
  23970. setDeltaPosition(position: Vector3): void;
  23971. /**
  23972. * Sets the delta rotation
  23973. * @param rotation The delta rotation amount
  23974. */
  23975. setDeltaRotation(rotation: Quaternion): void;
  23976. /**
  23977. * Gets the box size of the physics imposter and stores the result in the input parameter
  23978. * @param result Stores the box size
  23979. * @returns The physics imposter
  23980. */
  23981. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23982. /**
  23983. * Gets the radius of the physics imposter
  23984. * @returns Radius of the physics imposter
  23985. */
  23986. getRadius(): number;
  23987. /**
  23988. * Sync a bone with this impostor
  23989. * @param bone The bone to sync to the impostor.
  23990. * @param boneMesh The mesh that the bone is influencing.
  23991. * @param jointPivot The pivot of the joint / bone in local space.
  23992. * @param distToJoint Optional distance from the impostor to the joint.
  23993. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23994. */
  23995. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23996. /**
  23997. * Sync impostor to a bone
  23998. * @param bone The bone that the impostor will be synced to.
  23999. * @param boneMesh The mesh that the bone is influencing.
  24000. * @param jointPivot The pivot of the joint / bone in local space.
  24001. * @param distToJoint Optional distance from the impostor to the joint.
  24002. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24003. * @param boneAxis Optional vector3 axis the bone is aligned with
  24004. */
  24005. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24006. /**
  24007. * No-Imposter type
  24008. */
  24009. static NoImpostor: number;
  24010. /**
  24011. * Sphere-Imposter type
  24012. */
  24013. static SphereImpostor: number;
  24014. /**
  24015. * Box-Imposter type
  24016. */
  24017. static BoxImpostor: number;
  24018. /**
  24019. * Plane-Imposter type
  24020. */
  24021. static PlaneImpostor: number;
  24022. /**
  24023. * Mesh-imposter type
  24024. */
  24025. static MeshImpostor: number;
  24026. /**
  24027. * Capsule-Impostor type (Ammo.js plugin only)
  24028. */
  24029. static CapsuleImpostor: number;
  24030. /**
  24031. * Cylinder-Imposter type
  24032. */
  24033. static CylinderImpostor: number;
  24034. /**
  24035. * Particle-Imposter type
  24036. */
  24037. static ParticleImpostor: number;
  24038. /**
  24039. * Heightmap-Imposter type
  24040. */
  24041. static HeightmapImpostor: number;
  24042. /**
  24043. * ConvexHull-Impostor type (Ammo.js plugin only)
  24044. */
  24045. static ConvexHullImpostor: number;
  24046. /**
  24047. * Rope-Imposter type
  24048. */
  24049. static RopeImpostor: number;
  24050. /**
  24051. * Cloth-Imposter type
  24052. */
  24053. static ClothImpostor: number;
  24054. /**
  24055. * Softbody-Imposter type
  24056. */
  24057. static SoftbodyImpostor: number;
  24058. }
  24059. }
  24060. declare module "babylonjs/Meshes/mesh" {
  24061. import { Observable } from "babylonjs/Misc/observable";
  24062. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24063. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24064. import { Camera } from "babylonjs/Cameras/camera";
  24065. import { Scene } from "babylonjs/scene";
  24066. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24067. import { Color4 } from "babylonjs/Maths/math.color";
  24068. import { Engine } from "babylonjs/Engines/engine";
  24069. import { Node } from "babylonjs/node";
  24070. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24071. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24072. import { Buffer } from "babylonjs/Meshes/buffer";
  24073. import { Geometry } from "babylonjs/Meshes/geometry";
  24074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24075. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24076. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24077. import { Effect } from "babylonjs/Materials/effect";
  24078. import { Material } from "babylonjs/Materials/material";
  24079. import { Skeleton } from "babylonjs/Bones/skeleton";
  24080. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24081. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24082. import { Path3D } from "babylonjs/Maths/math.path";
  24083. import { Plane } from "babylonjs/Maths/math.plane";
  24084. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24085. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24086. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24087. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24088. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24089. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24090. /**
  24091. * @hidden
  24092. **/
  24093. export class _CreationDataStorage {
  24094. closePath?: boolean;
  24095. closeArray?: boolean;
  24096. idx: number[];
  24097. dashSize: number;
  24098. gapSize: number;
  24099. path3D: Path3D;
  24100. pathArray: Vector3[][];
  24101. arc: number;
  24102. radius: number;
  24103. cap: number;
  24104. tessellation: number;
  24105. }
  24106. /**
  24107. * @hidden
  24108. **/
  24109. class _InstanceDataStorage {
  24110. visibleInstances: any;
  24111. batchCache: _InstancesBatch;
  24112. instancesBufferSize: number;
  24113. instancesBuffer: Nullable<Buffer>;
  24114. instancesData: Float32Array;
  24115. overridenInstanceCount: number;
  24116. isFrozen: boolean;
  24117. previousBatch: Nullable<_InstancesBatch>;
  24118. hardwareInstancedRendering: boolean;
  24119. sideOrientation: number;
  24120. }
  24121. /**
  24122. * @hidden
  24123. **/
  24124. export class _InstancesBatch {
  24125. mustReturn: boolean;
  24126. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24127. renderSelf: boolean[];
  24128. hardwareInstancedRendering: boolean[];
  24129. }
  24130. /**
  24131. * Class used to represent renderable models
  24132. */
  24133. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24134. /**
  24135. * Mesh side orientation : usually the external or front surface
  24136. */
  24137. static readonly FRONTSIDE: number;
  24138. /**
  24139. * Mesh side orientation : usually the internal or back surface
  24140. */
  24141. static readonly BACKSIDE: number;
  24142. /**
  24143. * Mesh side orientation : both internal and external or front and back surfaces
  24144. */
  24145. static readonly DOUBLESIDE: number;
  24146. /**
  24147. * Mesh side orientation : by default, `FRONTSIDE`
  24148. */
  24149. static readonly DEFAULTSIDE: number;
  24150. /**
  24151. * Mesh cap setting : no cap
  24152. */
  24153. static readonly NO_CAP: number;
  24154. /**
  24155. * Mesh cap setting : one cap at the beginning of the mesh
  24156. */
  24157. static readonly CAP_START: number;
  24158. /**
  24159. * Mesh cap setting : one cap at the end of the mesh
  24160. */
  24161. static readonly CAP_END: number;
  24162. /**
  24163. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24164. */
  24165. static readonly CAP_ALL: number;
  24166. /**
  24167. * Mesh pattern setting : no flip or rotate
  24168. */
  24169. static readonly NO_FLIP: number;
  24170. /**
  24171. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24172. */
  24173. static readonly FLIP_TILE: number;
  24174. /**
  24175. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24176. */
  24177. static readonly ROTATE_TILE: number;
  24178. /**
  24179. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24180. */
  24181. static readonly FLIP_ROW: number;
  24182. /**
  24183. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24184. */
  24185. static readonly ROTATE_ROW: number;
  24186. /**
  24187. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24188. */
  24189. static readonly FLIP_N_ROTATE_TILE: number;
  24190. /**
  24191. * Mesh pattern setting : rotate pattern and rotate
  24192. */
  24193. static readonly FLIP_N_ROTATE_ROW: number;
  24194. /**
  24195. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24196. */
  24197. static readonly CENTER: number;
  24198. /**
  24199. * Mesh tile positioning : part tiles on left
  24200. */
  24201. static readonly LEFT: number;
  24202. /**
  24203. * Mesh tile positioning : part tiles on right
  24204. */
  24205. static readonly RIGHT: number;
  24206. /**
  24207. * Mesh tile positioning : part tiles on top
  24208. */
  24209. static readonly TOP: number;
  24210. /**
  24211. * Mesh tile positioning : part tiles on bottom
  24212. */
  24213. static readonly BOTTOM: number;
  24214. /**
  24215. * Gets the default side orientation.
  24216. * @param orientation the orientation to value to attempt to get
  24217. * @returns the default orientation
  24218. * @hidden
  24219. */
  24220. static _GetDefaultSideOrientation(orientation?: number): number;
  24221. private _internalMeshDataInfo;
  24222. /**
  24223. * An event triggered before rendering the mesh
  24224. */
  24225. readonly onBeforeRenderObservable: Observable<Mesh>;
  24226. /**
  24227. * An event triggered before binding the mesh
  24228. */
  24229. readonly onBeforeBindObservable: Observable<Mesh>;
  24230. /**
  24231. * An event triggered after rendering the mesh
  24232. */
  24233. readonly onAfterRenderObservable: Observable<Mesh>;
  24234. /**
  24235. * An event triggered before drawing the mesh
  24236. */
  24237. readonly onBeforeDrawObservable: Observable<Mesh>;
  24238. private _onBeforeDrawObserver;
  24239. /**
  24240. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24241. */
  24242. onBeforeDraw: () => void;
  24243. readonly hasInstances: boolean;
  24244. /**
  24245. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24246. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24247. */
  24248. delayLoadState: number;
  24249. /**
  24250. * Gets the list of instances created from this mesh
  24251. * it is not supposed to be modified manually.
  24252. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24253. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24254. */
  24255. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24256. /**
  24257. * Gets the file containing delay loading data for this mesh
  24258. */
  24259. delayLoadingFile: string;
  24260. /** @hidden */
  24261. _binaryInfo: any;
  24262. /**
  24263. * User defined function used to change how LOD level selection is done
  24264. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24265. */
  24266. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24267. /**
  24268. * Gets or sets the morph target manager
  24269. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24270. */
  24271. morphTargetManager: Nullable<MorphTargetManager>;
  24272. /** @hidden */
  24273. _creationDataStorage: Nullable<_CreationDataStorage>;
  24274. /** @hidden */
  24275. _geometry: Nullable<Geometry>;
  24276. /** @hidden */
  24277. _delayInfo: Array<string>;
  24278. /** @hidden */
  24279. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24280. /** @hidden */
  24281. _instanceDataStorage: _InstanceDataStorage;
  24282. private _effectiveMaterial;
  24283. /** @hidden */
  24284. _shouldGenerateFlatShading: boolean;
  24285. /** @hidden */
  24286. _originalBuilderSideOrientation: number;
  24287. /**
  24288. * Use this property to change the original side orientation defined at construction time
  24289. */
  24290. overrideMaterialSideOrientation: Nullable<number>;
  24291. /**
  24292. * Gets the source mesh (the one used to clone this one from)
  24293. */
  24294. readonly source: Nullable<Mesh>;
  24295. /**
  24296. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24297. */
  24298. isUnIndexed: boolean;
  24299. /**
  24300. * @constructor
  24301. * @param name The value used by scene.getMeshByName() to do a lookup.
  24302. * @param scene The scene to add this mesh to.
  24303. * @param parent The parent of this mesh, if it has one
  24304. * @param source An optional Mesh from which geometry is shared, cloned.
  24305. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24306. * When false, achieved by calling a clone(), also passing False.
  24307. * This will make creation of children, recursive.
  24308. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24309. */
  24310. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24311. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24312. /**
  24313. * Gets the class name
  24314. * @returns the string "Mesh".
  24315. */
  24316. getClassName(): string;
  24317. /** @hidden */
  24318. readonly _isMesh: boolean;
  24319. /**
  24320. * Returns a description of this mesh
  24321. * @param fullDetails define if full details about this mesh must be used
  24322. * @returns a descriptive string representing this mesh
  24323. */
  24324. toString(fullDetails?: boolean): string;
  24325. /** @hidden */
  24326. _unBindEffect(): void;
  24327. /**
  24328. * Gets a boolean indicating if this mesh has LOD
  24329. */
  24330. readonly hasLODLevels: boolean;
  24331. /**
  24332. * Gets the list of MeshLODLevel associated with the current mesh
  24333. * @returns an array of MeshLODLevel
  24334. */
  24335. getLODLevels(): MeshLODLevel[];
  24336. private _sortLODLevels;
  24337. /**
  24338. * Add a mesh as LOD level triggered at the given distance.
  24339. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24340. * @param distance The distance from the center of the object to show this level
  24341. * @param mesh The mesh to be added as LOD level (can be null)
  24342. * @return This mesh (for chaining)
  24343. */
  24344. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24345. /**
  24346. * Returns the LOD level mesh at the passed distance or null if not found.
  24347. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24348. * @param distance The distance from the center of the object to show this level
  24349. * @returns a Mesh or `null`
  24350. */
  24351. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24352. /**
  24353. * Remove a mesh from the LOD array
  24354. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24355. * @param mesh defines the mesh to be removed
  24356. * @return This mesh (for chaining)
  24357. */
  24358. removeLODLevel(mesh: Mesh): Mesh;
  24359. /**
  24360. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24361. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24362. * @param camera defines the camera to use to compute distance
  24363. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24364. * @return This mesh (for chaining)
  24365. */
  24366. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24367. /**
  24368. * Gets the mesh internal Geometry object
  24369. */
  24370. readonly geometry: Nullable<Geometry>;
  24371. /**
  24372. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24373. * @returns the total number of vertices
  24374. */
  24375. getTotalVertices(): number;
  24376. /**
  24377. * Returns the content of an associated vertex buffer
  24378. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24379. * - VertexBuffer.PositionKind
  24380. * - VertexBuffer.UVKind
  24381. * - VertexBuffer.UV2Kind
  24382. * - VertexBuffer.UV3Kind
  24383. * - VertexBuffer.UV4Kind
  24384. * - VertexBuffer.UV5Kind
  24385. * - VertexBuffer.UV6Kind
  24386. * - VertexBuffer.ColorKind
  24387. * - VertexBuffer.MatricesIndicesKind
  24388. * - VertexBuffer.MatricesIndicesExtraKind
  24389. * - VertexBuffer.MatricesWeightsKind
  24390. * - VertexBuffer.MatricesWeightsExtraKind
  24391. * @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
  24392. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24393. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24394. */
  24395. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24396. /**
  24397. * Returns the mesh VertexBuffer object from the requested `kind`
  24398. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24399. * - VertexBuffer.PositionKind
  24400. * - VertexBuffer.NormalKind
  24401. * - VertexBuffer.UVKind
  24402. * - VertexBuffer.UV2Kind
  24403. * - VertexBuffer.UV3Kind
  24404. * - VertexBuffer.UV4Kind
  24405. * - VertexBuffer.UV5Kind
  24406. * - VertexBuffer.UV6Kind
  24407. * - VertexBuffer.ColorKind
  24408. * - VertexBuffer.MatricesIndicesKind
  24409. * - VertexBuffer.MatricesIndicesExtraKind
  24410. * - VertexBuffer.MatricesWeightsKind
  24411. * - VertexBuffer.MatricesWeightsExtraKind
  24412. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24413. */
  24414. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24415. /**
  24416. * Tests if a specific vertex buffer is associated with this mesh
  24417. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24418. * - VertexBuffer.PositionKind
  24419. * - VertexBuffer.NormalKind
  24420. * - VertexBuffer.UVKind
  24421. * - VertexBuffer.UV2Kind
  24422. * - VertexBuffer.UV3Kind
  24423. * - VertexBuffer.UV4Kind
  24424. * - VertexBuffer.UV5Kind
  24425. * - VertexBuffer.UV6Kind
  24426. * - VertexBuffer.ColorKind
  24427. * - VertexBuffer.MatricesIndicesKind
  24428. * - VertexBuffer.MatricesIndicesExtraKind
  24429. * - VertexBuffer.MatricesWeightsKind
  24430. * - VertexBuffer.MatricesWeightsExtraKind
  24431. * @returns a boolean
  24432. */
  24433. isVerticesDataPresent(kind: string): boolean;
  24434. /**
  24435. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24436. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24437. * - VertexBuffer.PositionKind
  24438. * - VertexBuffer.UVKind
  24439. * - VertexBuffer.UV2Kind
  24440. * - VertexBuffer.UV3Kind
  24441. * - VertexBuffer.UV4Kind
  24442. * - VertexBuffer.UV5Kind
  24443. * - VertexBuffer.UV6Kind
  24444. * - VertexBuffer.ColorKind
  24445. * - VertexBuffer.MatricesIndicesKind
  24446. * - VertexBuffer.MatricesIndicesExtraKind
  24447. * - VertexBuffer.MatricesWeightsKind
  24448. * - VertexBuffer.MatricesWeightsExtraKind
  24449. * @returns a boolean
  24450. */
  24451. isVertexBufferUpdatable(kind: string): boolean;
  24452. /**
  24453. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24454. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24455. * - VertexBuffer.PositionKind
  24456. * - VertexBuffer.NormalKind
  24457. * - VertexBuffer.UVKind
  24458. * - VertexBuffer.UV2Kind
  24459. * - VertexBuffer.UV3Kind
  24460. * - VertexBuffer.UV4Kind
  24461. * - VertexBuffer.UV5Kind
  24462. * - VertexBuffer.UV6Kind
  24463. * - VertexBuffer.ColorKind
  24464. * - VertexBuffer.MatricesIndicesKind
  24465. * - VertexBuffer.MatricesIndicesExtraKind
  24466. * - VertexBuffer.MatricesWeightsKind
  24467. * - VertexBuffer.MatricesWeightsExtraKind
  24468. * @returns an array of strings
  24469. */
  24470. getVerticesDataKinds(): string[];
  24471. /**
  24472. * Returns a positive integer : the total number of indices in this mesh geometry.
  24473. * @returns the numner of indices or zero if the mesh has no geometry.
  24474. */
  24475. getTotalIndices(): number;
  24476. /**
  24477. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24478. * @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.
  24479. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24480. * @returns the indices array or an empty array if the mesh has no geometry
  24481. */
  24482. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24483. readonly isBlocked: boolean;
  24484. /**
  24485. * Determine if the current mesh is ready to be rendered
  24486. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24487. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24488. * @returns true if all associated assets are ready (material, textures, shaders)
  24489. */
  24490. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24491. /**
  24492. * 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.
  24493. */
  24494. readonly areNormalsFrozen: boolean;
  24495. /**
  24496. * 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.
  24497. * @returns the current mesh
  24498. */
  24499. freezeNormals(): Mesh;
  24500. /**
  24501. * 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
  24502. * @returns the current mesh
  24503. */
  24504. unfreezeNormals(): Mesh;
  24505. /**
  24506. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24507. */
  24508. overridenInstanceCount: number;
  24509. /** @hidden */
  24510. _preActivate(): Mesh;
  24511. /** @hidden */
  24512. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24513. /** @hidden */
  24514. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24515. /**
  24516. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24517. * This means the mesh underlying bounding box and sphere are recomputed.
  24518. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24519. * @returns the current mesh
  24520. */
  24521. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24522. /** @hidden */
  24523. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24524. /**
  24525. * This function will subdivide the mesh into multiple submeshes
  24526. * @param count defines the expected number of submeshes
  24527. */
  24528. subdivide(count: number): void;
  24529. /**
  24530. * Copy a FloatArray into a specific associated vertex buffer
  24531. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24532. * - VertexBuffer.PositionKind
  24533. * - VertexBuffer.UVKind
  24534. * - VertexBuffer.UV2Kind
  24535. * - VertexBuffer.UV3Kind
  24536. * - VertexBuffer.UV4Kind
  24537. * - VertexBuffer.UV5Kind
  24538. * - VertexBuffer.UV6Kind
  24539. * - VertexBuffer.ColorKind
  24540. * - VertexBuffer.MatricesIndicesKind
  24541. * - VertexBuffer.MatricesIndicesExtraKind
  24542. * - VertexBuffer.MatricesWeightsKind
  24543. * - VertexBuffer.MatricesWeightsExtraKind
  24544. * @param data defines the data source
  24545. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24546. * @param stride defines the data stride size (can be null)
  24547. * @returns the current mesh
  24548. */
  24549. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24550. /**
  24551. * Flags an associated vertex buffer as updatable
  24552. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24553. * - VertexBuffer.PositionKind
  24554. * - VertexBuffer.UVKind
  24555. * - VertexBuffer.UV2Kind
  24556. * - VertexBuffer.UV3Kind
  24557. * - VertexBuffer.UV4Kind
  24558. * - VertexBuffer.UV5Kind
  24559. * - VertexBuffer.UV6Kind
  24560. * - VertexBuffer.ColorKind
  24561. * - VertexBuffer.MatricesIndicesKind
  24562. * - VertexBuffer.MatricesIndicesExtraKind
  24563. * - VertexBuffer.MatricesWeightsKind
  24564. * - VertexBuffer.MatricesWeightsExtraKind
  24565. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24566. */
  24567. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24568. /**
  24569. * Sets the mesh global Vertex Buffer
  24570. * @param buffer defines the buffer to use
  24571. * @returns the current mesh
  24572. */
  24573. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24574. /**
  24575. * Update a specific associated vertex buffer
  24576. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24577. * - VertexBuffer.PositionKind
  24578. * - VertexBuffer.UVKind
  24579. * - VertexBuffer.UV2Kind
  24580. * - VertexBuffer.UV3Kind
  24581. * - VertexBuffer.UV4Kind
  24582. * - VertexBuffer.UV5Kind
  24583. * - VertexBuffer.UV6Kind
  24584. * - VertexBuffer.ColorKind
  24585. * - VertexBuffer.MatricesIndicesKind
  24586. * - VertexBuffer.MatricesIndicesExtraKind
  24587. * - VertexBuffer.MatricesWeightsKind
  24588. * - VertexBuffer.MatricesWeightsExtraKind
  24589. * @param data defines the data source
  24590. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24591. * @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)
  24592. * @returns the current mesh
  24593. */
  24594. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24595. /**
  24596. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24597. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24598. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24599. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24600. * @returns the current mesh
  24601. */
  24602. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24603. /**
  24604. * Creates a un-shared specific occurence of the geometry for the mesh.
  24605. * @returns the current mesh
  24606. */
  24607. makeGeometryUnique(): Mesh;
  24608. /**
  24609. * Set the index buffer of this mesh
  24610. * @param indices defines the source data
  24611. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24612. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24613. * @returns the current mesh
  24614. */
  24615. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24616. /**
  24617. * Update the current index buffer
  24618. * @param indices defines the source data
  24619. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24620. * @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)
  24621. * @returns the current mesh
  24622. */
  24623. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24624. /**
  24625. * Invert the geometry to move from a right handed system to a left handed one.
  24626. * @returns the current mesh
  24627. */
  24628. toLeftHanded(): Mesh;
  24629. /** @hidden */
  24630. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24631. /** @hidden */
  24632. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24633. /**
  24634. * Registers for this mesh a javascript function called just before the rendering process
  24635. * @param func defines the function to call before rendering this mesh
  24636. * @returns the current mesh
  24637. */
  24638. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24639. /**
  24640. * Disposes a previously registered javascript function called before the rendering
  24641. * @param func defines the function to remove
  24642. * @returns the current mesh
  24643. */
  24644. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24645. /**
  24646. * Registers for this mesh a javascript function called just after the rendering is complete
  24647. * @param func defines the function to call after rendering this mesh
  24648. * @returns the current mesh
  24649. */
  24650. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24651. /**
  24652. * Disposes a previously registered javascript function called after the rendering.
  24653. * @param func defines the function to remove
  24654. * @returns the current mesh
  24655. */
  24656. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24657. /** @hidden */
  24658. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24659. /** @hidden */
  24660. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24661. /** @hidden */
  24662. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24663. /** @hidden */
  24664. _rebuild(): void;
  24665. /** @hidden */
  24666. _freeze(): void;
  24667. /** @hidden */
  24668. _unFreeze(): void;
  24669. /**
  24670. * 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
  24671. * @param subMesh defines the subMesh to render
  24672. * @param enableAlphaMode defines if alpha mode can be changed
  24673. * @returns the current mesh
  24674. */
  24675. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24676. private _onBeforeDraw;
  24677. /**
  24678. * Renormalize the mesh and patch it up if there are no weights
  24679. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24680. * However in the case of zero weights then we set just a single influence to 1.
  24681. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24682. */
  24683. cleanMatrixWeights(): void;
  24684. private normalizeSkinFourWeights;
  24685. private normalizeSkinWeightsAndExtra;
  24686. /**
  24687. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24688. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24689. * the user know there was an issue with importing the mesh
  24690. * @returns a validation object with skinned, valid and report string
  24691. */
  24692. validateSkinning(): {
  24693. skinned: boolean;
  24694. valid: boolean;
  24695. report: string;
  24696. };
  24697. /** @hidden */
  24698. _checkDelayState(): Mesh;
  24699. private _queueLoad;
  24700. /**
  24701. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24702. * A mesh is in the frustum if its bounding box intersects the frustum
  24703. * @param frustumPlanes defines the frustum to test
  24704. * @returns true if the mesh is in the frustum planes
  24705. */
  24706. isInFrustum(frustumPlanes: Plane[]): boolean;
  24707. /**
  24708. * Sets the mesh material by the material or multiMaterial `id` property
  24709. * @param id is a string identifying the material or the multiMaterial
  24710. * @returns the current mesh
  24711. */
  24712. setMaterialByID(id: string): Mesh;
  24713. /**
  24714. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24715. * @returns an array of IAnimatable
  24716. */
  24717. getAnimatables(): IAnimatable[];
  24718. /**
  24719. * Modifies the mesh geometry according to the passed transformation matrix.
  24720. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24721. * The mesh normals are modified using the same transformation.
  24722. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24723. * @param transform defines the transform matrix to use
  24724. * @see http://doc.babylonjs.com/resources/baking_transformations
  24725. * @returns the current mesh
  24726. */
  24727. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24728. /**
  24729. * Modifies the mesh geometry according to its own current World Matrix.
  24730. * The mesh World Matrix is then reset.
  24731. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24732. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24733. * @see http://doc.babylonjs.com/resources/baking_transformations
  24734. * @returns the current mesh
  24735. */
  24736. bakeCurrentTransformIntoVertices(): Mesh;
  24737. /** @hidden */
  24738. readonly _positions: Nullable<Vector3[]>;
  24739. /** @hidden */
  24740. _resetPointsArrayCache(): Mesh;
  24741. /** @hidden */
  24742. _generatePointsArray(): boolean;
  24743. /**
  24744. * Returns a new Mesh object generated from the current mesh properties.
  24745. * This method must not get confused with createInstance()
  24746. * @param name is a string, the name given to the new mesh
  24747. * @param newParent can be any Node object (default `null`)
  24748. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24749. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24750. * @returns a new mesh
  24751. */
  24752. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24753. /**
  24754. * Releases resources associated with this mesh.
  24755. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24756. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24757. */
  24758. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24759. /**
  24760. * Modifies the mesh geometry according to a displacement map.
  24761. * 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.
  24762. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24763. * @param url is a string, the URL from the image file is to be downloaded.
  24764. * @param minHeight is the lower limit of the displacement.
  24765. * @param maxHeight is the upper limit of the displacement.
  24766. * @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.
  24767. * @param uvOffset is an optional vector2 used to offset UV.
  24768. * @param uvScale is an optional vector2 used to scale UV.
  24769. * @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.
  24770. * @returns the Mesh.
  24771. */
  24772. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24773. /**
  24774. * Modifies the mesh geometry according to a displacementMap buffer.
  24775. * 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.
  24776. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24777. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24778. * @param heightMapWidth is the width of the buffer image.
  24779. * @param heightMapHeight is the height of the buffer image.
  24780. * @param minHeight is the lower limit of the displacement.
  24781. * @param maxHeight is the upper limit of the displacement.
  24782. * @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.
  24783. * @param uvOffset is an optional vector2 used to offset UV.
  24784. * @param uvScale is an optional vector2 used to scale UV.
  24785. * @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.
  24786. * @returns the Mesh.
  24787. */
  24788. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24789. /**
  24790. * Modify the mesh to get a flat shading rendering.
  24791. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24792. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24793. * @returns current mesh
  24794. */
  24795. convertToFlatShadedMesh(): Mesh;
  24796. /**
  24797. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24798. * In other words, more vertices, no more indices and a single bigger VBO.
  24799. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24800. * @returns current mesh
  24801. */
  24802. convertToUnIndexedMesh(): Mesh;
  24803. /**
  24804. * Inverses facet orientations.
  24805. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24806. * @param flipNormals will also inverts the normals
  24807. * @returns current mesh
  24808. */
  24809. flipFaces(flipNormals?: boolean): Mesh;
  24810. /**
  24811. * Increase the number of facets and hence vertices in a mesh
  24812. * Vertex normals are interpolated from existing vertex normals
  24813. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24814. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24815. */
  24816. increaseVertices(numberPerEdge: number): void;
  24817. /**
  24818. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24819. * This will undo any application of covertToFlatShadedMesh
  24820. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24821. */
  24822. forceSharedVertices(): void;
  24823. /** @hidden */
  24824. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24825. /** @hidden */
  24826. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24827. /**
  24828. * Creates a new InstancedMesh object from the mesh model.
  24829. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24830. * @param name defines the name of the new instance
  24831. * @returns a new InstancedMesh
  24832. */
  24833. createInstance(name: string): InstancedMesh;
  24834. /**
  24835. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24836. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24837. * @returns the current mesh
  24838. */
  24839. synchronizeInstances(): Mesh;
  24840. /**
  24841. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24842. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24843. * This should be used together with the simplification to avoid disappearing triangles.
  24844. * @param successCallback an optional success callback to be called after the optimization finished.
  24845. * @returns the current mesh
  24846. */
  24847. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24848. /**
  24849. * Serialize current mesh
  24850. * @param serializationObject defines the object which will receive the serialization data
  24851. */
  24852. serialize(serializationObject: any): void;
  24853. /** @hidden */
  24854. _syncGeometryWithMorphTargetManager(): void;
  24855. /** @hidden */
  24856. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24857. /**
  24858. * Returns a new Mesh object parsed from the source provided.
  24859. * @param parsedMesh is the source
  24860. * @param scene defines the hosting scene
  24861. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24862. * @returns a new Mesh
  24863. */
  24864. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24865. /**
  24866. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24867. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24868. * @param name defines the name of the mesh to create
  24869. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24870. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24871. * @param closePath creates a seam between the first and the last points of each path of the path array
  24872. * @param offset is taken in account only if the `pathArray` is containing a single path
  24873. * @param scene defines the hosting scene
  24874. * @param updatable defines if the mesh must be flagged as updatable
  24875. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24876. * @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)
  24877. * @returns a new Mesh
  24878. */
  24879. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24880. /**
  24881. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24882. * @param name defines the name of the mesh to create
  24883. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24884. * @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
  24885. * @param scene defines the hosting scene
  24886. * @param updatable defines if the mesh must be flagged as updatable
  24887. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24888. * @returns a new Mesh
  24889. */
  24890. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24891. /**
  24892. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24893. * @param name defines the name of the mesh to create
  24894. * @param size sets the size (float) of each box side (default 1)
  24895. * @param scene defines the hosting scene
  24896. * @param updatable defines if the mesh must be flagged as updatable
  24897. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24898. * @returns a new Mesh
  24899. */
  24900. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24901. /**
  24902. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24903. * @param name defines the name of the mesh to create
  24904. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24905. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24906. * @param scene defines the hosting scene
  24907. * @param updatable defines if the mesh must be flagged as updatable
  24908. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24909. * @returns a new Mesh
  24910. */
  24911. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24912. /**
  24913. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24914. * @param name defines the name of the mesh to create
  24915. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24916. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24917. * @param scene defines the hosting scene
  24918. * @returns a new Mesh
  24919. */
  24920. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24921. /**
  24922. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24923. * @param name defines the name of the mesh to create
  24924. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24925. * @param diameterTop set the top cap diameter (floats, default 1)
  24926. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24927. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24928. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24929. * @param scene defines the hosting scene
  24930. * @param updatable defines if the mesh must be flagged as updatable
  24931. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24932. * @returns a new Mesh
  24933. */
  24934. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24935. /**
  24936. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24937. * @param name defines the name of the mesh to create
  24938. * @param diameter sets the diameter size (float) of the torus (default 1)
  24939. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24940. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24941. * @param scene defines the hosting scene
  24942. * @param updatable defines if the mesh must be flagged as updatable
  24943. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24944. * @returns a new Mesh
  24945. */
  24946. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24947. /**
  24948. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24949. * @param name defines the name of the mesh to create
  24950. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24951. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24952. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24953. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24954. * @param p the number of windings on X axis (positive integers, default 2)
  24955. * @param q the number of windings on Y axis (positive integers, default 3)
  24956. * @param scene defines the hosting scene
  24957. * @param updatable defines if the mesh must be flagged as updatable
  24958. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24959. * @returns a new Mesh
  24960. */
  24961. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24962. /**
  24963. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24964. * @param name defines the name of the mesh to create
  24965. * @param points is an array successive Vector3
  24966. * @param scene defines the hosting scene
  24967. * @param updatable defines if the mesh must be flagged as updatable
  24968. * @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).
  24969. * @returns a new Mesh
  24970. */
  24971. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24972. /**
  24973. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24974. * @param name defines the name of the mesh to create
  24975. * @param points is an array successive Vector3
  24976. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24977. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24978. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24979. * @param scene defines the hosting scene
  24980. * @param updatable defines if the mesh must be flagged as updatable
  24981. * @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)
  24982. * @returns a new Mesh
  24983. */
  24984. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24985. /**
  24986. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24987. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24988. * 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.
  24989. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24990. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24991. * Remember you can only change the shape positions, not their number when updating a polygon.
  24992. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24993. * @param name defines the name of the mesh to create
  24994. * @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
  24995. * @param scene defines the hosting scene
  24996. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24997. * @param updatable defines if the mesh must be flagged as updatable
  24998. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24999. * @param earcutInjection can be used to inject your own earcut reference
  25000. * @returns a new Mesh
  25001. */
  25002. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25003. /**
  25004. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25005. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25006. * @param name defines the name of the mesh to create
  25007. * @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
  25008. * @param depth defines the height of extrusion
  25009. * @param scene defines the hosting scene
  25010. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25011. * @param updatable defines if the mesh must be flagged as updatable
  25012. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25013. * @param earcutInjection can be used to inject your own earcut reference
  25014. * @returns a new Mesh
  25015. */
  25016. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25017. /**
  25018. * Creates an extruded shape mesh.
  25019. * 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
  25020. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25021. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25022. * @param name defines the name of the mesh to create
  25023. * @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
  25024. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25025. * @param scale is the value to scale the shape
  25026. * @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
  25027. * @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
  25028. * @param scene defines the hosting scene
  25029. * @param updatable defines if the mesh must be flagged as updatable
  25030. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25031. * @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)
  25032. * @returns a new Mesh
  25033. */
  25034. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25035. /**
  25036. * Creates an custom extruded shape mesh.
  25037. * The custom extrusion is a parametric shape.
  25038. * It has no predefined shape. Its final shape will depend on the input parameters.
  25039. * Please consider using the same method from the MeshBuilder class instead
  25040. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25041. * @param name defines the name of the mesh to create
  25042. * @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
  25043. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25044. * @param scaleFunction is a custom Javascript function called on each path point
  25045. * @param rotationFunction is a custom Javascript function called on each path point
  25046. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25047. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25048. * @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
  25049. * @param scene defines the hosting scene
  25050. * @param updatable defines if the mesh must be flagged as updatable
  25051. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25052. * @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)
  25053. * @returns a new Mesh
  25054. */
  25055. 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;
  25056. /**
  25057. * Creates lathe mesh.
  25058. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25059. * Please consider using the same method from the MeshBuilder class instead
  25060. * @param name defines the name of the mesh to create
  25061. * @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
  25062. * @param radius is the radius value of the lathe
  25063. * @param tessellation is the side number of the lathe.
  25064. * @param scene defines the hosting scene
  25065. * @param updatable defines if the mesh must be flagged as updatable
  25066. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25067. * @returns a new Mesh
  25068. */
  25069. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25070. /**
  25071. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25072. * @param name defines the name of the mesh to create
  25073. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25074. * @param scene defines the hosting scene
  25075. * @param updatable defines if the mesh must be flagged as updatable
  25076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25077. * @returns a new Mesh
  25078. */
  25079. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25080. /**
  25081. * Creates a ground mesh.
  25082. * Please consider using the same method from the MeshBuilder class instead
  25083. * @param name defines the name of the mesh to create
  25084. * @param width set the width of the ground
  25085. * @param height set the height of the ground
  25086. * @param subdivisions sets the number of subdivisions per side
  25087. * @param scene defines the hosting scene
  25088. * @param updatable defines if the mesh must be flagged as updatable
  25089. * @returns a new Mesh
  25090. */
  25091. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25092. /**
  25093. * Creates a tiled ground mesh.
  25094. * Please consider using the same method from the MeshBuilder class instead
  25095. * @param name defines the name of the mesh to create
  25096. * @param xmin set the ground minimum X coordinate
  25097. * @param zmin set the ground minimum Y coordinate
  25098. * @param xmax set the ground maximum X coordinate
  25099. * @param zmax set the ground maximum Z coordinate
  25100. * @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
  25101. * @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
  25102. * @param scene defines the hosting scene
  25103. * @param updatable defines if the mesh must be flagged as updatable
  25104. * @returns a new Mesh
  25105. */
  25106. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25107. w: number;
  25108. h: number;
  25109. }, precision: {
  25110. w: number;
  25111. h: number;
  25112. }, scene: Scene, updatable?: boolean): Mesh;
  25113. /**
  25114. * Creates a ground mesh from a height map.
  25115. * Please consider using the same method from the MeshBuilder class instead
  25116. * @see http://doc.babylonjs.com/babylon101/height_map
  25117. * @param name defines the name of the mesh to create
  25118. * @param url sets the URL of the height map image resource
  25119. * @param width set the ground width size
  25120. * @param height set the ground height size
  25121. * @param subdivisions sets the number of subdivision per side
  25122. * @param minHeight is the minimum altitude on the ground
  25123. * @param maxHeight is the maximum altitude on the ground
  25124. * @param scene defines the hosting scene
  25125. * @param updatable defines if the mesh must be flagged as updatable
  25126. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25127. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25128. * @returns a new Mesh
  25129. */
  25130. 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;
  25131. /**
  25132. * Creates a tube mesh.
  25133. * The tube is a parametric shape.
  25134. * It has no predefined shape. Its final shape will depend on the input parameters.
  25135. * Please consider using the same method from the MeshBuilder class instead
  25136. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25137. * @param name defines the name of the mesh to create
  25138. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25139. * @param radius sets the tube radius size
  25140. * @param tessellation is the number of sides on the tubular surface
  25141. * @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
  25142. * @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
  25143. * @param scene defines the hosting scene
  25144. * @param updatable defines if the mesh must be flagged as updatable
  25145. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25146. * @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)
  25147. * @returns a new Mesh
  25148. */
  25149. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25150. (i: number, distance: number): number;
  25151. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25152. /**
  25153. * Creates a polyhedron mesh.
  25154. * Please consider using the same method from the MeshBuilder class instead.
  25155. * * 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
  25156. * * The parameter `size` (positive float, default 1) sets the polygon size
  25157. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25158. * * 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`
  25159. * * 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
  25160. * * 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)`)
  25161. * * 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
  25162. * * 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
  25163. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25164. * * If you create a double-sided mesh, you can choose what parts of 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
  25165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25166. * @param name defines the name of the mesh to create
  25167. * @param options defines the options used to create the mesh
  25168. * @param scene defines the hosting scene
  25169. * @returns a new Mesh
  25170. */
  25171. static CreatePolyhedron(name: string, options: {
  25172. type?: number;
  25173. size?: number;
  25174. sizeX?: number;
  25175. sizeY?: number;
  25176. sizeZ?: number;
  25177. custom?: any;
  25178. faceUV?: Vector4[];
  25179. faceColors?: Color4[];
  25180. updatable?: boolean;
  25181. sideOrientation?: number;
  25182. }, scene: Scene): Mesh;
  25183. /**
  25184. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25185. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25186. * * 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`)
  25187. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25188. * * 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
  25189. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25190. * * If you create a double-sided mesh, you can choose what parts of 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
  25191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25192. * @param name defines the name of the mesh
  25193. * @param options defines the options used to create the mesh
  25194. * @param scene defines the hosting scene
  25195. * @returns a new Mesh
  25196. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25197. */
  25198. static CreateIcoSphere(name: string, options: {
  25199. radius?: number;
  25200. flat?: boolean;
  25201. subdivisions?: number;
  25202. sideOrientation?: number;
  25203. updatable?: boolean;
  25204. }, scene: Scene): Mesh;
  25205. /**
  25206. * Creates a decal mesh.
  25207. * Please consider using the same method from the MeshBuilder class instead.
  25208. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25209. * @param name defines the name of the mesh
  25210. * @param sourceMesh defines the mesh receiving the decal
  25211. * @param position sets the position of the decal in world coordinates
  25212. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25213. * @param size sets the decal scaling
  25214. * @param angle sets the angle to rotate the decal
  25215. * @returns a new Mesh
  25216. */
  25217. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25218. /**
  25219. * Prepare internal position array for software CPU skinning
  25220. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25221. */
  25222. setPositionsForCPUSkinning(): Float32Array;
  25223. /**
  25224. * Prepare internal normal array for software CPU skinning
  25225. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25226. */
  25227. setNormalsForCPUSkinning(): Float32Array;
  25228. /**
  25229. * Updates the vertex buffer by applying transformation from the bones
  25230. * @param skeleton defines the skeleton to apply to current mesh
  25231. * @returns the current mesh
  25232. */
  25233. applySkeleton(skeleton: Skeleton): Mesh;
  25234. /**
  25235. * 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
  25236. * @param meshes defines the list of meshes to scan
  25237. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25238. */
  25239. static MinMax(meshes: AbstractMesh[]): {
  25240. min: Vector3;
  25241. max: Vector3;
  25242. };
  25243. /**
  25244. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25245. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25246. * @returns a vector3
  25247. */
  25248. static Center(meshesOrMinMaxVector: {
  25249. min: Vector3;
  25250. max: Vector3;
  25251. } | AbstractMesh[]): Vector3;
  25252. /**
  25253. * Merge the array of meshes into a single mesh for performance reasons.
  25254. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25255. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25256. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25257. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25258. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25259. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25260. * @returns a new mesh
  25261. */
  25262. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25263. /** @hidden */
  25264. addInstance(instance: InstancedMesh): void;
  25265. /** @hidden */
  25266. removeInstance(instance: InstancedMesh): void;
  25267. }
  25268. }
  25269. declare module "babylonjs/Cameras/camera" {
  25270. import { SmartArray } from "babylonjs/Misc/smartArray";
  25271. import { Observable } from "babylonjs/Misc/observable";
  25272. import { Nullable } from "babylonjs/types";
  25273. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25274. import { Scene } from "babylonjs/scene";
  25275. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25276. import { Node } from "babylonjs/node";
  25277. import { Mesh } from "babylonjs/Meshes/mesh";
  25278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25279. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25280. import { Viewport } from "babylonjs/Maths/math.viewport";
  25281. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25282. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25283. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25284. import { Ray } from "babylonjs/Culling/ray";
  25285. /**
  25286. * This is the base class of all the camera used in the application.
  25287. * @see http://doc.babylonjs.com/features/cameras
  25288. */
  25289. export class Camera extends Node {
  25290. /** @hidden */
  25291. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25292. /**
  25293. * This is the default projection mode used by the cameras.
  25294. * It helps recreating a feeling of perspective and better appreciate depth.
  25295. * This is the best way to simulate real life cameras.
  25296. */
  25297. static readonly PERSPECTIVE_CAMERA: number;
  25298. /**
  25299. * This helps creating camera with an orthographic mode.
  25300. * 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.
  25301. */
  25302. static readonly ORTHOGRAPHIC_CAMERA: number;
  25303. /**
  25304. * This is the default FOV mode for perspective cameras.
  25305. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25306. */
  25307. static readonly FOVMODE_VERTICAL_FIXED: number;
  25308. /**
  25309. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25310. */
  25311. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25312. /**
  25313. * This specifies ther is no need for a camera rig.
  25314. * Basically only one eye is rendered corresponding to the camera.
  25315. */
  25316. static readonly RIG_MODE_NONE: number;
  25317. /**
  25318. * Simulates a camera Rig with one blue eye and one red eye.
  25319. * This can be use with 3d blue and red glasses.
  25320. */
  25321. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25322. /**
  25323. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25324. */
  25325. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25326. /**
  25327. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25328. */
  25329. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25330. /**
  25331. * Defines that both eyes of the camera will be rendered over under each other.
  25332. */
  25333. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25334. /**
  25335. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25336. */
  25337. static readonly RIG_MODE_VR: number;
  25338. /**
  25339. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25340. */
  25341. static readonly RIG_MODE_WEBVR: number;
  25342. /**
  25343. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25344. */
  25345. static readonly RIG_MODE_CUSTOM: number;
  25346. /**
  25347. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25348. */
  25349. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25350. /**
  25351. * Define the input manager associated with the camera.
  25352. */
  25353. inputs: CameraInputsManager<Camera>;
  25354. /** @hidden */
  25355. _position: Vector3;
  25356. /**
  25357. * Define the current local position of the camera in the scene
  25358. */
  25359. position: Vector3;
  25360. /**
  25361. * The vector the camera should consider as up.
  25362. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25363. */
  25364. upVector: Vector3;
  25365. /**
  25366. * Define the current limit on the left side for an orthographic camera
  25367. * In scene unit
  25368. */
  25369. orthoLeft: Nullable<number>;
  25370. /**
  25371. * Define the current limit on the right side for an orthographic camera
  25372. * In scene unit
  25373. */
  25374. orthoRight: Nullable<number>;
  25375. /**
  25376. * Define the current limit on the bottom side for an orthographic camera
  25377. * In scene unit
  25378. */
  25379. orthoBottom: Nullable<number>;
  25380. /**
  25381. * Define the current limit on the top side for an orthographic camera
  25382. * In scene unit
  25383. */
  25384. orthoTop: Nullable<number>;
  25385. /**
  25386. * Field Of View is set in Radians. (default is 0.8)
  25387. */
  25388. fov: number;
  25389. /**
  25390. * Define the minimum distance the camera can see from.
  25391. * This is important to note that the depth buffer are not infinite and the closer it starts
  25392. * the more your scene might encounter depth fighting issue.
  25393. */
  25394. minZ: number;
  25395. /**
  25396. * Define the maximum distance the camera can see to.
  25397. * This is important to note that the depth buffer are not infinite and the further it end
  25398. * the more your scene might encounter depth fighting issue.
  25399. */
  25400. maxZ: number;
  25401. /**
  25402. * Define the default inertia of the camera.
  25403. * This helps giving a smooth feeling to the camera movement.
  25404. */
  25405. inertia: number;
  25406. /**
  25407. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25408. */
  25409. mode: number;
  25410. /**
  25411. * Define wether the camera is intermediate.
  25412. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25413. */
  25414. isIntermediate: boolean;
  25415. /**
  25416. * Define the viewport of the camera.
  25417. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25418. */
  25419. viewport: Viewport;
  25420. /**
  25421. * Restricts the camera to viewing objects with the same layerMask.
  25422. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25423. */
  25424. layerMask: number;
  25425. /**
  25426. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25427. */
  25428. fovMode: number;
  25429. /**
  25430. * Rig mode of the camera.
  25431. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25432. * This is normally controlled byt the camera themselves as internal use.
  25433. */
  25434. cameraRigMode: number;
  25435. /**
  25436. * Defines the distance between both "eyes" in case of a RIG
  25437. */
  25438. interaxialDistance: number;
  25439. /**
  25440. * Defines if stereoscopic rendering is done side by side or over under.
  25441. */
  25442. isStereoscopicSideBySide: boolean;
  25443. /**
  25444. * 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
  25445. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25446. * else in the scene. (Eg. security camera)
  25447. *
  25448. * 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)
  25449. */
  25450. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25451. /**
  25452. * When set, the camera will render to this render target instead of the default canvas
  25453. *
  25454. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25455. */
  25456. outputRenderTarget: Nullable<RenderTargetTexture>;
  25457. /**
  25458. * Observable triggered when the camera view matrix has changed.
  25459. */
  25460. onViewMatrixChangedObservable: Observable<Camera>;
  25461. /**
  25462. * Observable triggered when the camera Projection matrix has changed.
  25463. */
  25464. onProjectionMatrixChangedObservable: Observable<Camera>;
  25465. /**
  25466. * Observable triggered when the inputs have been processed.
  25467. */
  25468. onAfterCheckInputsObservable: Observable<Camera>;
  25469. /**
  25470. * Observable triggered when reset has been called and applied to the camera.
  25471. */
  25472. onRestoreStateObservable: Observable<Camera>;
  25473. /** @hidden */
  25474. _cameraRigParams: any;
  25475. /** @hidden */
  25476. _rigCameras: Camera[];
  25477. /** @hidden */
  25478. _rigPostProcess: Nullable<PostProcess>;
  25479. protected _webvrViewMatrix: Matrix;
  25480. /** @hidden */
  25481. _skipRendering: boolean;
  25482. /** @hidden */
  25483. _projectionMatrix: Matrix;
  25484. /** @hidden */
  25485. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25486. /** @hidden */
  25487. _activeMeshes: SmartArray<AbstractMesh>;
  25488. protected _globalPosition: Vector3;
  25489. /** @hidden */
  25490. _computedViewMatrix: Matrix;
  25491. private _doNotComputeProjectionMatrix;
  25492. private _transformMatrix;
  25493. private _frustumPlanes;
  25494. private _refreshFrustumPlanes;
  25495. private _storedFov;
  25496. private _stateStored;
  25497. /**
  25498. * Instantiates a new camera object.
  25499. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25500. * @see http://doc.babylonjs.com/features/cameras
  25501. * @param name Defines the name of the camera in the scene
  25502. * @param position Defines the position of the camera
  25503. * @param scene Defines the scene the camera belongs too
  25504. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25505. */
  25506. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25507. /**
  25508. * Store current camera state (fov, position, etc..)
  25509. * @returns the camera
  25510. */
  25511. storeState(): Camera;
  25512. /**
  25513. * Restores the camera state values if it has been stored. You must call storeState() first
  25514. */
  25515. protected _restoreStateValues(): boolean;
  25516. /**
  25517. * Restored camera state. You must call storeState() first.
  25518. * @returns true if restored and false otherwise
  25519. */
  25520. restoreState(): boolean;
  25521. /**
  25522. * Gets the class name of the camera.
  25523. * @returns the class name
  25524. */
  25525. getClassName(): string;
  25526. /** @hidden */
  25527. readonly _isCamera: boolean;
  25528. /**
  25529. * Gets a string representation of the camera useful for debug purpose.
  25530. * @param fullDetails Defines that a more verboe level of logging is required
  25531. * @returns the string representation
  25532. */
  25533. toString(fullDetails?: boolean): string;
  25534. /**
  25535. * Gets the current world space position of the camera.
  25536. */
  25537. readonly globalPosition: Vector3;
  25538. /**
  25539. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25540. * @returns the active meshe list
  25541. */
  25542. getActiveMeshes(): SmartArray<AbstractMesh>;
  25543. /**
  25544. * Check wether a mesh is part of the current active mesh list of the camera
  25545. * @param mesh Defines the mesh to check
  25546. * @returns true if active, false otherwise
  25547. */
  25548. isActiveMesh(mesh: Mesh): boolean;
  25549. /**
  25550. * Is this camera ready to be used/rendered
  25551. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25552. * @return true if the camera is ready
  25553. */
  25554. isReady(completeCheck?: boolean): boolean;
  25555. /** @hidden */
  25556. _initCache(): void;
  25557. /** @hidden */
  25558. _updateCache(ignoreParentClass?: boolean): void;
  25559. /** @hidden */
  25560. _isSynchronized(): boolean;
  25561. /** @hidden */
  25562. _isSynchronizedViewMatrix(): boolean;
  25563. /** @hidden */
  25564. _isSynchronizedProjectionMatrix(): boolean;
  25565. /**
  25566. * Attach the input controls to a specific dom element to get the input from.
  25567. * @param element Defines the element the controls should be listened from
  25568. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25569. */
  25570. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25571. /**
  25572. * Detach the current controls from the specified dom element.
  25573. * @param element Defines the element to stop listening the inputs from
  25574. */
  25575. detachControl(element: HTMLElement): void;
  25576. /**
  25577. * Update the camera state according to the different inputs gathered during the frame.
  25578. */
  25579. update(): void;
  25580. /** @hidden */
  25581. _checkInputs(): void;
  25582. /** @hidden */
  25583. readonly rigCameras: Camera[];
  25584. /**
  25585. * Gets the post process used by the rig cameras
  25586. */
  25587. readonly rigPostProcess: Nullable<PostProcess>;
  25588. /**
  25589. * Internal, gets the first post proces.
  25590. * @returns the first post process to be run on this camera.
  25591. */
  25592. _getFirstPostProcess(): Nullable<PostProcess>;
  25593. private _cascadePostProcessesToRigCams;
  25594. /**
  25595. * Attach a post process to the camera.
  25596. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25597. * @param postProcess The post process to attach to the camera
  25598. * @param insertAt The position of the post process in case several of them are in use in the scene
  25599. * @returns the position the post process has been inserted at
  25600. */
  25601. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25602. /**
  25603. * Detach a post process to the camera.
  25604. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25605. * @param postProcess The post process to detach from the camera
  25606. */
  25607. detachPostProcess(postProcess: PostProcess): void;
  25608. /**
  25609. * Gets the current world matrix of the camera
  25610. */
  25611. getWorldMatrix(): Matrix;
  25612. /** @hidden */
  25613. _getViewMatrix(): Matrix;
  25614. /**
  25615. * Gets the current view matrix of the camera.
  25616. * @param force forces the camera to recompute the matrix without looking at the cached state
  25617. * @returns the view matrix
  25618. */
  25619. getViewMatrix(force?: boolean): Matrix;
  25620. /**
  25621. * Freeze the projection matrix.
  25622. * It will prevent the cache check of the camera projection compute and can speed up perf
  25623. * if no parameter of the camera are meant to change
  25624. * @param projection Defines manually a projection if necessary
  25625. */
  25626. freezeProjectionMatrix(projection?: Matrix): void;
  25627. /**
  25628. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25629. */
  25630. unfreezeProjectionMatrix(): void;
  25631. /**
  25632. * Gets the current projection matrix of the camera.
  25633. * @param force forces the camera to recompute the matrix without looking at the cached state
  25634. * @returns the projection matrix
  25635. */
  25636. getProjectionMatrix(force?: boolean): Matrix;
  25637. /**
  25638. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25639. * @returns a Matrix
  25640. */
  25641. getTransformationMatrix(): Matrix;
  25642. private _updateFrustumPlanes;
  25643. /**
  25644. * Checks if a cullable object (mesh...) is in the camera frustum
  25645. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25646. * @param target The object to check
  25647. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25648. * @returns true if the object is in frustum otherwise false
  25649. */
  25650. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25651. /**
  25652. * Checks if a cullable object (mesh...) is in the camera frustum
  25653. * Unlike isInFrustum this cheks the full bounding box
  25654. * @param target The object to check
  25655. * @returns true if the object is in frustum otherwise false
  25656. */
  25657. isCompletelyInFrustum(target: ICullable): boolean;
  25658. /**
  25659. * Gets a ray in the forward direction from the camera.
  25660. * @param length Defines the length of the ray to create
  25661. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25662. * @param origin Defines the start point of the ray which defaults to the camera position
  25663. * @returns the forward ray
  25664. */
  25665. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25666. /**
  25667. * Releases resources associated with this node.
  25668. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25669. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25670. */
  25671. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25672. /** @hidden */
  25673. _isLeftCamera: boolean;
  25674. /**
  25675. * Gets the left camera of a rig setup in case of Rigged Camera
  25676. */
  25677. readonly isLeftCamera: boolean;
  25678. /** @hidden */
  25679. _isRightCamera: boolean;
  25680. /**
  25681. * Gets the right camera of a rig setup in case of Rigged Camera
  25682. */
  25683. readonly isRightCamera: boolean;
  25684. /**
  25685. * Gets the left camera of a rig setup in case of Rigged Camera
  25686. */
  25687. readonly leftCamera: Nullable<FreeCamera>;
  25688. /**
  25689. * Gets the right camera of a rig setup in case of Rigged Camera
  25690. */
  25691. readonly rightCamera: Nullable<FreeCamera>;
  25692. /**
  25693. * Gets the left camera target of a rig setup in case of Rigged Camera
  25694. * @returns the target position
  25695. */
  25696. getLeftTarget(): Nullable<Vector3>;
  25697. /**
  25698. * Gets the right camera target of a rig setup in case of Rigged Camera
  25699. * @returns the target position
  25700. */
  25701. getRightTarget(): Nullable<Vector3>;
  25702. /**
  25703. * @hidden
  25704. */
  25705. setCameraRigMode(mode: number, rigParams: any): void;
  25706. /** @hidden */
  25707. static _setStereoscopicRigMode(camera: Camera): void;
  25708. /** @hidden */
  25709. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25710. /** @hidden */
  25711. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25712. /** @hidden */
  25713. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25714. /** @hidden */
  25715. _getVRProjectionMatrix(): Matrix;
  25716. protected _updateCameraRotationMatrix(): void;
  25717. protected _updateWebVRCameraRotationMatrix(): void;
  25718. /**
  25719. * This function MUST be overwritten by the different WebVR cameras available.
  25720. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25721. * @hidden
  25722. */
  25723. _getWebVRProjectionMatrix(): Matrix;
  25724. /**
  25725. * This function MUST be overwritten by the different WebVR cameras available.
  25726. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25727. * @hidden
  25728. */
  25729. _getWebVRViewMatrix(): Matrix;
  25730. /** @hidden */
  25731. setCameraRigParameter(name: string, value: any): void;
  25732. /**
  25733. * needs to be overridden by children so sub has required properties to be copied
  25734. * @hidden
  25735. */
  25736. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25737. /**
  25738. * May need to be overridden by children
  25739. * @hidden
  25740. */
  25741. _updateRigCameras(): void;
  25742. /** @hidden */
  25743. _setupInputs(): void;
  25744. /**
  25745. * Serialiaze the camera setup to a json represention
  25746. * @returns the JSON representation
  25747. */
  25748. serialize(): any;
  25749. /**
  25750. * Clones the current camera.
  25751. * @param name The cloned camera name
  25752. * @returns the cloned camera
  25753. */
  25754. clone(name: string): Camera;
  25755. /**
  25756. * Gets the direction of the camera relative to a given local axis.
  25757. * @param localAxis Defines the reference axis to provide a relative direction.
  25758. * @return the direction
  25759. */
  25760. getDirection(localAxis: Vector3): Vector3;
  25761. /**
  25762. * Returns the current camera absolute rotation
  25763. */
  25764. readonly absoluteRotation: Quaternion;
  25765. /**
  25766. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25767. * @param localAxis Defines the reference axis to provide a relative direction.
  25768. * @param result Defines the vector to store the result in
  25769. */
  25770. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25771. /**
  25772. * Gets a camera constructor for a given camera type
  25773. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25774. * @param name The name of the camera the result will be able to instantiate
  25775. * @param scene The scene the result will construct the camera in
  25776. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25777. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25778. * @returns a factory method to construc the camera
  25779. */
  25780. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25781. /**
  25782. * Compute the world matrix of the camera.
  25783. * @returns the camera workd matrix
  25784. */
  25785. computeWorldMatrix(): Matrix;
  25786. /**
  25787. * Parse a JSON and creates the camera from the parsed information
  25788. * @param parsedCamera The JSON to parse
  25789. * @param scene The scene to instantiate the camera in
  25790. * @returns the newly constructed camera
  25791. */
  25792. static Parse(parsedCamera: any, scene: Scene): Camera;
  25793. }
  25794. }
  25795. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25796. import { Nullable } from "babylonjs/types";
  25797. import { Scene } from "babylonjs/scene";
  25798. import { Vector4 } from "babylonjs/Maths/math.vector";
  25799. import { Mesh } from "babylonjs/Meshes/mesh";
  25800. /**
  25801. * Class containing static functions to help procedurally build meshes
  25802. */
  25803. export class DiscBuilder {
  25804. /**
  25805. * Creates a plane polygonal mesh. By default, this is a disc
  25806. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25807. * * 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
  25808. * * 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
  25809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25812. * @param name defines the name of the mesh
  25813. * @param options defines the options used to create the mesh
  25814. * @param scene defines the hosting scene
  25815. * @returns the plane polygonal mesh
  25816. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25817. */
  25818. static CreateDisc(name: string, options: {
  25819. radius?: number;
  25820. tessellation?: number;
  25821. arc?: number;
  25822. updatable?: boolean;
  25823. sideOrientation?: number;
  25824. frontUVs?: Vector4;
  25825. backUVs?: Vector4;
  25826. }, scene?: Nullable<Scene>): Mesh;
  25827. }
  25828. }
  25829. declare module "babylonjs/Particles/solidParticleSystem" {
  25830. import { Vector3 } from "babylonjs/Maths/math.vector";
  25831. import { Mesh } from "babylonjs/Meshes/mesh";
  25832. import { Scene, IDisposable } from "babylonjs/scene";
  25833. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25834. /**
  25835. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25836. *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.
  25837. * The SPS is also a particle system. It provides some methods to manage the particles.
  25838. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25839. *
  25840. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25841. */
  25842. export class SolidParticleSystem implements IDisposable {
  25843. /**
  25844. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25845. * Example : var p = SPS.particles[i];
  25846. */
  25847. particles: SolidParticle[];
  25848. /**
  25849. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25850. */
  25851. nbParticles: number;
  25852. /**
  25853. * If the particles must ever face the camera (default false). Useful for planar particles.
  25854. */
  25855. billboard: boolean;
  25856. /**
  25857. * Recompute normals when adding a shape
  25858. */
  25859. recomputeNormals: boolean;
  25860. /**
  25861. * This a counter ofr your own usage. It's not set by any SPS functions.
  25862. */
  25863. counter: number;
  25864. /**
  25865. * The SPS name. This name is also given to the underlying mesh.
  25866. */
  25867. name: string;
  25868. /**
  25869. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25870. */
  25871. mesh: Mesh;
  25872. /**
  25873. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25874. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25875. */
  25876. vars: any;
  25877. /**
  25878. * This array is populated when the SPS is set as 'pickable'.
  25879. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25880. * Each element of this array is an object `{idx: int, faceId: int}`.
  25881. * `idx` is the picked particle index in the `SPS.particles` array
  25882. * `faceId` is the picked face index counted within this particle.
  25883. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25884. */
  25885. pickedParticles: {
  25886. idx: number;
  25887. faceId: number;
  25888. }[];
  25889. /**
  25890. * This array is populated when `enableDepthSort` is set to true.
  25891. * Each element of this array is an instance of the class DepthSortedParticle.
  25892. */
  25893. depthSortedParticles: DepthSortedParticle[];
  25894. /**
  25895. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25896. * @hidden
  25897. */
  25898. _bSphereOnly: boolean;
  25899. /**
  25900. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25901. * @hidden
  25902. */
  25903. _bSphereRadiusFactor: number;
  25904. private _scene;
  25905. private _positions;
  25906. private _indices;
  25907. private _normals;
  25908. private _colors;
  25909. private _uvs;
  25910. private _indices32;
  25911. private _positions32;
  25912. private _normals32;
  25913. private _fixedNormal32;
  25914. private _colors32;
  25915. private _uvs32;
  25916. private _index;
  25917. private _updatable;
  25918. private _pickable;
  25919. private _isVisibilityBoxLocked;
  25920. private _alwaysVisible;
  25921. private _depthSort;
  25922. private _shapeCounter;
  25923. private _copy;
  25924. private _color;
  25925. private _computeParticleColor;
  25926. private _computeParticleTexture;
  25927. private _computeParticleRotation;
  25928. private _computeParticleVertex;
  25929. private _computeBoundingBox;
  25930. private _depthSortParticles;
  25931. private _camera;
  25932. private _mustUnrotateFixedNormals;
  25933. private _particlesIntersect;
  25934. private _needs32Bits;
  25935. /**
  25936. * Creates a SPS (Solid Particle System) object.
  25937. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25938. * @param scene (Scene) is the scene in which the SPS is added.
  25939. * @param options defines the options of the sps e.g.
  25940. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25941. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25942. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25943. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25944. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25945. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25946. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25947. */
  25948. constructor(name: string, scene: Scene, options?: {
  25949. updatable?: boolean;
  25950. isPickable?: boolean;
  25951. enableDepthSort?: boolean;
  25952. particleIntersection?: boolean;
  25953. boundingSphereOnly?: boolean;
  25954. bSphereRadiusFactor?: number;
  25955. });
  25956. /**
  25957. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25958. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25959. * @returns the created mesh
  25960. */
  25961. buildMesh(): Mesh;
  25962. /**
  25963. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25964. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25965. * Thus the particles generated from `digest()` have their property `position` set yet.
  25966. * @param mesh ( Mesh ) is the mesh to be digested
  25967. * @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
  25968. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25969. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25970. * @returns the current SPS
  25971. */
  25972. digest(mesh: Mesh, options?: {
  25973. facetNb?: number;
  25974. number?: number;
  25975. delta?: number;
  25976. }): SolidParticleSystem;
  25977. private _unrotateFixedNormals;
  25978. private _resetCopy;
  25979. private _meshBuilder;
  25980. private _posToShape;
  25981. private _uvsToShapeUV;
  25982. private _addParticle;
  25983. /**
  25984. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25985. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25986. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25987. * @param nb (positive integer) the number of particles to be created from this model
  25988. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25989. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25990. * @returns the number of shapes in the system
  25991. */
  25992. addShape(mesh: Mesh, nb: number, options?: {
  25993. positionFunction?: any;
  25994. vertexFunction?: any;
  25995. }): number;
  25996. private _rebuildParticle;
  25997. /**
  25998. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25999. * @returns the SPS.
  26000. */
  26001. rebuildMesh(): SolidParticleSystem;
  26002. /**
  26003. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26004. * This method calls `updateParticle()` for each particle of the SPS.
  26005. * For an animated SPS, it is usually called within the render loop.
  26006. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26007. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26008. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26009. * @returns the SPS.
  26010. */
  26011. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26012. /**
  26013. * Disposes the SPS.
  26014. */
  26015. dispose(): void;
  26016. /**
  26017. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26018. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26019. * @returns the SPS.
  26020. */
  26021. refreshVisibleSize(): SolidParticleSystem;
  26022. /**
  26023. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26024. * @param size the size (float) of the visibility box
  26025. * note : this doesn't lock the SPS mesh bounding box.
  26026. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26027. */
  26028. setVisibilityBox(size: number): void;
  26029. /**
  26030. * Gets whether the SPS as always visible or not
  26031. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26032. */
  26033. /**
  26034. * Sets the SPS as always visible or not
  26035. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26036. */
  26037. isAlwaysVisible: boolean;
  26038. /**
  26039. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26040. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26041. */
  26042. /**
  26043. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26044. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26045. */
  26046. isVisibilityBoxLocked: boolean;
  26047. /**
  26048. * Tells to `setParticles()` to compute the particle rotations or not.
  26049. * Default value : true. The SPS is faster when it's set to false.
  26050. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26051. */
  26052. /**
  26053. * Gets if `setParticles()` computes the particle rotations or not.
  26054. * Default value : true. The SPS is faster when it's set to false.
  26055. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26056. */
  26057. computeParticleRotation: boolean;
  26058. /**
  26059. * Tells to `setParticles()` to compute the particle colors or not.
  26060. * Default value : true. The SPS is faster when it's set to false.
  26061. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26062. */
  26063. /**
  26064. * Gets if `setParticles()` computes the particle colors or not.
  26065. * Default value : true. The SPS is faster when it's set to false.
  26066. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26067. */
  26068. computeParticleColor: boolean;
  26069. /**
  26070. * Gets if `setParticles()` computes the particle textures or not.
  26071. * Default value : true. The SPS is faster when it's set to false.
  26072. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26073. */
  26074. computeParticleTexture: boolean;
  26075. /**
  26076. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26077. * Default value : false. The SPS is faster when it's set to false.
  26078. * Note : the particle custom vertex positions aren't stored values.
  26079. */
  26080. /**
  26081. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26082. * Default value : false. The SPS is faster when it's set to false.
  26083. * Note : the particle custom vertex positions aren't stored values.
  26084. */
  26085. computeParticleVertex: boolean;
  26086. /**
  26087. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26088. */
  26089. /**
  26090. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26091. */
  26092. computeBoundingBox: boolean;
  26093. /**
  26094. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26095. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26096. * Default : `true`
  26097. */
  26098. /**
  26099. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26100. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26101. * Default : `true`
  26102. */
  26103. depthSortParticles: boolean;
  26104. /**
  26105. * This function does nothing. It may be overwritten to set all the particle first values.
  26106. * The SPS doesn't call this function, you may have to call it by your own.
  26107. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26108. */
  26109. initParticles(): void;
  26110. /**
  26111. * This function does nothing. It may be overwritten to recycle a particle.
  26112. * The SPS doesn't call this function, you may have to call it by your own.
  26113. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26114. * @param particle The particle to recycle
  26115. * @returns the recycled particle
  26116. */
  26117. recycleParticle(particle: SolidParticle): SolidParticle;
  26118. /**
  26119. * Updates a particle : this function should be overwritten by the user.
  26120. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26121. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26122. * @example : just set a particle position or velocity and recycle conditions
  26123. * @param particle The particle to update
  26124. * @returns the updated particle
  26125. */
  26126. updateParticle(particle: SolidParticle): SolidParticle;
  26127. /**
  26128. * Updates a vertex of a particle : it can be overwritten by the user.
  26129. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26130. * @param particle the current particle
  26131. * @param vertex the current index of the current particle
  26132. * @param pt the index of the current vertex in the particle shape
  26133. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26134. * @example : just set a vertex particle position
  26135. * @returns the updated vertex
  26136. */
  26137. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26138. /**
  26139. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26140. * This does nothing and may be overwritten by the user.
  26141. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26142. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26143. * @param update the boolean update value actually passed to setParticles()
  26144. */
  26145. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26146. /**
  26147. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26148. * This will be passed three parameters.
  26149. * This does nothing and may be overwritten by the user.
  26150. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26151. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26152. * @param update the boolean update value actually passed to setParticles()
  26153. */
  26154. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26155. }
  26156. }
  26157. declare module "babylonjs/Particles/solidParticle" {
  26158. import { Nullable } from "babylonjs/types";
  26159. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26160. import { Color4 } from "babylonjs/Maths/math.color";
  26161. import { Mesh } from "babylonjs/Meshes/mesh";
  26162. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26163. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26164. import { Plane } from "babylonjs/Maths/math.plane";
  26165. /**
  26166. * Represents one particle of a solid particle system.
  26167. */
  26168. export class SolidParticle {
  26169. /**
  26170. * particle global index
  26171. */
  26172. idx: number;
  26173. /**
  26174. * The color of the particle
  26175. */
  26176. color: Nullable<Color4>;
  26177. /**
  26178. * The world space position of the particle.
  26179. */
  26180. position: Vector3;
  26181. /**
  26182. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26183. */
  26184. rotation: Vector3;
  26185. /**
  26186. * The world space rotation quaternion of the particle.
  26187. */
  26188. rotationQuaternion: Nullable<Quaternion>;
  26189. /**
  26190. * The scaling of the particle.
  26191. */
  26192. scaling: Vector3;
  26193. /**
  26194. * The uvs of the particle.
  26195. */
  26196. uvs: Vector4;
  26197. /**
  26198. * The current speed of the particle.
  26199. */
  26200. velocity: Vector3;
  26201. /**
  26202. * The pivot point in the particle local space.
  26203. */
  26204. pivot: Vector3;
  26205. /**
  26206. * Must the particle be translated from its pivot point in its local space ?
  26207. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26208. * Default : false
  26209. */
  26210. translateFromPivot: boolean;
  26211. /**
  26212. * Is the particle active or not ?
  26213. */
  26214. alive: boolean;
  26215. /**
  26216. * Is the particle visible or not ?
  26217. */
  26218. isVisible: boolean;
  26219. /**
  26220. * Index of this particle in the global "positions" array (Internal use)
  26221. * @hidden
  26222. */
  26223. _pos: number;
  26224. /**
  26225. * @hidden Index of this particle in the global "indices" array (Internal use)
  26226. */
  26227. _ind: number;
  26228. /**
  26229. * @hidden ModelShape of this particle (Internal use)
  26230. */
  26231. _model: ModelShape;
  26232. /**
  26233. * ModelShape id of this particle
  26234. */
  26235. shapeId: number;
  26236. /**
  26237. * Index of the particle in its shape id
  26238. */
  26239. idxInShape: number;
  26240. /**
  26241. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26242. */
  26243. _modelBoundingInfo: BoundingInfo;
  26244. /**
  26245. * @hidden Particle BoundingInfo object (Internal use)
  26246. */
  26247. _boundingInfo: BoundingInfo;
  26248. /**
  26249. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26250. */
  26251. _sps: SolidParticleSystem;
  26252. /**
  26253. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26254. */
  26255. _stillInvisible: boolean;
  26256. /**
  26257. * @hidden Last computed particle rotation matrix
  26258. */
  26259. _rotationMatrix: number[];
  26260. /**
  26261. * Parent particle Id, if any.
  26262. * Default null.
  26263. */
  26264. parentId: Nullable<number>;
  26265. /**
  26266. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26267. * The possible values are :
  26268. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26269. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26270. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26271. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26272. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26273. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26274. * */
  26275. cullingStrategy: number;
  26276. /**
  26277. * @hidden Internal global position in the SPS.
  26278. */
  26279. _globalPosition: Vector3;
  26280. /**
  26281. * Creates a Solid Particle object.
  26282. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26283. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26284. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26285. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26286. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26287. * @param shapeId (integer) is the model shape identifier in the SPS.
  26288. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26289. * @param sps defines the sps it is associated to
  26290. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26291. */
  26292. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26293. /**
  26294. * Legacy support, changed scale to scaling
  26295. */
  26296. /**
  26297. * Legacy support, changed scale to scaling
  26298. */
  26299. scale: Vector3;
  26300. /**
  26301. * Legacy support, changed quaternion to rotationQuaternion
  26302. */
  26303. /**
  26304. * Legacy support, changed quaternion to rotationQuaternion
  26305. */
  26306. quaternion: Nullable<Quaternion>;
  26307. /**
  26308. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26309. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26310. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26311. * @returns true if it intersects
  26312. */
  26313. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26314. /**
  26315. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26316. * A particle is in the frustum if its bounding box intersects the frustum
  26317. * @param frustumPlanes defines the frustum to test
  26318. * @returns true if the particle is in the frustum planes
  26319. */
  26320. isInFrustum(frustumPlanes: Plane[]): boolean;
  26321. /**
  26322. * get the rotation matrix of the particle
  26323. * @hidden
  26324. */
  26325. getRotationMatrix(m: Matrix): void;
  26326. }
  26327. /**
  26328. * Represents the shape of the model used by one particle of a solid particle system.
  26329. * SPS internal tool, don't use it manually.
  26330. */
  26331. export class ModelShape {
  26332. /**
  26333. * The shape id
  26334. * @hidden
  26335. */
  26336. shapeID: number;
  26337. /**
  26338. * flat array of model positions (internal use)
  26339. * @hidden
  26340. */
  26341. _shape: Vector3[];
  26342. /**
  26343. * flat array of model UVs (internal use)
  26344. * @hidden
  26345. */
  26346. _shapeUV: number[];
  26347. /**
  26348. * length of the shape in the model indices array (internal use)
  26349. * @hidden
  26350. */
  26351. _indicesLength: number;
  26352. /**
  26353. * Custom position function (internal use)
  26354. * @hidden
  26355. */
  26356. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26357. /**
  26358. * Custom vertex function (internal use)
  26359. * @hidden
  26360. */
  26361. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26362. /**
  26363. * 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.
  26364. * SPS internal tool, don't use it manually.
  26365. * @hidden
  26366. */
  26367. 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>);
  26368. }
  26369. /**
  26370. * Represents a Depth Sorted Particle in the solid particle system.
  26371. */
  26372. export class DepthSortedParticle {
  26373. /**
  26374. * Index of the particle in the "indices" array
  26375. */
  26376. ind: number;
  26377. /**
  26378. * Length of the particle shape in the "indices" array
  26379. */
  26380. indicesLength: number;
  26381. /**
  26382. * Squared distance from the particle to the camera
  26383. */
  26384. sqDistance: number;
  26385. }
  26386. }
  26387. declare module "babylonjs/Collisions/meshCollisionData" {
  26388. import { Collider } from "babylonjs/Collisions/collider";
  26389. import { Vector3 } from "babylonjs/Maths/math.vector";
  26390. import { Nullable } from "babylonjs/types";
  26391. import { Observer } from "babylonjs/Misc/observable";
  26392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26393. /**
  26394. * @hidden
  26395. */
  26396. export class _MeshCollisionData {
  26397. _checkCollisions: boolean;
  26398. _collisionMask: number;
  26399. _collisionGroup: number;
  26400. _collider: Nullable<Collider>;
  26401. _oldPositionForCollisions: Vector3;
  26402. _diffPositionForCollisions: Vector3;
  26403. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26404. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26405. }
  26406. }
  26407. declare module "babylonjs/Meshes/abstractMesh" {
  26408. import { Observable } from "babylonjs/Misc/observable";
  26409. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26410. import { Camera } from "babylonjs/Cameras/camera";
  26411. import { Scene, IDisposable } from "babylonjs/scene";
  26412. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26413. import { Node } from "babylonjs/node";
  26414. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26415. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26416. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26417. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26418. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26419. import { Material } from "babylonjs/Materials/material";
  26420. import { Light } from "babylonjs/Lights/light";
  26421. import { Skeleton } from "babylonjs/Bones/skeleton";
  26422. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26423. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26424. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26425. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26426. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26427. import { Plane } from "babylonjs/Maths/math.plane";
  26428. import { Ray } from "babylonjs/Culling/ray";
  26429. import { Collider } from "babylonjs/Collisions/collider";
  26430. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26431. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26432. /** @hidden */
  26433. class _FacetDataStorage {
  26434. facetPositions: Vector3[];
  26435. facetNormals: Vector3[];
  26436. facetPartitioning: number[][];
  26437. facetNb: number;
  26438. partitioningSubdivisions: number;
  26439. partitioningBBoxRatio: number;
  26440. facetDataEnabled: boolean;
  26441. facetParameters: any;
  26442. bbSize: Vector3;
  26443. subDiv: {
  26444. max: number;
  26445. X: number;
  26446. Y: number;
  26447. Z: number;
  26448. };
  26449. facetDepthSort: boolean;
  26450. facetDepthSortEnabled: boolean;
  26451. depthSortedIndices: IndicesArray;
  26452. depthSortedFacets: {
  26453. ind: number;
  26454. sqDistance: number;
  26455. }[];
  26456. facetDepthSortFunction: (f1: {
  26457. ind: number;
  26458. sqDistance: number;
  26459. }, f2: {
  26460. ind: number;
  26461. sqDistance: number;
  26462. }) => number;
  26463. facetDepthSortFrom: Vector3;
  26464. facetDepthSortOrigin: Vector3;
  26465. invertedMatrix: Matrix;
  26466. }
  26467. /**
  26468. * @hidden
  26469. **/
  26470. class _InternalAbstractMeshDataInfo {
  26471. _hasVertexAlpha: boolean;
  26472. _useVertexColors: boolean;
  26473. _numBoneInfluencers: number;
  26474. _applyFog: boolean;
  26475. _receiveShadows: boolean;
  26476. _facetData: _FacetDataStorage;
  26477. _visibility: number;
  26478. _skeleton: Nullable<Skeleton>;
  26479. _layerMask: number;
  26480. _computeBonesUsingShaders: boolean;
  26481. _isActive: boolean;
  26482. _onlyForInstances: boolean;
  26483. _isActiveIntermediate: boolean;
  26484. _onlyForInstancesIntermediate: boolean;
  26485. }
  26486. /**
  26487. * Class used to store all common mesh properties
  26488. */
  26489. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26490. /** No occlusion */
  26491. static OCCLUSION_TYPE_NONE: number;
  26492. /** Occlusion set to optimisitic */
  26493. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26494. /** Occlusion set to strict */
  26495. static OCCLUSION_TYPE_STRICT: number;
  26496. /** Use an accurante occlusion algorithm */
  26497. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26498. /** Use a conservative occlusion algorithm */
  26499. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26500. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26501. * Test order :
  26502. * Is the bounding sphere outside the frustum ?
  26503. * If not, are the bounding box vertices outside the frustum ?
  26504. * It not, then the cullable object is in the frustum.
  26505. */
  26506. static readonly CULLINGSTRATEGY_STANDARD: number;
  26507. /** Culling strategy : Bounding Sphere Only.
  26508. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26509. * It's also less accurate than the standard because some not visible objects can still be selected.
  26510. * Test : is the bounding sphere outside the frustum ?
  26511. * If not, then the cullable object is in the frustum.
  26512. */
  26513. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26514. /** Culling strategy : Optimistic Inclusion.
  26515. * This in an inclusion test first, then the standard exclusion test.
  26516. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26517. * 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.
  26518. * Anyway, it's as accurate as the standard strategy.
  26519. * Test :
  26520. * Is the cullable object bounding sphere center in the frustum ?
  26521. * If not, apply the default culling strategy.
  26522. */
  26523. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26524. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26525. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26526. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26527. * 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.
  26528. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26529. * Test :
  26530. * Is the cullable object bounding sphere center in the frustum ?
  26531. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26532. */
  26533. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26534. /**
  26535. * No billboard
  26536. */
  26537. static readonly BILLBOARDMODE_NONE: number;
  26538. /** Billboard on X axis */
  26539. static readonly BILLBOARDMODE_X: number;
  26540. /** Billboard on Y axis */
  26541. static readonly BILLBOARDMODE_Y: number;
  26542. /** Billboard on Z axis */
  26543. static readonly BILLBOARDMODE_Z: number;
  26544. /** Billboard on all axes */
  26545. static readonly BILLBOARDMODE_ALL: number;
  26546. /** Billboard on using position instead of orientation */
  26547. static readonly BILLBOARDMODE_USE_POSITION: number;
  26548. /** @hidden */
  26549. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26550. /**
  26551. * The culling strategy to use to check whether the mesh must be rendered or not.
  26552. * This value can be changed at any time and will be used on the next render mesh selection.
  26553. * The possible values are :
  26554. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26555. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26556. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26557. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26558. * Please read each static variable documentation to get details about the culling process.
  26559. * */
  26560. cullingStrategy: number;
  26561. /**
  26562. * Gets the number of facets in the mesh
  26563. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26564. */
  26565. readonly facetNb: number;
  26566. /**
  26567. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26568. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26569. */
  26570. partitioningSubdivisions: number;
  26571. /**
  26572. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26573. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26574. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26575. */
  26576. partitioningBBoxRatio: number;
  26577. /**
  26578. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26579. * Works only for updatable meshes.
  26580. * Doesn't work with multi-materials
  26581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26582. */
  26583. mustDepthSortFacets: boolean;
  26584. /**
  26585. * The location (Vector3) where the facet depth sort must be computed from.
  26586. * By default, the active camera position.
  26587. * Used only when facet depth sort is enabled
  26588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26589. */
  26590. facetDepthSortFrom: Vector3;
  26591. /**
  26592. * gets a boolean indicating if facetData is enabled
  26593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26594. */
  26595. readonly isFacetDataEnabled: boolean;
  26596. /** @hidden */
  26597. _updateNonUniformScalingState(value: boolean): boolean;
  26598. /**
  26599. * An event triggered when this mesh collides with another one
  26600. */
  26601. onCollideObservable: Observable<AbstractMesh>;
  26602. /** Set a function to call when this mesh collides with another one */
  26603. onCollide: () => void;
  26604. /**
  26605. * An event triggered when the collision's position changes
  26606. */
  26607. onCollisionPositionChangeObservable: Observable<Vector3>;
  26608. /** Set a function to call when the collision's position changes */
  26609. onCollisionPositionChange: () => void;
  26610. /**
  26611. * An event triggered when material is changed
  26612. */
  26613. onMaterialChangedObservable: Observable<AbstractMesh>;
  26614. /**
  26615. * Gets or sets the orientation for POV movement & rotation
  26616. */
  26617. definedFacingForward: boolean;
  26618. /** @hidden */
  26619. _occlusionQuery: Nullable<WebGLQuery>;
  26620. /** @hidden */
  26621. _renderingGroup: Nullable<RenderingGroup>;
  26622. /**
  26623. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26624. */
  26625. /**
  26626. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26627. */
  26628. visibility: number;
  26629. /** Gets or sets the alpha index used to sort transparent meshes
  26630. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26631. */
  26632. alphaIndex: number;
  26633. /**
  26634. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26635. */
  26636. isVisible: boolean;
  26637. /**
  26638. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26639. */
  26640. isPickable: boolean;
  26641. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26642. showSubMeshesBoundingBox: boolean;
  26643. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26644. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26645. */
  26646. isBlocker: boolean;
  26647. /**
  26648. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26649. */
  26650. enablePointerMoveEvents: boolean;
  26651. /**
  26652. * Specifies the rendering group id for this mesh (0 by default)
  26653. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26654. */
  26655. renderingGroupId: number;
  26656. private _material;
  26657. /** Gets or sets current material */
  26658. material: Nullable<Material>;
  26659. /**
  26660. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26661. * @see http://doc.babylonjs.com/babylon101/shadows
  26662. */
  26663. receiveShadows: boolean;
  26664. /** Defines color to use when rendering outline */
  26665. outlineColor: Color3;
  26666. /** Define width to use when rendering outline */
  26667. outlineWidth: number;
  26668. /** Defines color to use when rendering overlay */
  26669. overlayColor: Color3;
  26670. /** Defines alpha to use when rendering overlay */
  26671. overlayAlpha: number;
  26672. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26673. hasVertexAlpha: boolean;
  26674. /** 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) */
  26675. useVertexColors: boolean;
  26676. /**
  26677. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26678. */
  26679. computeBonesUsingShaders: boolean;
  26680. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26681. numBoneInfluencers: number;
  26682. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26683. applyFog: boolean;
  26684. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26685. useOctreeForRenderingSelection: boolean;
  26686. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26687. useOctreeForPicking: boolean;
  26688. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26689. useOctreeForCollisions: boolean;
  26690. /**
  26691. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26692. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26693. */
  26694. layerMask: number;
  26695. /**
  26696. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26697. */
  26698. alwaysSelectAsActiveMesh: boolean;
  26699. /**
  26700. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26701. */
  26702. doNotSyncBoundingInfo: boolean;
  26703. /**
  26704. * Gets or sets the current action manager
  26705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26706. */
  26707. actionManager: Nullable<AbstractActionManager>;
  26708. private _meshCollisionData;
  26709. /**
  26710. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26711. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26712. */
  26713. ellipsoid: Vector3;
  26714. /**
  26715. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26716. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26717. */
  26718. ellipsoidOffset: Vector3;
  26719. /**
  26720. * Gets or sets a collision mask used to mask collisions (default is -1).
  26721. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26722. */
  26723. collisionMask: number;
  26724. /**
  26725. * Gets or sets the current collision group mask (-1 by default).
  26726. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26727. */
  26728. collisionGroup: number;
  26729. /**
  26730. * Defines edge width used when edgesRenderer is enabled
  26731. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26732. */
  26733. edgesWidth: number;
  26734. /**
  26735. * Defines edge color used when edgesRenderer is enabled
  26736. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26737. */
  26738. edgesColor: Color4;
  26739. /** @hidden */
  26740. _edgesRenderer: Nullable<IEdgesRenderer>;
  26741. /** @hidden */
  26742. _masterMesh: Nullable<AbstractMesh>;
  26743. /** @hidden */
  26744. _boundingInfo: Nullable<BoundingInfo>;
  26745. /** @hidden */
  26746. _renderId: number;
  26747. /**
  26748. * Gets or sets the list of subMeshes
  26749. * @see http://doc.babylonjs.com/how_to/multi_materials
  26750. */
  26751. subMeshes: SubMesh[];
  26752. /** @hidden */
  26753. _intersectionsInProgress: AbstractMesh[];
  26754. /** @hidden */
  26755. _unIndexed: boolean;
  26756. /** @hidden */
  26757. _lightSources: Light[];
  26758. /** Gets the list of lights affecting that mesh */
  26759. readonly lightSources: Light[];
  26760. /** @hidden */
  26761. readonly _positions: Nullable<Vector3[]>;
  26762. /** @hidden */
  26763. _waitingData: {
  26764. lods: Nullable<any>;
  26765. actions: Nullable<any>;
  26766. freezeWorldMatrix: Nullable<boolean>;
  26767. };
  26768. /** @hidden */
  26769. _bonesTransformMatrices: Nullable<Float32Array>;
  26770. /** @hidden */
  26771. _transformMatrixTexture: Nullable<RawTexture>;
  26772. /**
  26773. * Gets or sets a skeleton to apply skining transformations
  26774. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26775. */
  26776. skeleton: Nullable<Skeleton>;
  26777. /**
  26778. * An event triggered when the mesh is rebuilt.
  26779. */
  26780. onRebuildObservable: Observable<AbstractMesh>;
  26781. /**
  26782. * Creates a new AbstractMesh
  26783. * @param name defines the name of the mesh
  26784. * @param scene defines the hosting scene
  26785. */
  26786. constructor(name: string, scene?: Nullable<Scene>);
  26787. /**
  26788. * Returns the string "AbstractMesh"
  26789. * @returns "AbstractMesh"
  26790. */
  26791. getClassName(): string;
  26792. /**
  26793. * Gets a string representation of the current mesh
  26794. * @param fullDetails defines a boolean indicating if full details must be included
  26795. * @returns a string representation of the current mesh
  26796. */
  26797. toString(fullDetails?: boolean): string;
  26798. /**
  26799. * @hidden
  26800. */
  26801. protected _getEffectiveParent(): Nullable<Node>;
  26802. /** @hidden */
  26803. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26804. /** @hidden */
  26805. _rebuild(): void;
  26806. /** @hidden */
  26807. _resyncLightSources(): void;
  26808. /** @hidden */
  26809. _resyncLighSource(light: Light): void;
  26810. /** @hidden */
  26811. _unBindEffect(): void;
  26812. /** @hidden */
  26813. _removeLightSource(light: Light, dispose: boolean): void;
  26814. private _markSubMeshesAsDirty;
  26815. /** @hidden */
  26816. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26817. /** @hidden */
  26818. _markSubMeshesAsAttributesDirty(): void;
  26819. /** @hidden */
  26820. _markSubMeshesAsMiscDirty(): void;
  26821. /**
  26822. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26823. */
  26824. scaling: Vector3;
  26825. /**
  26826. * Returns true if the mesh is blocked. Implemented by child classes
  26827. */
  26828. readonly isBlocked: boolean;
  26829. /**
  26830. * Returns the mesh itself by default. Implemented by child classes
  26831. * @param camera defines the camera to use to pick the right LOD level
  26832. * @returns the currentAbstractMesh
  26833. */
  26834. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26835. /**
  26836. * Returns 0 by default. Implemented by child classes
  26837. * @returns an integer
  26838. */
  26839. getTotalVertices(): number;
  26840. /**
  26841. * Returns a positive integer : the total number of indices in this mesh geometry.
  26842. * @returns the numner of indices or zero if the mesh has no geometry.
  26843. */
  26844. getTotalIndices(): number;
  26845. /**
  26846. * Returns null by default. Implemented by child classes
  26847. * @returns null
  26848. */
  26849. getIndices(): Nullable<IndicesArray>;
  26850. /**
  26851. * Returns the array of the requested vertex data kind. Implemented by child classes
  26852. * @param kind defines the vertex data kind to use
  26853. * @returns null
  26854. */
  26855. getVerticesData(kind: string): Nullable<FloatArray>;
  26856. /**
  26857. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26858. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26859. * Note that a new underlying VertexBuffer object is created each call.
  26860. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26861. * @param kind defines vertex data kind:
  26862. * * VertexBuffer.PositionKind
  26863. * * VertexBuffer.UVKind
  26864. * * VertexBuffer.UV2Kind
  26865. * * VertexBuffer.UV3Kind
  26866. * * VertexBuffer.UV4Kind
  26867. * * VertexBuffer.UV5Kind
  26868. * * VertexBuffer.UV6Kind
  26869. * * VertexBuffer.ColorKind
  26870. * * VertexBuffer.MatricesIndicesKind
  26871. * * VertexBuffer.MatricesIndicesExtraKind
  26872. * * VertexBuffer.MatricesWeightsKind
  26873. * * VertexBuffer.MatricesWeightsExtraKind
  26874. * @param data defines the data source
  26875. * @param updatable defines if the data must be flagged as updatable (or static)
  26876. * @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
  26877. * @returns the current mesh
  26878. */
  26879. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26880. /**
  26881. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26882. * If the mesh has no geometry, it is simply returned as it is.
  26883. * @param kind defines vertex data kind:
  26884. * * VertexBuffer.PositionKind
  26885. * * VertexBuffer.UVKind
  26886. * * VertexBuffer.UV2Kind
  26887. * * VertexBuffer.UV3Kind
  26888. * * VertexBuffer.UV4Kind
  26889. * * VertexBuffer.UV5Kind
  26890. * * VertexBuffer.UV6Kind
  26891. * * VertexBuffer.ColorKind
  26892. * * VertexBuffer.MatricesIndicesKind
  26893. * * VertexBuffer.MatricesIndicesExtraKind
  26894. * * VertexBuffer.MatricesWeightsKind
  26895. * * VertexBuffer.MatricesWeightsExtraKind
  26896. * @param data defines the data source
  26897. * @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
  26898. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26899. * @returns the current mesh
  26900. */
  26901. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26902. /**
  26903. * Sets the mesh indices,
  26904. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26905. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26906. * @param totalVertices Defines the total number of vertices
  26907. * @returns the current mesh
  26908. */
  26909. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26910. /**
  26911. * Gets a boolean indicating if specific vertex data is present
  26912. * @param kind defines the vertex data kind to use
  26913. * @returns true is data kind is present
  26914. */
  26915. isVerticesDataPresent(kind: string): boolean;
  26916. /**
  26917. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26918. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26919. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26920. * @returns a BoundingInfo
  26921. */
  26922. getBoundingInfo(): BoundingInfo;
  26923. /**
  26924. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26925. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26926. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26927. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26928. * @returns the current mesh
  26929. */
  26930. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26931. /**
  26932. * Overwrite the current bounding info
  26933. * @param boundingInfo defines the new bounding info
  26934. * @returns the current mesh
  26935. */
  26936. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26937. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26938. readonly useBones: boolean;
  26939. /** @hidden */
  26940. _preActivate(): void;
  26941. /** @hidden */
  26942. _preActivateForIntermediateRendering(renderId: number): void;
  26943. /** @hidden */
  26944. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26945. /** @hidden */
  26946. _postActivate(): void;
  26947. /** @hidden */
  26948. _freeze(): void;
  26949. /** @hidden */
  26950. _unFreeze(): void;
  26951. /**
  26952. * Gets the current world matrix
  26953. * @returns a Matrix
  26954. */
  26955. getWorldMatrix(): Matrix;
  26956. /** @hidden */
  26957. _getWorldMatrixDeterminant(): number;
  26958. /**
  26959. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26960. */
  26961. readonly isAnInstance: boolean;
  26962. /**
  26963. * Gets a boolean indicating if this mesh has instances
  26964. */
  26965. readonly hasInstances: boolean;
  26966. /**
  26967. * Perform relative position change from the point of view of behind the front of the mesh.
  26968. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26969. * Supports definition of mesh facing forward or backward
  26970. * @param amountRight defines the distance on the right axis
  26971. * @param amountUp defines the distance on the up axis
  26972. * @param amountForward defines the distance on the forward axis
  26973. * @returns the current mesh
  26974. */
  26975. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26976. /**
  26977. * Calculate relative position change from the point of view of behind the front of the mesh.
  26978. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26979. * Supports definition of mesh facing forward or backward
  26980. * @param amountRight defines the distance on the right axis
  26981. * @param amountUp defines the distance on the up axis
  26982. * @param amountForward defines the distance on the forward axis
  26983. * @returns the new displacement vector
  26984. */
  26985. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26986. /**
  26987. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26988. * Supports definition of mesh facing forward or backward
  26989. * @param flipBack defines the flip
  26990. * @param twirlClockwise defines the twirl
  26991. * @param tiltRight defines the tilt
  26992. * @returns the current mesh
  26993. */
  26994. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26995. /**
  26996. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26997. * Supports definition of mesh facing forward or backward.
  26998. * @param flipBack defines the flip
  26999. * @param twirlClockwise defines the twirl
  27000. * @param tiltRight defines the tilt
  27001. * @returns the new rotation vector
  27002. */
  27003. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27004. /**
  27005. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27006. * This means the mesh underlying bounding box and sphere are recomputed.
  27007. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27008. * @returns the current mesh
  27009. */
  27010. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27011. /** @hidden */
  27012. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27013. /** @hidden */
  27014. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27015. /** @hidden */
  27016. _updateBoundingInfo(): AbstractMesh;
  27017. /** @hidden */
  27018. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27019. /** @hidden */
  27020. protected _afterComputeWorldMatrix(): void;
  27021. /** @hidden */
  27022. readonly _effectiveMesh: AbstractMesh;
  27023. /**
  27024. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27025. * A mesh is in the frustum if its bounding box intersects the frustum
  27026. * @param frustumPlanes defines the frustum to test
  27027. * @returns true if the mesh is in the frustum planes
  27028. */
  27029. isInFrustum(frustumPlanes: Plane[]): boolean;
  27030. /**
  27031. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27032. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27033. * @param frustumPlanes defines the frustum to test
  27034. * @returns true if the mesh is completely in the frustum planes
  27035. */
  27036. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27037. /**
  27038. * True if the mesh intersects another mesh or a SolidParticle object
  27039. * @param mesh defines a target mesh or SolidParticle to test
  27040. * @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)
  27041. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27042. * @returns true if there is an intersection
  27043. */
  27044. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27045. /**
  27046. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27047. * @param point defines the point to test
  27048. * @returns true if there is an intersection
  27049. */
  27050. intersectsPoint(point: Vector3): boolean;
  27051. /**
  27052. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27053. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27054. */
  27055. checkCollisions: boolean;
  27056. /**
  27057. * Gets Collider object used to compute collisions (not physics)
  27058. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27059. */
  27060. readonly collider: Nullable<Collider>;
  27061. /**
  27062. * Move the mesh using collision engine
  27063. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27064. * @param displacement defines the requested displacement vector
  27065. * @returns the current mesh
  27066. */
  27067. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27068. private _onCollisionPositionChange;
  27069. /** @hidden */
  27070. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27071. /** @hidden */
  27072. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27073. /** @hidden */
  27074. _checkCollision(collider: Collider): AbstractMesh;
  27075. /** @hidden */
  27076. _generatePointsArray(): boolean;
  27077. /**
  27078. * Checks if the passed Ray intersects with the mesh
  27079. * @param ray defines the ray to use
  27080. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27081. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27082. * @returns the picking info
  27083. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27084. */
  27085. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27086. /**
  27087. * Clones the current mesh
  27088. * @param name defines the mesh name
  27089. * @param newParent defines the new mesh parent
  27090. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27091. * @returns the new mesh
  27092. */
  27093. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27094. /**
  27095. * Disposes all the submeshes of the current meshnp
  27096. * @returns the current mesh
  27097. */
  27098. releaseSubMeshes(): AbstractMesh;
  27099. /**
  27100. * Releases resources associated with this abstract mesh.
  27101. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27102. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27103. */
  27104. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27105. /**
  27106. * Adds the passed mesh as a child to the current mesh
  27107. * @param mesh defines the child mesh
  27108. * @returns the current mesh
  27109. */
  27110. addChild(mesh: AbstractMesh): AbstractMesh;
  27111. /**
  27112. * Removes the passed mesh from the current mesh children list
  27113. * @param mesh defines the child mesh
  27114. * @returns the current mesh
  27115. */
  27116. removeChild(mesh: AbstractMesh): AbstractMesh;
  27117. /** @hidden */
  27118. private _initFacetData;
  27119. /**
  27120. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27121. * This method can be called within the render loop.
  27122. * 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
  27123. * @returns the current mesh
  27124. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27125. */
  27126. updateFacetData(): AbstractMesh;
  27127. /**
  27128. * Returns the facetLocalNormals array.
  27129. * The normals are expressed in the mesh local spac
  27130. * @returns an array of Vector3
  27131. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27132. */
  27133. getFacetLocalNormals(): Vector3[];
  27134. /**
  27135. * Returns the facetLocalPositions array.
  27136. * The facet positions are expressed in the mesh local space
  27137. * @returns an array of Vector3
  27138. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27139. */
  27140. getFacetLocalPositions(): Vector3[];
  27141. /**
  27142. * Returns the facetLocalPartioning array
  27143. * @returns an array of array of numbers
  27144. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27145. */
  27146. getFacetLocalPartitioning(): number[][];
  27147. /**
  27148. * Returns the i-th facet position in the world system.
  27149. * This method allocates a new Vector3 per call
  27150. * @param i defines the facet index
  27151. * @returns a new Vector3
  27152. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27153. */
  27154. getFacetPosition(i: number): Vector3;
  27155. /**
  27156. * Sets the reference Vector3 with the i-th facet position in the world system
  27157. * @param i defines the facet index
  27158. * @param ref defines the target vector
  27159. * @returns the current mesh
  27160. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27161. */
  27162. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27163. /**
  27164. * Returns the i-th facet normal in the world system.
  27165. * This method allocates a new Vector3 per call
  27166. * @param i defines the facet index
  27167. * @returns a new Vector3
  27168. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27169. */
  27170. getFacetNormal(i: number): Vector3;
  27171. /**
  27172. * Sets the reference Vector3 with the i-th facet normal in the world system
  27173. * @param i defines the facet index
  27174. * @param ref defines the target vector
  27175. * @returns the current mesh
  27176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27177. */
  27178. getFacetNormalToRef(i: number, ref: Vector3): this;
  27179. /**
  27180. * 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)
  27181. * @param x defines x coordinate
  27182. * @param y defines y coordinate
  27183. * @param z defines z coordinate
  27184. * @returns the array of facet indexes
  27185. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27186. */
  27187. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27188. /**
  27189. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27190. * @param projected sets as the (x,y,z) world projection on the facet
  27191. * @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
  27192. * @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
  27193. * @param x defines x coordinate
  27194. * @param y defines y coordinate
  27195. * @param z defines z coordinate
  27196. * @returns the face index if found (or null instead)
  27197. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27198. */
  27199. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27200. /**
  27201. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27202. * @param projected sets as the (x,y,z) local projection on the facet
  27203. * @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
  27204. * @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
  27205. * @param x defines x coordinate
  27206. * @param y defines y coordinate
  27207. * @param z defines z coordinate
  27208. * @returns the face index if found (or null instead)
  27209. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27210. */
  27211. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27212. /**
  27213. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27214. * @returns the parameters
  27215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27216. */
  27217. getFacetDataParameters(): any;
  27218. /**
  27219. * Disables the feature FacetData and frees the related memory
  27220. * @returns the current mesh
  27221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27222. */
  27223. disableFacetData(): AbstractMesh;
  27224. /**
  27225. * Updates the AbstractMesh indices array
  27226. * @param indices defines the data source
  27227. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27228. * @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)
  27229. * @returns the current mesh
  27230. */
  27231. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27232. /**
  27233. * Creates new normals data for the mesh
  27234. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27235. * @returns the current mesh
  27236. */
  27237. createNormals(updatable: boolean): AbstractMesh;
  27238. /**
  27239. * Align the mesh with a normal
  27240. * @param normal defines the normal to use
  27241. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27242. * @returns the current mesh
  27243. */
  27244. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27245. /** @hidden */
  27246. _checkOcclusionQuery(): boolean;
  27247. /**
  27248. * Disables the mesh edge rendering mode
  27249. * @returns the currentAbstractMesh
  27250. */
  27251. disableEdgesRendering(): AbstractMesh;
  27252. /**
  27253. * Enables the edge rendering mode on the mesh.
  27254. * This mode makes the mesh edges visible
  27255. * @param epsilon defines the maximal distance between two angles to detect a face
  27256. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27257. * @returns the currentAbstractMesh
  27258. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27259. */
  27260. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27261. }
  27262. }
  27263. declare module "babylonjs/Actions/actionEvent" {
  27264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27265. import { Nullable } from "babylonjs/types";
  27266. import { Sprite } from "babylonjs/Sprites/sprite";
  27267. import { Scene } from "babylonjs/scene";
  27268. import { Vector2 } from "babylonjs/Maths/math.vector";
  27269. /**
  27270. * Interface used to define ActionEvent
  27271. */
  27272. export interface IActionEvent {
  27273. /** The mesh or sprite that triggered the action */
  27274. source: any;
  27275. /** The X mouse cursor position at the time of the event */
  27276. pointerX: number;
  27277. /** The Y mouse cursor position at the time of the event */
  27278. pointerY: number;
  27279. /** The mesh that is currently pointed at (can be null) */
  27280. meshUnderPointer: Nullable<AbstractMesh>;
  27281. /** the original (browser) event that triggered the ActionEvent */
  27282. sourceEvent?: any;
  27283. /** additional data for the event */
  27284. additionalData?: any;
  27285. }
  27286. /**
  27287. * ActionEvent is the event being sent when an action is triggered.
  27288. */
  27289. export class ActionEvent implements IActionEvent {
  27290. /** The mesh or sprite that triggered the action */
  27291. source: any;
  27292. /** The X mouse cursor position at the time of the event */
  27293. pointerX: number;
  27294. /** The Y mouse cursor position at the time of the event */
  27295. pointerY: number;
  27296. /** The mesh that is currently pointed at (can be null) */
  27297. meshUnderPointer: Nullable<AbstractMesh>;
  27298. /** the original (browser) event that triggered the ActionEvent */
  27299. sourceEvent?: any;
  27300. /** additional data for the event */
  27301. additionalData?: any;
  27302. /**
  27303. * Creates a new ActionEvent
  27304. * @param source The mesh or sprite that triggered the action
  27305. * @param pointerX The X mouse cursor position at the time of the event
  27306. * @param pointerY The Y mouse cursor position at the time of the event
  27307. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27308. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27309. * @param additionalData additional data for the event
  27310. */
  27311. constructor(
  27312. /** The mesh or sprite that triggered the action */
  27313. source: any,
  27314. /** The X mouse cursor position at the time of the event */
  27315. pointerX: number,
  27316. /** The Y mouse cursor position at the time of the event */
  27317. pointerY: number,
  27318. /** The mesh that is currently pointed at (can be null) */
  27319. meshUnderPointer: Nullable<AbstractMesh>,
  27320. /** the original (browser) event that triggered the ActionEvent */
  27321. sourceEvent?: any,
  27322. /** additional data for the event */
  27323. additionalData?: any);
  27324. /**
  27325. * Helper function to auto-create an ActionEvent from a source mesh.
  27326. * @param source The source mesh that triggered the event
  27327. * @param evt The original (browser) event
  27328. * @param additionalData additional data for the event
  27329. * @returns the new ActionEvent
  27330. */
  27331. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27332. /**
  27333. * Helper function to auto-create an ActionEvent from a source sprite
  27334. * @param source The source sprite that triggered the event
  27335. * @param scene Scene associated with the sprite
  27336. * @param evt The original (browser) event
  27337. * @param additionalData additional data for the event
  27338. * @returns the new ActionEvent
  27339. */
  27340. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27341. /**
  27342. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27343. * @param scene the scene where the event occurred
  27344. * @param evt The original (browser) event
  27345. * @returns the new ActionEvent
  27346. */
  27347. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27348. /**
  27349. * Helper function to auto-create an ActionEvent from a primitive
  27350. * @param prim defines the target primitive
  27351. * @param pointerPos defines the pointer position
  27352. * @param evt The original (browser) event
  27353. * @param additionalData additional data for the event
  27354. * @returns the new ActionEvent
  27355. */
  27356. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27357. }
  27358. }
  27359. declare module "babylonjs/Actions/abstractActionManager" {
  27360. import { IDisposable } from "babylonjs/scene";
  27361. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27362. import { IAction } from "babylonjs/Actions/action";
  27363. import { Nullable } from "babylonjs/types";
  27364. /**
  27365. * Abstract class used to decouple action Manager from scene and meshes.
  27366. * Do not instantiate.
  27367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27368. */
  27369. export abstract class AbstractActionManager implements IDisposable {
  27370. /** Gets the list of active triggers */
  27371. static Triggers: {
  27372. [key: string]: number;
  27373. };
  27374. /** Gets the cursor to use when hovering items */
  27375. hoverCursor: string;
  27376. /** Gets the list of actions */
  27377. actions: IAction[];
  27378. /**
  27379. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27380. */
  27381. isRecursive: boolean;
  27382. /**
  27383. * Releases all associated resources
  27384. */
  27385. abstract dispose(): void;
  27386. /**
  27387. * Does this action manager has pointer triggers
  27388. */
  27389. abstract readonly hasPointerTriggers: boolean;
  27390. /**
  27391. * Does this action manager has pick triggers
  27392. */
  27393. abstract readonly hasPickTriggers: boolean;
  27394. /**
  27395. * Process a specific trigger
  27396. * @param trigger defines the trigger to process
  27397. * @param evt defines the event details to be processed
  27398. */
  27399. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27400. /**
  27401. * Does this action manager handles actions of any of the given triggers
  27402. * @param triggers defines the triggers to be tested
  27403. * @return a boolean indicating whether one (or more) of the triggers is handled
  27404. */
  27405. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27406. /**
  27407. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27408. * speed.
  27409. * @param triggerA defines the trigger to be tested
  27410. * @param triggerB defines the trigger to be tested
  27411. * @return a boolean indicating whether one (or more) of the triggers is handled
  27412. */
  27413. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27414. /**
  27415. * Does this action manager handles actions of a given trigger
  27416. * @param trigger defines the trigger to be tested
  27417. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27418. * @return whether the trigger is handled
  27419. */
  27420. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27421. /**
  27422. * Serialize this manager to a JSON object
  27423. * @param name defines the property name to store this manager
  27424. * @returns a JSON representation of this manager
  27425. */
  27426. abstract serialize(name: string): any;
  27427. /**
  27428. * Registers an action to this action manager
  27429. * @param action defines the action to be registered
  27430. * @return the action amended (prepared) after registration
  27431. */
  27432. abstract registerAction(action: IAction): Nullable<IAction>;
  27433. /**
  27434. * Unregisters an action to this action manager
  27435. * @param action defines the action to be unregistered
  27436. * @return a boolean indicating whether the action has been unregistered
  27437. */
  27438. abstract unregisterAction(action: IAction): Boolean;
  27439. /**
  27440. * Does exist one action manager with at least one trigger
  27441. **/
  27442. static readonly HasTriggers: boolean;
  27443. /**
  27444. * Does exist one action manager with at least one pick trigger
  27445. **/
  27446. static readonly HasPickTriggers: boolean;
  27447. /**
  27448. * Does exist one action manager that handles actions of a given trigger
  27449. * @param trigger defines the trigger to be tested
  27450. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27451. **/
  27452. static HasSpecificTrigger(trigger: number): boolean;
  27453. }
  27454. }
  27455. declare module "babylonjs/node" {
  27456. import { Scene } from "babylonjs/scene";
  27457. import { Nullable } from "babylonjs/types";
  27458. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27459. import { Engine } from "babylonjs/Engines/engine";
  27460. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27461. import { Observable } from "babylonjs/Misc/observable";
  27462. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27463. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27464. import { Animatable } from "babylonjs/Animations/animatable";
  27465. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27466. import { Animation } from "babylonjs/Animations/animation";
  27467. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27469. /**
  27470. * Defines how a node can be built from a string name.
  27471. */
  27472. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27473. /**
  27474. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27475. */
  27476. export class Node implements IBehaviorAware<Node> {
  27477. /** @hidden */
  27478. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27479. private static _NodeConstructors;
  27480. /**
  27481. * Add a new node constructor
  27482. * @param type defines the type name of the node to construct
  27483. * @param constructorFunc defines the constructor function
  27484. */
  27485. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27486. /**
  27487. * Returns a node constructor based on type name
  27488. * @param type defines the type name
  27489. * @param name defines the new node name
  27490. * @param scene defines the hosting scene
  27491. * @param options defines optional options to transmit to constructors
  27492. * @returns the new constructor or null
  27493. */
  27494. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27495. /**
  27496. * Gets or sets the name of the node
  27497. */
  27498. name: string;
  27499. /**
  27500. * Gets or sets the id of the node
  27501. */
  27502. id: string;
  27503. /**
  27504. * Gets or sets the unique id of the node
  27505. */
  27506. uniqueId: number;
  27507. /**
  27508. * Gets or sets a string used to store user defined state for the node
  27509. */
  27510. state: string;
  27511. /**
  27512. * Gets or sets an object used to store user defined information for the node
  27513. */
  27514. metadata: any;
  27515. /**
  27516. * For internal use only. Please do not use.
  27517. */
  27518. reservedDataStore: any;
  27519. /**
  27520. * List of inspectable custom properties (used by the Inspector)
  27521. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27522. */
  27523. inspectableCustomProperties: IInspectable[];
  27524. /**
  27525. * Gets or sets a boolean used to define if the node must be serialized
  27526. */
  27527. doNotSerialize: boolean;
  27528. /** @hidden */
  27529. _isDisposed: boolean;
  27530. /**
  27531. * Gets a list of Animations associated with the node
  27532. */
  27533. animations: import("babylonjs/Animations/animation").Animation[];
  27534. protected _ranges: {
  27535. [name: string]: Nullable<AnimationRange>;
  27536. };
  27537. /**
  27538. * Callback raised when the node is ready to be used
  27539. */
  27540. onReady: Nullable<(node: Node) => void>;
  27541. private _isEnabled;
  27542. private _isParentEnabled;
  27543. private _isReady;
  27544. /** @hidden */
  27545. _currentRenderId: number;
  27546. private _parentUpdateId;
  27547. /** @hidden */
  27548. _childUpdateId: number;
  27549. /** @hidden */
  27550. _waitingParentId: Nullable<string>;
  27551. /** @hidden */
  27552. _scene: Scene;
  27553. /** @hidden */
  27554. _cache: any;
  27555. private _parentNode;
  27556. private _children;
  27557. /** @hidden */
  27558. _worldMatrix: Matrix;
  27559. /** @hidden */
  27560. _worldMatrixDeterminant: number;
  27561. /** @hidden */
  27562. _worldMatrixDeterminantIsDirty: boolean;
  27563. /** @hidden */
  27564. private _sceneRootNodesIndex;
  27565. /**
  27566. * Gets a boolean indicating if the node has been disposed
  27567. * @returns true if the node was disposed
  27568. */
  27569. isDisposed(): boolean;
  27570. /**
  27571. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27572. * @see https://doc.babylonjs.com/how_to/parenting
  27573. */
  27574. parent: Nullable<Node>;
  27575. private addToSceneRootNodes;
  27576. private removeFromSceneRootNodes;
  27577. private _animationPropertiesOverride;
  27578. /**
  27579. * Gets or sets the animation properties override
  27580. */
  27581. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27582. /**
  27583. * Gets a string idenfifying the name of the class
  27584. * @returns "Node" string
  27585. */
  27586. getClassName(): string;
  27587. /** @hidden */
  27588. readonly _isNode: boolean;
  27589. /**
  27590. * An event triggered when the mesh is disposed
  27591. */
  27592. onDisposeObservable: Observable<Node>;
  27593. private _onDisposeObserver;
  27594. /**
  27595. * Sets a callback that will be raised when the node will be disposed
  27596. */
  27597. onDispose: () => void;
  27598. /**
  27599. * Creates a new Node
  27600. * @param name the name and id to be given to this node
  27601. * @param scene the scene this node will be added to
  27602. * @param addToRootNodes the node will be added to scene.rootNodes
  27603. */
  27604. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27605. /**
  27606. * Gets the scene of the node
  27607. * @returns a scene
  27608. */
  27609. getScene(): Scene;
  27610. /**
  27611. * Gets the engine of the node
  27612. * @returns a Engine
  27613. */
  27614. getEngine(): Engine;
  27615. private _behaviors;
  27616. /**
  27617. * Attach a behavior to the node
  27618. * @see http://doc.babylonjs.com/features/behaviour
  27619. * @param behavior defines the behavior to attach
  27620. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27621. * @returns the current Node
  27622. */
  27623. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27624. /**
  27625. * Remove an attached behavior
  27626. * @see http://doc.babylonjs.com/features/behaviour
  27627. * @param behavior defines the behavior to attach
  27628. * @returns the current Node
  27629. */
  27630. removeBehavior(behavior: Behavior<Node>): Node;
  27631. /**
  27632. * Gets the list of attached behaviors
  27633. * @see http://doc.babylonjs.com/features/behaviour
  27634. */
  27635. readonly behaviors: Behavior<Node>[];
  27636. /**
  27637. * Gets an attached behavior by name
  27638. * @param name defines the name of the behavior to look for
  27639. * @see http://doc.babylonjs.com/features/behaviour
  27640. * @returns null if behavior was not found else the requested behavior
  27641. */
  27642. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27643. /**
  27644. * Returns the latest update of the World matrix
  27645. * @returns a Matrix
  27646. */
  27647. getWorldMatrix(): Matrix;
  27648. /** @hidden */
  27649. _getWorldMatrixDeterminant(): number;
  27650. /**
  27651. * Returns directly the latest state of the mesh World matrix.
  27652. * A Matrix is returned.
  27653. */
  27654. readonly worldMatrixFromCache: Matrix;
  27655. /** @hidden */
  27656. _initCache(): void;
  27657. /** @hidden */
  27658. updateCache(force?: boolean): void;
  27659. /** @hidden */
  27660. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27661. /** @hidden */
  27662. _updateCache(ignoreParentClass?: boolean): void;
  27663. /** @hidden */
  27664. _isSynchronized(): boolean;
  27665. /** @hidden */
  27666. _markSyncedWithParent(): void;
  27667. /** @hidden */
  27668. isSynchronizedWithParent(): boolean;
  27669. /** @hidden */
  27670. isSynchronized(): boolean;
  27671. /**
  27672. * Is this node ready to be used/rendered
  27673. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27674. * @return true if the node is ready
  27675. */
  27676. isReady(completeCheck?: boolean): boolean;
  27677. /**
  27678. * Is this node enabled?
  27679. * 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
  27680. * @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
  27681. * @return whether this node (and its parent) is enabled
  27682. */
  27683. isEnabled(checkAncestors?: boolean): boolean;
  27684. /** @hidden */
  27685. protected _syncParentEnabledState(): void;
  27686. /**
  27687. * Set the enabled state of this node
  27688. * @param value defines the new enabled state
  27689. */
  27690. setEnabled(value: boolean): void;
  27691. /**
  27692. * Is this node a descendant of the given node?
  27693. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27694. * @param ancestor defines the parent node to inspect
  27695. * @returns a boolean indicating if this node is a descendant of the given node
  27696. */
  27697. isDescendantOf(ancestor: Node): boolean;
  27698. /** @hidden */
  27699. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27700. /**
  27701. * Will return all nodes that have this node as ascendant
  27702. * @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
  27703. * @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
  27704. * @return all children nodes of all types
  27705. */
  27706. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27707. /**
  27708. * Get all child-meshes of this node
  27709. * @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)
  27710. * @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
  27711. * @returns an array of AbstractMesh
  27712. */
  27713. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27714. /**
  27715. * Get all direct children of this node
  27716. * @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
  27717. * @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)
  27718. * @returns an array of Node
  27719. */
  27720. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27721. /** @hidden */
  27722. _setReady(state: boolean): void;
  27723. /**
  27724. * Get an animation by name
  27725. * @param name defines the name of the animation to look for
  27726. * @returns null if not found else the requested animation
  27727. */
  27728. getAnimationByName(name: string): Nullable<Animation>;
  27729. /**
  27730. * Creates an animation range for this node
  27731. * @param name defines the name of the range
  27732. * @param from defines the starting key
  27733. * @param to defines the end key
  27734. */
  27735. createAnimationRange(name: string, from: number, to: number): void;
  27736. /**
  27737. * Delete a specific animation range
  27738. * @param name defines the name of the range to delete
  27739. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27740. */
  27741. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27742. /**
  27743. * Get an animation range by name
  27744. * @param name defines the name of the animation range to look for
  27745. * @returns null if not found else the requested animation range
  27746. */
  27747. getAnimationRange(name: string): Nullable<AnimationRange>;
  27748. /**
  27749. * Gets the list of all animation ranges defined on this node
  27750. * @returns an array
  27751. */
  27752. getAnimationRanges(): Nullable<AnimationRange>[];
  27753. /**
  27754. * Will start the animation sequence
  27755. * @param name defines the range frames for animation sequence
  27756. * @param loop defines if the animation should loop (false by default)
  27757. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27758. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27759. * @returns the object created for this animation. If range does not exist, it will return null
  27760. */
  27761. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27762. /**
  27763. * Serialize animation ranges into a JSON compatible object
  27764. * @returns serialization object
  27765. */
  27766. serializeAnimationRanges(): any;
  27767. /**
  27768. * Computes the world matrix of the node
  27769. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27770. * @returns the world matrix
  27771. */
  27772. computeWorldMatrix(force?: boolean): Matrix;
  27773. /**
  27774. * Releases resources associated with this node.
  27775. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27776. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27777. */
  27778. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27779. /**
  27780. * Parse animation range data from a serialization object and store them into a given node
  27781. * @param node defines where to store the animation ranges
  27782. * @param parsedNode defines the serialization object to read data from
  27783. * @param scene defines the hosting scene
  27784. */
  27785. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27786. /**
  27787. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27788. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27789. * @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
  27790. * @returns the new bounding vectors
  27791. */
  27792. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27793. min: Vector3;
  27794. max: Vector3;
  27795. };
  27796. }
  27797. }
  27798. declare module "babylonjs/Animations/animation" {
  27799. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27800. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27801. import { Color3 } from "babylonjs/Maths/math.color";
  27802. import { Nullable } from "babylonjs/types";
  27803. import { Scene } from "babylonjs/scene";
  27804. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27805. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27806. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27807. import { Node } from "babylonjs/node";
  27808. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27809. import { Size } from "babylonjs/Maths/math.size";
  27810. import { Animatable } from "babylonjs/Animations/animatable";
  27811. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27812. /**
  27813. * @hidden
  27814. */
  27815. export class _IAnimationState {
  27816. key: number;
  27817. repeatCount: number;
  27818. workValue?: any;
  27819. loopMode?: number;
  27820. offsetValue?: any;
  27821. highLimitValue?: any;
  27822. }
  27823. /**
  27824. * Class used to store any kind of animation
  27825. */
  27826. export class Animation {
  27827. /**Name of the animation */
  27828. name: string;
  27829. /**Property to animate */
  27830. targetProperty: string;
  27831. /**The frames per second of the animation */
  27832. framePerSecond: number;
  27833. /**The data type of the animation */
  27834. dataType: number;
  27835. /**The loop mode of the animation */
  27836. loopMode?: number | undefined;
  27837. /**Specifies if blending should be enabled */
  27838. enableBlending?: boolean | undefined;
  27839. /**
  27840. * Use matrix interpolation instead of using direct key value when animating matrices
  27841. */
  27842. static AllowMatricesInterpolation: boolean;
  27843. /**
  27844. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27845. */
  27846. static AllowMatrixDecomposeForInterpolation: boolean;
  27847. /**
  27848. * Stores the key frames of the animation
  27849. */
  27850. private _keys;
  27851. /**
  27852. * Stores the easing function of the animation
  27853. */
  27854. private _easingFunction;
  27855. /**
  27856. * @hidden Internal use only
  27857. */
  27858. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27859. /**
  27860. * The set of event that will be linked to this animation
  27861. */
  27862. private _events;
  27863. /**
  27864. * Stores an array of target property paths
  27865. */
  27866. targetPropertyPath: string[];
  27867. /**
  27868. * Stores the blending speed of the animation
  27869. */
  27870. blendingSpeed: number;
  27871. /**
  27872. * Stores the animation ranges for the animation
  27873. */
  27874. private _ranges;
  27875. /**
  27876. * @hidden Internal use
  27877. */
  27878. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27879. /**
  27880. * Sets up an animation
  27881. * @param property The property to animate
  27882. * @param animationType The animation type to apply
  27883. * @param framePerSecond The frames per second of the animation
  27884. * @param easingFunction The easing function used in the animation
  27885. * @returns The created animation
  27886. */
  27887. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27888. /**
  27889. * Create and start an animation on a node
  27890. * @param name defines the name of the global animation that will be run on all nodes
  27891. * @param node defines the root node where the animation will take place
  27892. * @param targetProperty defines property to animate
  27893. * @param framePerSecond defines the number of frame per second yo use
  27894. * @param totalFrame defines the number of frames in total
  27895. * @param from defines the initial value
  27896. * @param to defines the final value
  27897. * @param loopMode defines which loop mode you want to use (off by default)
  27898. * @param easingFunction defines the easing function to use (linear by default)
  27899. * @param onAnimationEnd defines the callback to call when animation end
  27900. * @returns the animatable created for this animation
  27901. */
  27902. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27903. /**
  27904. * Create and start an animation on a node and its descendants
  27905. * @param name defines the name of the global animation that will be run on all nodes
  27906. * @param node defines the root node where the animation will take place
  27907. * @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
  27908. * @param targetProperty defines property to animate
  27909. * @param framePerSecond defines the number of frame per second to use
  27910. * @param totalFrame defines the number of frames in total
  27911. * @param from defines the initial value
  27912. * @param to defines the final value
  27913. * @param loopMode defines which loop mode you want to use (off by default)
  27914. * @param easingFunction defines the easing function to use (linear by default)
  27915. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27916. * @returns the list of animatables created for all nodes
  27917. * @example https://www.babylonjs-playground.com/#MH0VLI
  27918. */
  27919. 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[]>;
  27920. /**
  27921. * Creates a new animation, merges it with the existing animations and starts it
  27922. * @param name Name of the animation
  27923. * @param node Node which contains the scene that begins the animations
  27924. * @param targetProperty Specifies which property to animate
  27925. * @param framePerSecond The frames per second of the animation
  27926. * @param totalFrame The total number of frames
  27927. * @param from The frame at the beginning of the animation
  27928. * @param to The frame at the end of the animation
  27929. * @param loopMode Specifies the loop mode of the animation
  27930. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27931. * @param onAnimationEnd Callback to run once the animation is complete
  27932. * @returns Nullable animation
  27933. */
  27934. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27935. /**
  27936. * Transition property of an host to the target Value
  27937. * @param property The property to transition
  27938. * @param targetValue The target Value of the property
  27939. * @param host The object where the property to animate belongs
  27940. * @param scene Scene used to run the animation
  27941. * @param frameRate Framerate (in frame/s) to use
  27942. * @param transition The transition type we want to use
  27943. * @param duration The duration of the animation, in milliseconds
  27944. * @param onAnimationEnd Callback trigger at the end of the animation
  27945. * @returns Nullable animation
  27946. */
  27947. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27948. /**
  27949. * Return the array of runtime animations currently using this animation
  27950. */
  27951. readonly runtimeAnimations: RuntimeAnimation[];
  27952. /**
  27953. * Specifies if any of the runtime animations are currently running
  27954. */
  27955. readonly hasRunningRuntimeAnimations: boolean;
  27956. /**
  27957. * Initializes the animation
  27958. * @param name Name of the animation
  27959. * @param targetProperty Property to animate
  27960. * @param framePerSecond The frames per second of the animation
  27961. * @param dataType The data type of the animation
  27962. * @param loopMode The loop mode of the animation
  27963. * @param enableBlending Specifies if blending should be enabled
  27964. */
  27965. constructor(
  27966. /**Name of the animation */
  27967. name: string,
  27968. /**Property to animate */
  27969. targetProperty: string,
  27970. /**The frames per second of the animation */
  27971. framePerSecond: number,
  27972. /**The data type of the animation */
  27973. dataType: number,
  27974. /**The loop mode of the animation */
  27975. loopMode?: number | undefined,
  27976. /**Specifies if blending should be enabled */
  27977. enableBlending?: boolean | undefined);
  27978. /**
  27979. * Converts the animation to a string
  27980. * @param fullDetails support for multiple levels of logging within scene loading
  27981. * @returns String form of the animation
  27982. */
  27983. toString(fullDetails?: boolean): string;
  27984. /**
  27985. * Add an event to this animation
  27986. * @param event Event to add
  27987. */
  27988. addEvent(event: AnimationEvent): void;
  27989. /**
  27990. * Remove all events found at the given frame
  27991. * @param frame The frame to remove events from
  27992. */
  27993. removeEvents(frame: number): void;
  27994. /**
  27995. * Retrieves all the events from the animation
  27996. * @returns Events from the animation
  27997. */
  27998. getEvents(): AnimationEvent[];
  27999. /**
  28000. * Creates an animation range
  28001. * @param name Name of the animation range
  28002. * @param from Starting frame of the animation range
  28003. * @param to Ending frame of the animation
  28004. */
  28005. createRange(name: string, from: number, to: number): void;
  28006. /**
  28007. * Deletes an animation range by name
  28008. * @param name Name of the animation range to delete
  28009. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28010. */
  28011. deleteRange(name: string, deleteFrames?: boolean): void;
  28012. /**
  28013. * Gets the animation range by name, or null if not defined
  28014. * @param name Name of the animation range
  28015. * @returns Nullable animation range
  28016. */
  28017. getRange(name: string): Nullable<AnimationRange>;
  28018. /**
  28019. * Gets the key frames from the animation
  28020. * @returns The key frames of the animation
  28021. */
  28022. getKeys(): Array<IAnimationKey>;
  28023. /**
  28024. * Gets the highest frame rate of the animation
  28025. * @returns Highest frame rate of the animation
  28026. */
  28027. getHighestFrame(): number;
  28028. /**
  28029. * Gets the easing function of the animation
  28030. * @returns Easing function of the animation
  28031. */
  28032. getEasingFunction(): IEasingFunction;
  28033. /**
  28034. * Sets the easing function of the animation
  28035. * @param easingFunction A custom mathematical formula for animation
  28036. */
  28037. setEasingFunction(easingFunction: EasingFunction): void;
  28038. /**
  28039. * Interpolates a scalar linearly
  28040. * @param startValue Start value of the animation curve
  28041. * @param endValue End value of the animation curve
  28042. * @param gradient Scalar amount to interpolate
  28043. * @returns Interpolated scalar value
  28044. */
  28045. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28046. /**
  28047. * Interpolates a scalar cubically
  28048. * @param startValue Start value of the animation curve
  28049. * @param outTangent End tangent of the animation
  28050. * @param endValue End value of the animation curve
  28051. * @param inTangent Start tangent of the animation curve
  28052. * @param gradient Scalar amount to interpolate
  28053. * @returns Interpolated scalar value
  28054. */
  28055. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28056. /**
  28057. * Interpolates a quaternion using a spherical linear interpolation
  28058. * @param startValue Start value of the animation curve
  28059. * @param endValue End value of the animation curve
  28060. * @param gradient Scalar amount to interpolate
  28061. * @returns Interpolated quaternion value
  28062. */
  28063. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28064. /**
  28065. * Interpolates a quaternion cubically
  28066. * @param startValue Start value of the animation curve
  28067. * @param outTangent End tangent of the animation curve
  28068. * @param endValue End value of the animation curve
  28069. * @param inTangent Start tangent of the animation curve
  28070. * @param gradient Scalar amount to interpolate
  28071. * @returns Interpolated quaternion value
  28072. */
  28073. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28074. /**
  28075. * Interpolates a Vector3 linearl
  28076. * @param startValue Start value of the animation curve
  28077. * @param endValue End value of the animation curve
  28078. * @param gradient Scalar amount to interpolate
  28079. * @returns Interpolated scalar value
  28080. */
  28081. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28082. /**
  28083. * Interpolates a Vector3 cubically
  28084. * @param startValue Start value of the animation curve
  28085. * @param outTangent End tangent of the animation
  28086. * @param endValue End value of the animation curve
  28087. * @param inTangent Start tangent of the animation curve
  28088. * @param gradient Scalar amount to interpolate
  28089. * @returns InterpolatedVector3 value
  28090. */
  28091. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28092. /**
  28093. * Interpolates a Vector2 linearly
  28094. * @param startValue Start value of the animation curve
  28095. * @param endValue End value of the animation curve
  28096. * @param gradient Scalar amount to interpolate
  28097. * @returns Interpolated Vector2 value
  28098. */
  28099. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28100. /**
  28101. * Interpolates a Vector2 cubically
  28102. * @param startValue Start value of the animation curve
  28103. * @param outTangent End tangent of the animation
  28104. * @param endValue End value of the animation curve
  28105. * @param inTangent Start tangent of the animation curve
  28106. * @param gradient Scalar amount to interpolate
  28107. * @returns Interpolated Vector2 value
  28108. */
  28109. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28110. /**
  28111. * Interpolates a size linearly
  28112. * @param startValue Start value of the animation curve
  28113. * @param endValue End value of the animation curve
  28114. * @param gradient Scalar amount to interpolate
  28115. * @returns Interpolated Size value
  28116. */
  28117. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28118. /**
  28119. * Interpolates a Color3 linearly
  28120. * @param startValue Start value of the animation curve
  28121. * @param endValue End value of the animation curve
  28122. * @param gradient Scalar amount to interpolate
  28123. * @returns Interpolated Color3 value
  28124. */
  28125. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28126. /**
  28127. * @hidden Internal use only
  28128. */
  28129. _getKeyValue(value: any): any;
  28130. /**
  28131. * @hidden Internal use only
  28132. */
  28133. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28134. /**
  28135. * Defines the function to use to interpolate matrices
  28136. * @param startValue defines the start matrix
  28137. * @param endValue defines the end matrix
  28138. * @param gradient defines the gradient between both matrices
  28139. * @param result defines an optional target matrix where to store the interpolation
  28140. * @returns the interpolated matrix
  28141. */
  28142. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28143. /**
  28144. * Makes a copy of the animation
  28145. * @returns Cloned animation
  28146. */
  28147. clone(): Animation;
  28148. /**
  28149. * Sets the key frames of the animation
  28150. * @param values The animation key frames to set
  28151. */
  28152. setKeys(values: Array<IAnimationKey>): void;
  28153. /**
  28154. * Serializes the animation to an object
  28155. * @returns Serialized object
  28156. */
  28157. serialize(): any;
  28158. /**
  28159. * Float animation type
  28160. */
  28161. private static _ANIMATIONTYPE_FLOAT;
  28162. /**
  28163. * Vector3 animation type
  28164. */
  28165. private static _ANIMATIONTYPE_VECTOR3;
  28166. /**
  28167. * Quaternion animation type
  28168. */
  28169. private static _ANIMATIONTYPE_QUATERNION;
  28170. /**
  28171. * Matrix animation type
  28172. */
  28173. private static _ANIMATIONTYPE_MATRIX;
  28174. /**
  28175. * Color3 animation type
  28176. */
  28177. private static _ANIMATIONTYPE_COLOR3;
  28178. /**
  28179. * Vector2 animation type
  28180. */
  28181. private static _ANIMATIONTYPE_VECTOR2;
  28182. /**
  28183. * Size animation type
  28184. */
  28185. private static _ANIMATIONTYPE_SIZE;
  28186. /**
  28187. * Relative Loop Mode
  28188. */
  28189. private static _ANIMATIONLOOPMODE_RELATIVE;
  28190. /**
  28191. * Cycle Loop Mode
  28192. */
  28193. private static _ANIMATIONLOOPMODE_CYCLE;
  28194. /**
  28195. * Constant Loop Mode
  28196. */
  28197. private static _ANIMATIONLOOPMODE_CONSTANT;
  28198. /**
  28199. * Get the float animation type
  28200. */
  28201. static readonly ANIMATIONTYPE_FLOAT: number;
  28202. /**
  28203. * Get the Vector3 animation type
  28204. */
  28205. static readonly ANIMATIONTYPE_VECTOR3: number;
  28206. /**
  28207. * Get the Vector2 animation type
  28208. */
  28209. static readonly ANIMATIONTYPE_VECTOR2: number;
  28210. /**
  28211. * Get the Size animation type
  28212. */
  28213. static readonly ANIMATIONTYPE_SIZE: number;
  28214. /**
  28215. * Get the Quaternion animation type
  28216. */
  28217. static readonly ANIMATIONTYPE_QUATERNION: number;
  28218. /**
  28219. * Get the Matrix animation type
  28220. */
  28221. static readonly ANIMATIONTYPE_MATRIX: number;
  28222. /**
  28223. * Get the Color3 animation type
  28224. */
  28225. static readonly ANIMATIONTYPE_COLOR3: number;
  28226. /**
  28227. * Get the Relative Loop Mode
  28228. */
  28229. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28230. /**
  28231. * Get the Cycle Loop Mode
  28232. */
  28233. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28234. /**
  28235. * Get the Constant Loop Mode
  28236. */
  28237. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28238. /** @hidden */
  28239. static _UniversalLerp(left: any, right: any, amount: number): any;
  28240. /**
  28241. * Parses an animation object and creates an animation
  28242. * @param parsedAnimation Parsed animation object
  28243. * @returns Animation object
  28244. */
  28245. static Parse(parsedAnimation: any): Animation;
  28246. /**
  28247. * Appends the serialized animations from the source animations
  28248. * @param source Source containing the animations
  28249. * @param destination Target to store the animations
  28250. */
  28251. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28252. }
  28253. }
  28254. declare module "babylonjs/Animations/animatable.interface" {
  28255. import { Nullable } from "babylonjs/types";
  28256. import { Animation } from "babylonjs/Animations/animation";
  28257. /**
  28258. * Interface containing an array of animations
  28259. */
  28260. export interface IAnimatable {
  28261. /**
  28262. * Array of animations
  28263. */
  28264. animations: Nullable<Array<Animation>>;
  28265. }
  28266. }
  28267. declare module "babylonjs/Materials/fresnelParameters" {
  28268. import { Color3 } from "babylonjs/Maths/math.color";
  28269. /**
  28270. * This represents all the required information to add a fresnel effect on a material:
  28271. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28272. */
  28273. export class FresnelParameters {
  28274. private _isEnabled;
  28275. /**
  28276. * Define if the fresnel effect is enable or not.
  28277. */
  28278. isEnabled: boolean;
  28279. /**
  28280. * Define the color used on edges (grazing angle)
  28281. */
  28282. leftColor: Color3;
  28283. /**
  28284. * Define the color used on center
  28285. */
  28286. rightColor: Color3;
  28287. /**
  28288. * Define bias applied to computed fresnel term
  28289. */
  28290. bias: number;
  28291. /**
  28292. * Defined the power exponent applied to fresnel term
  28293. */
  28294. power: number;
  28295. /**
  28296. * Clones the current fresnel and its valuues
  28297. * @returns a clone fresnel configuration
  28298. */
  28299. clone(): FresnelParameters;
  28300. /**
  28301. * Serializes the current fresnel parameters to a JSON representation.
  28302. * @return the JSON serialization
  28303. */
  28304. serialize(): any;
  28305. /**
  28306. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28307. * @param parsedFresnelParameters Define the JSON representation
  28308. * @returns the parsed parameters
  28309. */
  28310. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28311. }
  28312. }
  28313. declare module "babylonjs/Misc/decorators" {
  28314. import { Nullable } from "babylonjs/types";
  28315. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28316. import { Scene } from "babylonjs/scene";
  28317. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28318. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28319. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28320. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28321. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28322. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28323. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28324. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28325. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28326. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28327. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28328. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28329. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28330. /**
  28331. * Decorator used to define property that can be serialized as reference to a camera
  28332. * @param sourceName defines the name of the property to decorate
  28333. */
  28334. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28335. /**
  28336. * Class used to help serialization objects
  28337. */
  28338. export class SerializationHelper {
  28339. /** @hidden */
  28340. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28341. /** @hidden */
  28342. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28343. /** @hidden */
  28344. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28345. /** @hidden */
  28346. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28347. /**
  28348. * Appends the serialized animations from the source animations
  28349. * @param source Source containing the animations
  28350. * @param destination Target to store the animations
  28351. */
  28352. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28353. /**
  28354. * Static function used to serialized a specific entity
  28355. * @param entity defines the entity to serialize
  28356. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28357. * @returns a JSON compatible object representing the serialization of the entity
  28358. */
  28359. static Serialize<T>(entity: T, serializationObject?: any): any;
  28360. /**
  28361. * Creates a new entity from a serialization data object
  28362. * @param creationFunction defines a function used to instanciated the new entity
  28363. * @param source defines the source serialization data
  28364. * @param scene defines the hosting scene
  28365. * @param rootUrl defines the root url for resources
  28366. * @returns a new entity
  28367. */
  28368. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28369. /**
  28370. * Clones an object
  28371. * @param creationFunction defines the function used to instanciate the new object
  28372. * @param source defines the source object
  28373. * @returns the cloned object
  28374. */
  28375. static Clone<T>(creationFunction: () => T, source: T): T;
  28376. /**
  28377. * Instanciates a new object based on a source one (some data will be shared between both object)
  28378. * @param creationFunction defines the function used to instanciate the new object
  28379. * @param source defines the source object
  28380. * @returns the new object
  28381. */
  28382. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28383. }
  28384. }
  28385. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28386. import { Nullable } from "babylonjs/types";
  28387. /**
  28388. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28389. */
  28390. export interface CubeMapInfo {
  28391. /**
  28392. * The pixel array for the front face.
  28393. * This is stored in format, left to right, up to down format.
  28394. */
  28395. front: Nullable<ArrayBufferView>;
  28396. /**
  28397. * The pixel array for the back face.
  28398. * This is stored in format, left to right, up to down format.
  28399. */
  28400. back: Nullable<ArrayBufferView>;
  28401. /**
  28402. * The pixel array for the left face.
  28403. * This is stored in format, left to right, up to down format.
  28404. */
  28405. left: Nullable<ArrayBufferView>;
  28406. /**
  28407. * The pixel array for the right face.
  28408. * This is stored in format, left to right, up to down format.
  28409. */
  28410. right: Nullable<ArrayBufferView>;
  28411. /**
  28412. * The pixel array for the up face.
  28413. * This is stored in format, left to right, up to down format.
  28414. */
  28415. up: Nullable<ArrayBufferView>;
  28416. /**
  28417. * The pixel array for the down face.
  28418. * This is stored in format, left to right, up to down format.
  28419. */
  28420. down: Nullable<ArrayBufferView>;
  28421. /**
  28422. * The size of the cubemap stored.
  28423. *
  28424. * Each faces will be size * size pixels.
  28425. */
  28426. size: number;
  28427. /**
  28428. * The format of the texture.
  28429. *
  28430. * RGBA, RGB.
  28431. */
  28432. format: number;
  28433. /**
  28434. * The type of the texture data.
  28435. *
  28436. * UNSIGNED_INT, FLOAT.
  28437. */
  28438. type: number;
  28439. /**
  28440. * Specifies whether the texture is in gamma space.
  28441. */
  28442. gammaSpace: boolean;
  28443. }
  28444. /**
  28445. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28446. */
  28447. export class PanoramaToCubeMapTools {
  28448. private static FACE_FRONT;
  28449. private static FACE_BACK;
  28450. private static FACE_RIGHT;
  28451. private static FACE_LEFT;
  28452. private static FACE_DOWN;
  28453. private static FACE_UP;
  28454. /**
  28455. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28456. *
  28457. * @param float32Array The source data.
  28458. * @param inputWidth The width of the input panorama.
  28459. * @param inputHeight The height of the input panorama.
  28460. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28461. * @return The cubemap data
  28462. */
  28463. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28464. private static CreateCubemapTexture;
  28465. private static CalcProjectionSpherical;
  28466. }
  28467. }
  28468. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28469. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28470. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28471. import { Nullable } from "babylonjs/types";
  28472. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28473. /**
  28474. * Helper class dealing with the extraction of spherical polynomial dataArray
  28475. * from a cube map.
  28476. */
  28477. export class CubeMapToSphericalPolynomialTools {
  28478. private static FileFaces;
  28479. /**
  28480. * Converts a texture to the according Spherical Polynomial data.
  28481. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28482. *
  28483. * @param texture The texture to extract the information from.
  28484. * @return The Spherical Polynomial data.
  28485. */
  28486. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28487. /**
  28488. * Converts a cubemap to the according Spherical Polynomial data.
  28489. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28490. *
  28491. * @param cubeInfo The Cube map to extract the information from.
  28492. * @return The Spherical Polynomial data.
  28493. */
  28494. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28495. }
  28496. }
  28497. declare module "babylonjs/Misc/guid" {
  28498. /**
  28499. * Class used to manipulate GUIDs
  28500. */
  28501. export class GUID {
  28502. /**
  28503. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28504. * Be aware Math.random() could cause collisions, but:
  28505. * "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"
  28506. * @returns a pseudo random id
  28507. */
  28508. static RandomId(): string;
  28509. }
  28510. }
  28511. declare module "babylonjs/Materials/Textures/baseTexture" {
  28512. import { Observable } from "babylonjs/Misc/observable";
  28513. import { Nullable } from "babylonjs/types";
  28514. import { Scene } from "babylonjs/scene";
  28515. import { Matrix } from "babylonjs/Maths/math.vector";
  28516. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28517. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28518. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28519. import { ISize } from "babylonjs/Maths/math.size";
  28520. /**
  28521. * Base class of all the textures in babylon.
  28522. * It groups all the common properties the materials, post process, lights... might need
  28523. * in order to make a correct use of the texture.
  28524. */
  28525. export class BaseTexture implements IAnimatable {
  28526. /**
  28527. * Default anisotropic filtering level for the application.
  28528. * It is set to 4 as a good tradeoff between perf and quality.
  28529. */
  28530. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28531. /**
  28532. * Gets or sets the unique id of the texture
  28533. */
  28534. uniqueId: number;
  28535. /**
  28536. * Define the name of the texture.
  28537. */
  28538. name: string;
  28539. /**
  28540. * Gets or sets an object used to store user defined information.
  28541. */
  28542. metadata: any;
  28543. /**
  28544. * For internal use only. Please do not use.
  28545. */
  28546. reservedDataStore: any;
  28547. private _hasAlpha;
  28548. /**
  28549. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28550. */
  28551. hasAlpha: boolean;
  28552. /**
  28553. * Defines if the alpha value should be determined via the rgb values.
  28554. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28555. */
  28556. getAlphaFromRGB: boolean;
  28557. /**
  28558. * Intensity or strength of the texture.
  28559. * It is commonly used by materials to fine tune the intensity of the texture
  28560. */
  28561. level: number;
  28562. /**
  28563. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28564. * This is part of the texture as textures usually maps to one uv set.
  28565. */
  28566. coordinatesIndex: number;
  28567. private _coordinatesMode;
  28568. /**
  28569. * How a texture is mapped.
  28570. *
  28571. * | Value | Type | Description |
  28572. * | ----- | ----------------------------------- | ----------- |
  28573. * | 0 | EXPLICIT_MODE | |
  28574. * | 1 | SPHERICAL_MODE | |
  28575. * | 2 | PLANAR_MODE | |
  28576. * | 3 | CUBIC_MODE | |
  28577. * | 4 | PROJECTION_MODE | |
  28578. * | 5 | SKYBOX_MODE | |
  28579. * | 6 | INVCUBIC_MODE | |
  28580. * | 7 | EQUIRECTANGULAR_MODE | |
  28581. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28582. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28583. */
  28584. coordinatesMode: number;
  28585. /**
  28586. * | Value | Type | Description |
  28587. * | ----- | ------------------ | ----------- |
  28588. * | 0 | CLAMP_ADDRESSMODE | |
  28589. * | 1 | WRAP_ADDRESSMODE | |
  28590. * | 2 | MIRROR_ADDRESSMODE | |
  28591. */
  28592. wrapU: number;
  28593. /**
  28594. * | Value | Type | Description |
  28595. * | ----- | ------------------ | ----------- |
  28596. * | 0 | CLAMP_ADDRESSMODE | |
  28597. * | 1 | WRAP_ADDRESSMODE | |
  28598. * | 2 | MIRROR_ADDRESSMODE | |
  28599. */
  28600. wrapV: number;
  28601. /**
  28602. * | Value | Type | Description |
  28603. * | ----- | ------------------ | ----------- |
  28604. * | 0 | CLAMP_ADDRESSMODE | |
  28605. * | 1 | WRAP_ADDRESSMODE | |
  28606. * | 2 | MIRROR_ADDRESSMODE | |
  28607. */
  28608. wrapR: number;
  28609. /**
  28610. * With compliant hardware and browser (supporting anisotropic filtering)
  28611. * this defines the level of anisotropic filtering in the texture.
  28612. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28613. */
  28614. anisotropicFilteringLevel: number;
  28615. /**
  28616. * Define if the texture is a cube texture or if false a 2d texture.
  28617. */
  28618. isCube: boolean;
  28619. /**
  28620. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28621. */
  28622. is3D: boolean;
  28623. /**
  28624. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28625. * HDR texture are usually stored in linear space.
  28626. * This only impacts the PBR and Background materials
  28627. */
  28628. gammaSpace: boolean;
  28629. /**
  28630. * Gets or sets whether or not the texture contains RGBD data.
  28631. */
  28632. isRGBD: boolean;
  28633. /**
  28634. * Is Z inverted in the texture (useful in a cube texture).
  28635. */
  28636. invertZ: boolean;
  28637. /**
  28638. * Are mip maps generated for this texture or not.
  28639. */
  28640. readonly noMipmap: boolean;
  28641. /**
  28642. * @hidden
  28643. */
  28644. lodLevelInAlpha: boolean;
  28645. /**
  28646. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28647. */
  28648. lodGenerationOffset: number;
  28649. /**
  28650. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28651. */
  28652. lodGenerationScale: number;
  28653. /**
  28654. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28655. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28656. * average roughness values.
  28657. */
  28658. linearSpecularLOD: boolean;
  28659. /**
  28660. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28661. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28662. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28663. */
  28664. irradianceTexture: Nullable<BaseTexture>;
  28665. /**
  28666. * Define if the texture is a render target.
  28667. */
  28668. isRenderTarget: boolean;
  28669. /**
  28670. * Define the unique id of the texture in the scene.
  28671. */
  28672. readonly uid: string;
  28673. /**
  28674. * Return a string representation of the texture.
  28675. * @returns the texture as a string
  28676. */
  28677. toString(): string;
  28678. /**
  28679. * Get the class name of the texture.
  28680. * @returns "BaseTexture"
  28681. */
  28682. getClassName(): string;
  28683. /**
  28684. * Define the list of animation attached to the texture.
  28685. */
  28686. animations: import("babylonjs/Animations/animation").Animation[];
  28687. /**
  28688. * An event triggered when the texture is disposed.
  28689. */
  28690. onDisposeObservable: Observable<BaseTexture>;
  28691. private _onDisposeObserver;
  28692. /**
  28693. * Callback triggered when the texture has been disposed.
  28694. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28695. */
  28696. onDispose: () => void;
  28697. /**
  28698. * Define the current state of the loading sequence when in delayed load mode.
  28699. */
  28700. delayLoadState: number;
  28701. private _scene;
  28702. /** @hidden */
  28703. _texture: Nullable<InternalTexture>;
  28704. private _uid;
  28705. /**
  28706. * Define if the texture is preventinga material to render or not.
  28707. * If not and the texture is not ready, the engine will use a default black texture instead.
  28708. */
  28709. readonly isBlocking: boolean;
  28710. /**
  28711. * Instantiates a new BaseTexture.
  28712. * Base class of all the textures in babylon.
  28713. * It groups all the common properties the materials, post process, lights... might need
  28714. * in order to make a correct use of the texture.
  28715. * @param scene Define the scene the texture blongs to
  28716. */
  28717. constructor(scene: Nullable<Scene>);
  28718. /**
  28719. * Get the scene the texture belongs to.
  28720. * @returns the scene or null if undefined
  28721. */
  28722. getScene(): Nullable<Scene>;
  28723. /**
  28724. * Get the texture transform matrix used to offset tile the texture for istance.
  28725. * @returns the transformation matrix
  28726. */
  28727. getTextureMatrix(): Matrix;
  28728. /**
  28729. * Get the texture reflection matrix used to rotate/transform the reflection.
  28730. * @returns the reflection matrix
  28731. */
  28732. getReflectionTextureMatrix(): Matrix;
  28733. /**
  28734. * Get the underlying lower level texture from Babylon.
  28735. * @returns the insternal texture
  28736. */
  28737. getInternalTexture(): Nullable<InternalTexture>;
  28738. /**
  28739. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28740. * @returns true if ready or not blocking
  28741. */
  28742. isReadyOrNotBlocking(): boolean;
  28743. /**
  28744. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28745. * @returns true if fully ready
  28746. */
  28747. isReady(): boolean;
  28748. private _cachedSize;
  28749. /**
  28750. * Get the size of the texture.
  28751. * @returns the texture size.
  28752. */
  28753. getSize(): ISize;
  28754. /**
  28755. * Get the base size of the texture.
  28756. * It can be different from the size if the texture has been resized for POT for instance
  28757. * @returns the base size
  28758. */
  28759. getBaseSize(): ISize;
  28760. /**
  28761. * Update the sampling mode of the texture.
  28762. * Default is Trilinear mode.
  28763. *
  28764. * | Value | Type | Description |
  28765. * | ----- | ------------------ | ----------- |
  28766. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28767. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28768. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28769. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28770. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28771. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28772. * | 7 | NEAREST_LINEAR | |
  28773. * | 8 | NEAREST_NEAREST | |
  28774. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28775. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28776. * | 11 | LINEAR_LINEAR | |
  28777. * | 12 | LINEAR_NEAREST | |
  28778. *
  28779. * > _mag_: magnification filter (close to the viewer)
  28780. * > _min_: minification filter (far from the viewer)
  28781. * > _mip_: filter used between mip map levels
  28782. *@param samplingMode Define the new sampling mode of the texture
  28783. */
  28784. updateSamplingMode(samplingMode: number): void;
  28785. /**
  28786. * Scales the texture if is `canRescale()`
  28787. * @param ratio the resize factor we want to use to rescale
  28788. */
  28789. scale(ratio: number): void;
  28790. /**
  28791. * Get if the texture can rescale.
  28792. */
  28793. readonly canRescale: boolean;
  28794. /** @hidden */
  28795. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28796. /** @hidden */
  28797. _rebuild(): void;
  28798. /**
  28799. * Triggers the load sequence in delayed load mode.
  28800. */
  28801. delayLoad(): void;
  28802. /**
  28803. * Clones the texture.
  28804. * @returns the cloned texture
  28805. */
  28806. clone(): Nullable<BaseTexture>;
  28807. /**
  28808. * Get the texture underlying type (INT, FLOAT...)
  28809. */
  28810. readonly textureType: number;
  28811. /**
  28812. * Get the texture underlying format (RGB, RGBA...)
  28813. */
  28814. readonly textureFormat: number;
  28815. /**
  28816. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28817. * This will returns an RGBA array buffer containing either in values (0-255) or
  28818. * float values (0-1) depending of the underlying buffer type.
  28819. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28820. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28821. * @param buffer defines a user defined buffer to fill with data (can be null)
  28822. * @returns The Array buffer containing the pixels data.
  28823. */
  28824. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28825. /**
  28826. * Release and destroy the underlying lower level texture aka internalTexture.
  28827. */
  28828. releaseInternalTexture(): void;
  28829. /**
  28830. * Get the polynomial representation of the texture data.
  28831. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28832. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28833. */
  28834. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28835. /** @hidden */
  28836. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28837. /** @hidden */
  28838. readonly _lodTextureMid: Nullable<BaseTexture>;
  28839. /** @hidden */
  28840. readonly _lodTextureLow: Nullable<BaseTexture>;
  28841. /**
  28842. * Dispose the texture and release its associated resources.
  28843. */
  28844. dispose(): void;
  28845. /**
  28846. * Serialize the texture into a JSON representation that can be parsed later on.
  28847. * @returns the JSON representation of the texture
  28848. */
  28849. serialize(): any;
  28850. /**
  28851. * Helper function to be called back once a list of texture contains only ready textures.
  28852. * @param textures Define the list of textures to wait for
  28853. * @param callback Define the callback triggered once the entire list will be ready
  28854. */
  28855. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28856. }
  28857. }
  28858. declare module "babylonjs/Materials/Textures/internalTexture" {
  28859. import { Observable } from "babylonjs/Misc/observable";
  28860. import { Nullable, int } from "babylonjs/types";
  28861. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28862. import { Engine } from "babylonjs/Engines/engine";
  28863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28864. /**
  28865. * Class used to store data associated with WebGL texture data for the engine
  28866. * This class should not be used directly
  28867. */
  28868. export class InternalTexture {
  28869. /** @hidden */
  28870. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28871. /**
  28872. * The source of the texture data is unknown
  28873. */
  28874. static DATASOURCE_UNKNOWN: number;
  28875. /**
  28876. * Texture data comes from an URL
  28877. */
  28878. static DATASOURCE_URL: number;
  28879. /**
  28880. * Texture data is only used for temporary storage
  28881. */
  28882. static DATASOURCE_TEMP: number;
  28883. /**
  28884. * Texture data comes from raw data (ArrayBuffer)
  28885. */
  28886. static DATASOURCE_RAW: number;
  28887. /**
  28888. * Texture content is dynamic (video or dynamic texture)
  28889. */
  28890. static DATASOURCE_DYNAMIC: number;
  28891. /**
  28892. * Texture content is generated by rendering to it
  28893. */
  28894. static DATASOURCE_RENDERTARGET: number;
  28895. /**
  28896. * Texture content is part of a multi render target process
  28897. */
  28898. static DATASOURCE_MULTIRENDERTARGET: number;
  28899. /**
  28900. * Texture data comes from a cube data file
  28901. */
  28902. static DATASOURCE_CUBE: number;
  28903. /**
  28904. * Texture data comes from a raw cube data
  28905. */
  28906. static DATASOURCE_CUBERAW: number;
  28907. /**
  28908. * Texture data come from a prefiltered cube data file
  28909. */
  28910. static DATASOURCE_CUBEPREFILTERED: number;
  28911. /**
  28912. * Texture content is raw 3D data
  28913. */
  28914. static DATASOURCE_RAW3D: number;
  28915. /**
  28916. * Texture content is a depth texture
  28917. */
  28918. static DATASOURCE_DEPTHTEXTURE: number;
  28919. /**
  28920. * Texture data comes from a raw cube data encoded with RGBD
  28921. */
  28922. static DATASOURCE_CUBERAW_RGBD: number;
  28923. /**
  28924. * Defines if the texture is ready
  28925. */
  28926. isReady: boolean;
  28927. /**
  28928. * Defines if the texture is a cube texture
  28929. */
  28930. isCube: boolean;
  28931. /**
  28932. * Defines if the texture contains 3D data
  28933. */
  28934. is3D: boolean;
  28935. /**
  28936. * Defines if the texture contains multiview data
  28937. */
  28938. isMultiview: boolean;
  28939. /**
  28940. * Gets the URL used to load this texture
  28941. */
  28942. url: string;
  28943. /**
  28944. * Gets the sampling mode of the texture
  28945. */
  28946. samplingMode: number;
  28947. /**
  28948. * Gets a boolean indicating if the texture needs mipmaps generation
  28949. */
  28950. generateMipMaps: boolean;
  28951. /**
  28952. * Gets the number of samples used by the texture (WebGL2+ only)
  28953. */
  28954. samples: number;
  28955. /**
  28956. * Gets the type of the texture (int, float...)
  28957. */
  28958. type: number;
  28959. /**
  28960. * Gets the format of the texture (RGB, RGBA...)
  28961. */
  28962. format: number;
  28963. /**
  28964. * Observable called when the texture is loaded
  28965. */
  28966. onLoadedObservable: Observable<InternalTexture>;
  28967. /**
  28968. * Gets the width of the texture
  28969. */
  28970. width: number;
  28971. /**
  28972. * Gets the height of the texture
  28973. */
  28974. height: number;
  28975. /**
  28976. * Gets the depth of the texture
  28977. */
  28978. depth: number;
  28979. /**
  28980. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28981. */
  28982. baseWidth: number;
  28983. /**
  28984. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28985. */
  28986. baseHeight: number;
  28987. /**
  28988. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28989. */
  28990. baseDepth: number;
  28991. /**
  28992. * Gets a boolean indicating if the texture is inverted on Y axis
  28993. */
  28994. invertY: boolean;
  28995. /** @hidden */
  28996. _invertVScale: boolean;
  28997. /** @hidden */
  28998. _associatedChannel: number;
  28999. /** @hidden */
  29000. _dataSource: number;
  29001. /** @hidden */
  29002. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  29003. /** @hidden */
  29004. _bufferView: Nullable<ArrayBufferView>;
  29005. /** @hidden */
  29006. _bufferViewArray: Nullable<ArrayBufferView[]>;
  29007. /** @hidden */
  29008. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  29009. /** @hidden */
  29010. _size: number;
  29011. /** @hidden */
  29012. _extension: string;
  29013. /** @hidden */
  29014. _files: Nullable<string[]>;
  29015. /** @hidden */
  29016. _workingCanvas: Nullable<HTMLCanvasElement>;
  29017. /** @hidden */
  29018. _workingContext: Nullable<CanvasRenderingContext2D>;
  29019. /** @hidden */
  29020. _framebuffer: Nullable<WebGLFramebuffer>;
  29021. /** @hidden */
  29022. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  29023. /** @hidden */
  29024. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  29025. /** @hidden */
  29026. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  29027. /** @hidden */
  29028. _attachments: Nullable<number[]>;
  29029. /** @hidden */
  29030. _cachedCoordinatesMode: Nullable<number>;
  29031. /** @hidden */
  29032. _cachedWrapU: Nullable<number>;
  29033. /** @hidden */
  29034. _cachedWrapV: Nullable<number>;
  29035. /** @hidden */
  29036. _cachedWrapR: Nullable<number>;
  29037. /** @hidden */
  29038. _cachedAnisotropicFilteringLevel: Nullable<number>;
  29039. /** @hidden */
  29040. _isDisabled: boolean;
  29041. /** @hidden */
  29042. _compression: Nullable<string>;
  29043. /** @hidden */
  29044. _generateStencilBuffer: boolean;
  29045. /** @hidden */
  29046. _generateDepthBuffer: boolean;
  29047. /** @hidden */
  29048. _comparisonFunction: number;
  29049. /** @hidden */
  29050. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  29051. /** @hidden */
  29052. _lodGenerationScale: number;
  29053. /** @hidden */
  29054. _lodGenerationOffset: number;
  29055. /** @hidden */
  29056. _colorTextureArray: Nullable<WebGLTexture>;
  29057. /** @hidden */
  29058. _depthStencilTextureArray: Nullable<WebGLTexture>;
  29059. /** @hidden */
  29060. _lodTextureHigh: Nullable<BaseTexture>;
  29061. /** @hidden */
  29062. _lodTextureMid: Nullable<BaseTexture>;
  29063. /** @hidden */
  29064. _lodTextureLow: Nullable<BaseTexture>;
  29065. /** @hidden */
  29066. _isRGBD: boolean;
  29067. /** @hidden */
  29068. _linearSpecularLOD: boolean;
  29069. /** @hidden */
  29070. _irradianceTexture: Nullable<BaseTexture>;
  29071. /** @hidden */
  29072. _webGLTexture: Nullable<WebGLTexture>;
  29073. /** @hidden */
  29074. _references: number;
  29075. private _engine;
  29076. /**
  29077. * Gets the Engine the texture belongs to.
  29078. * @returns The babylon engine
  29079. */
  29080. getEngine(): Engine;
  29081. /**
  29082. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  29083. */
  29084. readonly dataSource: number;
  29085. /**
  29086. * Creates a new InternalTexture
  29087. * @param engine defines the engine to use
  29088. * @param dataSource defines the type of data that will be used
  29089. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29090. */
  29091. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  29092. /**
  29093. * Increments the number of references (ie. the number of Texture that point to it)
  29094. */
  29095. incrementReferences(): void;
  29096. /**
  29097. * Change the size of the texture (not the size of the content)
  29098. * @param width defines the new width
  29099. * @param height defines the new height
  29100. * @param depth defines the new depth (1 by default)
  29101. */
  29102. updateSize(width: int, height: int, depth?: int): void;
  29103. /** @hidden */
  29104. _rebuild(): void;
  29105. /** @hidden */
  29106. _swapAndDie(target: InternalTexture): void;
  29107. /**
  29108. * Dispose the current allocated resources
  29109. */
  29110. dispose(): void;
  29111. }
  29112. }
  29113. declare module "babylonjs/Materials/effect" {
  29114. import { Observable } from "babylonjs/Misc/observable";
  29115. import { Nullable } from "babylonjs/types";
  29116. import { IDisposable } from "babylonjs/scene";
  29117. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29118. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29119. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29120. import { Engine } from "babylonjs/Engines/engine";
  29121. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29122. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29123. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29124. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29126. /**
  29127. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29128. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29129. */
  29130. export class EffectFallbacks {
  29131. private _defines;
  29132. private _currentRank;
  29133. private _maxRank;
  29134. private _mesh;
  29135. /**
  29136. * Removes the fallback from the bound mesh.
  29137. */
  29138. unBindMesh(): void;
  29139. /**
  29140. * Adds a fallback on the specified property.
  29141. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29142. * @param define The name of the define in the shader
  29143. */
  29144. addFallback(rank: number, define: string): void;
  29145. /**
  29146. * Sets the mesh to use CPU skinning when needing to fallback.
  29147. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29148. * @param mesh The mesh to use the fallbacks.
  29149. */
  29150. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29151. /**
  29152. * Checks to see if more fallbacks are still availible.
  29153. */
  29154. readonly hasMoreFallbacks: boolean;
  29155. /**
  29156. * Removes the defines that should be removed when falling back.
  29157. * @param currentDefines defines the current define statements for the shader.
  29158. * @param effect defines the current effect we try to compile
  29159. * @returns The resulting defines with defines of the current rank removed.
  29160. */
  29161. reduce(currentDefines: string, effect: Effect): string;
  29162. }
  29163. /**
  29164. * Options to be used when creating an effect.
  29165. */
  29166. export class EffectCreationOptions {
  29167. /**
  29168. * Atrributes that will be used in the shader.
  29169. */
  29170. attributes: string[];
  29171. /**
  29172. * Uniform varible names that will be set in the shader.
  29173. */
  29174. uniformsNames: string[];
  29175. /**
  29176. * Uniform buffer varible names that will be set in the shader.
  29177. */
  29178. uniformBuffersNames: string[];
  29179. /**
  29180. * Sampler texture variable names that will be set in the shader.
  29181. */
  29182. samplers: string[];
  29183. /**
  29184. * Define statements that will be set in the shader.
  29185. */
  29186. defines: any;
  29187. /**
  29188. * Possible fallbacks for this effect to improve performance when needed.
  29189. */
  29190. fallbacks: Nullable<EffectFallbacks>;
  29191. /**
  29192. * Callback that will be called when the shader is compiled.
  29193. */
  29194. onCompiled: Nullable<(effect: Effect) => void>;
  29195. /**
  29196. * Callback that will be called if an error occurs during shader compilation.
  29197. */
  29198. onError: Nullable<(effect: Effect, errors: string) => void>;
  29199. /**
  29200. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29201. */
  29202. indexParameters: any;
  29203. /**
  29204. * Max number of lights that can be used in the shader.
  29205. */
  29206. maxSimultaneousLights: number;
  29207. /**
  29208. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29209. */
  29210. transformFeedbackVaryings: Nullable<string[]>;
  29211. }
  29212. /**
  29213. * Effect containing vertex and fragment shader that can be executed on an object.
  29214. */
  29215. export class Effect implements IDisposable {
  29216. /**
  29217. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29218. */
  29219. static ShadersRepository: string;
  29220. /**
  29221. * Name of the effect.
  29222. */
  29223. name: any;
  29224. /**
  29225. * String container all the define statements that should be set on the shader.
  29226. */
  29227. defines: string;
  29228. /**
  29229. * Callback that will be called when the shader is compiled.
  29230. */
  29231. onCompiled: Nullable<(effect: Effect) => void>;
  29232. /**
  29233. * Callback that will be called if an error occurs during shader compilation.
  29234. */
  29235. onError: Nullable<(effect: Effect, errors: string) => void>;
  29236. /**
  29237. * Callback that will be called when effect is bound.
  29238. */
  29239. onBind: Nullable<(effect: Effect) => void>;
  29240. /**
  29241. * Unique ID of the effect.
  29242. */
  29243. uniqueId: number;
  29244. /**
  29245. * Observable that will be called when the shader is compiled.
  29246. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29247. */
  29248. onCompileObservable: Observable<Effect>;
  29249. /**
  29250. * Observable that will be called if an error occurs during shader compilation.
  29251. */
  29252. onErrorObservable: Observable<Effect>;
  29253. /** @hidden */
  29254. _onBindObservable: Nullable<Observable<Effect>>;
  29255. /**
  29256. * Observable that will be called when effect is bound.
  29257. */
  29258. readonly onBindObservable: Observable<Effect>;
  29259. /** @hidden */
  29260. _bonesComputationForcedToCPU: boolean;
  29261. private static _uniqueIdSeed;
  29262. private _engine;
  29263. private _uniformBuffersNames;
  29264. private _uniformsNames;
  29265. private _samplerList;
  29266. private _samplers;
  29267. private _isReady;
  29268. private _compilationError;
  29269. private _attributesNames;
  29270. private _attributes;
  29271. private _uniforms;
  29272. /**
  29273. * Key for the effect.
  29274. * @hidden
  29275. */
  29276. _key: string;
  29277. private _indexParameters;
  29278. private _fallbacks;
  29279. private _vertexSourceCode;
  29280. private _fragmentSourceCode;
  29281. private _vertexSourceCodeOverride;
  29282. private _fragmentSourceCodeOverride;
  29283. private _transformFeedbackVaryings;
  29284. /**
  29285. * Compiled shader to webGL program.
  29286. * @hidden
  29287. */
  29288. _pipelineContext: Nullable<IPipelineContext>;
  29289. private _valueCache;
  29290. private static _baseCache;
  29291. /**
  29292. * Instantiates an effect.
  29293. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29294. * @param baseName Name of the effect.
  29295. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29296. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29297. * @param samplers List of sampler variables that will be passed to the shader.
  29298. * @param engine Engine to be used to render the effect
  29299. * @param defines Define statements to be added to the shader.
  29300. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29301. * @param onCompiled Callback that will be called when the shader is compiled.
  29302. * @param onError Callback that will be called if an error occurs during shader compilation.
  29303. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29304. */
  29305. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29306. private _useFinalCode;
  29307. /**
  29308. * Unique key for this effect
  29309. */
  29310. readonly key: string;
  29311. /**
  29312. * If the effect has been compiled and prepared.
  29313. * @returns if the effect is compiled and prepared.
  29314. */
  29315. isReady(): boolean;
  29316. private _isReadyInternal;
  29317. /**
  29318. * The engine the effect was initialized with.
  29319. * @returns the engine.
  29320. */
  29321. getEngine(): Engine;
  29322. /**
  29323. * The pipeline context for this effect
  29324. * @returns the associated pipeline context
  29325. */
  29326. getPipelineContext(): Nullable<IPipelineContext>;
  29327. /**
  29328. * The set of names of attribute variables for the shader.
  29329. * @returns An array of attribute names.
  29330. */
  29331. getAttributesNames(): string[];
  29332. /**
  29333. * Returns the attribute at the given index.
  29334. * @param index The index of the attribute.
  29335. * @returns The location of the attribute.
  29336. */
  29337. getAttributeLocation(index: number): number;
  29338. /**
  29339. * Returns the attribute based on the name of the variable.
  29340. * @param name of the attribute to look up.
  29341. * @returns the attribute location.
  29342. */
  29343. getAttributeLocationByName(name: string): number;
  29344. /**
  29345. * The number of attributes.
  29346. * @returns the numnber of attributes.
  29347. */
  29348. getAttributesCount(): number;
  29349. /**
  29350. * Gets the index of a uniform variable.
  29351. * @param uniformName of the uniform to look up.
  29352. * @returns the index.
  29353. */
  29354. getUniformIndex(uniformName: string): number;
  29355. /**
  29356. * Returns the attribute based on the name of the variable.
  29357. * @param uniformName of the uniform to look up.
  29358. * @returns the location of the uniform.
  29359. */
  29360. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29361. /**
  29362. * Returns an array of sampler variable names
  29363. * @returns The array of sampler variable neames.
  29364. */
  29365. getSamplers(): string[];
  29366. /**
  29367. * The error from the last compilation.
  29368. * @returns the error string.
  29369. */
  29370. getCompilationError(): string;
  29371. /**
  29372. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29373. * @param func The callback to be used.
  29374. */
  29375. executeWhenCompiled(func: (effect: Effect) => void): void;
  29376. private _checkIsReady;
  29377. /** @hidden */
  29378. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29379. /** @hidden */
  29380. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29381. /** @hidden */
  29382. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29383. /**
  29384. * Recompiles the webGL program
  29385. * @param vertexSourceCode The source code for the vertex shader.
  29386. * @param fragmentSourceCode The source code for the fragment shader.
  29387. * @param onCompiled Callback called when completed.
  29388. * @param onError Callback called on error.
  29389. * @hidden
  29390. */
  29391. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29392. /**
  29393. * Prepares the effect
  29394. * @hidden
  29395. */
  29396. _prepareEffect(): void;
  29397. private _processCompilationErrors;
  29398. /**
  29399. * Checks if the effect is supported. (Must be called after compilation)
  29400. */
  29401. readonly isSupported: boolean;
  29402. /**
  29403. * Binds a texture to the engine to be used as output of the shader.
  29404. * @param channel Name of the output variable.
  29405. * @param texture Texture to bind.
  29406. * @hidden
  29407. */
  29408. _bindTexture(channel: string, texture: InternalTexture): void;
  29409. /**
  29410. * Sets a texture on the engine to be used in the shader.
  29411. * @param channel Name of the sampler variable.
  29412. * @param texture Texture to set.
  29413. */
  29414. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29415. /**
  29416. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29417. * @param channel Name of the sampler variable.
  29418. * @param texture Texture to set.
  29419. */
  29420. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29421. /**
  29422. * Sets an array of textures on the engine to be used in the shader.
  29423. * @param channel Name of the variable.
  29424. * @param textures Textures to set.
  29425. */
  29426. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29427. /**
  29428. * 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)
  29429. * @param channel Name of the sampler variable.
  29430. * @param postProcess Post process to get the input texture from.
  29431. */
  29432. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29433. /**
  29434. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29435. * 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)
  29436. * @param channel Name of the sampler variable.
  29437. * @param postProcess Post process to get the output texture from.
  29438. */
  29439. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29440. /** @hidden */
  29441. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29442. /** @hidden */
  29443. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29444. /** @hidden */
  29445. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29446. /** @hidden */
  29447. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29448. /**
  29449. * Binds a buffer to a uniform.
  29450. * @param buffer Buffer to bind.
  29451. * @param name Name of the uniform variable to bind to.
  29452. */
  29453. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29454. /**
  29455. * Binds block to a uniform.
  29456. * @param blockName Name of the block to bind.
  29457. * @param index Index to bind.
  29458. */
  29459. bindUniformBlock(blockName: string, index: number): void;
  29460. /**
  29461. * Sets an interger value on a uniform variable.
  29462. * @param uniformName Name of the variable.
  29463. * @param value Value to be set.
  29464. * @returns this effect.
  29465. */
  29466. setInt(uniformName: string, value: number): Effect;
  29467. /**
  29468. * Sets an int array on a uniform variable.
  29469. * @param uniformName Name of the variable.
  29470. * @param array array to be set.
  29471. * @returns this effect.
  29472. */
  29473. setIntArray(uniformName: string, array: Int32Array): Effect;
  29474. /**
  29475. * 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)
  29476. * @param uniformName Name of the variable.
  29477. * @param array array to be set.
  29478. * @returns this effect.
  29479. */
  29480. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29481. /**
  29482. * 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)
  29483. * @param uniformName Name of the variable.
  29484. * @param array array to be set.
  29485. * @returns this effect.
  29486. */
  29487. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29488. /**
  29489. * 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)
  29490. * @param uniformName Name of the variable.
  29491. * @param array array to be set.
  29492. * @returns this effect.
  29493. */
  29494. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29495. /**
  29496. * Sets an float array on a uniform variable.
  29497. * @param uniformName Name of the variable.
  29498. * @param array array to be set.
  29499. * @returns this effect.
  29500. */
  29501. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29502. /**
  29503. * 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)
  29504. * @param uniformName Name of the variable.
  29505. * @param array array to be set.
  29506. * @returns this effect.
  29507. */
  29508. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29509. /**
  29510. * 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)
  29511. * @param uniformName Name of the variable.
  29512. * @param array array to be set.
  29513. * @returns this effect.
  29514. */
  29515. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29516. /**
  29517. * 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)
  29518. * @param uniformName Name of the variable.
  29519. * @param array array to be set.
  29520. * @returns this effect.
  29521. */
  29522. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29523. /**
  29524. * Sets an array on a uniform variable.
  29525. * @param uniformName Name of the variable.
  29526. * @param array array to be set.
  29527. * @returns this effect.
  29528. */
  29529. setArray(uniformName: string, array: number[]): Effect;
  29530. /**
  29531. * 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)
  29532. * @param uniformName Name of the variable.
  29533. * @param array array to be set.
  29534. * @returns this effect.
  29535. */
  29536. setArray2(uniformName: string, array: number[]): Effect;
  29537. /**
  29538. * 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)
  29539. * @param uniformName Name of the variable.
  29540. * @param array array to be set.
  29541. * @returns this effect.
  29542. */
  29543. setArray3(uniformName: string, array: number[]): Effect;
  29544. /**
  29545. * 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)
  29546. * @param uniformName Name of the variable.
  29547. * @param array array to be set.
  29548. * @returns this effect.
  29549. */
  29550. setArray4(uniformName: string, array: number[]): Effect;
  29551. /**
  29552. * Sets matrices on a uniform variable.
  29553. * @param uniformName Name of the variable.
  29554. * @param matrices matrices to be set.
  29555. * @returns this effect.
  29556. */
  29557. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29558. /**
  29559. * Sets matrix on a uniform variable.
  29560. * @param uniformName Name of the variable.
  29561. * @param matrix matrix to be set.
  29562. * @returns this effect.
  29563. */
  29564. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29565. /**
  29566. * 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)
  29567. * @param uniformName Name of the variable.
  29568. * @param matrix matrix to be set.
  29569. * @returns this effect.
  29570. */
  29571. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29572. /**
  29573. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29574. * @param uniformName Name of the variable.
  29575. * @param matrix matrix to be set.
  29576. * @returns this effect.
  29577. */
  29578. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29579. /**
  29580. * Sets a float on a uniform variable.
  29581. * @param uniformName Name of the variable.
  29582. * @param value value to be set.
  29583. * @returns this effect.
  29584. */
  29585. setFloat(uniformName: string, value: number): Effect;
  29586. /**
  29587. * Sets a boolean on a uniform variable.
  29588. * @param uniformName Name of the variable.
  29589. * @param bool value to be set.
  29590. * @returns this effect.
  29591. */
  29592. setBool(uniformName: string, bool: boolean): Effect;
  29593. /**
  29594. * Sets a Vector2 on a uniform variable.
  29595. * @param uniformName Name of the variable.
  29596. * @param vector2 vector2 to be set.
  29597. * @returns this effect.
  29598. */
  29599. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29600. /**
  29601. * Sets a float2 on a uniform variable.
  29602. * @param uniformName Name of the variable.
  29603. * @param x First float in float2.
  29604. * @param y Second float in float2.
  29605. * @returns this effect.
  29606. */
  29607. setFloat2(uniformName: string, x: number, y: number): Effect;
  29608. /**
  29609. * Sets a Vector3 on a uniform variable.
  29610. * @param uniformName Name of the variable.
  29611. * @param vector3 Value to be set.
  29612. * @returns this effect.
  29613. */
  29614. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29615. /**
  29616. * Sets a float3 on a uniform variable.
  29617. * @param uniformName Name of the variable.
  29618. * @param x First float in float3.
  29619. * @param y Second float in float3.
  29620. * @param z Third float in float3.
  29621. * @returns this effect.
  29622. */
  29623. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29624. /**
  29625. * Sets a Vector4 on a uniform variable.
  29626. * @param uniformName Name of the variable.
  29627. * @param vector4 Value to be set.
  29628. * @returns this effect.
  29629. */
  29630. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29631. /**
  29632. * Sets a float4 on a uniform variable.
  29633. * @param uniformName Name of the variable.
  29634. * @param x First float in float4.
  29635. * @param y Second float in float4.
  29636. * @param z Third float in float4.
  29637. * @param w Fourth float in float4.
  29638. * @returns this effect.
  29639. */
  29640. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29641. /**
  29642. * Sets a Color3 on a uniform variable.
  29643. * @param uniformName Name of the variable.
  29644. * @param color3 Value to be set.
  29645. * @returns this effect.
  29646. */
  29647. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29648. /**
  29649. * Sets a Color4 on a uniform variable.
  29650. * @param uniformName Name of the variable.
  29651. * @param color3 Value to be set.
  29652. * @param alpha Alpha value to be set.
  29653. * @returns this effect.
  29654. */
  29655. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29656. /**
  29657. * Sets a Color4 on a uniform variable
  29658. * @param uniformName defines the name of the variable
  29659. * @param color4 defines the value to be set
  29660. * @returns this effect.
  29661. */
  29662. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29663. /** Release all associated resources */
  29664. dispose(): void;
  29665. /**
  29666. * This function will add a new shader to the shader store
  29667. * @param name the name of the shader
  29668. * @param pixelShader optional pixel shader content
  29669. * @param vertexShader optional vertex shader content
  29670. */
  29671. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29672. /**
  29673. * Store of each shader (The can be looked up using effect.key)
  29674. */
  29675. static ShadersStore: {
  29676. [key: string]: string;
  29677. };
  29678. /**
  29679. * Store of each included file for a shader (The can be looked up using effect.key)
  29680. */
  29681. static IncludesShadersStore: {
  29682. [key: string]: string;
  29683. };
  29684. /**
  29685. * Resets the cache of effects.
  29686. */
  29687. static ResetCache(): void;
  29688. }
  29689. }
  29690. declare module "babylonjs/Materials/uniformBuffer" {
  29691. import { Nullable, FloatArray } from "babylonjs/types";
  29692. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29693. import { Engine } from "babylonjs/Engines/engine";
  29694. import { Effect } from "babylonjs/Materials/effect";
  29695. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29696. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29697. import { Color3 } from "babylonjs/Maths/math.color";
  29698. /**
  29699. * Uniform buffer objects.
  29700. *
  29701. * Handles blocks of uniform on the GPU.
  29702. *
  29703. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29704. *
  29705. * For more information, please refer to :
  29706. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29707. */
  29708. export class UniformBuffer {
  29709. private _engine;
  29710. private _buffer;
  29711. private _data;
  29712. private _bufferData;
  29713. private _dynamic?;
  29714. private _uniformLocations;
  29715. private _uniformSizes;
  29716. private _uniformLocationPointer;
  29717. private _needSync;
  29718. private _noUBO;
  29719. private _currentEffect;
  29720. private static _MAX_UNIFORM_SIZE;
  29721. private static _tempBuffer;
  29722. /**
  29723. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29724. * This is dynamic to allow compat with webgl 1 and 2.
  29725. * You will need to pass the name of the uniform as well as the value.
  29726. */
  29727. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29728. /**
  29729. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29730. * This is dynamic to allow compat with webgl 1 and 2.
  29731. * You will need to pass the name of the uniform as well as the value.
  29732. */
  29733. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29734. /**
  29735. * Lambda to Update a single float in a uniform buffer.
  29736. * This is dynamic to allow compat with webgl 1 and 2.
  29737. * You will need to pass the name of the uniform as well as the value.
  29738. */
  29739. updateFloat: (name: string, x: number) => void;
  29740. /**
  29741. * Lambda to Update a vec2 of float in a uniform buffer.
  29742. * This is dynamic to allow compat with webgl 1 and 2.
  29743. * You will need to pass the name of the uniform as well as the value.
  29744. */
  29745. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29746. /**
  29747. * Lambda to Update a vec3 of float in a uniform buffer.
  29748. * This is dynamic to allow compat with webgl 1 and 2.
  29749. * You will need to pass the name of the uniform as well as the value.
  29750. */
  29751. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29752. /**
  29753. * Lambda to Update a vec4 of float in a uniform buffer.
  29754. * This is dynamic to allow compat with webgl 1 and 2.
  29755. * You will need to pass the name of the uniform as well as the value.
  29756. */
  29757. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29758. /**
  29759. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29760. * This is dynamic to allow compat with webgl 1 and 2.
  29761. * You will need to pass the name of the uniform as well as the value.
  29762. */
  29763. updateMatrix: (name: string, mat: Matrix) => void;
  29764. /**
  29765. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29766. * This is dynamic to allow compat with webgl 1 and 2.
  29767. * You will need to pass the name of the uniform as well as the value.
  29768. */
  29769. updateVector3: (name: string, vector: Vector3) => void;
  29770. /**
  29771. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29772. * This is dynamic to allow compat with webgl 1 and 2.
  29773. * You will need to pass the name of the uniform as well as the value.
  29774. */
  29775. updateVector4: (name: string, vector: Vector4) => void;
  29776. /**
  29777. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29778. * This is dynamic to allow compat with webgl 1 and 2.
  29779. * You will need to pass the name of the uniform as well as the value.
  29780. */
  29781. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29782. /**
  29783. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29784. * This is dynamic to allow compat with webgl 1 and 2.
  29785. * You will need to pass the name of the uniform as well as the value.
  29786. */
  29787. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29788. /**
  29789. * Instantiates a new Uniform buffer objects.
  29790. *
  29791. * Handles blocks of uniform on the GPU.
  29792. *
  29793. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29794. *
  29795. * For more information, please refer to :
  29796. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29797. * @param engine Define the engine the buffer is associated with
  29798. * @param data Define the data contained in the buffer
  29799. * @param dynamic Define if the buffer is updatable
  29800. */
  29801. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29802. /**
  29803. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29804. * or just falling back on setUniformXXX calls.
  29805. */
  29806. readonly useUbo: boolean;
  29807. /**
  29808. * Indicates if the WebGL underlying uniform buffer is in sync
  29809. * with the javascript cache data.
  29810. */
  29811. readonly isSync: boolean;
  29812. /**
  29813. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29814. * Also, a dynamic UniformBuffer will disable cache verification and always
  29815. * update the underlying WebGL uniform buffer to the GPU.
  29816. * @returns if Dynamic, otherwise false
  29817. */
  29818. isDynamic(): boolean;
  29819. /**
  29820. * The data cache on JS side.
  29821. * @returns the underlying data as a float array
  29822. */
  29823. getData(): Float32Array;
  29824. /**
  29825. * The underlying WebGL Uniform buffer.
  29826. * @returns the webgl buffer
  29827. */
  29828. getBuffer(): Nullable<DataBuffer>;
  29829. /**
  29830. * std140 layout specifies how to align data within an UBO structure.
  29831. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29832. * for specs.
  29833. */
  29834. private _fillAlignment;
  29835. /**
  29836. * Adds an uniform in the buffer.
  29837. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29838. * for the layout to be correct !
  29839. * @param name Name of the uniform, as used in the uniform block in the shader.
  29840. * @param size Data size, or data directly.
  29841. */
  29842. addUniform(name: string, size: number | number[]): void;
  29843. /**
  29844. * Adds a Matrix 4x4 to the uniform buffer.
  29845. * @param name Name of the uniform, as used in the uniform block in the shader.
  29846. * @param mat A 4x4 matrix.
  29847. */
  29848. addMatrix(name: string, mat: Matrix): void;
  29849. /**
  29850. * Adds a vec2 to the uniform buffer.
  29851. * @param name Name of the uniform, as used in the uniform block in the shader.
  29852. * @param x Define the x component value of the vec2
  29853. * @param y Define the y component value of the vec2
  29854. */
  29855. addFloat2(name: string, x: number, y: number): void;
  29856. /**
  29857. * Adds a vec3 to the uniform buffer.
  29858. * @param name Name of the uniform, as used in the uniform block in the shader.
  29859. * @param x Define the x component value of the vec3
  29860. * @param y Define the y component value of the vec3
  29861. * @param z Define the z component value of the vec3
  29862. */
  29863. addFloat3(name: string, x: number, y: number, z: number): void;
  29864. /**
  29865. * Adds a vec3 to the uniform buffer.
  29866. * @param name Name of the uniform, as used in the uniform block in the shader.
  29867. * @param color Define the vec3 from a Color
  29868. */
  29869. addColor3(name: string, color: Color3): void;
  29870. /**
  29871. * Adds a vec4 to the uniform buffer.
  29872. * @param name Name of the uniform, as used in the uniform block in the shader.
  29873. * @param color Define the rgb components from a Color
  29874. * @param alpha Define the a component of the vec4
  29875. */
  29876. addColor4(name: string, color: Color3, alpha: number): void;
  29877. /**
  29878. * Adds a vec3 to the uniform buffer.
  29879. * @param name Name of the uniform, as used in the uniform block in the shader.
  29880. * @param vector Define the vec3 components from a Vector
  29881. */
  29882. addVector3(name: string, vector: Vector3): void;
  29883. /**
  29884. * Adds a Matrix 3x3 to the uniform buffer.
  29885. * @param name Name of the uniform, as used in the uniform block in the shader.
  29886. */
  29887. addMatrix3x3(name: string): void;
  29888. /**
  29889. * Adds a Matrix 2x2 to the uniform buffer.
  29890. * @param name Name of the uniform, as used in the uniform block in the shader.
  29891. */
  29892. addMatrix2x2(name: string): void;
  29893. /**
  29894. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29895. */
  29896. create(): void;
  29897. /** @hidden */
  29898. _rebuild(): void;
  29899. /**
  29900. * Updates the WebGL Uniform Buffer on the GPU.
  29901. * If the `dynamic` flag is set to true, no cache comparison is done.
  29902. * Otherwise, the buffer will be updated only if the cache differs.
  29903. */
  29904. update(): void;
  29905. /**
  29906. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29907. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29908. * @param data Define the flattened data
  29909. * @param size Define the size of the data.
  29910. */
  29911. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29912. private _valueCache;
  29913. private _cacheMatrix;
  29914. private _updateMatrix3x3ForUniform;
  29915. private _updateMatrix3x3ForEffect;
  29916. private _updateMatrix2x2ForEffect;
  29917. private _updateMatrix2x2ForUniform;
  29918. private _updateFloatForEffect;
  29919. private _updateFloatForUniform;
  29920. private _updateFloat2ForEffect;
  29921. private _updateFloat2ForUniform;
  29922. private _updateFloat3ForEffect;
  29923. private _updateFloat3ForUniform;
  29924. private _updateFloat4ForEffect;
  29925. private _updateFloat4ForUniform;
  29926. private _updateMatrixForEffect;
  29927. private _updateMatrixForUniform;
  29928. private _updateVector3ForEffect;
  29929. private _updateVector3ForUniform;
  29930. private _updateVector4ForEffect;
  29931. private _updateVector4ForUniform;
  29932. private _updateColor3ForEffect;
  29933. private _updateColor3ForUniform;
  29934. private _updateColor4ForEffect;
  29935. private _updateColor4ForUniform;
  29936. /**
  29937. * Sets a sampler uniform on the effect.
  29938. * @param name Define the name of the sampler.
  29939. * @param texture Define the texture to set in the sampler
  29940. */
  29941. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29942. /**
  29943. * Directly updates the value of the uniform in the cache AND on the GPU.
  29944. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29945. * @param data Define the flattened data
  29946. */
  29947. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29948. /**
  29949. * Binds this uniform buffer to an effect.
  29950. * @param effect Define the effect to bind the buffer to
  29951. * @param name Name of the uniform block in the shader.
  29952. */
  29953. bindToEffect(effect: Effect, name: string): void;
  29954. /**
  29955. * Disposes the uniform buffer.
  29956. */
  29957. dispose(): void;
  29958. }
  29959. }
  29960. declare module "babylonjs/Audio/analyser" {
  29961. import { Scene } from "babylonjs/scene";
  29962. /**
  29963. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29965. */
  29966. export class Analyser {
  29967. /**
  29968. * Gets or sets the smoothing
  29969. * @ignorenaming
  29970. */
  29971. SMOOTHING: number;
  29972. /**
  29973. * Gets or sets the FFT table size
  29974. * @ignorenaming
  29975. */
  29976. FFT_SIZE: number;
  29977. /**
  29978. * Gets or sets the bar graph amplitude
  29979. * @ignorenaming
  29980. */
  29981. BARGRAPHAMPLITUDE: number;
  29982. /**
  29983. * Gets or sets the position of the debug canvas
  29984. * @ignorenaming
  29985. */
  29986. DEBUGCANVASPOS: {
  29987. x: number;
  29988. y: number;
  29989. };
  29990. /**
  29991. * Gets or sets the debug canvas size
  29992. * @ignorenaming
  29993. */
  29994. DEBUGCANVASSIZE: {
  29995. width: number;
  29996. height: number;
  29997. };
  29998. private _byteFreqs;
  29999. private _byteTime;
  30000. private _floatFreqs;
  30001. private _webAudioAnalyser;
  30002. private _debugCanvas;
  30003. private _debugCanvasContext;
  30004. private _scene;
  30005. private _registerFunc;
  30006. private _audioEngine;
  30007. /**
  30008. * Creates a new analyser
  30009. * @param scene defines hosting scene
  30010. */
  30011. constructor(scene: Scene);
  30012. /**
  30013. * Get the number of data values you will have to play with for the visualization
  30014. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30015. * @returns a number
  30016. */
  30017. getFrequencyBinCount(): number;
  30018. /**
  30019. * Gets the current frequency data as a byte array
  30020. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30021. * @returns a Uint8Array
  30022. */
  30023. getByteFrequencyData(): Uint8Array;
  30024. /**
  30025. * Gets the current waveform as a byte array
  30026. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30027. * @returns a Uint8Array
  30028. */
  30029. getByteTimeDomainData(): Uint8Array;
  30030. /**
  30031. * Gets the current frequency data as a float array
  30032. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30033. * @returns a Float32Array
  30034. */
  30035. getFloatFrequencyData(): Float32Array;
  30036. /**
  30037. * Renders the debug canvas
  30038. */
  30039. drawDebugCanvas(): void;
  30040. /**
  30041. * Stops rendering the debug canvas and removes it
  30042. */
  30043. stopDebugCanvas(): void;
  30044. /**
  30045. * Connects two audio nodes
  30046. * @param inputAudioNode defines first node to connect
  30047. * @param outputAudioNode defines second node to connect
  30048. */
  30049. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30050. /**
  30051. * Releases all associated resources
  30052. */
  30053. dispose(): void;
  30054. }
  30055. }
  30056. declare module "babylonjs/Audio/audioEngine" {
  30057. import { IDisposable } from "babylonjs/scene";
  30058. import { Analyser } from "babylonjs/Audio/analyser";
  30059. import { Nullable } from "babylonjs/types";
  30060. import { Observable } from "babylonjs/Misc/observable";
  30061. /**
  30062. * This represents an audio engine and it is responsible
  30063. * to play, synchronize and analyse sounds throughout the application.
  30064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30065. */
  30066. export interface IAudioEngine extends IDisposable {
  30067. /**
  30068. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30069. */
  30070. readonly canUseWebAudio: boolean;
  30071. /**
  30072. * Gets the current AudioContext if available.
  30073. */
  30074. readonly audioContext: Nullable<AudioContext>;
  30075. /**
  30076. * The master gain node defines the global audio volume of your audio engine.
  30077. */
  30078. readonly masterGain: GainNode;
  30079. /**
  30080. * Gets whether or not mp3 are supported by your browser.
  30081. */
  30082. readonly isMP3supported: boolean;
  30083. /**
  30084. * Gets whether or not ogg are supported by your browser.
  30085. */
  30086. readonly isOGGsupported: boolean;
  30087. /**
  30088. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30089. * @ignoreNaming
  30090. */
  30091. WarnedWebAudioUnsupported: boolean;
  30092. /**
  30093. * Defines if the audio engine relies on a custom unlocked button.
  30094. * In this case, the embedded button will not be displayed.
  30095. */
  30096. useCustomUnlockedButton: boolean;
  30097. /**
  30098. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30099. */
  30100. readonly unlocked: boolean;
  30101. /**
  30102. * Event raised when audio has been unlocked on the browser.
  30103. */
  30104. onAudioUnlockedObservable: Observable<AudioEngine>;
  30105. /**
  30106. * Event raised when audio has been locked on the browser.
  30107. */
  30108. onAudioLockedObservable: Observable<AudioEngine>;
  30109. /**
  30110. * Flags the audio engine in Locked state.
  30111. * This happens due to new browser policies preventing audio to autoplay.
  30112. */
  30113. lock(): void;
  30114. /**
  30115. * Unlocks the audio engine once a user action has been done on the dom.
  30116. * This is helpful to resume play once browser policies have been satisfied.
  30117. */
  30118. unlock(): void;
  30119. }
  30120. /**
  30121. * This represents the default audio engine used in babylon.
  30122. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30124. */
  30125. export class AudioEngine implements IAudioEngine {
  30126. private _audioContext;
  30127. private _audioContextInitialized;
  30128. private _muteButton;
  30129. private _hostElement;
  30130. /**
  30131. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30132. */
  30133. canUseWebAudio: boolean;
  30134. /**
  30135. * The master gain node defines the global audio volume of your audio engine.
  30136. */
  30137. masterGain: GainNode;
  30138. /**
  30139. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30140. * @ignoreNaming
  30141. */
  30142. WarnedWebAudioUnsupported: boolean;
  30143. /**
  30144. * Gets whether or not mp3 are supported by your browser.
  30145. */
  30146. isMP3supported: boolean;
  30147. /**
  30148. * Gets whether or not ogg are supported by your browser.
  30149. */
  30150. isOGGsupported: boolean;
  30151. /**
  30152. * Gets whether audio has been unlocked on the device.
  30153. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30154. * a user interaction has happened.
  30155. */
  30156. unlocked: boolean;
  30157. /**
  30158. * Defines if the audio engine relies on a custom unlocked button.
  30159. * In this case, the embedded button will not be displayed.
  30160. */
  30161. useCustomUnlockedButton: boolean;
  30162. /**
  30163. * Event raised when audio has been unlocked on the browser.
  30164. */
  30165. onAudioUnlockedObservable: Observable<AudioEngine>;
  30166. /**
  30167. * Event raised when audio has been locked on the browser.
  30168. */
  30169. onAudioLockedObservable: Observable<AudioEngine>;
  30170. /**
  30171. * Gets the current AudioContext if available.
  30172. */
  30173. readonly audioContext: Nullable<AudioContext>;
  30174. private _connectedAnalyser;
  30175. /**
  30176. * Instantiates a new audio engine.
  30177. *
  30178. * There should be only one per page as some browsers restrict the number
  30179. * of audio contexts you can create.
  30180. * @param hostElement defines the host element where to display the mute icon if necessary
  30181. */
  30182. constructor(hostElement?: Nullable<HTMLElement>);
  30183. /**
  30184. * Flags the audio engine in Locked state.
  30185. * This happens due to new browser policies preventing audio to autoplay.
  30186. */
  30187. lock(): void;
  30188. /**
  30189. * Unlocks the audio engine once a user action has been done on the dom.
  30190. * This is helpful to resume play once browser policies have been satisfied.
  30191. */
  30192. unlock(): void;
  30193. private _resumeAudioContext;
  30194. private _initializeAudioContext;
  30195. private _tryToRun;
  30196. private _triggerRunningState;
  30197. private _triggerSuspendedState;
  30198. private _displayMuteButton;
  30199. private _moveButtonToTopLeft;
  30200. private _onResize;
  30201. private _hideMuteButton;
  30202. /**
  30203. * Destroy and release the resources associated with the audio ccontext.
  30204. */
  30205. dispose(): void;
  30206. /**
  30207. * Gets the global volume sets on the master gain.
  30208. * @returns the global volume if set or -1 otherwise
  30209. */
  30210. getGlobalVolume(): number;
  30211. /**
  30212. * Sets the global volume of your experience (sets on the master gain).
  30213. * @param newVolume Defines the new global volume of the application
  30214. */
  30215. setGlobalVolume(newVolume: number): void;
  30216. /**
  30217. * Connect the audio engine to an audio analyser allowing some amazing
  30218. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30219. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30220. * @param analyser The analyser to connect to the engine
  30221. */
  30222. connectToAnalyser(analyser: Analyser): void;
  30223. }
  30224. }
  30225. declare module "babylonjs/Loading/loadingScreen" {
  30226. /**
  30227. * Interface used to present a loading screen while loading a scene
  30228. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30229. */
  30230. export interface ILoadingScreen {
  30231. /**
  30232. * Function called to display the loading screen
  30233. */
  30234. displayLoadingUI: () => void;
  30235. /**
  30236. * Function called to hide the loading screen
  30237. */
  30238. hideLoadingUI: () => void;
  30239. /**
  30240. * Gets or sets the color to use for the background
  30241. */
  30242. loadingUIBackgroundColor: string;
  30243. /**
  30244. * Gets or sets the text to display while loading
  30245. */
  30246. loadingUIText: string;
  30247. }
  30248. /**
  30249. * Class used for the default loading screen
  30250. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30251. */
  30252. export class DefaultLoadingScreen implements ILoadingScreen {
  30253. private _renderingCanvas;
  30254. private _loadingText;
  30255. private _loadingDivBackgroundColor;
  30256. private _loadingDiv;
  30257. private _loadingTextDiv;
  30258. /** Gets or sets the logo url to use for the default loading screen */
  30259. static DefaultLogoUrl: string;
  30260. /** Gets or sets the spinner url to use for the default loading screen */
  30261. static DefaultSpinnerUrl: string;
  30262. /**
  30263. * Creates a new default loading screen
  30264. * @param _renderingCanvas defines the canvas used to render the scene
  30265. * @param _loadingText defines the default text to display
  30266. * @param _loadingDivBackgroundColor defines the default background color
  30267. */
  30268. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30269. /**
  30270. * Function called to display the loading screen
  30271. */
  30272. displayLoadingUI(): void;
  30273. /**
  30274. * Function called to hide the loading screen
  30275. */
  30276. hideLoadingUI(): void;
  30277. /**
  30278. * Gets or sets the text to display while loading
  30279. */
  30280. loadingUIText: string;
  30281. /**
  30282. * Gets or sets the color to use for the background
  30283. */
  30284. loadingUIBackgroundColor: string;
  30285. private _resizeLoadingUI;
  30286. }
  30287. }
  30288. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30289. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30290. import { Engine } from "babylonjs/Engines/engine";
  30291. import { Nullable } from "babylonjs/types";
  30292. /** @hidden */
  30293. export class WebGLPipelineContext implements IPipelineContext {
  30294. engine: Engine;
  30295. program: Nullable<WebGLProgram>;
  30296. context?: WebGLRenderingContext;
  30297. vertexShader?: WebGLShader;
  30298. fragmentShader?: WebGLShader;
  30299. isParallelCompiled: boolean;
  30300. onCompiled?: () => void;
  30301. transformFeedback?: WebGLTransformFeedback | null;
  30302. readonly isAsync: boolean;
  30303. readonly isReady: boolean;
  30304. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30305. }
  30306. }
  30307. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30308. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30309. /** @hidden */
  30310. export class WebGLDataBuffer extends DataBuffer {
  30311. private _buffer;
  30312. constructor(resource: WebGLBuffer);
  30313. readonly underlyingResource: any;
  30314. }
  30315. }
  30316. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30317. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30318. /** @hidden */
  30319. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30320. attributeProcessor(attribute: string): string;
  30321. varyingProcessor(varying: string, isFragment: boolean): string;
  30322. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30323. }
  30324. }
  30325. declare module "babylonjs/Misc/perfCounter" {
  30326. /**
  30327. * This class is used to track a performance counter which is number based.
  30328. * The user has access to many properties which give statistics of different nature.
  30329. *
  30330. * The implementer can track two kinds of Performance Counter: time and count.
  30331. * 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.
  30332. * 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.
  30333. */
  30334. export class PerfCounter {
  30335. /**
  30336. * Gets or sets a global boolean to turn on and off all the counters
  30337. */
  30338. static Enabled: boolean;
  30339. /**
  30340. * Returns the smallest value ever
  30341. */
  30342. readonly min: number;
  30343. /**
  30344. * Returns the biggest value ever
  30345. */
  30346. readonly max: number;
  30347. /**
  30348. * Returns the average value since the performance counter is running
  30349. */
  30350. readonly average: number;
  30351. /**
  30352. * Returns the average value of the last second the counter was monitored
  30353. */
  30354. readonly lastSecAverage: number;
  30355. /**
  30356. * Returns the current value
  30357. */
  30358. readonly current: number;
  30359. /**
  30360. * Gets the accumulated total
  30361. */
  30362. readonly total: number;
  30363. /**
  30364. * Gets the total value count
  30365. */
  30366. readonly count: number;
  30367. /**
  30368. * Creates a new counter
  30369. */
  30370. constructor();
  30371. /**
  30372. * Call this method to start monitoring a new frame.
  30373. * 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.
  30374. */
  30375. fetchNewFrame(): void;
  30376. /**
  30377. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30378. * @param newCount the count value to add to the monitored count
  30379. * @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.
  30380. */
  30381. addCount(newCount: number, fetchResult: boolean): void;
  30382. /**
  30383. * Start monitoring this performance counter
  30384. */
  30385. beginMonitoring(): void;
  30386. /**
  30387. * Compute the time lapsed since the previous beginMonitoring() call.
  30388. * @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
  30389. */
  30390. endMonitoring(newFrame?: boolean): void;
  30391. private _fetchResult;
  30392. private _startMonitoringTime;
  30393. private _min;
  30394. private _max;
  30395. private _average;
  30396. private _current;
  30397. private _totalValueCount;
  30398. private _totalAccumulated;
  30399. private _lastSecAverage;
  30400. private _lastSecAccumulated;
  30401. private _lastSecTime;
  30402. private _lastSecValueCount;
  30403. }
  30404. }
  30405. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30406. /**
  30407. * Interface for any object that can request an animation frame
  30408. */
  30409. export interface ICustomAnimationFrameRequester {
  30410. /**
  30411. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30412. */
  30413. renderFunction?: Function;
  30414. /**
  30415. * Called to request the next frame to render to
  30416. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30417. */
  30418. requestAnimationFrame: Function;
  30419. /**
  30420. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30421. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30422. */
  30423. requestID?: number;
  30424. }
  30425. }
  30426. declare module "babylonjs/Materials/Textures/videoTexture" {
  30427. import { Observable } from "babylonjs/Misc/observable";
  30428. import { Nullable } from "babylonjs/types";
  30429. import { Scene } from "babylonjs/scene";
  30430. import { Texture } from "babylonjs/Materials/Textures/texture";
  30431. /**
  30432. * Settings for finer control over video usage
  30433. */
  30434. export interface VideoTextureSettings {
  30435. /**
  30436. * Applies `autoplay` to video, if specified
  30437. */
  30438. autoPlay?: boolean;
  30439. /**
  30440. * Applies `loop` to video, if specified
  30441. */
  30442. loop?: boolean;
  30443. /**
  30444. * Automatically updates internal texture from video at every frame in the render loop
  30445. */
  30446. autoUpdateTexture: boolean;
  30447. /**
  30448. * Image src displayed during the video loading or until the user interacts with the video.
  30449. */
  30450. poster?: string;
  30451. }
  30452. /**
  30453. * If you want to display a video in your scene, this is the special texture for that.
  30454. * This special texture works similar to other textures, with the exception of a few parameters.
  30455. * @see https://doc.babylonjs.com/how_to/video_texture
  30456. */
  30457. export class VideoTexture extends Texture {
  30458. /**
  30459. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30460. */
  30461. readonly autoUpdateTexture: boolean;
  30462. /**
  30463. * The video instance used by the texture internally
  30464. */
  30465. readonly video: HTMLVideoElement;
  30466. private _onUserActionRequestedObservable;
  30467. /**
  30468. * Event triggerd when a dom action is required by the user to play the video.
  30469. * This happens due to recent changes in browser policies preventing video to auto start.
  30470. */
  30471. readonly onUserActionRequestedObservable: Observable<Texture>;
  30472. private _generateMipMaps;
  30473. private _engine;
  30474. private _stillImageCaptured;
  30475. private _displayingPosterTexture;
  30476. private _settings;
  30477. private _createInternalTextureOnEvent;
  30478. private _frameId;
  30479. /**
  30480. * Creates a video texture.
  30481. * If you want to display a video in your scene, this is the special texture for that.
  30482. * This special texture works similar to other textures, with the exception of a few parameters.
  30483. * @see https://doc.babylonjs.com/how_to/video_texture
  30484. * @param name optional name, will detect from video source, if not defined
  30485. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30486. * @param scene is obviously the current scene.
  30487. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30488. * @param invertY is false by default but can be used to invert video on Y axis
  30489. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30490. * @param settings allows finer control over video usage
  30491. */
  30492. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30493. private _getName;
  30494. private _getVideo;
  30495. private _createInternalTexture;
  30496. private reset;
  30497. /**
  30498. * @hidden Internal method to initiate `update`.
  30499. */
  30500. _rebuild(): void;
  30501. /**
  30502. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30503. */
  30504. update(): void;
  30505. /**
  30506. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30507. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30508. */
  30509. updateTexture(isVisible: boolean): void;
  30510. protected _updateInternalTexture: () => void;
  30511. /**
  30512. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30513. * @param url New url.
  30514. */
  30515. updateURL(url: string): void;
  30516. /**
  30517. * Dispose the texture and release its associated resources.
  30518. */
  30519. dispose(): void;
  30520. /**
  30521. * Creates a video texture straight from a stream.
  30522. * @param scene Define the scene the texture should be created in
  30523. * @param stream Define the stream the texture should be created from
  30524. * @returns The created video texture as a promise
  30525. */
  30526. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30527. /**
  30528. * Creates a video texture straight from your WebCam video feed.
  30529. * @param scene Define the scene the texture should be created in
  30530. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30531. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30532. * @returns The created video texture as a promise
  30533. */
  30534. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30535. minWidth: number;
  30536. maxWidth: number;
  30537. minHeight: number;
  30538. maxHeight: number;
  30539. deviceId: string;
  30540. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30541. /**
  30542. * Creates a video texture straight from your WebCam video feed.
  30543. * @param scene Define the scene the texture should be created in
  30544. * @param onReady Define a callback to triggered once the texture will be ready
  30545. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30546. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30547. */
  30548. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30549. minWidth: number;
  30550. maxWidth: number;
  30551. minHeight: number;
  30552. maxHeight: number;
  30553. deviceId: string;
  30554. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30555. }
  30556. }
  30557. declare module "babylonjs/Engines/engine" {
  30558. import { Observable } from "babylonjs/Misc/observable";
  30559. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30560. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30561. import { Scene } from "babylonjs/scene";
  30562. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30563. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30564. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30565. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30566. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30567. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30568. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30569. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30570. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30571. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30572. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30573. import { WebRequest } from "babylonjs/Misc/webRequest";
  30574. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30575. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30576. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30577. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30578. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30579. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30580. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30581. import { Material } from "babylonjs/Materials/material";
  30582. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30583. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30584. /**
  30585. * Defines the interface used by objects containing a viewport (like a camera)
  30586. */
  30587. interface IViewportOwnerLike {
  30588. /**
  30589. * Gets or sets the viewport
  30590. */
  30591. viewport: IViewportLike;
  30592. }
  30593. /**
  30594. * Interface for attribute information associated with buffer instanciation
  30595. */
  30596. export class InstancingAttributeInfo {
  30597. /**
  30598. * Index/offset of the attribute in the vertex shader
  30599. */
  30600. index: number;
  30601. /**
  30602. * size of the attribute, 1, 2, 3 or 4
  30603. */
  30604. attributeSize: number;
  30605. /**
  30606. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30607. * default is FLOAT
  30608. */
  30609. attribyteType: number;
  30610. /**
  30611. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30612. */
  30613. normalized: boolean;
  30614. /**
  30615. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30616. */
  30617. offset: number;
  30618. /**
  30619. * Name of the GLSL attribute, for debugging purpose only
  30620. */
  30621. attributeName: string;
  30622. }
  30623. /**
  30624. * Define options used to create a depth texture
  30625. */
  30626. export class DepthTextureCreationOptions {
  30627. /** Specifies whether or not a stencil should be allocated in the texture */
  30628. generateStencil?: boolean;
  30629. /** Specifies whether or not bilinear filtering is enable on the texture */
  30630. bilinearFiltering?: boolean;
  30631. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30632. comparisonFunction?: number;
  30633. /** Specifies if the created texture is a cube texture */
  30634. isCube?: boolean;
  30635. }
  30636. /**
  30637. * Class used to describe the capabilities of the engine relatively to the current browser
  30638. */
  30639. export class EngineCapabilities {
  30640. /** Maximum textures units per fragment shader */
  30641. maxTexturesImageUnits: number;
  30642. /** Maximum texture units per vertex shader */
  30643. maxVertexTextureImageUnits: number;
  30644. /** Maximum textures units in the entire pipeline */
  30645. maxCombinedTexturesImageUnits: number;
  30646. /** Maximum texture size */
  30647. maxTextureSize: number;
  30648. /** Maximum cube texture size */
  30649. maxCubemapTextureSize: number;
  30650. /** Maximum render texture size */
  30651. maxRenderTextureSize: number;
  30652. /** Maximum number of vertex attributes */
  30653. maxVertexAttribs: number;
  30654. /** Maximum number of varyings */
  30655. maxVaryingVectors: number;
  30656. /** Maximum number of uniforms per vertex shader */
  30657. maxVertexUniformVectors: number;
  30658. /** Maximum number of uniforms per fragment shader */
  30659. maxFragmentUniformVectors: number;
  30660. /** Defines if standard derivates (dx/dy) are supported */
  30661. standardDerivatives: boolean;
  30662. /** Defines if s3tc texture compression is supported */
  30663. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30664. /** Defines if pvrtc texture compression is supported */
  30665. pvrtc: any;
  30666. /** Defines if etc1 texture compression is supported */
  30667. etc1: any;
  30668. /** Defines if etc2 texture compression is supported */
  30669. etc2: any;
  30670. /** Defines if astc texture compression is supported */
  30671. astc: any;
  30672. /** Defines if float textures are supported */
  30673. textureFloat: boolean;
  30674. /** Defines if vertex array objects are supported */
  30675. vertexArrayObject: boolean;
  30676. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30677. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30678. /** Gets the maximum level of anisotropy supported */
  30679. maxAnisotropy: number;
  30680. /** Defines if instancing is supported */
  30681. instancedArrays: boolean;
  30682. /** Defines if 32 bits indices are supported */
  30683. uintIndices: boolean;
  30684. /** Defines if high precision shaders are supported */
  30685. highPrecisionShaderSupported: boolean;
  30686. /** Defines if depth reading in the fragment shader is supported */
  30687. fragmentDepthSupported: boolean;
  30688. /** Defines if float texture linear filtering is supported*/
  30689. textureFloatLinearFiltering: boolean;
  30690. /** Defines if rendering to float textures is supported */
  30691. textureFloatRender: boolean;
  30692. /** Defines if half float textures are supported*/
  30693. textureHalfFloat: boolean;
  30694. /** Defines if half float texture linear filtering is supported*/
  30695. textureHalfFloatLinearFiltering: boolean;
  30696. /** Defines if rendering to half float textures is supported */
  30697. textureHalfFloatRender: boolean;
  30698. /** Defines if textureLOD shader command is supported */
  30699. textureLOD: boolean;
  30700. /** Defines if draw buffers extension is supported */
  30701. drawBuffersExtension: boolean;
  30702. /** Defines if depth textures are supported */
  30703. depthTextureExtension: boolean;
  30704. /** Defines if float color buffer are supported */
  30705. colorBufferFloat: boolean;
  30706. /** Gets disjoint timer query extension (null if not supported) */
  30707. timerQuery: EXT_disjoint_timer_query;
  30708. /** Defines if timestamp can be used with timer query */
  30709. canUseTimestampForTimerQuery: boolean;
  30710. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30711. multiview: any;
  30712. /** Function used to let the system compiles shaders in background */
  30713. parallelShaderCompile: {
  30714. COMPLETION_STATUS_KHR: number;
  30715. };
  30716. /** Max number of texture samples for MSAA */
  30717. maxMSAASamples: number;
  30718. /** Defines if the blend min max extension is supported */
  30719. blendMinMax: boolean;
  30720. }
  30721. /** Interface defining initialization parameters for Engine class */
  30722. export interface EngineOptions extends WebGLContextAttributes {
  30723. /**
  30724. * Defines if the engine should no exceed a specified device ratio
  30725. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30726. */
  30727. limitDeviceRatio?: number;
  30728. /**
  30729. * Defines if webvr should be enabled automatically
  30730. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30731. */
  30732. autoEnableWebVR?: boolean;
  30733. /**
  30734. * Defines if webgl2 should be turned off even if supported
  30735. * @see http://doc.babylonjs.com/features/webgl2
  30736. */
  30737. disableWebGL2Support?: boolean;
  30738. /**
  30739. * Defines if webaudio should be initialized as well
  30740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30741. */
  30742. audioEngine?: boolean;
  30743. /**
  30744. * Defines if animations should run using a deterministic lock step
  30745. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30746. */
  30747. deterministicLockstep?: boolean;
  30748. /** Defines the maximum steps to use with deterministic lock step mode */
  30749. lockstepMaxSteps?: number;
  30750. /**
  30751. * Defines that engine should ignore context lost events
  30752. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30753. */
  30754. doNotHandleContextLost?: boolean;
  30755. /**
  30756. * Defines that engine should ignore modifying touch action attribute and style
  30757. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30758. */
  30759. doNotHandleTouchAction?: boolean;
  30760. /**
  30761. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30762. */
  30763. useHighPrecisionFloats?: boolean;
  30764. }
  30765. /**
  30766. * Defines the interface used by display changed events
  30767. */
  30768. export interface IDisplayChangedEventArgs {
  30769. /** Gets the vrDisplay object (if any) */
  30770. vrDisplay: Nullable<any>;
  30771. /** Gets a boolean indicating if webVR is supported */
  30772. vrSupported: boolean;
  30773. }
  30774. /**
  30775. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30776. */
  30777. export class Engine {
  30778. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30779. static ExceptionList: ({
  30780. key: string;
  30781. capture: string;
  30782. captureConstraint: number;
  30783. targets: string[];
  30784. } | {
  30785. key: string;
  30786. capture: null;
  30787. captureConstraint: null;
  30788. targets: string[];
  30789. })[];
  30790. /** Gets the list of created engines */
  30791. static readonly Instances: Engine[];
  30792. /**
  30793. * Gets the latest created engine
  30794. */
  30795. static readonly LastCreatedEngine: Nullable<Engine>;
  30796. /**
  30797. * Gets the latest created scene
  30798. */
  30799. static readonly LastCreatedScene: Nullable<Scene>;
  30800. /**
  30801. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30802. * @param flag defines which part of the materials must be marked as dirty
  30803. * @param predicate defines a predicate used to filter which materials should be affected
  30804. */
  30805. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30806. /** @hidden */
  30807. static _TextureLoaders: IInternalTextureLoader[];
  30808. /** Defines that alpha blending is disabled */
  30809. static readonly ALPHA_DISABLE: number;
  30810. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30811. static readonly ALPHA_ADD: number;
  30812. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30813. static readonly ALPHA_COMBINE: number;
  30814. /** Defines that alpha blending to DEST - SRC * DEST */
  30815. static readonly ALPHA_SUBTRACT: number;
  30816. /** Defines that alpha blending to SRC * DEST */
  30817. static readonly ALPHA_MULTIPLY: number;
  30818. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30819. static readonly ALPHA_MAXIMIZED: number;
  30820. /** Defines that alpha blending to SRC + DEST */
  30821. static readonly ALPHA_ONEONE: number;
  30822. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30823. static readonly ALPHA_PREMULTIPLIED: number;
  30824. /**
  30825. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30826. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30827. */
  30828. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30829. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30830. static readonly ALPHA_INTERPOLATE: number;
  30831. /**
  30832. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30833. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30834. */
  30835. static readonly ALPHA_SCREENMODE: number;
  30836. /** Defines that the ressource is not delayed*/
  30837. static readonly DELAYLOADSTATE_NONE: number;
  30838. /** Defines that the ressource was successfully delay loaded */
  30839. static readonly DELAYLOADSTATE_LOADED: number;
  30840. /** Defines that the ressource is currently delay loading */
  30841. static readonly DELAYLOADSTATE_LOADING: number;
  30842. /** Defines that the ressource is delayed and has not started loading */
  30843. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30844. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30845. static readonly NEVER: number;
  30846. /** 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 */
  30847. static readonly ALWAYS: number;
  30848. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30849. static readonly LESS: number;
  30850. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30851. static readonly EQUAL: number;
  30852. /** 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 */
  30853. static readonly LEQUAL: number;
  30854. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30855. static readonly GREATER: number;
  30856. /** 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 */
  30857. static readonly GEQUAL: number;
  30858. /** 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 */
  30859. static readonly NOTEQUAL: number;
  30860. /** Passed to stencilOperation to specify that stencil value must be kept */
  30861. static readonly KEEP: number;
  30862. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30863. static readonly REPLACE: number;
  30864. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30865. static readonly INCR: number;
  30866. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30867. static readonly DECR: number;
  30868. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30869. static readonly INVERT: number;
  30870. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30871. static readonly INCR_WRAP: number;
  30872. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30873. static readonly DECR_WRAP: number;
  30874. /** Texture is not repeating outside of 0..1 UVs */
  30875. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30876. /** Texture is repeating outside of 0..1 UVs */
  30877. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30878. /** Texture is repeating and mirrored */
  30879. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30880. /** ALPHA */
  30881. static readonly TEXTUREFORMAT_ALPHA: number;
  30882. /** LUMINANCE */
  30883. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30884. /** LUMINANCE_ALPHA */
  30885. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30886. /** RGB */
  30887. static readonly TEXTUREFORMAT_RGB: number;
  30888. /** RGBA */
  30889. static readonly TEXTUREFORMAT_RGBA: number;
  30890. /** RED */
  30891. static readonly TEXTUREFORMAT_RED: number;
  30892. /** RED (2nd reference) */
  30893. static readonly TEXTUREFORMAT_R: number;
  30894. /** RG */
  30895. static readonly TEXTUREFORMAT_RG: number;
  30896. /** RED_INTEGER */
  30897. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30898. /** RED_INTEGER (2nd reference) */
  30899. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30900. /** RG_INTEGER */
  30901. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30902. /** RGB_INTEGER */
  30903. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30904. /** RGBA_INTEGER */
  30905. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30906. /** UNSIGNED_BYTE */
  30907. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30908. /** UNSIGNED_BYTE (2nd reference) */
  30909. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30910. /** FLOAT */
  30911. static readonly TEXTURETYPE_FLOAT: number;
  30912. /** HALF_FLOAT */
  30913. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30914. /** BYTE */
  30915. static readonly TEXTURETYPE_BYTE: number;
  30916. /** SHORT */
  30917. static readonly TEXTURETYPE_SHORT: number;
  30918. /** UNSIGNED_SHORT */
  30919. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30920. /** INT */
  30921. static readonly TEXTURETYPE_INT: number;
  30922. /** UNSIGNED_INT */
  30923. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30924. /** UNSIGNED_SHORT_4_4_4_4 */
  30925. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30926. /** UNSIGNED_SHORT_5_5_5_1 */
  30927. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30928. /** UNSIGNED_SHORT_5_6_5 */
  30929. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30930. /** UNSIGNED_INT_2_10_10_10_REV */
  30931. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30932. /** UNSIGNED_INT_24_8 */
  30933. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30934. /** UNSIGNED_INT_10F_11F_11F_REV */
  30935. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30936. /** UNSIGNED_INT_5_9_9_9_REV */
  30937. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30938. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30939. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30940. /** nearest is mag = nearest and min = nearest and mip = linear */
  30941. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30942. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30943. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30944. /** Trilinear is mag = linear and min = linear and mip = linear */
  30945. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30946. /** nearest is mag = nearest and min = nearest and mip = linear */
  30947. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30948. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30949. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30950. /** Trilinear is mag = linear and min = linear and mip = linear */
  30951. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30952. /** mag = nearest and min = nearest and mip = nearest */
  30953. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30954. /** mag = nearest and min = linear and mip = nearest */
  30955. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30956. /** mag = nearest and min = linear and mip = linear */
  30957. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30958. /** mag = nearest and min = linear and mip = none */
  30959. static readonly TEXTURE_NEAREST_LINEAR: number;
  30960. /** mag = nearest and min = nearest and mip = none */
  30961. static readonly TEXTURE_NEAREST_NEAREST: number;
  30962. /** mag = linear and min = nearest and mip = nearest */
  30963. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30964. /** mag = linear and min = nearest and mip = linear */
  30965. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30966. /** mag = linear and min = linear and mip = none */
  30967. static readonly TEXTURE_LINEAR_LINEAR: number;
  30968. /** mag = linear and min = nearest and mip = none */
  30969. static readonly TEXTURE_LINEAR_NEAREST: number;
  30970. /** Explicit coordinates mode */
  30971. static readonly TEXTURE_EXPLICIT_MODE: number;
  30972. /** Spherical coordinates mode */
  30973. static readonly TEXTURE_SPHERICAL_MODE: number;
  30974. /** Planar coordinates mode */
  30975. static readonly TEXTURE_PLANAR_MODE: number;
  30976. /** Cubic coordinates mode */
  30977. static readonly TEXTURE_CUBIC_MODE: number;
  30978. /** Projection coordinates mode */
  30979. static readonly TEXTURE_PROJECTION_MODE: number;
  30980. /** Skybox coordinates mode */
  30981. static readonly TEXTURE_SKYBOX_MODE: number;
  30982. /** Inverse Cubic coordinates mode */
  30983. static readonly TEXTURE_INVCUBIC_MODE: number;
  30984. /** Equirectangular coordinates mode */
  30985. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30986. /** Equirectangular Fixed coordinates mode */
  30987. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30988. /** Equirectangular Fixed Mirrored coordinates mode */
  30989. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30990. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30991. static readonly SCALEMODE_FLOOR: number;
  30992. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30993. static readonly SCALEMODE_NEAREST: number;
  30994. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30995. static readonly SCALEMODE_CEILING: number;
  30996. /**
  30997. * Returns the current npm package of the sdk
  30998. */
  30999. static readonly NpmPackage: string;
  31000. /**
  31001. * Returns the current version of the framework
  31002. */
  31003. static readonly Version: string;
  31004. /**
  31005. * Returns a string describing the current engine
  31006. */
  31007. readonly description: string;
  31008. /**
  31009. * Gets or sets the epsilon value used by collision engine
  31010. */
  31011. static CollisionsEpsilon: number;
  31012. /**
  31013. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31014. */
  31015. static ShadersRepository: string;
  31016. /**
  31017. * Method called to create the default loading screen.
  31018. * This can be overriden in your own app.
  31019. * @param canvas The rendering canvas element
  31020. * @returns The loading screen
  31021. */
  31022. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31023. /**
  31024. * Method called to create the default rescale post process on each engine.
  31025. */
  31026. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31027. /** @hidden */
  31028. _shaderProcessor: IShaderProcessor;
  31029. /**
  31030. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31031. */
  31032. forcePOTTextures: boolean;
  31033. /**
  31034. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31035. */
  31036. isFullscreen: boolean;
  31037. /**
  31038. * Gets a boolean indicating if the pointer is currently locked
  31039. */
  31040. isPointerLock: boolean;
  31041. /**
  31042. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31043. */
  31044. cullBackFaces: boolean;
  31045. /**
  31046. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31047. */
  31048. renderEvenInBackground: boolean;
  31049. /**
  31050. * Gets or sets a boolean indicating that cache can be kept between frames
  31051. */
  31052. preventCacheWipeBetweenFrames: boolean;
  31053. /**
  31054. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31055. **/
  31056. enableOfflineSupport: boolean;
  31057. /**
  31058. * 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)
  31059. **/
  31060. disableManifestCheck: boolean;
  31061. /**
  31062. * Gets the list of created scenes
  31063. */
  31064. scenes: Scene[];
  31065. /**
  31066. * Event raised when a new scene is created
  31067. */
  31068. onNewSceneAddedObservable: Observable<Scene>;
  31069. /**
  31070. * Gets the list of created postprocesses
  31071. */
  31072. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  31073. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31074. validateShaderPrograms: boolean;
  31075. /**
  31076. * Observable event triggered each time the rendering canvas is resized
  31077. */
  31078. onResizeObservable: Observable<Engine>;
  31079. /**
  31080. * Observable event triggered each time the canvas loses focus
  31081. */
  31082. onCanvasBlurObservable: Observable<Engine>;
  31083. /**
  31084. * Observable event triggered each time the canvas gains focus
  31085. */
  31086. onCanvasFocusObservable: Observable<Engine>;
  31087. /**
  31088. * Observable event triggered each time the canvas receives pointerout event
  31089. */
  31090. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31091. /**
  31092. * Observable event triggered before each texture is initialized
  31093. */
  31094. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31095. /**
  31096. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31097. */
  31098. disableUniformBuffers: boolean;
  31099. /** @hidden */
  31100. _uniformBuffers: UniformBuffer[];
  31101. /**
  31102. * Gets a boolean indicating that the engine supports uniform buffers
  31103. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31104. */
  31105. readonly supportsUniformBuffers: boolean;
  31106. /**
  31107. * Observable raised when the engine begins a new frame
  31108. */
  31109. onBeginFrameObservable: Observable<Engine>;
  31110. /**
  31111. * If set, will be used to request the next animation frame for the render loop
  31112. */
  31113. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31114. /**
  31115. * Observable raised when the engine ends the current frame
  31116. */
  31117. onEndFrameObservable: Observable<Engine>;
  31118. /**
  31119. * Observable raised when the engine is about to compile a shader
  31120. */
  31121. onBeforeShaderCompilationObservable: Observable<Engine>;
  31122. /**
  31123. * Observable raised when the engine has jsut compiled a shader
  31124. */
  31125. onAfterShaderCompilationObservable: Observable<Engine>;
  31126. /** @hidden */
  31127. _gl: WebGLRenderingContext;
  31128. private _renderingCanvas;
  31129. private _windowIsBackground;
  31130. protected _webGLVersion: number;
  31131. protected _highPrecisionShadersAllowed: boolean;
  31132. /** @hidden */
  31133. readonly _shouldUseHighPrecisionShader: boolean;
  31134. /**
  31135. * Gets a boolean indicating that only power of 2 textures are supported
  31136. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31137. */
  31138. readonly needPOTTextures: boolean;
  31139. /** @hidden */
  31140. _badOS: boolean;
  31141. /** @hidden */
  31142. _badDesktopOS: boolean;
  31143. /**
  31144. * Gets the audio engine
  31145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31146. * @ignorenaming
  31147. */
  31148. static audioEngine: IAudioEngine;
  31149. /**
  31150. * Default AudioEngine factory responsible of creating the Audio Engine.
  31151. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31152. */
  31153. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31154. /**
  31155. * Default offline support factory responsible of creating a tool used to store data locally.
  31156. * By default, this will create a Database object if the workload has been embedded.
  31157. */
  31158. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31159. private _onFocus;
  31160. private _onBlur;
  31161. private _onCanvasPointerOut;
  31162. private _onCanvasBlur;
  31163. private _onCanvasFocus;
  31164. private _onFullscreenChange;
  31165. private _onPointerLockChange;
  31166. private _hardwareScalingLevel;
  31167. /** @hidden */
  31168. _caps: EngineCapabilities;
  31169. private _pointerLockRequested;
  31170. private _isStencilEnable;
  31171. protected _colorWrite: boolean;
  31172. private _loadingScreen;
  31173. /** @hidden */
  31174. _drawCalls: PerfCounter;
  31175. private _glVersion;
  31176. private _glRenderer;
  31177. private _glVendor;
  31178. private _videoTextureSupported;
  31179. private _renderingQueueLaunched;
  31180. private _activeRenderLoops;
  31181. private _deterministicLockstep;
  31182. private _lockstepMaxSteps;
  31183. /**
  31184. * Observable signaled when a context lost event is raised
  31185. */
  31186. onContextLostObservable: Observable<Engine>;
  31187. /**
  31188. * Observable signaled when a context restored event is raised
  31189. */
  31190. onContextRestoredObservable: Observable<Engine>;
  31191. private _onContextLost;
  31192. private _onContextRestored;
  31193. private _contextWasLost;
  31194. /** @hidden */
  31195. _doNotHandleContextLost: boolean;
  31196. /**
  31197. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31198. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31199. */
  31200. doNotHandleContextLost: boolean;
  31201. private _performanceMonitor;
  31202. private _fps;
  31203. private _deltaTime;
  31204. /**
  31205. * Turn this value on if you want to pause FPS computation when in background
  31206. */
  31207. disablePerformanceMonitorInBackground: boolean;
  31208. /**
  31209. * Gets the performance monitor attached to this engine
  31210. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31211. */
  31212. readonly performanceMonitor: PerformanceMonitor;
  31213. /**
  31214. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31215. */
  31216. disableVertexArrayObjects: boolean;
  31217. /** @hidden */
  31218. protected _depthCullingState: _DepthCullingState;
  31219. /** @hidden */
  31220. protected _stencilState: _StencilState;
  31221. /** @hidden */
  31222. protected _alphaState: _AlphaState;
  31223. /** @hidden */
  31224. protected _alphaMode: number;
  31225. /** @hidden */
  31226. protected _alphaEquation: number;
  31227. /** @hidden */
  31228. _internalTexturesCache: InternalTexture[];
  31229. /** @hidden */
  31230. protected _activeChannel: number;
  31231. private _currentTextureChannel;
  31232. /** @hidden */
  31233. protected _boundTexturesCache: {
  31234. [key: string]: Nullable<InternalTexture>;
  31235. };
  31236. /** @hidden */
  31237. protected _currentEffect: Nullable<Effect>;
  31238. /** @hidden */
  31239. protected _currentProgram: Nullable<WebGLProgram>;
  31240. private _compiledEffects;
  31241. private _vertexAttribArraysEnabled;
  31242. /** @hidden */
  31243. protected _cachedViewport: Nullable<IViewportLike>;
  31244. private _cachedVertexArrayObject;
  31245. /** @hidden */
  31246. protected _cachedVertexBuffers: any;
  31247. /** @hidden */
  31248. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31249. /** @hidden */
  31250. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31251. /** @hidden */
  31252. _currentRenderTarget: Nullable<InternalTexture>;
  31253. private _uintIndicesCurrentlySet;
  31254. private _currentBoundBuffer;
  31255. /** @hidden */
  31256. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31257. private _currentBufferPointers;
  31258. private _currentInstanceLocations;
  31259. private _currentInstanceBuffers;
  31260. private _textureUnits;
  31261. /** @hidden */
  31262. _workingCanvas: Nullable<HTMLCanvasElement>;
  31263. /** @hidden */
  31264. _workingContext: Nullable<CanvasRenderingContext2D>;
  31265. private _rescalePostProcess;
  31266. private _dummyFramebuffer;
  31267. private _externalData;
  31268. /** @hidden */
  31269. _bindedRenderFunction: any;
  31270. private _vaoRecordInProgress;
  31271. private _mustWipeVertexAttributes;
  31272. private _emptyTexture;
  31273. private _emptyCubeTexture;
  31274. private _emptyTexture3D;
  31275. /** @hidden */
  31276. _frameHandler: number;
  31277. private _nextFreeTextureSlots;
  31278. private _maxSimultaneousTextures;
  31279. private _activeRequests;
  31280. private _texturesSupported;
  31281. /** @hidden */
  31282. _textureFormatInUse: Nullable<string>;
  31283. /**
  31284. * Gets the list of texture formats supported
  31285. */
  31286. readonly texturesSupported: Array<string>;
  31287. /**
  31288. * Gets the list of texture formats in use
  31289. */
  31290. readonly textureFormatInUse: Nullable<string>;
  31291. /**
  31292. * Gets the current viewport
  31293. */
  31294. readonly currentViewport: Nullable<IViewportLike>;
  31295. /**
  31296. * Gets the default empty texture
  31297. */
  31298. readonly emptyTexture: InternalTexture;
  31299. /**
  31300. * Gets the default empty 3D texture
  31301. */
  31302. readonly emptyTexture3D: InternalTexture;
  31303. /**
  31304. * Gets the default empty cube texture
  31305. */
  31306. readonly emptyCubeTexture: InternalTexture;
  31307. /**
  31308. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31309. */
  31310. readonly premultipliedAlpha: boolean;
  31311. /**
  31312. * Creates a new engine
  31313. * @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
  31314. * @param antialias defines enable antialiasing (default: false)
  31315. * @param options defines further options to be sent to the getContext() function
  31316. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31317. */
  31318. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31319. /**
  31320. * Initializes a webVR display and starts listening to display change events
  31321. * The onVRDisplayChangedObservable will be notified upon these changes
  31322. * @returns The onVRDisplayChangedObservable
  31323. */
  31324. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31325. /** @hidden */
  31326. _prepareVRComponent(): void;
  31327. /** @hidden */
  31328. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31329. /** @hidden */
  31330. _submitVRFrame(): void;
  31331. /**
  31332. * Call this function to leave webVR mode
  31333. * Will do nothing if webVR is not supported or if there is no webVR device
  31334. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31335. */
  31336. disableVR(): void;
  31337. /**
  31338. * Gets a boolean indicating that the system is in VR mode and is presenting
  31339. * @returns true if VR mode is engaged
  31340. */
  31341. isVRPresenting(): boolean;
  31342. /** @hidden */
  31343. _requestVRFrame(): void;
  31344. private _disableTouchAction;
  31345. private _rebuildInternalTextures;
  31346. private _rebuildEffects;
  31347. /**
  31348. * Gets a boolean indicating if all created effects are ready
  31349. * @returns true if all effects are ready
  31350. */
  31351. areAllEffectsReady(): boolean;
  31352. private _rebuildBuffers;
  31353. private _initGLContext;
  31354. /**
  31355. * Gets version of the current webGL context
  31356. */
  31357. readonly webGLVersion: number;
  31358. /**
  31359. * Gets a string idenfifying the name of the class
  31360. * @returns "Engine" string
  31361. */
  31362. getClassName(): string;
  31363. /**
  31364. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31365. */
  31366. readonly isStencilEnable: boolean;
  31367. /** @hidden */
  31368. _prepareWorkingCanvas(): void;
  31369. /**
  31370. * Reset the texture cache to empty state
  31371. */
  31372. resetTextureCache(): void;
  31373. /**
  31374. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31375. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31376. * @returns true if engine is in deterministic lock step mode
  31377. */
  31378. isDeterministicLockStep(): boolean;
  31379. /**
  31380. * Gets the max steps when engine is running in deterministic lock step
  31381. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31382. * @returns the max steps
  31383. */
  31384. getLockstepMaxSteps(): number;
  31385. /**
  31386. * Gets an object containing information about the current webGL context
  31387. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31388. */
  31389. getGlInfo(): {
  31390. vendor: string;
  31391. renderer: string;
  31392. version: string;
  31393. };
  31394. /**
  31395. * Gets current aspect ratio
  31396. * @param viewportOwner defines the camera to use to get the aspect ratio
  31397. * @param useScreen defines if screen size must be used (or the current render target if any)
  31398. * @returns a number defining the aspect ratio
  31399. */
  31400. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31401. /**
  31402. * Gets current screen aspect ratio
  31403. * @returns a number defining the aspect ratio
  31404. */
  31405. getScreenAspectRatio(): number;
  31406. /**
  31407. * Gets the current render width
  31408. * @param useScreen defines if screen size must be used (or the current render target if any)
  31409. * @returns a number defining the current render width
  31410. */
  31411. getRenderWidth(useScreen?: boolean): number;
  31412. /**
  31413. * Gets the current render height
  31414. * @param useScreen defines if screen size must be used (or the current render target if any)
  31415. * @returns a number defining the current render height
  31416. */
  31417. getRenderHeight(useScreen?: boolean): number;
  31418. /**
  31419. * Gets the HTML canvas attached with the current webGL context
  31420. * @returns a HTML canvas
  31421. */
  31422. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31423. /**
  31424. * Gets host window
  31425. * @returns the host window object
  31426. */
  31427. getHostWindow(): Window;
  31428. /**
  31429. * Gets host document
  31430. * @returns the host document object
  31431. */
  31432. getHostDocument(): Document;
  31433. /**
  31434. * Gets the client rect of the HTML canvas attached with the current webGL context
  31435. * @returns a client rectanglee
  31436. */
  31437. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31438. /**
  31439. * Defines the hardware scaling level.
  31440. * By default the hardware scaling level is computed from the window device ratio.
  31441. * 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.
  31442. * @param level defines the level to use
  31443. */
  31444. setHardwareScalingLevel(level: number): void;
  31445. /**
  31446. * Gets the current hardware scaling level.
  31447. * By default the hardware scaling level is computed from the window device ratio.
  31448. * 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.
  31449. * @returns a number indicating the current hardware scaling level
  31450. */
  31451. getHardwareScalingLevel(): number;
  31452. /**
  31453. * Gets the list of loaded textures
  31454. * @returns an array containing all loaded textures
  31455. */
  31456. getLoadedTexturesCache(): InternalTexture[];
  31457. /**
  31458. * Gets the object containing all engine capabilities
  31459. * @returns the EngineCapabilities object
  31460. */
  31461. getCaps(): EngineCapabilities;
  31462. /**
  31463. * Gets the current depth function
  31464. * @returns a number defining the depth function
  31465. */
  31466. getDepthFunction(): Nullable<number>;
  31467. /**
  31468. * Sets the current depth function
  31469. * @param depthFunc defines the function to use
  31470. */
  31471. setDepthFunction(depthFunc: number): void;
  31472. /**
  31473. * Sets the current depth function to GREATER
  31474. */
  31475. setDepthFunctionToGreater(): void;
  31476. /**
  31477. * Sets the current depth function to GEQUAL
  31478. */
  31479. setDepthFunctionToGreaterOrEqual(): void;
  31480. /**
  31481. * Sets the current depth function to LESS
  31482. */
  31483. setDepthFunctionToLess(): void;
  31484. private _cachedStencilBuffer;
  31485. private _cachedStencilFunction;
  31486. private _cachedStencilMask;
  31487. private _cachedStencilOperationPass;
  31488. private _cachedStencilOperationFail;
  31489. private _cachedStencilOperationDepthFail;
  31490. private _cachedStencilReference;
  31491. /**
  31492. * Caches the the state of the stencil buffer
  31493. */
  31494. cacheStencilState(): void;
  31495. /**
  31496. * Restores the state of the stencil buffer
  31497. */
  31498. restoreStencilState(): void;
  31499. /**
  31500. * Sets the current depth function to LEQUAL
  31501. */
  31502. setDepthFunctionToLessOrEqual(): void;
  31503. /**
  31504. * Gets a boolean indicating if stencil buffer is enabled
  31505. * @returns the current stencil buffer state
  31506. */
  31507. getStencilBuffer(): boolean;
  31508. /**
  31509. * Enable or disable the stencil buffer
  31510. * @param enable defines if the stencil buffer must be enabled or disabled
  31511. */
  31512. setStencilBuffer(enable: boolean): void;
  31513. /**
  31514. * Gets the current stencil mask
  31515. * @returns a number defining the new stencil mask to use
  31516. */
  31517. getStencilMask(): number;
  31518. /**
  31519. * Sets the current stencil mask
  31520. * @param mask defines the new stencil mask to use
  31521. */
  31522. setStencilMask(mask: number): void;
  31523. /**
  31524. * Gets the current stencil function
  31525. * @returns a number defining the stencil function to use
  31526. */
  31527. getStencilFunction(): number;
  31528. /**
  31529. * Gets the current stencil reference value
  31530. * @returns a number defining the stencil reference value to use
  31531. */
  31532. getStencilFunctionReference(): number;
  31533. /**
  31534. * Gets the current stencil mask
  31535. * @returns a number defining the stencil mask to use
  31536. */
  31537. getStencilFunctionMask(): number;
  31538. /**
  31539. * Sets the current stencil function
  31540. * @param stencilFunc defines the new stencil function to use
  31541. */
  31542. setStencilFunction(stencilFunc: number): void;
  31543. /**
  31544. * Sets the current stencil reference
  31545. * @param reference defines the new stencil reference to use
  31546. */
  31547. setStencilFunctionReference(reference: number): void;
  31548. /**
  31549. * Sets the current stencil mask
  31550. * @param mask defines the new stencil mask to use
  31551. */
  31552. setStencilFunctionMask(mask: number): void;
  31553. /**
  31554. * Gets the current stencil operation when stencil fails
  31555. * @returns a number defining stencil operation to use when stencil fails
  31556. */
  31557. getStencilOperationFail(): number;
  31558. /**
  31559. * Gets the current stencil operation when depth fails
  31560. * @returns a number defining stencil operation to use when depth fails
  31561. */
  31562. getStencilOperationDepthFail(): number;
  31563. /**
  31564. * Gets the current stencil operation when stencil passes
  31565. * @returns a number defining stencil operation to use when stencil passes
  31566. */
  31567. getStencilOperationPass(): number;
  31568. /**
  31569. * Sets the stencil operation to use when stencil fails
  31570. * @param operation defines the stencil operation to use when stencil fails
  31571. */
  31572. setStencilOperationFail(operation: number): void;
  31573. /**
  31574. * Sets the stencil operation to use when depth fails
  31575. * @param operation defines the stencil operation to use when depth fails
  31576. */
  31577. setStencilOperationDepthFail(operation: number): void;
  31578. /**
  31579. * Sets the stencil operation to use when stencil passes
  31580. * @param operation defines the stencil operation to use when stencil passes
  31581. */
  31582. setStencilOperationPass(operation: number): void;
  31583. /**
  31584. * Sets a boolean indicating if the dithering state is enabled or disabled
  31585. * @param value defines the dithering state
  31586. */
  31587. setDitheringState(value: boolean): void;
  31588. /**
  31589. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31590. * @param value defines the rasterizer state
  31591. */
  31592. setRasterizerState(value: boolean): void;
  31593. /**
  31594. * stop executing a render loop function and remove it from the execution array
  31595. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31596. */
  31597. stopRenderLoop(renderFunction?: () => void): void;
  31598. /** @hidden */
  31599. _renderLoop(): void;
  31600. /**
  31601. * Can be used to override the current requestAnimationFrame requester.
  31602. * @hidden
  31603. */
  31604. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31605. /**
  31606. * Register and execute a render loop. The engine can have more than one render function
  31607. * @param renderFunction defines the function to continuously execute
  31608. */
  31609. runRenderLoop(renderFunction: () => void): void;
  31610. /**
  31611. * Toggle full screen mode
  31612. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31613. */
  31614. switchFullscreen(requestPointerLock: boolean): void;
  31615. /**
  31616. * Enters full screen mode
  31617. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31618. */
  31619. enterFullscreen(requestPointerLock: boolean): void;
  31620. /**
  31621. * Exits full screen mode
  31622. */
  31623. exitFullscreen(): void;
  31624. /**
  31625. * Enters Pointerlock mode
  31626. */
  31627. enterPointerlock(): void;
  31628. /**
  31629. * Exits Pointerlock mode
  31630. */
  31631. exitPointerlock(): void;
  31632. /**
  31633. * Clear the current render buffer or the current render target (if any is set up)
  31634. * @param color defines the color to use
  31635. * @param backBuffer defines if the back buffer must be cleared
  31636. * @param depth defines if the depth buffer must be cleared
  31637. * @param stencil defines if the stencil buffer must be cleared
  31638. */
  31639. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31640. /**
  31641. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31642. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31643. * @param y defines the y-coordinate of the corner of the clear rectangle
  31644. * @param width defines the width of the clear rectangle
  31645. * @param height defines the height of the clear rectangle
  31646. * @param clearColor defines the clear color
  31647. */
  31648. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31649. /**
  31650. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31651. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31652. * @param y defines the y-coordinate of the corner of the clear rectangle
  31653. * @param width defines the width of the clear rectangle
  31654. * @param height defines the height of the clear rectangle
  31655. */
  31656. enableScissor(x: number, y: number, width: number, height: number): void;
  31657. /**
  31658. * Disable previously set scissor test rectangle
  31659. */
  31660. disableScissor(): void;
  31661. private _viewportCached;
  31662. /** @hidden */
  31663. _viewport(x: number, y: number, width: number, height: number): void;
  31664. /**
  31665. * Set the WebGL's viewport
  31666. * @param viewport defines the viewport element to be used
  31667. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31668. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31669. */
  31670. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31671. /**
  31672. * Directly set the WebGL Viewport
  31673. * @param x defines the x coordinate of the viewport (in screen space)
  31674. * @param y defines the y coordinate of the viewport (in screen space)
  31675. * @param width defines the width of the viewport (in screen space)
  31676. * @param height defines the height of the viewport (in screen space)
  31677. * @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
  31678. */
  31679. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31680. /**
  31681. * Begin a new frame
  31682. */
  31683. beginFrame(): void;
  31684. /**
  31685. * Enf the current frame
  31686. */
  31687. endFrame(): void;
  31688. /**
  31689. * Resize the view according to the canvas' size
  31690. */
  31691. resize(): void;
  31692. /**
  31693. * Force a specific size of the canvas
  31694. * @param width defines the new canvas' width
  31695. * @param height defines the new canvas' height
  31696. */
  31697. setSize(width: number, height: number): void;
  31698. /**
  31699. * Binds the frame buffer to the specified texture.
  31700. * @param texture The texture to render to or null for the default canvas
  31701. * @param faceIndex The face of the texture to render to in case of cube texture
  31702. * @param requiredWidth The width of the target to render to
  31703. * @param requiredHeight The height of the target to render to
  31704. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31705. * @param depthStencilTexture The depth stencil texture to use to render
  31706. * @param lodLevel defines le lod level to bind to the frame buffer
  31707. */
  31708. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31709. /** @hidden */
  31710. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31711. /**
  31712. * Unbind the current render target texture from the webGL context
  31713. * @param texture defines the render target texture to unbind
  31714. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31715. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31716. */
  31717. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31718. /**
  31719. * Force the mipmap generation for the given render target texture
  31720. * @param texture defines the render target texture to use
  31721. */
  31722. generateMipMapsForCubemap(texture: InternalTexture): void;
  31723. /**
  31724. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31725. */
  31726. flushFramebuffer(): void;
  31727. /**
  31728. * Unbind the current render target and bind the default framebuffer
  31729. */
  31730. restoreDefaultFramebuffer(): void;
  31731. /**
  31732. * Create an uniform buffer
  31733. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31734. * @param elements defines the content of the uniform buffer
  31735. * @returns the webGL uniform buffer
  31736. */
  31737. createUniformBuffer(elements: FloatArray): DataBuffer;
  31738. /**
  31739. * Create a dynamic uniform buffer
  31740. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31741. * @param elements defines the content of the uniform buffer
  31742. * @returns the webGL uniform buffer
  31743. */
  31744. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31745. /**
  31746. * Update an existing uniform buffer
  31747. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31748. * @param uniformBuffer defines the target uniform buffer
  31749. * @param elements defines the content to update
  31750. * @param offset defines the offset in the uniform buffer where update should start
  31751. * @param count defines the size of the data to update
  31752. */
  31753. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31754. private _resetVertexBufferBinding;
  31755. /**
  31756. * Creates a vertex buffer
  31757. * @param data the data for the vertex buffer
  31758. * @returns the new WebGL static buffer
  31759. */
  31760. createVertexBuffer(data: DataArray): DataBuffer;
  31761. /**
  31762. * Creates a dynamic vertex buffer
  31763. * @param data the data for the dynamic vertex buffer
  31764. * @returns the new WebGL dynamic buffer
  31765. */
  31766. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31767. /**
  31768. * Update a dynamic index buffer
  31769. * @param indexBuffer defines the target index buffer
  31770. * @param indices defines the data to update
  31771. * @param offset defines the offset in the target index buffer where update should start
  31772. */
  31773. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31774. /**
  31775. * Updates a dynamic vertex buffer.
  31776. * @param vertexBuffer the vertex buffer to update
  31777. * @param data the data used to update the vertex buffer
  31778. * @param byteOffset the byte offset of the data
  31779. * @param byteLength the byte length of the data
  31780. */
  31781. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31782. private _resetIndexBufferBinding;
  31783. /**
  31784. * Creates a new index buffer
  31785. * @param indices defines the content of the index buffer
  31786. * @param updatable defines if the index buffer must be updatable
  31787. * @returns a new webGL buffer
  31788. */
  31789. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31790. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31791. /**
  31792. * Bind a webGL buffer to the webGL context
  31793. * @param buffer defines the buffer to bind
  31794. */
  31795. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31796. /**
  31797. * Bind an uniform buffer to the current webGL context
  31798. * @param buffer defines the buffer to bind
  31799. */
  31800. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31801. /**
  31802. * Bind a buffer to the current webGL context at a given location
  31803. * @param buffer defines the buffer to bind
  31804. * @param location defines the index where to bind the buffer
  31805. */
  31806. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31807. /**
  31808. * Bind a specific block at a given index in a specific shader program
  31809. * @param pipelineContext defines the pipeline context to use
  31810. * @param blockName defines the block name
  31811. * @param index defines the index where to bind the block
  31812. */
  31813. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31814. private bindIndexBuffer;
  31815. private bindBuffer;
  31816. /**
  31817. * update the bound buffer with the given data
  31818. * @param data defines the data to update
  31819. */
  31820. updateArrayBuffer(data: Float32Array): void;
  31821. private _vertexAttribPointer;
  31822. private _bindIndexBufferWithCache;
  31823. private _bindVertexBuffersAttributes;
  31824. /**
  31825. * Records a vertex array object
  31826. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31827. * @param vertexBuffers defines the list of vertex buffers to store
  31828. * @param indexBuffer defines the index buffer to store
  31829. * @param effect defines the effect to store
  31830. * @returns the new vertex array object
  31831. */
  31832. recordVertexArrayObject(vertexBuffers: {
  31833. [key: string]: VertexBuffer;
  31834. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31835. /**
  31836. * Bind a specific vertex array object
  31837. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31838. * @param vertexArrayObject defines the vertex array object to bind
  31839. * @param indexBuffer defines the index buffer to bind
  31840. */
  31841. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31842. /**
  31843. * Bind webGl buffers directly to the webGL context
  31844. * @param vertexBuffer defines the vertex buffer to bind
  31845. * @param indexBuffer defines the index buffer to bind
  31846. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31847. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31848. * @param effect defines the effect associated with the vertex buffer
  31849. */
  31850. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31851. private _unbindVertexArrayObject;
  31852. /**
  31853. * Bind a list of vertex buffers to the webGL context
  31854. * @param vertexBuffers defines the list of vertex buffers to bind
  31855. * @param indexBuffer defines the index buffer to bind
  31856. * @param effect defines the effect associated with the vertex buffers
  31857. */
  31858. bindBuffers(vertexBuffers: {
  31859. [key: string]: Nullable<VertexBuffer>;
  31860. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31861. /**
  31862. * Unbind all instance attributes
  31863. */
  31864. unbindInstanceAttributes(): void;
  31865. /**
  31866. * Release and free the memory of a vertex array object
  31867. * @param vao defines the vertex array object to delete
  31868. */
  31869. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31870. /** @hidden */
  31871. _releaseBuffer(buffer: DataBuffer): boolean;
  31872. protected _deleteBuffer(buffer: DataBuffer): void;
  31873. /**
  31874. * Creates a webGL buffer to use with instanciation
  31875. * @param capacity defines the size of the buffer
  31876. * @returns the webGL buffer
  31877. */
  31878. createInstancesBuffer(capacity: number): DataBuffer;
  31879. /**
  31880. * Delete a webGL buffer used with instanciation
  31881. * @param buffer defines the webGL buffer to delete
  31882. */
  31883. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31884. /**
  31885. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31886. * @param instancesBuffer defines the webGL buffer to update and bind
  31887. * @param data defines the data to store in the buffer
  31888. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31889. */
  31890. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31891. /**
  31892. * Apply all cached states (depth, culling, stencil and alpha)
  31893. */
  31894. applyStates(): void;
  31895. /**
  31896. * Send a draw order
  31897. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31898. * @param indexStart defines the starting index
  31899. * @param indexCount defines the number of index to draw
  31900. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31901. */
  31902. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31903. /**
  31904. * Draw a list of points
  31905. * @param verticesStart defines the index of first vertex to draw
  31906. * @param verticesCount defines the count of vertices to draw
  31907. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31908. */
  31909. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31910. /**
  31911. * Draw a list of unindexed primitives
  31912. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31913. * @param verticesStart defines the index of first vertex to draw
  31914. * @param verticesCount defines the count of vertices to draw
  31915. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31916. */
  31917. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31918. /**
  31919. * Draw a list of indexed primitives
  31920. * @param fillMode defines the primitive to use
  31921. * @param indexStart defines the starting index
  31922. * @param indexCount defines the number of index to draw
  31923. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31924. */
  31925. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31926. /**
  31927. * Draw a list of unindexed primitives
  31928. * @param fillMode defines the primitive to use
  31929. * @param verticesStart defines the index of first vertex to draw
  31930. * @param verticesCount defines the count of vertices to draw
  31931. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31932. */
  31933. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31934. private _drawMode;
  31935. /** @hidden */
  31936. _releaseEffect(effect: Effect): void;
  31937. /** @hidden */
  31938. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31939. /**
  31940. * Create a new effect (used to store vertex/fragment shaders)
  31941. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31942. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31943. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31944. * @param samplers defines an array of string used to represent textures
  31945. * @param defines defines the string containing the defines to use to compile the shaders
  31946. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31947. * @param onCompiled defines a function to call when the effect creation is successful
  31948. * @param onError defines a function to call when the effect creation has failed
  31949. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31950. * @returns the new Effect
  31951. */
  31952. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31953. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31954. private _compileShader;
  31955. private _compileRawShader;
  31956. /**
  31957. * Directly creates a webGL program
  31958. * @param pipelineContext defines the pipeline context to attach to
  31959. * @param vertexCode defines the vertex shader code to use
  31960. * @param fragmentCode defines the fragment shader code to use
  31961. * @param context defines the webGL context to use (if not set, the current one will be used)
  31962. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31963. * @returns the new webGL program
  31964. */
  31965. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31966. /**
  31967. * Creates a webGL program
  31968. * @param pipelineContext defines the pipeline context to attach to
  31969. * @param vertexCode defines the vertex shader code to use
  31970. * @param fragmentCode defines the fragment shader code to use
  31971. * @param defines defines the string containing the defines to use to compile the shaders
  31972. * @param context defines the webGL context to use (if not set, the current one will be used)
  31973. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31974. * @returns the new webGL program
  31975. */
  31976. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31977. /**
  31978. * Creates a new pipeline context
  31979. * @returns the new pipeline
  31980. */
  31981. createPipelineContext(): IPipelineContext;
  31982. private _createShaderProgram;
  31983. private _finalizePipelineContext;
  31984. /** @hidden */
  31985. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31986. /** @hidden */
  31987. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31988. /** @hidden */
  31989. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31990. /**
  31991. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31992. * @param pipelineContext defines the pipeline context to use
  31993. * @param uniformsNames defines the list of uniform names
  31994. * @returns an array of webGL uniform locations
  31995. */
  31996. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31997. /**
  31998. * Gets the lsit of active attributes for a given webGL program
  31999. * @param pipelineContext defines the pipeline context to use
  32000. * @param attributesNames defines the list of attribute names to get
  32001. * @returns an array of indices indicating the offset of each attribute
  32002. */
  32003. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32004. /**
  32005. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32006. * @param effect defines the effect to activate
  32007. */
  32008. enableEffect(effect: Nullable<Effect>): void;
  32009. /**
  32010. * Set the value of an uniform to an array of int32
  32011. * @param uniform defines the webGL uniform location where to store the value
  32012. * @param array defines the array of int32 to store
  32013. */
  32014. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32015. /**
  32016. * Set the value of an uniform to an array of int32 (stored as vec2)
  32017. * @param uniform defines the webGL uniform location where to store the value
  32018. * @param array defines the array of int32 to store
  32019. */
  32020. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32021. /**
  32022. * Set the value of an uniform to an array of int32 (stored as vec3)
  32023. * @param uniform defines the webGL uniform location where to store the value
  32024. * @param array defines the array of int32 to store
  32025. */
  32026. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32027. /**
  32028. * Set the value of an uniform to an array of int32 (stored as vec4)
  32029. * @param uniform defines the webGL uniform location where to store the value
  32030. * @param array defines the array of int32 to store
  32031. */
  32032. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32033. /**
  32034. * Set the value of an uniform to an array of float32
  32035. * @param uniform defines the webGL uniform location where to store the value
  32036. * @param array defines the array of float32 to store
  32037. */
  32038. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32039. /**
  32040. * Set the value of an uniform to an array of float32 (stored as vec2)
  32041. * @param uniform defines the webGL uniform location where to store the value
  32042. * @param array defines the array of float32 to store
  32043. */
  32044. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32045. /**
  32046. * Set the value of an uniform to an array of float32 (stored as vec3)
  32047. * @param uniform defines the webGL uniform location where to store the value
  32048. * @param array defines the array of float32 to store
  32049. */
  32050. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32051. /**
  32052. * Set the value of an uniform to an array of float32 (stored as vec4)
  32053. * @param uniform defines the webGL uniform location where to store the value
  32054. * @param array defines the array of float32 to store
  32055. */
  32056. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32057. /**
  32058. * Set the value of an uniform to an array of number
  32059. * @param uniform defines the webGL uniform location where to store the value
  32060. * @param array defines the array of number to store
  32061. */
  32062. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32063. /**
  32064. * Set the value of an uniform to an array of number (stored as vec2)
  32065. * @param uniform defines the webGL uniform location where to store the value
  32066. * @param array defines the array of number to store
  32067. */
  32068. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32069. /**
  32070. * Set the value of an uniform to an array of number (stored as vec3)
  32071. * @param uniform defines the webGL uniform location where to store the value
  32072. * @param array defines the array of number to store
  32073. */
  32074. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32075. /**
  32076. * Set the value of an uniform to an array of number (stored as vec4)
  32077. * @param uniform defines the webGL uniform location where to store the value
  32078. * @param array defines the array of number to store
  32079. */
  32080. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32081. /**
  32082. * Set the value of an uniform to an array of float32 (stored as matrices)
  32083. * @param uniform defines the webGL uniform location where to store the value
  32084. * @param matrices defines the array of float32 to store
  32085. */
  32086. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32087. /**
  32088. * Set the value of an uniform to a matrix (3x3)
  32089. * @param uniform defines the webGL uniform location where to store the value
  32090. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32091. */
  32092. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32093. /**
  32094. * Set the value of an uniform to a matrix (2x2)
  32095. * @param uniform defines the webGL uniform location where to store the value
  32096. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32097. */
  32098. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32099. /**
  32100. * Set the value of an uniform to a number (int)
  32101. * @param uniform defines the webGL uniform location where to store the value
  32102. * @param value defines the int number to store
  32103. */
  32104. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32105. /**
  32106. * Set the value of an uniform to a number (float)
  32107. * @param uniform defines the webGL uniform location where to store the value
  32108. * @param value defines the float number to store
  32109. */
  32110. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32111. /**
  32112. * Set the value of an uniform to a vec2
  32113. * @param uniform defines the webGL uniform location where to store the value
  32114. * @param x defines the 1st component of the value
  32115. * @param y defines the 2nd component of the value
  32116. */
  32117. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32118. /**
  32119. * Set the value of an uniform to a vec3
  32120. * @param uniform defines the webGL uniform location where to store the value
  32121. * @param x defines the 1st component of the value
  32122. * @param y defines the 2nd component of the value
  32123. * @param z defines the 3rd component of the value
  32124. */
  32125. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32126. /**
  32127. * Set the value of an uniform to a boolean
  32128. * @param uniform defines the webGL uniform location where to store the value
  32129. * @param bool defines the boolean to store
  32130. */
  32131. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  32132. /**
  32133. * Set the value of an uniform to a vec4
  32134. * @param uniform defines the webGL uniform location where to store the value
  32135. * @param x defines the 1st component of the value
  32136. * @param y defines the 2nd component of the value
  32137. * @param z defines the 3rd component of the value
  32138. * @param w defines the 4th component of the value
  32139. */
  32140. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32141. /**
  32142. * Sets a Color4 on a uniform variable
  32143. * @param uniform defines the uniform location
  32144. * @param color4 defines the value to be set
  32145. */
  32146. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  32147. /**
  32148. * Set various states to the webGL context
  32149. * @param culling defines backface culling state
  32150. * @param zOffset defines the value to apply to zOffset (0 by default)
  32151. * @param force defines if states must be applied even if cache is up to date
  32152. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32153. */
  32154. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32155. /**
  32156. * Set the z offset to apply to current rendering
  32157. * @param value defines the offset to apply
  32158. */
  32159. setZOffset(value: number): void;
  32160. /**
  32161. * Gets the current value of the zOffset
  32162. * @returns the current zOffset state
  32163. */
  32164. getZOffset(): number;
  32165. /**
  32166. * Enable or disable depth buffering
  32167. * @param enable defines the state to set
  32168. */
  32169. setDepthBuffer(enable: boolean): void;
  32170. /**
  32171. * Gets a boolean indicating if depth writing is enabled
  32172. * @returns the current depth writing state
  32173. */
  32174. getDepthWrite(): boolean;
  32175. /**
  32176. * Enable or disable depth writing
  32177. * @param enable defines the state to set
  32178. */
  32179. setDepthWrite(enable: boolean): void;
  32180. /**
  32181. * Enable or disable color writing
  32182. * @param enable defines the state to set
  32183. */
  32184. setColorWrite(enable: boolean): void;
  32185. /**
  32186. * Gets a boolean indicating if color writing is enabled
  32187. * @returns the current color writing state
  32188. */
  32189. getColorWrite(): boolean;
  32190. /**
  32191. * Sets alpha constants used by some alpha blending modes
  32192. * @param r defines the red component
  32193. * @param g defines the green component
  32194. * @param b defines the blue component
  32195. * @param a defines the alpha component
  32196. */
  32197. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32198. /**
  32199. * Sets the current alpha mode
  32200. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32201. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32202. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32203. */
  32204. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32205. /**
  32206. * Gets the current alpha mode
  32207. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32208. * @returns the current alpha mode
  32209. */
  32210. getAlphaMode(): number;
  32211. /**
  32212. * Sets the current alpha equation
  32213. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32214. */
  32215. setAlphaEquation(equation: number): void;
  32216. /**
  32217. * Gets the current alpha equation.
  32218. * @returns the current alpha equation
  32219. */
  32220. getAlphaEquation(): number;
  32221. /**
  32222. * Clears the list of texture accessible through engine.
  32223. * This can help preventing texture load conflict due to name collision.
  32224. */
  32225. clearInternalTexturesCache(): void;
  32226. /**
  32227. * Force the entire cache to be cleared
  32228. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32229. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32230. */
  32231. wipeCaches(bruteForce?: boolean): void;
  32232. /**
  32233. * Set the compressed texture format to use, based on the formats you have, and the formats
  32234. * supported by the hardware / browser.
  32235. *
  32236. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32237. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32238. * to API arguments needed to compressed textures. This puts the burden on the container
  32239. * generator to house the arcane code for determining these for current & future formats.
  32240. *
  32241. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32242. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32243. *
  32244. * Note: The result of this call is not taken into account when a texture is base64.
  32245. *
  32246. * @param formatsAvailable defines the list of those format families you have created
  32247. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32248. *
  32249. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32250. * @returns The extension selected.
  32251. */
  32252. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32253. /** @hidden */
  32254. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32255. min: number;
  32256. mag: number;
  32257. };
  32258. /** @hidden */
  32259. _createTexture(): WebGLTexture;
  32260. /**
  32261. * Usually called from Texture.ts.
  32262. * Passed information to create a WebGLTexture
  32263. * @param urlArg defines a value which contains one of the following:
  32264. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32265. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32266. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32267. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32268. * @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)
  32269. * @param scene needed for loading to the correct scene
  32270. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32271. * @param onLoad optional callback to be called upon successful completion
  32272. * @param onError optional callback to be called upon failure
  32273. * @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
  32274. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32275. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32276. * @param forcedExtension defines the extension to use to pick the right loader
  32277. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32278. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32279. */
  32280. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32281. /**
  32282. * @hidden
  32283. * Rescales a texture
  32284. * @param source input texutre
  32285. * @param destination destination texture
  32286. * @param scene scene to use to render the resize
  32287. * @param internalFormat format to use when resizing
  32288. * @param onComplete callback to be called when resize has completed
  32289. */
  32290. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32291. private _unpackFlipYCached;
  32292. /**
  32293. * In case you are sharing the context with other applications, it might
  32294. * be interested to not cache the unpack flip y state to ensure a consistent
  32295. * value would be set.
  32296. */
  32297. enableUnpackFlipYCached: boolean;
  32298. /** @hidden */
  32299. _unpackFlipY(value: boolean): void;
  32300. /** @hidden */
  32301. _getUnpackAlignement(): number;
  32302. /**
  32303. * Creates a dynamic texture
  32304. * @param width defines the width of the texture
  32305. * @param height defines the height of the texture
  32306. * @param generateMipMaps defines if the engine should generate the mip levels
  32307. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32308. * @returns the dynamic texture inside an InternalTexture
  32309. */
  32310. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32311. /**
  32312. * Update the sampling mode of a given texture
  32313. * @param samplingMode defines the required sampling mode
  32314. * @param texture defines the texture to update
  32315. */
  32316. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32317. /**
  32318. * Update the content of a dynamic texture
  32319. * @param texture defines the texture to update
  32320. * @param canvas defines the canvas containing the source
  32321. * @param invertY defines if data must be stored with Y axis inverted
  32322. * @param premulAlpha defines if alpha is stored as premultiplied
  32323. * @param format defines the format of the data
  32324. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32325. */
  32326. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32327. /**
  32328. * Update a video texture
  32329. * @param texture defines the texture to update
  32330. * @param video defines the video element to use
  32331. * @param invertY defines if data must be stored with Y axis inverted
  32332. */
  32333. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32334. /**
  32335. * Updates a depth texture Comparison Mode and Function.
  32336. * If the comparison Function is equal to 0, the mode will be set to none.
  32337. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32338. * @param texture The texture to set the comparison function for
  32339. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32340. */
  32341. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32342. /** @hidden */
  32343. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32344. width: number;
  32345. height: number;
  32346. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32347. /**
  32348. * Creates a depth stencil texture.
  32349. * This is only available in WebGL 2 or with the depth texture extension available.
  32350. * @param size The size of face edge in the texture.
  32351. * @param options The options defining the texture.
  32352. * @returns The texture
  32353. */
  32354. createDepthStencilTexture(size: number | {
  32355. width: number;
  32356. height: number;
  32357. }, options: DepthTextureCreationOptions): InternalTexture;
  32358. /**
  32359. * Creates a depth stencil texture.
  32360. * This is only available in WebGL 2 or with the depth texture extension available.
  32361. * @param size The size of face edge in the texture.
  32362. * @param options The options defining the texture.
  32363. * @returns The texture
  32364. */
  32365. private _createDepthStencilTexture;
  32366. /**
  32367. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32368. * @param renderTarget The render target to set the frame buffer for
  32369. */
  32370. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32371. /**
  32372. * Creates a new render target texture
  32373. * @param size defines the size of the texture
  32374. * @param options defines the options used to create the texture
  32375. * @returns a new render target texture stored in an InternalTexture
  32376. */
  32377. createRenderTargetTexture(size: number | {
  32378. width: number;
  32379. height: number;
  32380. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32381. /** @hidden */
  32382. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32383. /**
  32384. * Updates the sample count of a render target texture
  32385. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32386. * @param texture defines the texture to update
  32387. * @param samples defines the sample count to set
  32388. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32389. */
  32390. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32391. /** @hidden */
  32392. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32393. /** @hidden */
  32394. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32395. /** @hidden */
  32396. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32397. /** @hidden */
  32398. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32399. /**
  32400. * @hidden
  32401. */
  32402. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32403. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32404. private _prepareWebGLTexture;
  32405. /** @hidden */
  32406. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32407. /** @hidden */
  32408. _releaseFramebufferObjects(texture: InternalTexture): void;
  32409. /** @hidden */
  32410. _releaseTexture(texture: InternalTexture): void;
  32411. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32412. protected _setProgram(program: WebGLProgram): void;
  32413. protected _boundUniforms: {
  32414. [key: number]: WebGLUniformLocation;
  32415. };
  32416. /**
  32417. * Binds an effect to the webGL context
  32418. * @param effect defines the effect to bind
  32419. */
  32420. bindSamplers(effect: Effect): void;
  32421. private _activateCurrentTexture;
  32422. /** @hidden */
  32423. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32424. /** @hidden */
  32425. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32426. /**
  32427. * Sets a texture to the webGL context from a postprocess
  32428. * @param channel defines the channel to use
  32429. * @param postProcess defines the source postprocess
  32430. */
  32431. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32432. /**
  32433. * Binds the output of the passed in post process to the texture channel specified
  32434. * @param channel The channel the texture should be bound to
  32435. * @param postProcess The post process which's output should be bound
  32436. */
  32437. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32438. /**
  32439. * Unbind all textures from the webGL context
  32440. */
  32441. unbindAllTextures(): void;
  32442. /**
  32443. * Sets a texture to the according uniform.
  32444. * @param channel The texture channel
  32445. * @param uniform The uniform to set
  32446. * @param texture The texture to apply
  32447. */
  32448. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32449. /**
  32450. * Sets a depth stencil texture from a render target to the according uniform.
  32451. * @param channel The texture channel
  32452. * @param uniform The uniform to set
  32453. * @param texture The render target texture containing the depth stencil texture to apply
  32454. */
  32455. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32456. private _bindSamplerUniformToChannel;
  32457. private _getTextureWrapMode;
  32458. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32459. /**
  32460. * Sets an array of texture to the webGL context
  32461. * @param channel defines the channel where the texture array must be set
  32462. * @param uniform defines the associated uniform location
  32463. * @param textures defines the array of textures to bind
  32464. */
  32465. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32466. /** @hidden */
  32467. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32468. private _setTextureParameterFloat;
  32469. private _setTextureParameterInteger;
  32470. /**
  32471. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32472. * @param x defines the x coordinate of the rectangle where pixels must be read
  32473. * @param y defines the y coordinate of the rectangle where pixels must be read
  32474. * @param width defines the width of the rectangle where pixels must be read
  32475. * @param height defines the height of the rectangle where pixels must be read
  32476. * @returns a Uint8Array containing RGBA colors
  32477. */
  32478. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32479. /**
  32480. * Add an externaly attached data from its key.
  32481. * This method call will fail and return false, if such key already exists.
  32482. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32483. * @param key the unique key that identifies the data
  32484. * @param data the data object to associate to the key for this Engine instance
  32485. * @return true if no such key were already present and the data was added successfully, false otherwise
  32486. */
  32487. addExternalData<T>(key: string, data: T): boolean;
  32488. /**
  32489. * Get an externaly attached data from its key
  32490. * @param key the unique key that identifies the data
  32491. * @return the associated data, if present (can be null), or undefined if not present
  32492. */
  32493. getExternalData<T>(key: string): T;
  32494. /**
  32495. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32496. * @param key the unique key that identifies the data
  32497. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32498. * @return the associated data, can be null if the factory returned null.
  32499. */
  32500. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32501. /**
  32502. * Remove an externaly attached data from the Engine instance
  32503. * @param key the unique key that identifies the data
  32504. * @return true if the data was successfully removed, false if it doesn't exist
  32505. */
  32506. removeExternalData(key: string): boolean;
  32507. /**
  32508. * Unbind all vertex attributes from the webGL context
  32509. */
  32510. unbindAllAttributes(): void;
  32511. /**
  32512. * 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
  32513. */
  32514. releaseEffects(): void;
  32515. /**
  32516. * Dispose and release all associated resources
  32517. */
  32518. dispose(): void;
  32519. /**
  32520. * Display the loading screen
  32521. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32522. */
  32523. displayLoadingUI(): void;
  32524. /**
  32525. * Hide the loading screen
  32526. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32527. */
  32528. hideLoadingUI(): void;
  32529. /**
  32530. * Gets the current loading screen object
  32531. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32532. */
  32533. /**
  32534. * Sets the current loading screen object
  32535. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32536. */
  32537. loadingScreen: ILoadingScreen;
  32538. /**
  32539. * Sets the current loading screen text
  32540. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32541. */
  32542. loadingUIText: string;
  32543. /**
  32544. * Sets the current loading screen background color
  32545. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32546. */
  32547. loadingUIBackgroundColor: string;
  32548. /**
  32549. * Attach a new callback raised when context lost event is fired
  32550. * @param callback defines the callback to call
  32551. */
  32552. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32553. /**
  32554. * Attach a new callback raised when context restored event is fired
  32555. * @param callback defines the callback to call
  32556. */
  32557. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32558. /**
  32559. * Gets the source code of the vertex shader associated with a specific webGL program
  32560. * @param program defines the program to use
  32561. * @returns a string containing the source code of the vertex shader associated with the program
  32562. */
  32563. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32564. /**
  32565. * Gets the source code of the fragment shader associated with a specific webGL program
  32566. * @param program defines the program to use
  32567. * @returns a string containing the source code of the fragment shader associated with the program
  32568. */
  32569. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32570. /**
  32571. * Get the current error code of the webGL context
  32572. * @returns the error code
  32573. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32574. */
  32575. getError(): number;
  32576. /**
  32577. * Gets the current framerate
  32578. * @returns a number representing the framerate
  32579. */
  32580. getFps(): number;
  32581. /**
  32582. * Gets the time spent between current and previous frame
  32583. * @returns a number representing the delta time in ms
  32584. */
  32585. getDeltaTime(): number;
  32586. private _measureFps;
  32587. /** @hidden */
  32588. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32589. private _canRenderToFloatFramebuffer;
  32590. private _canRenderToHalfFloatFramebuffer;
  32591. private _canRenderToFramebuffer;
  32592. /** @hidden */
  32593. _getWebGLTextureType(type: number): number;
  32594. /** @hidden */
  32595. _getInternalFormat(format: number): number;
  32596. /** @hidden */
  32597. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32598. /** @hidden */
  32599. _getRGBAMultiSampleBufferFormat(type: number): number;
  32600. /** @hidden */
  32601. _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;
  32602. /** @hidden */
  32603. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32604. /**
  32605. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32606. * @returns true if the engine can be created
  32607. * @ignorenaming
  32608. */
  32609. static isSupported(): boolean;
  32610. /**
  32611. * Find the next highest power of two.
  32612. * @param x Number to start search from.
  32613. * @return Next highest power of two.
  32614. */
  32615. static CeilingPOT(x: number): number;
  32616. /**
  32617. * Find the next lowest power of two.
  32618. * @param x Number to start search from.
  32619. * @return Next lowest power of two.
  32620. */
  32621. static FloorPOT(x: number): number;
  32622. /**
  32623. * Find the nearest power of two.
  32624. * @param x Number to start search from.
  32625. * @return Next nearest power of two.
  32626. */
  32627. static NearestPOT(x: number): number;
  32628. /**
  32629. * Get the closest exponent of two
  32630. * @param value defines the value to approximate
  32631. * @param max defines the maximum value to return
  32632. * @param mode defines how to define the closest value
  32633. * @returns closest exponent of two of the given value
  32634. */
  32635. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32636. /**
  32637. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32638. * @param func - the function to be called
  32639. * @param requester - the object that will request the next frame. Falls back to window.
  32640. * @returns frame number
  32641. */
  32642. static QueueNewFrame(func: () => void, requester?: any): number;
  32643. /**
  32644. * Ask the browser to promote the current element to pointerlock mode
  32645. * @param element defines the DOM element to promote
  32646. */
  32647. static _RequestPointerlock(element: HTMLElement): void;
  32648. /**
  32649. * Asks the browser to exit pointerlock mode
  32650. */
  32651. static _ExitPointerlock(): void;
  32652. /**
  32653. * Ask the browser to promote the current element to fullscreen rendering mode
  32654. * @param element defines the DOM element to promote
  32655. */
  32656. static _RequestFullscreen(element: HTMLElement): void;
  32657. /**
  32658. * Asks the browser to exit fullscreen mode
  32659. */
  32660. static _ExitFullscreen(): void;
  32661. }
  32662. }
  32663. declare module "babylonjs/Engines/engineStore" {
  32664. import { Nullable } from "babylonjs/types";
  32665. import { Engine } from "babylonjs/Engines/engine";
  32666. import { Scene } from "babylonjs/scene";
  32667. /**
  32668. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32669. * during the life time of the application.
  32670. */
  32671. export class EngineStore {
  32672. /** Gets the list of created engines */
  32673. static Instances: import("babylonjs/Engines/engine").Engine[];
  32674. /** @hidden */
  32675. static _LastCreatedScene: Nullable<Scene>;
  32676. /**
  32677. * Gets the latest created engine
  32678. */
  32679. static readonly LastCreatedEngine: Nullable<Engine>;
  32680. /**
  32681. * Gets the latest created scene
  32682. */
  32683. static readonly LastCreatedScene: Nullable<Scene>;
  32684. /**
  32685. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32686. * @ignorenaming
  32687. */
  32688. static UseFallbackTexture: boolean;
  32689. /**
  32690. * Texture content used if a texture cannot loaded
  32691. * @ignorenaming
  32692. */
  32693. static FallbackTexture: string;
  32694. }
  32695. }
  32696. declare module "babylonjs/Misc/promise" {
  32697. /**
  32698. * Helper class that provides a small promise polyfill
  32699. */
  32700. export class PromisePolyfill {
  32701. /**
  32702. * Static function used to check if the polyfill is required
  32703. * If this is the case then the function will inject the polyfill to window.Promise
  32704. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32705. */
  32706. static Apply(force?: boolean): void;
  32707. }
  32708. }
  32709. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32710. /**
  32711. * Interface for screenshot methods with describe argument called `size` as object with options
  32712. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32713. */
  32714. export interface IScreenshotSize {
  32715. /**
  32716. * number in pixels for canvas height
  32717. */
  32718. height?: number;
  32719. /**
  32720. * multiplier allowing render at a higher or lower resolution
  32721. * If value is defined then height and width will be ignored and taken from camera
  32722. */
  32723. precision?: number;
  32724. /**
  32725. * number in pixels for canvas width
  32726. */
  32727. width?: number;
  32728. }
  32729. }
  32730. declare module "babylonjs/Misc/tools" {
  32731. import { Nullable, float } from "babylonjs/types";
  32732. import { DomManagement } from "babylonjs/Misc/domManagement";
  32733. import { WebRequest } from "babylonjs/Misc/webRequest";
  32734. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32735. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32736. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32737. import { Camera } from "babylonjs/Cameras/camera";
  32738. import { Engine } from "babylonjs/Engines/engine";
  32739. interface IColor4Like {
  32740. r: float;
  32741. g: float;
  32742. b: float;
  32743. a: float;
  32744. }
  32745. /**
  32746. * Class containing a set of static utilities functions
  32747. */
  32748. export class Tools {
  32749. /**
  32750. * Gets or sets the base URL to use to load assets
  32751. */
  32752. static BaseUrl: string;
  32753. /**
  32754. * Enable/Disable Custom HTTP Request Headers globally.
  32755. * default = false
  32756. * @see CustomRequestHeaders
  32757. */
  32758. static UseCustomRequestHeaders: boolean;
  32759. /**
  32760. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32761. * i.e. when loading files, where the server/service expects an Authorization header
  32762. */
  32763. static CustomRequestHeaders: {
  32764. [key: string]: string;
  32765. };
  32766. /**
  32767. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32768. */
  32769. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32770. /**
  32771. * Default behaviour for cors in the application.
  32772. * It can be a string if the expected behavior is identical in the entire app.
  32773. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32774. */
  32775. static CorsBehavior: string | ((url: string | string[]) => string);
  32776. /**
  32777. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32778. * @ignorenaming
  32779. */
  32780. static UseFallbackTexture: boolean;
  32781. /**
  32782. * Use this object to register external classes like custom textures or material
  32783. * to allow the laoders to instantiate them
  32784. */
  32785. static RegisteredExternalClasses: {
  32786. [key: string]: Object;
  32787. };
  32788. /**
  32789. * Texture content used if a texture cannot loaded
  32790. * @ignorenaming
  32791. */
  32792. static fallbackTexture: string;
  32793. /**
  32794. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32795. * @param u defines the coordinate on X axis
  32796. * @param v defines the coordinate on Y axis
  32797. * @param width defines the width of the source data
  32798. * @param height defines the height of the source data
  32799. * @param pixels defines the source byte array
  32800. * @param color defines the output color
  32801. */
  32802. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32803. /**
  32804. * Interpolates between a and b via alpha
  32805. * @param a The lower value (returned when alpha = 0)
  32806. * @param b The upper value (returned when alpha = 1)
  32807. * @param alpha The interpolation-factor
  32808. * @return The mixed value
  32809. */
  32810. static Mix(a: number, b: number, alpha: number): number;
  32811. /**
  32812. * Tries to instantiate a new object from a given class name
  32813. * @param className defines the class name to instantiate
  32814. * @returns the new object or null if the system was not able to do the instantiation
  32815. */
  32816. static Instantiate(className: string): any;
  32817. /**
  32818. * Provides a slice function that will work even on IE
  32819. * @param data defines the array to slice
  32820. * @param start defines the start of the data (optional)
  32821. * @param end defines the end of the data (optional)
  32822. * @returns the new sliced array
  32823. */
  32824. static Slice<T>(data: T, start?: number, end?: number): T;
  32825. /**
  32826. * Polyfill for setImmediate
  32827. * @param action defines the action to execute after the current execution block
  32828. */
  32829. static SetImmediate(action: () => void): void;
  32830. /**
  32831. * Function indicating if a number is an exponent of 2
  32832. * @param value defines the value to test
  32833. * @returns true if the value is an exponent of 2
  32834. */
  32835. static IsExponentOfTwo(value: number): boolean;
  32836. private static _tmpFloatArray;
  32837. /**
  32838. * Returns the nearest 32-bit single precision float representation of a Number
  32839. * @param value A Number. If the parameter is of a different type, it will get converted
  32840. * to a number or to NaN if it cannot be converted
  32841. * @returns number
  32842. */
  32843. static FloatRound(value: number): number;
  32844. /**
  32845. * Extracts the filename from a path
  32846. * @param path defines the path to use
  32847. * @returns the filename
  32848. */
  32849. static GetFilename(path: string): string;
  32850. /**
  32851. * Extracts the "folder" part of a path (everything before the filename).
  32852. * @param uri The URI to extract the info from
  32853. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32854. * @returns The "folder" part of the path
  32855. */
  32856. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32857. /**
  32858. * Extracts text content from a DOM element hierarchy
  32859. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32860. */
  32861. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32862. /**
  32863. * Convert an angle in radians to degrees
  32864. * @param angle defines the angle to convert
  32865. * @returns the angle in degrees
  32866. */
  32867. static ToDegrees(angle: number): number;
  32868. /**
  32869. * Convert an angle in degrees to radians
  32870. * @param angle defines the angle to convert
  32871. * @returns the angle in radians
  32872. */
  32873. static ToRadians(angle: number): number;
  32874. /**
  32875. * Encode a buffer to a base64 string
  32876. * @param buffer defines the buffer to encode
  32877. * @returns the encoded string
  32878. */
  32879. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32880. /**
  32881. * Returns an array if obj is not an array
  32882. * @param obj defines the object to evaluate as an array
  32883. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32884. * @returns either obj directly if obj is an array or a new array containing obj
  32885. */
  32886. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32887. /**
  32888. * Gets the pointer prefix to use
  32889. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32890. */
  32891. static GetPointerPrefix(): string;
  32892. /**
  32893. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32894. * @param url define the url we are trying
  32895. * @param element define the dom element where to configure the cors policy
  32896. */
  32897. static SetCorsBehavior(url: string | string[], element: {
  32898. crossOrigin: string | null;
  32899. }): void;
  32900. /**
  32901. * Removes unwanted characters from an url
  32902. * @param url defines the url to clean
  32903. * @returns the cleaned url
  32904. */
  32905. static CleanUrl(url: string): string;
  32906. /**
  32907. * Gets or sets a function used to pre-process url before using them to load assets
  32908. */
  32909. static PreprocessUrl: (url: string) => string;
  32910. /**
  32911. * Loads an image as an HTMLImageElement.
  32912. * @param input url string, ArrayBuffer, or Blob to load
  32913. * @param onLoad callback called when the image successfully loads
  32914. * @param onError callback called when the image fails to load
  32915. * @param offlineProvider offline provider for caching
  32916. * @returns the HTMLImageElement of the loaded image
  32917. */
  32918. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32919. /**
  32920. * Loads a file
  32921. * @param url url string, ArrayBuffer, or Blob to load
  32922. * @param onSuccess callback called when the file successfully loads
  32923. * @param onProgress callback called while file is loading (if the server supports this mode)
  32924. * @param offlineProvider defines the offline provider for caching
  32925. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32926. * @param onError callback called when the file fails to load
  32927. * @returns a file request object
  32928. */
  32929. 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;
  32930. /**
  32931. * Loads a file from a url
  32932. * @param url the file url to load
  32933. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32934. */
  32935. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32936. /**
  32937. * Load a script (identified by an url). When the url returns, the
  32938. * content of this file is added into a new script element, attached to the DOM (body element)
  32939. * @param scriptUrl defines the url of the script to laod
  32940. * @param onSuccess defines the callback called when the script is loaded
  32941. * @param onError defines the callback to call if an error occurs
  32942. * @param scriptId defines the id of the script element
  32943. */
  32944. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32945. /**
  32946. * Load an asynchronous script (identified by an url). When the url returns, the
  32947. * content of this file is added into a new script element, attached to the DOM (body element)
  32948. * @param scriptUrl defines the url of the script to laod
  32949. * @param scriptId defines the id of the script element
  32950. * @returns a promise request object
  32951. */
  32952. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32953. /**
  32954. * Loads a file from a blob
  32955. * @param fileToLoad defines the blob to use
  32956. * @param callback defines the callback to call when data is loaded
  32957. * @param progressCallback defines the callback to call during loading process
  32958. * @returns a file request object
  32959. */
  32960. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32961. /**
  32962. * Loads a file
  32963. * @param fileToLoad defines the file to load
  32964. * @param callback defines the callback to call when data is loaded
  32965. * @param progressCallBack defines the callback to call during loading process
  32966. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32967. * @returns a file request object
  32968. */
  32969. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32970. /**
  32971. * Creates a data url from a given string content
  32972. * @param content defines the content to convert
  32973. * @returns the new data url link
  32974. */
  32975. static FileAsURL(content: string): string;
  32976. /**
  32977. * Format the given number to a specific decimal format
  32978. * @param value defines the number to format
  32979. * @param decimals defines the number of decimals to use
  32980. * @returns the formatted string
  32981. */
  32982. static Format(value: number, decimals?: number): string;
  32983. /**
  32984. * Tries to copy an object by duplicating every property
  32985. * @param source defines the source object
  32986. * @param destination defines the target object
  32987. * @param doNotCopyList defines a list of properties to avoid
  32988. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32989. */
  32990. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32991. /**
  32992. * Gets a boolean indicating if the given object has no own property
  32993. * @param obj defines the object to test
  32994. * @returns true if object has no own property
  32995. */
  32996. static IsEmpty(obj: any): boolean;
  32997. /**
  32998. * Function used to register events at window level
  32999. * @param windowElement defines the Window object to use
  33000. * @param events defines the events to register
  33001. */
  33002. static RegisterTopRootEvents(windowElement: Window, events: {
  33003. name: string;
  33004. handler: Nullable<(e: FocusEvent) => any>;
  33005. }[]): void;
  33006. /**
  33007. * Function used to unregister events from window level
  33008. * @param windowElement defines the Window object to use
  33009. * @param events defines the events to unregister
  33010. */
  33011. static UnregisterTopRootEvents(windowElement: Window, events: {
  33012. name: string;
  33013. handler: Nullable<(e: FocusEvent) => any>;
  33014. }[]): void;
  33015. /**
  33016. * @ignore
  33017. */
  33018. static _ScreenshotCanvas: HTMLCanvasElement;
  33019. /**
  33020. * Dumps the current bound framebuffer
  33021. * @param width defines the rendering width
  33022. * @param height defines the rendering height
  33023. * @param engine defines the hosting engine
  33024. * @param successCallback defines the callback triggered once the data are available
  33025. * @param mimeType defines the mime type of the result
  33026. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33027. */
  33028. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33029. /**
  33030. * Converts the canvas data to blob.
  33031. * This acts as a polyfill for browsers not supporting the to blob function.
  33032. * @param canvas Defines the canvas to extract the data from
  33033. * @param successCallback Defines the callback triggered once the data are available
  33034. * @param mimeType Defines the mime type of the result
  33035. */
  33036. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33037. /**
  33038. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33039. * @param successCallback defines the callback triggered once the data are available
  33040. * @param mimeType defines the mime type of the result
  33041. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33042. */
  33043. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33044. /**
  33045. * Downloads a blob in the browser
  33046. * @param blob defines the blob to download
  33047. * @param fileName defines the name of the downloaded file
  33048. */
  33049. static Download(blob: Blob, fileName: string): void;
  33050. /**
  33051. * Captures a screenshot of the current rendering
  33052. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33053. * @param engine defines the rendering engine
  33054. * @param camera defines the source camera
  33055. * @param size This parameter can be set to a single number or to an object with the
  33056. * following (optional) properties: precision, width, height. If a single number is passed,
  33057. * it will be used for both width and height. If an object is passed, the screenshot size
  33058. * will be derived from the parameters. The precision property is a multiplier allowing
  33059. * rendering at a higher or lower resolution
  33060. * @param successCallback defines the callback receives a single parameter which contains the
  33061. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33062. * src parameter of an <img> to display it
  33063. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33064. * Check your browser for supported MIME types
  33065. */
  33066. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33067. /**
  33068. * Captures a screenshot of the current rendering
  33069. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33070. * @param engine defines the rendering engine
  33071. * @param camera defines the source camera
  33072. * @param size This parameter can be set to a single number or to an object with the
  33073. * following (optional) properties: precision, width, height. If a single number is passed,
  33074. * it will be used for both width and height. If an object is passed, the screenshot size
  33075. * will be derived from the parameters. The precision property is a multiplier allowing
  33076. * rendering at a higher or lower resolution
  33077. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33078. * Check your browser for supported MIME types
  33079. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33080. * to the src parameter of an <img> to display it
  33081. */
  33082. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33083. /**
  33084. * Generates an image screenshot from the specified camera.
  33085. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33086. * @param engine The engine to use for rendering
  33087. * @param camera The camera to use for rendering
  33088. * @param size This parameter can be set to a single number or to an object with the
  33089. * following (optional) properties: precision, width, height. If a single number is passed,
  33090. * it will be used for both width and height. If an object is passed, the screenshot size
  33091. * will be derived from the parameters. The precision property is a multiplier allowing
  33092. * rendering at a higher or lower resolution
  33093. * @param successCallback The callback receives a single parameter which contains the
  33094. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33095. * src parameter of an <img> to display it
  33096. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33097. * Check your browser for supported MIME types
  33098. * @param samples Texture samples (default: 1)
  33099. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33100. * @param fileName A name for for the downloaded file.
  33101. */
  33102. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33103. /**
  33104. * Generates an image screenshot from the specified camera.
  33105. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33106. * @param engine The engine to use for rendering
  33107. * @param camera The camera to use for rendering
  33108. * @param size This parameter can be set to a single number or to an object with the
  33109. * following (optional) properties: precision, width, height. If a single number is passed,
  33110. * it will be used for both width and height. If an object is passed, the screenshot size
  33111. * will be derived from the parameters. The precision property is a multiplier allowing
  33112. * rendering at a higher or lower resolution
  33113. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33114. * Check your browser for supported MIME types
  33115. * @param samples Texture samples (default: 1)
  33116. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33117. * @param fileName A name for for the downloaded file.
  33118. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33119. * to the src parameter of an <img> to display it
  33120. */
  33121. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33122. /**
  33123. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33124. * Be aware Math.random() could cause collisions, but:
  33125. * "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"
  33126. * @returns a pseudo random id
  33127. */
  33128. static RandomId(): string;
  33129. /**
  33130. * Test if the given uri is a base64 string
  33131. * @param uri The uri to test
  33132. * @return True if the uri is a base64 string or false otherwise
  33133. */
  33134. static IsBase64(uri: string): boolean;
  33135. /**
  33136. * Decode the given base64 uri.
  33137. * @param uri The uri to decode
  33138. * @return The decoded base64 data.
  33139. */
  33140. static DecodeBase64(uri: string): ArrayBuffer;
  33141. /**
  33142. * Gets the absolute url.
  33143. * @param url the input url
  33144. * @return the absolute url
  33145. */
  33146. static GetAbsoluteUrl(url: string): string;
  33147. /**
  33148. * No log
  33149. */
  33150. static readonly NoneLogLevel: number;
  33151. /**
  33152. * Only message logs
  33153. */
  33154. static readonly MessageLogLevel: number;
  33155. /**
  33156. * Only warning logs
  33157. */
  33158. static readonly WarningLogLevel: number;
  33159. /**
  33160. * Only error logs
  33161. */
  33162. static readonly ErrorLogLevel: number;
  33163. /**
  33164. * All logs
  33165. */
  33166. static readonly AllLogLevel: number;
  33167. /**
  33168. * Gets a value indicating the number of loading errors
  33169. * @ignorenaming
  33170. */
  33171. static readonly errorsCount: number;
  33172. /**
  33173. * Callback called when a new log is added
  33174. */
  33175. static OnNewCacheEntry: (entry: string) => void;
  33176. /**
  33177. * Log a message to the console
  33178. * @param message defines the message to log
  33179. */
  33180. static Log(message: string): void;
  33181. /**
  33182. * Write a warning message to the console
  33183. * @param message defines the message to log
  33184. */
  33185. static Warn(message: string): void;
  33186. /**
  33187. * Write an error message to the console
  33188. * @param message defines the message to log
  33189. */
  33190. static Error(message: string): void;
  33191. /**
  33192. * Gets current log cache (list of logs)
  33193. */
  33194. static readonly LogCache: string;
  33195. /**
  33196. * Clears the log cache
  33197. */
  33198. static ClearLogCache(): void;
  33199. /**
  33200. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33201. */
  33202. static LogLevels: number;
  33203. /**
  33204. * Checks if the window object exists
  33205. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33206. */
  33207. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33208. /**
  33209. * No performance log
  33210. */
  33211. static readonly PerformanceNoneLogLevel: number;
  33212. /**
  33213. * Use user marks to log performance
  33214. */
  33215. static readonly PerformanceUserMarkLogLevel: number;
  33216. /**
  33217. * Log performance to the console
  33218. */
  33219. static readonly PerformanceConsoleLogLevel: number;
  33220. private static _performance;
  33221. /**
  33222. * Sets the current performance log level
  33223. */
  33224. static PerformanceLogLevel: number;
  33225. private static _StartPerformanceCounterDisabled;
  33226. private static _EndPerformanceCounterDisabled;
  33227. private static _StartUserMark;
  33228. private static _EndUserMark;
  33229. private static _StartPerformanceConsole;
  33230. private static _EndPerformanceConsole;
  33231. /**
  33232. * Starts a performance counter
  33233. */
  33234. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33235. /**
  33236. * Ends a specific performance coutner
  33237. */
  33238. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33239. /**
  33240. * Gets either window.performance.now() if supported or Date.now() else
  33241. */
  33242. static readonly Now: number;
  33243. /**
  33244. * This method will return the name of the class used to create the instance of the given object.
  33245. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33246. * @param object the object to get the class name from
  33247. * @param isType defines if the object is actually a type
  33248. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33249. */
  33250. static GetClassName(object: any, isType?: boolean): string;
  33251. /**
  33252. * Gets the first element of an array satisfying a given predicate
  33253. * @param array defines the array to browse
  33254. * @param predicate defines the predicate to use
  33255. * @returns null if not found or the element
  33256. */
  33257. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33258. /**
  33259. * This method will return the name of the full name of the class, including its owning module (if any).
  33260. * 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).
  33261. * @param object the object to get the class name from
  33262. * @param isType defines if the object is actually a type
  33263. * @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.
  33264. * @ignorenaming
  33265. */
  33266. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33267. /**
  33268. * Returns a promise that resolves after the given amount of time.
  33269. * @param delay Number of milliseconds to delay
  33270. * @returns Promise that resolves after the given amount of time
  33271. */
  33272. static DelayAsync(delay: number): Promise<void>;
  33273. }
  33274. /**
  33275. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33276. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33277. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33278. * @param name The name of the class, case should be preserved
  33279. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33280. */
  33281. export function className(name: string, module?: string): (target: Object) => void;
  33282. /**
  33283. * An implementation of a loop for asynchronous functions.
  33284. */
  33285. export class AsyncLoop {
  33286. /**
  33287. * Defines the number of iterations for the loop
  33288. */
  33289. iterations: number;
  33290. /**
  33291. * Defines the current index of the loop.
  33292. */
  33293. index: number;
  33294. private _done;
  33295. private _fn;
  33296. private _successCallback;
  33297. /**
  33298. * Constructor.
  33299. * @param iterations the number of iterations.
  33300. * @param func the function to run each iteration
  33301. * @param successCallback the callback that will be called upon succesful execution
  33302. * @param offset starting offset.
  33303. */
  33304. constructor(
  33305. /**
  33306. * Defines the number of iterations for the loop
  33307. */
  33308. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33309. /**
  33310. * Execute the next iteration. Must be called after the last iteration was finished.
  33311. */
  33312. executeNext(): void;
  33313. /**
  33314. * Break the loop and run the success callback.
  33315. */
  33316. breakLoop(): void;
  33317. /**
  33318. * Create and run an async loop.
  33319. * @param iterations the number of iterations.
  33320. * @param fn the function to run each iteration
  33321. * @param successCallback the callback that will be called upon succesful execution
  33322. * @param offset starting offset.
  33323. * @returns the created async loop object
  33324. */
  33325. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33326. /**
  33327. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33328. * @param iterations total number of iterations
  33329. * @param syncedIterations number of synchronous iterations in each async iteration.
  33330. * @param fn the function to call each iteration.
  33331. * @param callback a success call back that will be called when iterating stops.
  33332. * @param breakFunction a break condition (optional)
  33333. * @param timeout timeout settings for the setTimeout function. default - 0.
  33334. * @returns the created async loop object
  33335. */
  33336. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33337. }
  33338. }
  33339. declare module "babylonjs/Collisions/collisionCoordinator" {
  33340. import { Nullable } from "babylonjs/types";
  33341. import { Scene } from "babylonjs/scene";
  33342. import { Vector3 } from "babylonjs/Maths/math.vector";
  33343. import { Collider } from "babylonjs/Collisions/collider";
  33344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33345. /** @hidden */
  33346. export interface ICollisionCoordinator {
  33347. createCollider(): Collider;
  33348. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33349. init(scene: Scene): void;
  33350. }
  33351. /** @hidden */
  33352. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33353. private _scene;
  33354. private _scaledPosition;
  33355. private _scaledVelocity;
  33356. private _finalPosition;
  33357. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33358. createCollider(): Collider;
  33359. init(scene: Scene): void;
  33360. private _collideWithWorld;
  33361. }
  33362. }
  33363. declare module "babylonjs/Inputs/scene.inputManager" {
  33364. import { Nullable } from "babylonjs/types";
  33365. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33366. import { Vector2 } from "babylonjs/Maths/math.vector";
  33367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33368. import { Scene } from "babylonjs/scene";
  33369. /**
  33370. * Class used to manage all inputs for the scene.
  33371. */
  33372. export class InputManager {
  33373. /** The distance in pixel that you have to move to prevent some events */
  33374. static DragMovementThreshold: number;
  33375. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33376. static LongPressDelay: number;
  33377. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33378. static DoubleClickDelay: number;
  33379. /** If you need to check double click without raising a single click at first click, enable this flag */
  33380. static ExclusiveDoubleClickMode: boolean;
  33381. private _wheelEventName;
  33382. private _onPointerMove;
  33383. private _onPointerDown;
  33384. private _onPointerUp;
  33385. private _initClickEvent;
  33386. private _initActionManager;
  33387. private _delayedSimpleClick;
  33388. private _delayedSimpleClickTimeout;
  33389. private _previousDelayedSimpleClickTimeout;
  33390. private _meshPickProceed;
  33391. private _previousButtonPressed;
  33392. private _currentPickResult;
  33393. private _previousPickResult;
  33394. private _totalPointersPressed;
  33395. private _doubleClickOccured;
  33396. private _pointerOverMesh;
  33397. private _pickedDownMesh;
  33398. private _pickedUpMesh;
  33399. private _pointerX;
  33400. private _pointerY;
  33401. private _unTranslatedPointerX;
  33402. private _unTranslatedPointerY;
  33403. private _startingPointerPosition;
  33404. private _previousStartingPointerPosition;
  33405. private _startingPointerTime;
  33406. private _previousStartingPointerTime;
  33407. private _pointerCaptures;
  33408. private _onKeyDown;
  33409. private _onKeyUp;
  33410. private _onCanvasFocusObserver;
  33411. private _onCanvasBlurObserver;
  33412. private _scene;
  33413. /**
  33414. * Creates a new InputManager
  33415. * @param scene defines the hosting scene
  33416. */
  33417. constructor(scene: Scene);
  33418. /**
  33419. * Gets the mesh that is currently under the pointer
  33420. */
  33421. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33422. /**
  33423. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33424. */
  33425. readonly unTranslatedPointer: Vector2;
  33426. /**
  33427. * Gets or sets the current on-screen X position of the pointer
  33428. */
  33429. pointerX: number;
  33430. /**
  33431. * Gets or sets the current on-screen Y position of the pointer
  33432. */
  33433. pointerY: number;
  33434. private _updatePointerPosition;
  33435. private _processPointerMove;
  33436. private _setRayOnPointerInfo;
  33437. private _checkPrePointerObservable;
  33438. /**
  33439. * Use this method to simulate a pointer move on a mesh
  33440. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33441. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33442. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33443. */
  33444. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33445. /**
  33446. * Use this method to simulate a pointer down on a mesh
  33447. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33448. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33449. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33450. */
  33451. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33452. private _processPointerDown;
  33453. /** @hidden */
  33454. _isPointerSwiping(): boolean;
  33455. /**
  33456. * Use this method to simulate a pointer up on a mesh
  33457. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33458. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33459. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33460. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33461. */
  33462. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33463. private _processPointerUp;
  33464. /**
  33465. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33466. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33467. * @returns true if the pointer was captured
  33468. */
  33469. isPointerCaptured(pointerId?: number): boolean;
  33470. /**
  33471. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33472. * @param attachUp defines if you want to attach events to pointerup
  33473. * @param attachDown defines if you want to attach events to pointerdown
  33474. * @param attachMove defines if you want to attach events to pointermove
  33475. */
  33476. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33477. /**
  33478. * Detaches all event handlers
  33479. */
  33480. detachControl(): void;
  33481. /**
  33482. * Force the value of meshUnderPointer
  33483. * @param mesh defines the mesh to use
  33484. */
  33485. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33486. /**
  33487. * Gets the mesh under the pointer
  33488. * @returns a Mesh or null if no mesh is under the pointer
  33489. */
  33490. getPointerOverMesh(): Nullable<AbstractMesh>;
  33491. }
  33492. }
  33493. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33494. /**
  33495. * Helper class used to generate session unique ID
  33496. */
  33497. export class UniqueIdGenerator {
  33498. private static _UniqueIdCounter;
  33499. /**
  33500. * Gets an unique (relatively to the current scene) Id
  33501. */
  33502. static readonly UniqueId: number;
  33503. }
  33504. }
  33505. declare module "babylonjs/Animations/animationGroup" {
  33506. import { Animatable } from "babylonjs/Animations/animatable";
  33507. import { Animation } from "babylonjs/Animations/animation";
  33508. import { Scene, IDisposable } from "babylonjs/scene";
  33509. import { Observable } from "babylonjs/Misc/observable";
  33510. import { Nullable } from "babylonjs/types";
  33511. import "babylonjs/Animations/animatable";
  33512. /**
  33513. * This class defines the direct association between an animation and a target
  33514. */
  33515. export class TargetedAnimation {
  33516. /**
  33517. * Animation to perform
  33518. */
  33519. animation: Animation;
  33520. /**
  33521. * Target to animate
  33522. */
  33523. target: any;
  33524. /**
  33525. * Serialize the object
  33526. * @returns the JSON object representing the current entity
  33527. */
  33528. serialize(): any;
  33529. }
  33530. /**
  33531. * Use this class to create coordinated animations on multiple targets
  33532. */
  33533. export class AnimationGroup implements IDisposable {
  33534. /** The name of the animation group */
  33535. name: string;
  33536. private _scene;
  33537. private _targetedAnimations;
  33538. private _animatables;
  33539. private _from;
  33540. private _to;
  33541. private _isStarted;
  33542. private _isPaused;
  33543. private _speedRatio;
  33544. private _loopAnimation;
  33545. /**
  33546. * Gets or sets the unique id of the node
  33547. */
  33548. uniqueId: number;
  33549. /**
  33550. * This observable will notify when one animation have ended
  33551. */
  33552. onAnimationEndObservable: Observable<TargetedAnimation>;
  33553. /**
  33554. * Observer raised when one animation loops
  33555. */
  33556. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33557. /**
  33558. * This observable will notify when all animations have ended.
  33559. */
  33560. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33561. /**
  33562. * This observable will notify when all animations have paused.
  33563. */
  33564. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33565. /**
  33566. * This observable will notify when all animations are playing.
  33567. */
  33568. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33569. /**
  33570. * Gets the first frame
  33571. */
  33572. readonly from: number;
  33573. /**
  33574. * Gets the last frame
  33575. */
  33576. readonly to: number;
  33577. /**
  33578. * Define if the animations are started
  33579. */
  33580. readonly isStarted: boolean;
  33581. /**
  33582. * Gets a value indicating that the current group is playing
  33583. */
  33584. readonly isPlaying: boolean;
  33585. /**
  33586. * Gets or sets the speed ratio to use for all animations
  33587. */
  33588. /**
  33589. * Gets or sets the speed ratio to use for all animations
  33590. */
  33591. speedRatio: number;
  33592. /**
  33593. * Gets or sets if all animations should loop or not
  33594. */
  33595. loopAnimation: boolean;
  33596. /**
  33597. * Gets the targeted animations for this animation group
  33598. */
  33599. readonly targetedAnimations: Array<TargetedAnimation>;
  33600. /**
  33601. * returning the list of animatables controlled by this animation group.
  33602. */
  33603. readonly animatables: Array<Animatable>;
  33604. /**
  33605. * Instantiates a new Animation Group.
  33606. * This helps managing several animations at once.
  33607. * @see http://doc.babylonjs.com/how_to/group
  33608. * @param name Defines the name of the group
  33609. * @param scene Defines the scene the group belongs to
  33610. */
  33611. constructor(
  33612. /** The name of the animation group */
  33613. name: string, scene?: Nullable<Scene>);
  33614. /**
  33615. * Add an animation (with its target) in the group
  33616. * @param animation defines the animation we want to add
  33617. * @param target defines the target of the animation
  33618. * @returns the TargetedAnimation object
  33619. */
  33620. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33621. /**
  33622. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33623. * It can add constant keys at begin or end
  33624. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33625. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33626. * @returns the animation group
  33627. */
  33628. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33629. /**
  33630. * Start all animations on given targets
  33631. * @param loop defines if animations must loop
  33632. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33633. * @param from defines the from key (optional)
  33634. * @param to defines the to key (optional)
  33635. * @returns the current animation group
  33636. */
  33637. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33638. /**
  33639. * Pause all animations
  33640. * @returns the animation group
  33641. */
  33642. pause(): AnimationGroup;
  33643. /**
  33644. * Play all animations to initial state
  33645. * This function will start() the animations if they were not started or will restart() them if they were paused
  33646. * @param loop defines if animations must loop
  33647. * @returns the animation group
  33648. */
  33649. play(loop?: boolean): AnimationGroup;
  33650. /**
  33651. * Reset all animations to initial state
  33652. * @returns the animation group
  33653. */
  33654. reset(): AnimationGroup;
  33655. /**
  33656. * Restart animations from key 0
  33657. * @returns the animation group
  33658. */
  33659. restart(): AnimationGroup;
  33660. /**
  33661. * Stop all animations
  33662. * @returns the animation group
  33663. */
  33664. stop(): AnimationGroup;
  33665. /**
  33666. * Set animation weight for all animatables
  33667. * @param weight defines the weight to use
  33668. * @return the animationGroup
  33669. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33670. */
  33671. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33672. /**
  33673. * Synchronize and normalize all animatables with a source animatable
  33674. * @param root defines the root animatable to synchronize with
  33675. * @return the animationGroup
  33676. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33677. */
  33678. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33679. /**
  33680. * Goes to a specific frame in this animation group
  33681. * @param frame the frame number to go to
  33682. * @return the animationGroup
  33683. */
  33684. goToFrame(frame: number): AnimationGroup;
  33685. /**
  33686. * Dispose all associated resources
  33687. */
  33688. dispose(): void;
  33689. private _checkAnimationGroupEnded;
  33690. /**
  33691. * Clone the current animation group and returns a copy
  33692. * @param newName defines the name of the new group
  33693. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33694. * @returns the new aniamtion group
  33695. */
  33696. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33697. /**
  33698. * Serializes the animationGroup to an object
  33699. * @returns Serialized object
  33700. */
  33701. serialize(): any;
  33702. /**
  33703. * Returns a new AnimationGroup object parsed from the source provided.
  33704. * @param parsedAnimationGroup defines the source
  33705. * @param scene defines the scene that will receive the animationGroup
  33706. * @returns a new AnimationGroup
  33707. */
  33708. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33709. /**
  33710. * Returns the string "AnimationGroup"
  33711. * @returns "AnimationGroup"
  33712. */
  33713. getClassName(): string;
  33714. /**
  33715. * Creates a detailled string about the object
  33716. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33717. * @returns a string representing the object
  33718. */
  33719. toString(fullDetails?: boolean): string;
  33720. }
  33721. }
  33722. declare module "babylonjs/scene" {
  33723. import { Nullable } from "babylonjs/types";
  33724. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33725. import { Observable } from "babylonjs/Misc/observable";
  33726. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33727. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33728. import { Geometry } from "babylonjs/Meshes/geometry";
  33729. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33730. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33732. import { Mesh } from "babylonjs/Meshes/mesh";
  33733. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33734. import { Bone } from "babylonjs/Bones/bone";
  33735. import { Skeleton } from "babylonjs/Bones/skeleton";
  33736. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33737. import { Camera } from "babylonjs/Cameras/camera";
  33738. import { AbstractScene } from "babylonjs/abstractScene";
  33739. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33740. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33741. import { Material } from "babylonjs/Materials/material";
  33742. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33743. import { Effect } from "babylonjs/Materials/effect";
  33744. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33745. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33746. import { Light } from "babylonjs/Lights/light";
  33747. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33748. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33749. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33750. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33751. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33752. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33753. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33754. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33755. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33756. import { Engine } from "babylonjs/Engines/engine";
  33757. import { Node } from "babylonjs/node";
  33758. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33759. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33760. import { WebRequest } from "babylonjs/Misc/webRequest";
  33761. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33762. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33763. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33764. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33765. import { Plane } from "babylonjs/Maths/math.plane";
  33766. import { Ray } from "babylonjs/Culling/ray";
  33767. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33768. import { Animation } from "babylonjs/Animations/animation";
  33769. import { Animatable } from "babylonjs/Animations/animatable";
  33770. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33771. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33772. import { Collider } from "babylonjs/Collisions/collider";
  33773. /**
  33774. * Define an interface for all classes that will hold resources
  33775. */
  33776. export interface IDisposable {
  33777. /**
  33778. * Releases all held resources
  33779. */
  33780. dispose(): void;
  33781. }
  33782. /** Interface defining initialization parameters for Scene class */
  33783. export interface SceneOptions {
  33784. /**
  33785. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33786. * It will improve performance when the number of geometries becomes important.
  33787. */
  33788. useGeometryUniqueIdsMap?: boolean;
  33789. /**
  33790. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33791. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33792. */
  33793. useMaterialMeshMap?: boolean;
  33794. /**
  33795. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33796. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33797. */
  33798. useClonedMeshhMap?: boolean;
  33799. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33800. virtual?: boolean;
  33801. }
  33802. /**
  33803. * Represents a scene to be rendered by the engine.
  33804. * @see http://doc.babylonjs.com/features/scene
  33805. */
  33806. export class Scene extends AbstractScene implements IAnimatable {
  33807. /** The fog is deactivated */
  33808. static readonly FOGMODE_NONE: number;
  33809. /** The fog density is following an exponential function */
  33810. static readonly FOGMODE_EXP: number;
  33811. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33812. static readonly FOGMODE_EXP2: number;
  33813. /** The fog density is following a linear function. */
  33814. static readonly FOGMODE_LINEAR: number;
  33815. /**
  33816. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33817. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33818. */
  33819. static MinDeltaTime: number;
  33820. /**
  33821. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33822. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33823. */
  33824. static MaxDeltaTime: number;
  33825. /**
  33826. * Factory used to create the default material.
  33827. * @param name The name of the material to create
  33828. * @param scene The scene to create the material for
  33829. * @returns The default material
  33830. */
  33831. static DefaultMaterialFactory(scene: Scene): Material;
  33832. /**
  33833. * Factory used to create the a collision coordinator.
  33834. * @returns The collision coordinator
  33835. */
  33836. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33837. /** @hidden */
  33838. _inputManager: InputManager;
  33839. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33840. cameraToUseForPointers: Nullable<Camera>;
  33841. /** @hidden */
  33842. readonly _isScene: boolean;
  33843. /**
  33844. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33845. */
  33846. autoClear: boolean;
  33847. /**
  33848. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33849. */
  33850. autoClearDepthAndStencil: boolean;
  33851. /**
  33852. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33853. */
  33854. clearColor: Color4;
  33855. /**
  33856. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33857. */
  33858. ambientColor: Color3;
  33859. /**
  33860. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33861. * It should only be one of the following (if not the default embedded one):
  33862. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33863. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33864. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33865. * The material properties need to be setup according to the type of texture in use.
  33866. */
  33867. environmentBRDFTexture: BaseTexture;
  33868. /** @hidden */
  33869. protected _environmentTexture: Nullable<BaseTexture>;
  33870. /**
  33871. * Texture used in all pbr material as the reflection texture.
  33872. * As in the majority of the scene they are the same (exception for multi room and so on),
  33873. * this is easier to reference from here than from all the materials.
  33874. */
  33875. /**
  33876. * Texture used in all pbr material as the reflection texture.
  33877. * As in the majority of the scene they are the same (exception for multi room and so on),
  33878. * this is easier to set here than in all the materials.
  33879. */
  33880. environmentTexture: Nullable<BaseTexture>;
  33881. /** @hidden */
  33882. protected _environmentIntensity: number;
  33883. /**
  33884. * Intensity of the environment in all pbr material.
  33885. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33886. * As in the majority of the scene they are the same (exception for multi room and so on),
  33887. * this is easier to reference from here than from all the materials.
  33888. */
  33889. /**
  33890. * Intensity of the environment in all pbr material.
  33891. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33892. * As in the majority of the scene they are the same (exception for multi room and so on),
  33893. * this is easier to set here than in all the materials.
  33894. */
  33895. environmentIntensity: number;
  33896. /** @hidden */
  33897. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33898. /**
  33899. * Default image processing configuration used either in the rendering
  33900. * Forward main pass or through the imageProcessingPostProcess if present.
  33901. * As in the majority of the scene they are the same (exception for multi camera),
  33902. * this is easier to reference from here than from all the materials and post process.
  33903. *
  33904. * No setter as we it is a shared configuration, you can set the values instead.
  33905. */
  33906. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33907. private _forceWireframe;
  33908. /**
  33909. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33910. */
  33911. forceWireframe: boolean;
  33912. private _forcePointsCloud;
  33913. /**
  33914. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33915. */
  33916. forcePointsCloud: boolean;
  33917. /**
  33918. * Gets or sets the active clipplane 1
  33919. */
  33920. clipPlane: Nullable<Plane>;
  33921. /**
  33922. * Gets or sets the active clipplane 2
  33923. */
  33924. clipPlane2: Nullable<Plane>;
  33925. /**
  33926. * Gets or sets the active clipplane 3
  33927. */
  33928. clipPlane3: Nullable<Plane>;
  33929. /**
  33930. * Gets or sets the active clipplane 4
  33931. */
  33932. clipPlane4: Nullable<Plane>;
  33933. /**
  33934. * Gets or sets a boolean indicating if animations are enabled
  33935. */
  33936. animationsEnabled: boolean;
  33937. private _animationPropertiesOverride;
  33938. /**
  33939. * Gets or sets the animation properties override
  33940. */
  33941. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33942. /**
  33943. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33944. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33945. */
  33946. useConstantAnimationDeltaTime: boolean;
  33947. /**
  33948. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33949. * Please note that it requires to run a ray cast through the scene on every frame
  33950. */
  33951. constantlyUpdateMeshUnderPointer: boolean;
  33952. /**
  33953. * Defines the HTML cursor to use when hovering over interactive elements
  33954. */
  33955. hoverCursor: string;
  33956. /**
  33957. * Defines the HTML default cursor to use (empty by default)
  33958. */
  33959. defaultCursor: string;
  33960. /**
  33961. * This is used to call preventDefault() on pointer down
  33962. * in order to block unwanted artifacts like system double clicks
  33963. */
  33964. preventDefaultOnPointerDown: boolean;
  33965. /**
  33966. * This is used to call preventDefault() on pointer up
  33967. * in order to block unwanted artifacts like system double clicks
  33968. */
  33969. preventDefaultOnPointerUp: boolean;
  33970. /**
  33971. * Gets or sets user defined metadata
  33972. */
  33973. metadata: any;
  33974. /**
  33975. * For internal use only. Please do not use.
  33976. */
  33977. reservedDataStore: any;
  33978. /**
  33979. * Gets the name of the plugin used to load this scene (null by default)
  33980. */
  33981. loadingPluginName: string;
  33982. /**
  33983. * Use this array to add regular expressions used to disable offline support for specific urls
  33984. */
  33985. disableOfflineSupportExceptionRules: RegExp[];
  33986. /**
  33987. * An event triggered when the scene is disposed.
  33988. */
  33989. onDisposeObservable: Observable<Scene>;
  33990. private _onDisposeObserver;
  33991. /** Sets a function to be executed when this scene is disposed. */
  33992. onDispose: () => void;
  33993. /**
  33994. * An event triggered before rendering the scene (right after animations and physics)
  33995. */
  33996. onBeforeRenderObservable: Observable<Scene>;
  33997. private _onBeforeRenderObserver;
  33998. /** Sets a function to be executed before rendering this scene */
  33999. beforeRender: Nullable<() => void>;
  34000. /**
  34001. * An event triggered after rendering the scene
  34002. */
  34003. onAfterRenderObservable: Observable<Scene>;
  34004. /**
  34005. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34006. */
  34007. onAfterRenderCameraObservable: Observable<Camera>;
  34008. private _onAfterRenderObserver;
  34009. /** Sets a function to be executed after rendering this scene */
  34010. afterRender: Nullable<() => void>;
  34011. /**
  34012. * An event triggered before animating the scene
  34013. */
  34014. onBeforeAnimationsObservable: Observable<Scene>;
  34015. /**
  34016. * An event triggered after animations processing
  34017. */
  34018. onAfterAnimationsObservable: Observable<Scene>;
  34019. /**
  34020. * An event triggered before draw calls are ready to be sent
  34021. */
  34022. onBeforeDrawPhaseObservable: Observable<Scene>;
  34023. /**
  34024. * An event triggered after draw calls have been sent
  34025. */
  34026. onAfterDrawPhaseObservable: Observable<Scene>;
  34027. /**
  34028. * An event triggered when the scene is ready
  34029. */
  34030. onReadyObservable: Observable<Scene>;
  34031. /**
  34032. * An event triggered before rendering a camera
  34033. */
  34034. onBeforeCameraRenderObservable: Observable<Camera>;
  34035. private _onBeforeCameraRenderObserver;
  34036. /** Sets a function to be executed before rendering a camera*/
  34037. beforeCameraRender: () => void;
  34038. /**
  34039. * An event triggered after rendering a camera
  34040. */
  34041. onAfterCameraRenderObservable: Observable<Camera>;
  34042. private _onAfterCameraRenderObserver;
  34043. /** Sets a function to be executed after rendering a camera*/
  34044. afterCameraRender: () => void;
  34045. /**
  34046. * An event triggered when active meshes evaluation is about to start
  34047. */
  34048. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34049. /**
  34050. * An event triggered when active meshes evaluation is done
  34051. */
  34052. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34053. /**
  34054. * An event triggered when particles rendering is about to start
  34055. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34056. */
  34057. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34058. /**
  34059. * An event triggered when particles rendering is done
  34060. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34061. */
  34062. onAfterParticlesRenderingObservable: Observable<Scene>;
  34063. /**
  34064. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34065. */
  34066. onDataLoadedObservable: Observable<Scene>;
  34067. /**
  34068. * An event triggered when a camera is created
  34069. */
  34070. onNewCameraAddedObservable: Observable<Camera>;
  34071. /**
  34072. * An event triggered when a camera is removed
  34073. */
  34074. onCameraRemovedObservable: Observable<Camera>;
  34075. /**
  34076. * An event triggered when a light is created
  34077. */
  34078. onNewLightAddedObservable: Observable<Light>;
  34079. /**
  34080. * An event triggered when a light is removed
  34081. */
  34082. onLightRemovedObservable: Observable<Light>;
  34083. /**
  34084. * An event triggered when a geometry is created
  34085. */
  34086. onNewGeometryAddedObservable: Observable<Geometry>;
  34087. /**
  34088. * An event triggered when a geometry is removed
  34089. */
  34090. onGeometryRemovedObservable: Observable<Geometry>;
  34091. /**
  34092. * An event triggered when a transform node is created
  34093. */
  34094. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34095. /**
  34096. * An event triggered when a transform node is removed
  34097. */
  34098. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34099. /**
  34100. * An event triggered when a mesh is created
  34101. */
  34102. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34103. /**
  34104. * An event triggered when a mesh is removed
  34105. */
  34106. onMeshRemovedObservable: Observable<AbstractMesh>;
  34107. /**
  34108. * An event triggered when a skeleton is created
  34109. */
  34110. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34111. /**
  34112. * An event triggered when a skeleton is removed
  34113. */
  34114. onSkeletonRemovedObservable: Observable<Skeleton>;
  34115. /**
  34116. * An event triggered when a material is created
  34117. */
  34118. onNewMaterialAddedObservable: Observable<Material>;
  34119. /**
  34120. * An event triggered when a material is removed
  34121. */
  34122. onMaterialRemovedObservable: Observable<Material>;
  34123. /**
  34124. * An event triggered when a texture is created
  34125. */
  34126. onNewTextureAddedObservable: Observable<BaseTexture>;
  34127. /**
  34128. * An event triggered when a texture is removed
  34129. */
  34130. onTextureRemovedObservable: Observable<BaseTexture>;
  34131. /**
  34132. * An event triggered when render targets are about to be rendered
  34133. * Can happen multiple times per frame.
  34134. */
  34135. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34136. /**
  34137. * An event triggered when render targets were rendered.
  34138. * Can happen multiple times per frame.
  34139. */
  34140. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34141. /**
  34142. * An event triggered before calculating deterministic simulation step
  34143. */
  34144. onBeforeStepObservable: Observable<Scene>;
  34145. /**
  34146. * An event triggered after calculating deterministic simulation step
  34147. */
  34148. onAfterStepObservable: Observable<Scene>;
  34149. /**
  34150. * An event triggered when the activeCamera property is updated
  34151. */
  34152. onActiveCameraChanged: Observable<Scene>;
  34153. /**
  34154. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34155. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34156. * 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)
  34157. */
  34158. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34159. /**
  34160. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34161. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34162. * 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)
  34163. */
  34164. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34165. /**
  34166. * This Observable will when a mesh has been imported into the scene.
  34167. */
  34168. onMeshImportedObservable: Observable<AbstractMesh>;
  34169. /**
  34170. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34171. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34172. */
  34173. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34174. /** @hidden */
  34175. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34176. /**
  34177. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34178. */
  34179. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34180. /**
  34181. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34182. */
  34183. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34184. /**
  34185. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34186. */
  34187. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34188. /** Callback called when a pointer move is detected */
  34189. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34190. /** Callback called when a pointer down is detected */
  34191. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34192. /** Callback called when a pointer up is detected */
  34193. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34194. /** Callback called when a pointer pick is detected */
  34195. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34196. /**
  34197. * 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).
  34198. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34199. */
  34200. onPrePointerObservable: Observable<PointerInfoPre>;
  34201. /**
  34202. * Observable event triggered each time an input event is received from the rendering canvas
  34203. */
  34204. onPointerObservable: Observable<PointerInfo>;
  34205. /**
  34206. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34207. */
  34208. readonly unTranslatedPointer: Vector2;
  34209. /**
  34210. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34211. */
  34212. static DragMovementThreshold: number;
  34213. /**
  34214. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34215. */
  34216. static LongPressDelay: number;
  34217. /**
  34218. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34219. */
  34220. static DoubleClickDelay: number;
  34221. /** If you need to check double click without raising a single click at first click, enable this flag */
  34222. static ExclusiveDoubleClickMode: boolean;
  34223. /** @hidden */
  34224. _mirroredCameraPosition: Nullable<Vector3>;
  34225. /**
  34226. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34227. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34228. */
  34229. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34230. /**
  34231. * Observable event triggered each time an keyboard event is received from the hosting window
  34232. */
  34233. onKeyboardObservable: Observable<KeyboardInfo>;
  34234. private _useRightHandedSystem;
  34235. /**
  34236. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34237. */
  34238. useRightHandedSystem: boolean;
  34239. private _timeAccumulator;
  34240. private _currentStepId;
  34241. private _currentInternalStep;
  34242. /**
  34243. * Sets the step Id used by deterministic lock step
  34244. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34245. * @param newStepId defines the step Id
  34246. */
  34247. setStepId(newStepId: number): void;
  34248. /**
  34249. * Gets the step Id used by deterministic lock step
  34250. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34251. * @returns the step Id
  34252. */
  34253. getStepId(): number;
  34254. /**
  34255. * Gets the internal step used by deterministic lock step
  34256. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34257. * @returns the internal step
  34258. */
  34259. getInternalStep(): number;
  34260. private _fogEnabled;
  34261. /**
  34262. * Gets or sets a boolean indicating if fog is enabled on this scene
  34263. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34264. * (Default is true)
  34265. */
  34266. fogEnabled: boolean;
  34267. private _fogMode;
  34268. /**
  34269. * Gets or sets the fog mode to use
  34270. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34271. * | mode | value |
  34272. * | --- | --- |
  34273. * | FOGMODE_NONE | 0 |
  34274. * | FOGMODE_EXP | 1 |
  34275. * | FOGMODE_EXP2 | 2 |
  34276. * | FOGMODE_LINEAR | 3 |
  34277. */
  34278. fogMode: number;
  34279. /**
  34280. * Gets or sets the fog color to use
  34281. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34282. * (Default is Color3(0.2, 0.2, 0.3))
  34283. */
  34284. fogColor: Color3;
  34285. /**
  34286. * Gets or sets the fog density to use
  34287. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34288. * (Default is 0.1)
  34289. */
  34290. fogDensity: number;
  34291. /**
  34292. * Gets or sets the fog start distance to use
  34293. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34294. * (Default is 0)
  34295. */
  34296. fogStart: number;
  34297. /**
  34298. * Gets or sets the fog end distance to use
  34299. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34300. * (Default is 1000)
  34301. */
  34302. fogEnd: number;
  34303. private _shadowsEnabled;
  34304. /**
  34305. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34306. */
  34307. shadowsEnabled: boolean;
  34308. private _lightsEnabled;
  34309. /**
  34310. * Gets or sets a boolean indicating if lights are enabled on this scene
  34311. */
  34312. lightsEnabled: boolean;
  34313. /** All of the active cameras added to this scene. */
  34314. activeCameras: Camera[];
  34315. /** @hidden */
  34316. _activeCamera: Nullable<Camera>;
  34317. /** Gets or sets the current active camera */
  34318. activeCamera: Nullable<Camera>;
  34319. private _defaultMaterial;
  34320. /** The default material used on meshes when no material is affected */
  34321. /** The default material used on meshes when no material is affected */
  34322. defaultMaterial: Material;
  34323. private _texturesEnabled;
  34324. /**
  34325. * Gets or sets a boolean indicating if textures are enabled on this scene
  34326. */
  34327. texturesEnabled: boolean;
  34328. /**
  34329. * Gets or sets a boolean indicating if particles are enabled on this scene
  34330. */
  34331. particlesEnabled: boolean;
  34332. /**
  34333. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34334. */
  34335. spritesEnabled: boolean;
  34336. private _skeletonsEnabled;
  34337. /**
  34338. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34339. */
  34340. skeletonsEnabled: boolean;
  34341. /**
  34342. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34343. */
  34344. lensFlaresEnabled: boolean;
  34345. /**
  34346. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34347. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34348. */
  34349. collisionsEnabled: boolean;
  34350. private _collisionCoordinator;
  34351. /** @hidden */
  34352. readonly collisionCoordinator: ICollisionCoordinator;
  34353. /**
  34354. * Defines the gravity applied to this scene (used only for collisions)
  34355. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34356. */
  34357. gravity: Vector3;
  34358. /**
  34359. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34360. */
  34361. postProcessesEnabled: boolean;
  34362. /**
  34363. * The list of postprocesses added to the scene
  34364. */
  34365. postProcesses: PostProcess[];
  34366. /**
  34367. * Gets the current postprocess manager
  34368. */
  34369. postProcessManager: PostProcessManager;
  34370. /**
  34371. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34372. */
  34373. renderTargetsEnabled: boolean;
  34374. /**
  34375. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34376. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34377. */
  34378. dumpNextRenderTargets: boolean;
  34379. /**
  34380. * The list of user defined render targets added to the scene
  34381. */
  34382. customRenderTargets: RenderTargetTexture[];
  34383. /**
  34384. * Defines if texture loading must be delayed
  34385. * If true, textures will only be loaded when they need to be rendered
  34386. */
  34387. useDelayedTextureLoading: boolean;
  34388. /**
  34389. * Gets the list of meshes imported to the scene through SceneLoader
  34390. */
  34391. importedMeshesFiles: String[];
  34392. /**
  34393. * Gets or sets a boolean indicating if probes are enabled on this scene
  34394. */
  34395. probesEnabled: boolean;
  34396. /**
  34397. * Gets or sets the current offline provider to use to store scene data
  34398. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34399. */
  34400. offlineProvider: IOfflineProvider;
  34401. /**
  34402. * Gets or sets the action manager associated with the scene
  34403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34404. */
  34405. actionManager: AbstractActionManager;
  34406. private _meshesForIntersections;
  34407. /**
  34408. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34409. */
  34410. proceduralTexturesEnabled: boolean;
  34411. private _engine;
  34412. private _totalVertices;
  34413. /** @hidden */
  34414. _activeIndices: PerfCounter;
  34415. /** @hidden */
  34416. _activeParticles: PerfCounter;
  34417. /** @hidden */
  34418. _activeBones: PerfCounter;
  34419. private _animationRatio;
  34420. /** @hidden */
  34421. _animationTimeLast: number;
  34422. /** @hidden */
  34423. _animationTime: number;
  34424. /**
  34425. * Gets or sets a general scale for animation speed
  34426. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34427. */
  34428. animationTimeScale: number;
  34429. /** @hidden */
  34430. _cachedMaterial: Nullable<Material>;
  34431. /** @hidden */
  34432. _cachedEffect: Nullable<Effect>;
  34433. /** @hidden */
  34434. _cachedVisibility: Nullable<number>;
  34435. private _renderId;
  34436. private _frameId;
  34437. private _executeWhenReadyTimeoutId;
  34438. private _intermediateRendering;
  34439. private _viewUpdateFlag;
  34440. private _projectionUpdateFlag;
  34441. /** @hidden */
  34442. _toBeDisposed: Nullable<IDisposable>[];
  34443. private _activeRequests;
  34444. /** @hidden */
  34445. _pendingData: any[];
  34446. private _isDisposed;
  34447. /**
  34448. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34449. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34450. */
  34451. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34452. private _activeMeshes;
  34453. private _processedMaterials;
  34454. private _renderTargets;
  34455. /** @hidden */
  34456. _activeParticleSystems: SmartArray<IParticleSystem>;
  34457. private _activeSkeletons;
  34458. private _softwareSkinnedMeshes;
  34459. private _renderingManager;
  34460. /** @hidden */
  34461. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34462. private _transformMatrix;
  34463. private _sceneUbo;
  34464. /** @hidden */
  34465. _viewMatrix: Matrix;
  34466. private _projectionMatrix;
  34467. /** @hidden */
  34468. _forcedViewPosition: Nullable<Vector3>;
  34469. /** @hidden */
  34470. _frustumPlanes: Plane[];
  34471. /**
  34472. * Gets the list of frustum planes (built from the active camera)
  34473. */
  34474. readonly frustumPlanes: Plane[];
  34475. /**
  34476. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34477. * This is useful if there are more lights that the maximum simulteanous authorized
  34478. */
  34479. requireLightSorting: boolean;
  34480. /** @hidden */
  34481. readonly useMaterialMeshMap: boolean;
  34482. /** @hidden */
  34483. readonly useClonedMeshhMap: boolean;
  34484. private _externalData;
  34485. private _uid;
  34486. /**
  34487. * @hidden
  34488. * Backing store of defined scene components.
  34489. */
  34490. _components: ISceneComponent[];
  34491. /**
  34492. * @hidden
  34493. * Backing store of defined scene components.
  34494. */
  34495. _serializableComponents: ISceneSerializableComponent[];
  34496. /**
  34497. * List of components to register on the next registration step.
  34498. */
  34499. private _transientComponents;
  34500. /**
  34501. * Registers the transient components if needed.
  34502. */
  34503. private _registerTransientComponents;
  34504. /**
  34505. * @hidden
  34506. * Add a component to the scene.
  34507. * Note that the ccomponent could be registered on th next frame if this is called after
  34508. * the register component stage.
  34509. * @param component Defines the component to add to the scene
  34510. */
  34511. _addComponent(component: ISceneComponent): void;
  34512. /**
  34513. * @hidden
  34514. * Gets a component from the scene.
  34515. * @param name defines the name of the component to retrieve
  34516. * @returns the component or null if not present
  34517. */
  34518. _getComponent(name: string): Nullable<ISceneComponent>;
  34519. /**
  34520. * @hidden
  34521. * Defines the actions happening before camera updates.
  34522. */
  34523. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34524. /**
  34525. * @hidden
  34526. * Defines the actions happening before clear the canvas.
  34527. */
  34528. _beforeClearStage: Stage<SimpleStageAction>;
  34529. /**
  34530. * @hidden
  34531. * Defines the actions when collecting render targets for the frame.
  34532. */
  34533. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34534. /**
  34535. * @hidden
  34536. * Defines the actions happening for one camera in the frame.
  34537. */
  34538. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34539. /**
  34540. * @hidden
  34541. * Defines the actions happening during the per mesh ready checks.
  34542. */
  34543. _isReadyForMeshStage: Stage<MeshStageAction>;
  34544. /**
  34545. * @hidden
  34546. * Defines the actions happening before evaluate active mesh checks.
  34547. */
  34548. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34549. /**
  34550. * @hidden
  34551. * Defines the actions happening during the evaluate sub mesh checks.
  34552. */
  34553. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34554. /**
  34555. * @hidden
  34556. * Defines the actions happening during the active mesh stage.
  34557. */
  34558. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34559. /**
  34560. * @hidden
  34561. * Defines the actions happening during the per camera render target step.
  34562. */
  34563. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34564. /**
  34565. * @hidden
  34566. * Defines the actions happening just before the active camera is drawing.
  34567. */
  34568. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34569. /**
  34570. * @hidden
  34571. * Defines the actions happening just before a render target is drawing.
  34572. */
  34573. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34574. /**
  34575. * @hidden
  34576. * Defines the actions happening just before a rendering group is drawing.
  34577. */
  34578. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34579. /**
  34580. * @hidden
  34581. * Defines the actions happening just before a mesh is drawing.
  34582. */
  34583. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34584. /**
  34585. * @hidden
  34586. * Defines the actions happening just after a mesh has been drawn.
  34587. */
  34588. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34589. /**
  34590. * @hidden
  34591. * Defines the actions happening just after a rendering group has been drawn.
  34592. */
  34593. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34594. /**
  34595. * @hidden
  34596. * Defines the actions happening just after the active camera has been drawn.
  34597. */
  34598. _afterCameraDrawStage: Stage<CameraStageAction>;
  34599. /**
  34600. * @hidden
  34601. * Defines the actions happening just after a render target has been drawn.
  34602. */
  34603. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34604. /**
  34605. * @hidden
  34606. * Defines the actions happening just after rendering all cameras and computing intersections.
  34607. */
  34608. _afterRenderStage: Stage<SimpleStageAction>;
  34609. /**
  34610. * @hidden
  34611. * Defines the actions happening when a pointer move event happens.
  34612. */
  34613. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34614. /**
  34615. * @hidden
  34616. * Defines the actions happening when a pointer down event happens.
  34617. */
  34618. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34619. /**
  34620. * @hidden
  34621. * Defines the actions happening when a pointer up event happens.
  34622. */
  34623. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34624. /**
  34625. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34626. */
  34627. private geometriesByUniqueId;
  34628. /**
  34629. * Creates a new Scene
  34630. * @param engine defines the engine to use to render this scene
  34631. * @param options defines the scene options
  34632. */
  34633. constructor(engine: Engine, options?: SceneOptions);
  34634. /**
  34635. * Gets a string idenfifying the name of the class
  34636. * @returns "Scene" string
  34637. */
  34638. getClassName(): string;
  34639. private _defaultMeshCandidates;
  34640. /**
  34641. * @hidden
  34642. */
  34643. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34644. private _defaultSubMeshCandidates;
  34645. /**
  34646. * @hidden
  34647. */
  34648. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34649. /**
  34650. * Sets the default candidate providers for the scene.
  34651. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34652. * and getCollidingSubMeshCandidates to their default function
  34653. */
  34654. setDefaultCandidateProviders(): void;
  34655. /**
  34656. * Gets the mesh that is currently under the pointer
  34657. */
  34658. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34659. /**
  34660. * Gets or sets the current on-screen X position of the pointer
  34661. */
  34662. pointerX: number;
  34663. /**
  34664. * Gets or sets the current on-screen Y position of the pointer
  34665. */
  34666. pointerY: number;
  34667. /**
  34668. * Gets the cached material (ie. the latest rendered one)
  34669. * @returns the cached material
  34670. */
  34671. getCachedMaterial(): Nullable<Material>;
  34672. /**
  34673. * Gets the cached effect (ie. the latest rendered one)
  34674. * @returns the cached effect
  34675. */
  34676. getCachedEffect(): Nullable<Effect>;
  34677. /**
  34678. * Gets the cached visibility state (ie. the latest rendered one)
  34679. * @returns the cached visibility state
  34680. */
  34681. getCachedVisibility(): Nullable<number>;
  34682. /**
  34683. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34684. * @param material defines the current material
  34685. * @param effect defines the current effect
  34686. * @param visibility defines the current visibility state
  34687. * @returns true if one parameter is not cached
  34688. */
  34689. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34690. /**
  34691. * Gets the engine associated with the scene
  34692. * @returns an Engine
  34693. */
  34694. getEngine(): Engine;
  34695. /**
  34696. * Gets the total number of vertices rendered per frame
  34697. * @returns the total number of vertices rendered per frame
  34698. */
  34699. getTotalVertices(): number;
  34700. /**
  34701. * Gets the performance counter for total vertices
  34702. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34703. */
  34704. readonly totalVerticesPerfCounter: PerfCounter;
  34705. /**
  34706. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34707. * @returns the total number of active indices rendered per frame
  34708. */
  34709. getActiveIndices(): number;
  34710. /**
  34711. * Gets the performance counter for active indices
  34712. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34713. */
  34714. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34715. /**
  34716. * Gets the total number of active particles rendered per frame
  34717. * @returns the total number of active particles rendered per frame
  34718. */
  34719. getActiveParticles(): number;
  34720. /**
  34721. * Gets the performance counter for active particles
  34722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34723. */
  34724. readonly activeParticlesPerfCounter: PerfCounter;
  34725. /**
  34726. * Gets the total number of active bones rendered per frame
  34727. * @returns the total number of active bones rendered per frame
  34728. */
  34729. getActiveBones(): number;
  34730. /**
  34731. * Gets the performance counter for active bones
  34732. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34733. */
  34734. readonly activeBonesPerfCounter: PerfCounter;
  34735. /**
  34736. * Gets the array of active meshes
  34737. * @returns an array of AbstractMesh
  34738. */
  34739. getActiveMeshes(): SmartArray<AbstractMesh>;
  34740. /**
  34741. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34742. * @returns a number
  34743. */
  34744. getAnimationRatio(): number;
  34745. /**
  34746. * Gets an unique Id for the current render phase
  34747. * @returns a number
  34748. */
  34749. getRenderId(): number;
  34750. /**
  34751. * Gets an unique Id for the current frame
  34752. * @returns a number
  34753. */
  34754. getFrameId(): number;
  34755. /** Call this function if you want to manually increment the render Id*/
  34756. incrementRenderId(): void;
  34757. private _createUbo;
  34758. /**
  34759. * Use this method to simulate a pointer move on a mesh
  34760. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34761. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34762. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34763. * @returns the current scene
  34764. */
  34765. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34766. /**
  34767. * Use this method to simulate a pointer down on a mesh
  34768. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34769. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34770. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34771. * @returns the current scene
  34772. */
  34773. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34774. /**
  34775. * Use this method to simulate a pointer up on a mesh
  34776. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34777. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34778. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34779. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34780. * @returns the current scene
  34781. */
  34782. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34783. /**
  34784. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34785. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34786. * @returns true if the pointer was captured
  34787. */
  34788. isPointerCaptured(pointerId?: number): boolean;
  34789. /**
  34790. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34791. * @param attachUp defines if you want to attach events to pointerup
  34792. * @param attachDown defines if you want to attach events to pointerdown
  34793. * @param attachMove defines if you want to attach events to pointermove
  34794. */
  34795. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34796. /** Detaches all event handlers*/
  34797. detachControl(): void;
  34798. /**
  34799. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34800. * Delay loaded resources are not taking in account
  34801. * @return true if all required resources are ready
  34802. */
  34803. isReady(): boolean;
  34804. /** Resets all cached information relative to material (including effect and visibility) */
  34805. resetCachedMaterial(): void;
  34806. /**
  34807. * Registers a function to be called before every frame render
  34808. * @param func defines the function to register
  34809. */
  34810. registerBeforeRender(func: () => void): void;
  34811. /**
  34812. * Unregisters a function called before every frame render
  34813. * @param func defines the function to unregister
  34814. */
  34815. unregisterBeforeRender(func: () => void): void;
  34816. /**
  34817. * Registers a function to be called after every frame render
  34818. * @param func defines the function to register
  34819. */
  34820. registerAfterRender(func: () => void): void;
  34821. /**
  34822. * Unregisters a function called after every frame render
  34823. * @param func defines the function to unregister
  34824. */
  34825. unregisterAfterRender(func: () => void): void;
  34826. private _executeOnceBeforeRender;
  34827. /**
  34828. * The provided function will run before render once and will be disposed afterwards.
  34829. * A timeout delay can be provided so that the function will be executed in N ms.
  34830. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34831. * @param func The function to be executed.
  34832. * @param timeout optional delay in ms
  34833. */
  34834. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34835. /** @hidden */
  34836. _addPendingData(data: any): void;
  34837. /** @hidden */
  34838. _removePendingData(data: any): void;
  34839. /**
  34840. * Returns the number of items waiting to be loaded
  34841. * @returns the number of items waiting to be loaded
  34842. */
  34843. getWaitingItemsCount(): number;
  34844. /**
  34845. * Returns a boolean indicating if the scene is still loading data
  34846. */
  34847. readonly isLoading: boolean;
  34848. /**
  34849. * Registers a function to be executed when the scene is ready
  34850. * @param {Function} func - the function to be executed
  34851. */
  34852. executeWhenReady(func: () => void): void;
  34853. /**
  34854. * Returns a promise that resolves when the scene is ready
  34855. * @returns A promise that resolves when the scene is ready
  34856. */
  34857. whenReadyAsync(): Promise<void>;
  34858. /** @hidden */
  34859. _checkIsReady(): void;
  34860. /**
  34861. * Gets all animatable attached to the scene
  34862. */
  34863. readonly animatables: Animatable[];
  34864. /**
  34865. * Resets the last animation time frame.
  34866. * Useful to override when animations start running when loading a scene for the first time.
  34867. */
  34868. resetLastAnimationTimeFrame(): void;
  34869. /**
  34870. * Gets the current view matrix
  34871. * @returns a Matrix
  34872. */
  34873. getViewMatrix(): Matrix;
  34874. /**
  34875. * Gets the current projection matrix
  34876. * @returns a Matrix
  34877. */
  34878. getProjectionMatrix(): Matrix;
  34879. /**
  34880. * Gets the current transform matrix
  34881. * @returns a Matrix made of View * Projection
  34882. */
  34883. getTransformMatrix(): Matrix;
  34884. /**
  34885. * Sets the current transform matrix
  34886. * @param viewL defines the View matrix to use
  34887. * @param projectionL defines the Projection matrix to use
  34888. * @param viewR defines the right View matrix to use (if provided)
  34889. * @param projectionR defines the right Projection matrix to use (if provided)
  34890. */
  34891. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34892. /**
  34893. * Gets the uniform buffer used to store scene data
  34894. * @returns a UniformBuffer
  34895. */
  34896. getSceneUniformBuffer(): UniformBuffer;
  34897. /**
  34898. * Gets an unique (relatively to the current scene) Id
  34899. * @returns an unique number for the scene
  34900. */
  34901. getUniqueId(): number;
  34902. /**
  34903. * Add a mesh to the list of scene's meshes
  34904. * @param newMesh defines the mesh to add
  34905. * @param recursive if all child meshes should also be added to the scene
  34906. */
  34907. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34908. /**
  34909. * Remove a mesh for the list of scene's meshes
  34910. * @param toRemove defines the mesh to remove
  34911. * @param recursive if all child meshes should also be removed from the scene
  34912. * @returns the index where the mesh was in the mesh list
  34913. */
  34914. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34915. /**
  34916. * Add a transform node to the list of scene's transform nodes
  34917. * @param newTransformNode defines the transform node to add
  34918. */
  34919. addTransformNode(newTransformNode: TransformNode): void;
  34920. /**
  34921. * Remove a transform node for the list of scene's transform nodes
  34922. * @param toRemove defines the transform node to remove
  34923. * @returns the index where the transform node was in the transform node list
  34924. */
  34925. removeTransformNode(toRemove: TransformNode): number;
  34926. /**
  34927. * Remove a skeleton for the list of scene's skeletons
  34928. * @param toRemove defines the skeleton to remove
  34929. * @returns the index where the skeleton was in the skeleton list
  34930. */
  34931. removeSkeleton(toRemove: Skeleton): number;
  34932. /**
  34933. * Remove a morph target for the list of scene's morph targets
  34934. * @param toRemove defines the morph target to remove
  34935. * @returns the index where the morph target was in the morph target list
  34936. */
  34937. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34938. /**
  34939. * Remove a light for the list of scene's lights
  34940. * @param toRemove defines the light to remove
  34941. * @returns the index where the light was in the light list
  34942. */
  34943. removeLight(toRemove: Light): number;
  34944. /**
  34945. * Remove a camera for the list of scene's cameras
  34946. * @param toRemove defines the camera to remove
  34947. * @returns the index where the camera was in the camera list
  34948. */
  34949. removeCamera(toRemove: Camera): number;
  34950. /**
  34951. * Remove a particle system for the list of scene's particle systems
  34952. * @param toRemove defines the particle system to remove
  34953. * @returns the index where the particle system was in the particle system list
  34954. */
  34955. removeParticleSystem(toRemove: IParticleSystem): number;
  34956. /**
  34957. * Remove a animation for the list of scene's animations
  34958. * @param toRemove defines the animation to remove
  34959. * @returns the index where the animation was in the animation list
  34960. */
  34961. removeAnimation(toRemove: Animation): number;
  34962. /**
  34963. * Will stop the animation of the given target
  34964. * @param target - the target
  34965. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34966. * @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)
  34967. */
  34968. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34969. /**
  34970. * Removes the given animation group from this scene.
  34971. * @param toRemove The animation group to remove
  34972. * @returns The index of the removed animation group
  34973. */
  34974. removeAnimationGroup(toRemove: AnimationGroup): number;
  34975. /**
  34976. * Removes the given multi-material from this scene.
  34977. * @param toRemove The multi-material to remove
  34978. * @returns The index of the removed multi-material
  34979. */
  34980. removeMultiMaterial(toRemove: MultiMaterial): number;
  34981. /**
  34982. * Removes the given material from this scene.
  34983. * @param toRemove The material to remove
  34984. * @returns The index of the removed material
  34985. */
  34986. removeMaterial(toRemove: Material): number;
  34987. /**
  34988. * Removes the given action manager from this scene.
  34989. * @param toRemove The action manager to remove
  34990. * @returns The index of the removed action manager
  34991. */
  34992. removeActionManager(toRemove: AbstractActionManager): number;
  34993. /**
  34994. * Removes the given texture from this scene.
  34995. * @param toRemove The texture to remove
  34996. * @returns The index of the removed texture
  34997. */
  34998. removeTexture(toRemove: BaseTexture): number;
  34999. /**
  35000. * Adds the given light to this scene
  35001. * @param newLight The light to add
  35002. */
  35003. addLight(newLight: Light): void;
  35004. /**
  35005. * Sorts the list list based on light priorities
  35006. */
  35007. sortLightsByPriority(): void;
  35008. /**
  35009. * Adds the given camera to this scene
  35010. * @param newCamera The camera to add
  35011. */
  35012. addCamera(newCamera: Camera): void;
  35013. /**
  35014. * Adds the given skeleton to this scene
  35015. * @param newSkeleton The skeleton to add
  35016. */
  35017. addSkeleton(newSkeleton: Skeleton): void;
  35018. /**
  35019. * Adds the given particle system to this scene
  35020. * @param newParticleSystem The particle system to add
  35021. */
  35022. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35023. /**
  35024. * Adds the given animation to this scene
  35025. * @param newAnimation The animation to add
  35026. */
  35027. addAnimation(newAnimation: Animation): void;
  35028. /**
  35029. * Adds the given animation group to this scene.
  35030. * @param newAnimationGroup The animation group to add
  35031. */
  35032. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35033. /**
  35034. * Adds the given multi-material to this scene
  35035. * @param newMultiMaterial The multi-material to add
  35036. */
  35037. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35038. /**
  35039. * Adds the given material to this scene
  35040. * @param newMaterial The material to add
  35041. */
  35042. addMaterial(newMaterial: Material): void;
  35043. /**
  35044. * Adds the given morph target to this scene
  35045. * @param newMorphTargetManager The morph target to add
  35046. */
  35047. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35048. /**
  35049. * Adds the given geometry to this scene
  35050. * @param newGeometry The geometry to add
  35051. */
  35052. addGeometry(newGeometry: Geometry): void;
  35053. /**
  35054. * Adds the given action manager to this scene
  35055. * @param newActionManager The action manager to add
  35056. */
  35057. addActionManager(newActionManager: AbstractActionManager): void;
  35058. /**
  35059. * Adds the given texture to this scene.
  35060. * @param newTexture The texture to add
  35061. */
  35062. addTexture(newTexture: BaseTexture): void;
  35063. /**
  35064. * Switch active camera
  35065. * @param newCamera defines the new active camera
  35066. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35067. */
  35068. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35069. /**
  35070. * sets the active camera of the scene using its ID
  35071. * @param id defines the camera's ID
  35072. * @return the new active camera or null if none found.
  35073. */
  35074. setActiveCameraByID(id: string): Nullable<Camera>;
  35075. /**
  35076. * sets the active camera of the scene using its name
  35077. * @param name defines the camera's name
  35078. * @returns the new active camera or null if none found.
  35079. */
  35080. setActiveCameraByName(name: string): Nullable<Camera>;
  35081. /**
  35082. * get an animation group using its name
  35083. * @param name defines the material's name
  35084. * @return the animation group or null if none found.
  35085. */
  35086. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35087. /**
  35088. * Get a material using its unique id
  35089. * @param uniqueId defines the material's unique id
  35090. * @return the material or null if none found.
  35091. */
  35092. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35093. /**
  35094. * get a material using its id
  35095. * @param id defines the material's ID
  35096. * @return the material or null if none found.
  35097. */
  35098. getMaterialByID(id: string): Nullable<Material>;
  35099. /**
  35100. * Gets a the last added material using a given id
  35101. * @param id defines the material's ID
  35102. * @return the last material with the given id or null if none found.
  35103. */
  35104. getLastMaterialByID(id: string): Nullable<Material>;
  35105. /**
  35106. * Gets a material using its name
  35107. * @param name defines the material's name
  35108. * @return the material or null if none found.
  35109. */
  35110. getMaterialByName(name: string): Nullable<Material>;
  35111. /**
  35112. * Get a texture using its unique id
  35113. * @param uniqueId defines the texture's unique id
  35114. * @return the texture or null if none found.
  35115. */
  35116. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35117. /**
  35118. * Gets a camera using its id
  35119. * @param id defines the id to look for
  35120. * @returns the camera or null if not found
  35121. */
  35122. getCameraByID(id: string): Nullable<Camera>;
  35123. /**
  35124. * Gets a camera using its unique id
  35125. * @param uniqueId defines the unique id to look for
  35126. * @returns the camera or null if not found
  35127. */
  35128. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35129. /**
  35130. * Gets a camera using its name
  35131. * @param name defines the camera's name
  35132. * @return the camera or null if none found.
  35133. */
  35134. getCameraByName(name: string): Nullable<Camera>;
  35135. /**
  35136. * Gets a bone using its id
  35137. * @param id defines the bone's id
  35138. * @return the bone or null if not found
  35139. */
  35140. getBoneByID(id: string): Nullable<Bone>;
  35141. /**
  35142. * Gets a bone using its id
  35143. * @param name defines the bone's name
  35144. * @return the bone or null if not found
  35145. */
  35146. getBoneByName(name: string): Nullable<Bone>;
  35147. /**
  35148. * Gets a light node using its name
  35149. * @param name defines the the light's name
  35150. * @return the light or null if none found.
  35151. */
  35152. getLightByName(name: string): Nullable<Light>;
  35153. /**
  35154. * Gets a light node using its id
  35155. * @param id defines the light's id
  35156. * @return the light or null if none found.
  35157. */
  35158. getLightByID(id: string): Nullable<Light>;
  35159. /**
  35160. * Gets a light node using its scene-generated unique ID
  35161. * @param uniqueId defines the light's unique id
  35162. * @return the light or null if none found.
  35163. */
  35164. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35165. /**
  35166. * Gets a particle system by id
  35167. * @param id defines the particle system id
  35168. * @return the corresponding system or null if none found
  35169. */
  35170. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35171. /**
  35172. * Gets a geometry using its ID
  35173. * @param id defines the geometry's id
  35174. * @return the geometry or null if none found.
  35175. */
  35176. getGeometryByID(id: string): Nullable<Geometry>;
  35177. private _getGeometryByUniqueID;
  35178. /**
  35179. * Add a new geometry to this scene
  35180. * @param geometry defines the geometry to be added to the scene.
  35181. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35182. * @return a boolean defining if the geometry was added or not
  35183. */
  35184. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35185. /**
  35186. * Removes an existing geometry
  35187. * @param geometry defines the geometry to be removed from the scene
  35188. * @return a boolean defining if the geometry was removed or not
  35189. */
  35190. removeGeometry(geometry: Geometry): boolean;
  35191. /**
  35192. * Gets the list of geometries attached to the scene
  35193. * @returns an array of Geometry
  35194. */
  35195. getGeometries(): Geometry[];
  35196. /**
  35197. * Gets the first added mesh found of a given ID
  35198. * @param id defines the id to search for
  35199. * @return the mesh found or null if not found at all
  35200. */
  35201. getMeshByID(id: string): Nullable<AbstractMesh>;
  35202. /**
  35203. * Gets a list of meshes using their id
  35204. * @param id defines the id to search for
  35205. * @returns a list of meshes
  35206. */
  35207. getMeshesByID(id: string): Array<AbstractMesh>;
  35208. /**
  35209. * Gets the first added transform node found of a given ID
  35210. * @param id defines the id to search for
  35211. * @return the found transform node or null if not found at all.
  35212. */
  35213. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35214. /**
  35215. * Gets a transform node with its auto-generated unique id
  35216. * @param uniqueId efines the unique id to search for
  35217. * @return the found transform node or null if not found at all.
  35218. */
  35219. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35220. /**
  35221. * Gets a list of transform nodes using their id
  35222. * @param id defines the id to search for
  35223. * @returns a list of transform nodes
  35224. */
  35225. getTransformNodesByID(id: string): Array<TransformNode>;
  35226. /**
  35227. * Gets a mesh with its auto-generated unique id
  35228. * @param uniqueId defines the unique id to search for
  35229. * @return the found mesh or null if not found at all.
  35230. */
  35231. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35232. /**
  35233. * Gets a the last added mesh using a given id
  35234. * @param id defines the id to search for
  35235. * @return the found mesh or null if not found at all.
  35236. */
  35237. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35238. /**
  35239. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35240. * @param id defines the id to search for
  35241. * @return the found node or null if not found at all
  35242. */
  35243. getLastEntryByID(id: string): Nullable<Node>;
  35244. /**
  35245. * Gets a node (Mesh, Camera, Light) using a given id
  35246. * @param id defines the id to search for
  35247. * @return the found node or null if not found at all
  35248. */
  35249. getNodeByID(id: string): Nullable<Node>;
  35250. /**
  35251. * Gets a node (Mesh, Camera, Light) using a given name
  35252. * @param name defines the name to search for
  35253. * @return the found node or null if not found at all.
  35254. */
  35255. getNodeByName(name: string): Nullable<Node>;
  35256. /**
  35257. * Gets a mesh using a given name
  35258. * @param name defines the name to search for
  35259. * @return the found mesh or null if not found at all.
  35260. */
  35261. getMeshByName(name: string): Nullable<AbstractMesh>;
  35262. /**
  35263. * Gets a transform node using a given name
  35264. * @param name defines the name to search for
  35265. * @return the found transform node or null if not found at all.
  35266. */
  35267. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35268. /**
  35269. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35270. * @param id defines the id to search for
  35271. * @return the found skeleton or null if not found at all.
  35272. */
  35273. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35274. /**
  35275. * Gets a skeleton using a given auto generated unique id
  35276. * @param uniqueId defines the unique id to search for
  35277. * @return the found skeleton or null if not found at all.
  35278. */
  35279. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35280. /**
  35281. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35282. * @param id defines the id to search for
  35283. * @return the found skeleton or null if not found at all.
  35284. */
  35285. getSkeletonById(id: string): Nullable<Skeleton>;
  35286. /**
  35287. * Gets a skeleton using a given name
  35288. * @param name defines the name to search for
  35289. * @return the found skeleton or null if not found at all.
  35290. */
  35291. getSkeletonByName(name: string): Nullable<Skeleton>;
  35292. /**
  35293. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35294. * @param id defines the id to search for
  35295. * @return the found morph target manager or null if not found at all.
  35296. */
  35297. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35298. /**
  35299. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35300. * @param id defines the id to search for
  35301. * @return the found morph target or null if not found at all.
  35302. */
  35303. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35304. /**
  35305. * Gets a boolean indicating if the given mesh is active
  35306. * @param mesh defines the mesh to look for
  35307. * @returns true if the mesh is in the active list
  35308. */
  35309. isActiveMesh(mesh: AbstractMesh): boolean;
  35310. /**
  35311. * Return a unique id as a string which can serve as an identifier for the scene
  35312. */
  35313. readonly uid: string;
  35314. /**
  35315. * Add an externaly attached data from its key.
  35316. * This method call will fail and return false, if such key already exists.
  35317. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35318. * @param key the unique key that identifies the data
  35319. * @param data the data object to associate to the key for this Engine instance
  35320. * @return true if no such key were already present and the data was added successfully, false otherwise
  35321. */
  35322. addExternalData<T>(key: string, data: T): boolean;
  35323. /**
  35324. * Get an externaly attached data from its key
  35325. * @param key the unique key that identifies the data
  35326. * @return the associated data, if present (can be null), or undefined if not present
  35327. */
  35328. getExternalData<T>(key: string): Nullable<T>;
  35329. /**
  35330. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35331. * @param key the unique key that identifies the data
  35332. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35333. * @return the associated data, can be null if the factory returned null.
  35334. */
  35335. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35336. /**
  35337. * Remove an externaly attached data from the Engine instance
  35338. * @param key the unique key that identifies the data
  35339. * @return true if the data was successfully removed, false if it doesn't exist
  35340. */
  35341. removeExternalData(key: string): boolean;
  35342. private _evaluateSubMesh;
  35343. /**
  35344. * Clear the processed materials smart array preventing retention point in material dispose.
  35345. */
  35346. freeProcessedMaterials(): void;
  35347. private _preventFreeActiveMeshesAndRenderingGroups;
  35348. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35349. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35350. * when disposing several meshes in a row or a hierarchy of meshes.
  35351. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35352. */
  35353. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35354. /**
  35355. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35356. */
  35357. freeActiveMeshes(): void;
  35358. /**
  35359. * Clear the info related to rendering groups preventing retention points during dispose.
  35360. */
  35361. freeRenderingGroups(): void;
  35362. /** @hidden */
  35363. _isInIntermediateRendering(): boolean;
  35364. /**
  35365. * Lambda returning the list of potentially active meshes.
  35366. */
  35367. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35368. /**
  35369. * Lambda returning the list of potentially active sub meshes.
  35370. */
  35371. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35372. /**
  35373. * Lambda returning the list of potentially intersecting sub meshes.
  35374. */
  35375. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35376. /**
  35377. * Lambda returning the list of potentially colliding sub meshes.
  35378. */
  35379. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35380. private _activeMeshesFrozen;
  35381. /**
  35382. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35383. * @returns the current scene
  35384. */
  35385. freezeActiveMeshes(): Scene;
  35386. /**
  35387. * Use this function to restart evaluating active meshes on every frame
  35388. * @returns the current scene
  35389. */
  35390. unfreezeActiveMeshes(): Scene;
  35391. private _evaluateActiveMeshes;
  35392. private _activeMesh;
  35393. /**
  35394. * Update the transform matrix to update from the current active camera
  35395. * @param force defines a boolean used to force the update even if cache is up to date
  35396. */
  35397. updateTransformMatrix(force?: boolean): void;
  35398. private _bindFrameBuffer;
  35399. /** @hidden */
  35400. _allowPostProcessClearColor: boolean;
  35401. /** @hidden */
  35402. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35403. private _processSubCameras;
  35404. private _checkIntersections;
  35405. /** @hidden */
  35406. _advancePhysicsEngineStep(step: number): void;
  35407. /**
  35408. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35409. */
  35410. getDeterministicFrameTime: () => number;
  35411. /** @hidden */
  35412. _animate(): void;
  35413. /** Execute all animations (for a frame) */
  35414. animate(): void;
  35415. /**
  35416. * Render the scene
  35417. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35418. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35419. */
  35420. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35421. /**
  35422. * Freeze all materials
  35423. * A frozen material will not be updatable but should be faster to render
  35424. */
  35425. freezeMaterials(): void;
  35426. /**
  35427. * Unfreeze all materials
  35428. * A frozen material will not be updatable but should be faster to render
  35429. */
  35430. unfreezeMaterials(): void;
  35431. /**
  35432. * Releases all held ressources
  35433. */
  35434. dispose(): void;
  35435. /**
  35436. * Gets if the scene is already disposed
  35437. */
  35438. readonly isDisposed: boolean;
  35439. /**
  35440. * Call this function to reduce memory footprint of the scene.
  35441. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35442. */
  35443. clearCachedVertexData(): void;
  35444. /**
  35445. * This function will remove the local cached buffer data from texture.
  35446. * It will save memory but will prevent the texture from being rebuilt
  35447. */
  35448. cleanCachedTextureBuffer(): void;
  35449. /**
  35450. * Get the world extend vectors with an optional filter
  35451. *
  35452. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35453. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35454. */
  35455. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35456. min: Vector3;
  35457. max: Vector3;
  35458. };
  35459. /**
  35460. * Creates a ray that can be used to pick in the scene
  35461. * @param x defines the x coordinate of the origin (on-screen)
  35462. * @param y defines the y coordinate of the origin (on-screen)
  35463. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35464. * @param camera defines the camera to use for the picking
  35465. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35466. * @returns a Ray
  35467. */
  35468. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35469. /**
  35470. * Creates a ray that can be used to pick in the scene
  35471. * @param x defines the x coordinate of the origin (on-screen)
  35472. * @param y defines the y coordinate of the origin (on-screen)
  35473. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35474. * @param result defines the ray where to store the picking ray
  35475. * @param camera defines the camera to use for the picking
  35476. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35477. * @returns the current scene
  35478. */
  35479. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35480. /**
  35481. * Creates a ray that can be used to pick in the scene
  35482. * @param x defines the x coordinate of the origin (on-screen)
  35483. * @param y defines the y coordinate of the origin (on-screen)
  35484. * @param camera defines the camera to use for the picking
  35485. * @returns a Ray
  35486. */
  35487. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35488. /**
  35489. * Creates a ray that can be used to pick in the scene
  35490. * @param x defines the x coordinate of the origin (on-screen)
  35491. * @param y defines the y coordinate of the origin (on-screen)
  35492. * @param result defines the ray where to store the picking ray
  35493. * @param camera defines the camera to use for the picking
  35494. * @returns the current scene
  35495. */
  35496. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35497. /** Launch a ray to try to pick a mesh in the scene
  35498. * @param x position on screen
  35499. * @param y position on screen
  35500. * @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
  35501. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35502. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35503. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35504. * @returns a PickingInfo
  35505. */
  35506. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35507. /** Use the given ray to pick a mesh in the scene
  35508. * @param ray The ray to use to pick meshes
  35509. * @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
  35510. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35511. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35512. * @returns a PickingInfo
  35513. */
  35514. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35515. /**
  35516. * Launch a ray to try to pick a mesh in the scene
  35517. * @param x X position on screen
  35518. * @param y Y position on screen
  35519. * @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
  35520. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35521. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35522. * @returns an array of PickingInfo
  35523. */
  35524. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35525. /**
  35526. * Launch a ray to try to pick a mesh in the scene
  35527. * @param ray Ray to use
  35528. * @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
  35529. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35530. * @returns an array of PickingInfo
  35531. */
  35532. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35533. /**
  35534. * Force the value of meshUnderPointer
  35535. * @param mesh defines the mesh to use
  35536. */
  35537. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35538. /**
  35539. * Gets the mesh under the pointer
  35540. * @returns a Mesh or null if no mesh is under the pointer
  35541. */
  35542. getPointerOverMesh(): Nullable<AbstractMesh>;
  35543. /** @hidden */
  35544. _rebuildGeometries(): void;
  35545. /** @hidden */
  35546. _rebuildTextures(): void;
  35547. private _getByTags;
  35548. /**
  35549. * Get a list of meshes by tags
  35550. * @param tagsQuery defines the tags query to use
  35551. * @param forEach defines a predicate used to filter results
  35552. * @returns an array of Mesh
  35553. */
  35554. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35555. /**
  35556. * Get a list of cameras by tags
  35557. * @param tagsQuery defines the tags query to use
  35558. * @param forEach defines a predicate used to filter results
  35559. * @returns an array of Camera
  35560. */
  35561. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35562. /**
  35563. * Get a list of lights by tags
  35564. * @param tagsQuery defines the tags query to use
  35565. * @param forEach defines a predicate used to filter results
  35566. * @returns an array of Light
  35567. */
  35568. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35569. /**
  35570. * Get a list of materials by tags
  35571. * @param tagsQuery defines the tags query to use
  35572. * @param forEach defines a predicate used to filter results
  35573. * @returns an array of Material
  35574. */
  35575. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35576. /**
  35577. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35578. * This allowed control for front to back rendering or reversly depending of the special needs.
  35579. *
  35580. * @param renderingGroupId The rendering group id corresponding to its index
  35581. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35582. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35583. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35584. */
  35585. 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;
  35586. /**
  35587. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35588. *
  35589. * @param renderingGroupId The rendering group id corresponding to its index
  35590. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35591. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35592. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35593. */
  35594. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35595. /**
  35596. * Gets the current auto clear configuration for one rendering group of the rendering
  35597. * manager.
  35598. * @param index the rendering group index to get the information for
  35599. * @returns The auto clear setup for the requested rendering group
  35600. */
  35601. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35602. private _blockMaterialDirtyMechanism;
  35603. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35604. blockMaterialDirtyMechanism: boolean;
  35605. /**
  35606. * Will flag all materials as dirty to trigger new shader compilation
  35607. * @param flag defines the flag used to specify which material part must be marked as dirty
  35608. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35609. */
  35610. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35611. /** @hidden */
  35612. _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;
  35613. /** @hidden */
  35614. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35615. }
  35616. }
  35617. declare module "babylonjs/assetContainer" {
  35618. import { AbstractScene } from "babylonjs/abstractScene";
  35619. import { Scene } from "babylonjs/scene";
  35620. import { Mesh } from "babylonjs/Meshes/mesh";
  35621. /**
  35622. * Set of assets to keep when moving a scene into an asset container.
  35623. */
  35624. export class KeepAssets extends AbstractScene {
  35625. }
  35626. /**
  35627. * Container with a set of assets that can be added or removed from a scene.
  35628. */
  35629. export class AssetContainer extends AbstractScene {
  35630. /**
  35631. * The scene the AssetContainer belongs to.
  35632. */
  35633. scene: Scene;
  35634. /**
  35635. * Instantiates an AssetContainer.
  35636. * @param scene The scene the AssetContainer belongs to.
  35637. */
  35638. constructor(scene: Scene);
  35639. /**
  35640. * Adds all the assets from the container to the scene.
  35641. */
  35642. addAllToScene(): void;
  35643. /**
  35644. * Removes all the assets in the container from the scene
  35645. */
  35646. removeAllFromScene(): void;
  35647. /**
  35648. * Disposes all the assets in the container
  35649. */
  35650. dispose(): void;
  35651. private _moveAssets;
  35652. /**
  35653. * Removes all the assets contained in the scene and adds them to the container.
  35654. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35655. */
  35656. moveAllFromScene(keepAssets?: KeepAssets): void;
  35657. /**
  35658. * 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.
  35659. * @returns the root mesh
  35660. */
  35661. createRootMesh(): Mesh;
  35662. }
  35663. }
  35664. declare module "babylonjs/abstractScene" {
  35665. import { Scene } from "babylonjs/scene";
  35666. import { Nullable } from "babylonjs/types";
  35667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35668. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35669. import { Geometry } from "babylonjs/Meshes/geometry";
  35670. import { Skeleton } from "babylonjs/Bones/skeleton";
  35671. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35672. import { AssetContainer } from "babylonjs/assetContainer";
  35673. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35674. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35675. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35676. import { Material } from "babylonjs/Materials/material";
  35677. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35678. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35679. import { Camera } from "babylonjs/Cameras/camera";
  35680. import { Light } from "babylonjs/Lights/light";
  35681. import { Node } from "babylonjs/node";
  35682. import { Animation } from "babylonjs/Animations/animation";
  35683. /**
  35684. * Defines how the parser contract is defined.
  35685. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35686. */
  35687. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35688. /**
  35689. * Defines how the individual parser contract is defined.
  35690. * These parser can parse an individual asset
  35691. */
  35692. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35693. /**
  35694. * Base class of the scene acting as a container for the different elements composing a scene.
  35695. * This class is dynamically extended by the different components of the scene increasing
  35696. * flexibility and reducing coupling
  35697. */
  35698. export abstract class AbstractScene {
  35699. /**
  35700. * Stores the list of available parsers in the application.
  35701. */
  35702. private static _BabylonFileParsers;
  35703. /**
  35704. * Stores the list of available individual parsers in the application.
  35705. */
  35706. private static _IndividualBabylonFileParsers;
  35707. /**
  35708. * Adds a parser in the list of available ones
  35709. * @param name Defines the name of the parser
  35710. * @param parser Defines the parser to add
  35711. */
  35712. static AddParser(name: string, parser: BabylonFileParser): void;
  35713. /**
  35714. * Gets a general parser from the list of avaialble ones
  35715. * @param name Defines the name of the parser
  35716. * @returns the requested parser or null
  35717. */
  35718. static GetParser(name: string): Nullable<BabylonFileParser>;
  35719. /**
  35720. * Adds n individual parser in the list of available ones
  35721. * @param name Defines the name of the parser
  35722. * @param parser Defines the parser to add
  35723. */
  35724. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35725. /**
  35726. * Gets an individual parser from the list of avaialble ones
  35727. * @param name Defines the name of the parser
  35728. * @returns the requested parser or null
  35729. */
  35730. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35731. /**
  35732. * Parser json data and populate both a scene and its associated container object
  35733. * @param jsonData Defines the data to parse
  35734. * @param scene Defines the scene to parse the data for
  35735. * @param container Defines the container attached to the parsing sequence
  35736. * @param rootUrl Defines the root url of the data
  35737. */
  35738. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35739. /**
  35740. * Gets the list of root nodes (ie. nodes with no parent)
  35741. */
  35742. rootNodes: Node[];
  35743. /** All of the cameras added to this scene
  35744. * @see http://doc.babylonjs.com/babylon101/cameras
  35745. */
  35746. cameras: Camera[];
  35747. /**
  35748. * All of the lights added to this scene
  35749. * @see http://doc.babylonjs.com/babylon101/lights
  35750. */
  35751. lights: Light[];
  35752. /**
  35753. * All of the (abstract) meshes added to this scene
  35754. */
  35755. meshes: AbstractMesh[];
  35756. /**
  35757. * The list of skeletons added to the scene
  35758. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35759. */
  35760. skeletons: Skeleton[];
  35761. /**
  35762. * All of the particle systems added to this scene
  35763. * @see http://doc.babylonjs.com/babylon101/particles
  35764. */
  35765. particleSystems: IParticleSystem[];
  35766. /**
  35767. * Gets a list of Animations associated with the scene
  35768. */
  35769. animations: Animation[];
  35770. /**
  35771. * All of the animation groups added to this scene
  35772. * @see http://doc.babylonjs.com/how_to/group
  35773. */
  35774. animationGroups: AnimationGroup[];
  35775. /**
  35776. * All of the multi-materials added to this scene
  35777. * @see http://doc.babylonjs.com/how_to/multi_materials
  35778. */
  35779. multiMaterials: MultiMaterial[];
  35780. /**
  35781. * All of the materials added to this scene
  35782. * In the context of a Scene, it is not supposed to be modified manually.
  35783. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35784. * Note also that the order of the Material wihin the array is not significant and might change.
  35785. * @see http://doc.babylonjs.com/babylon101/materials
  35786. */
  35787. materials: Material[];
  35788. /**
  35789. * The list of morph target managers added to the scene
  35790. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35791. */
  35792. morphTargetManagers: MorphTargetManager[];
  35793. /**
  35794. * The list of geometries used in the scene.
  35795. */
  35796. geometries: Geometry[];
  35797. /**
  35798. * All of the tranform nodes added to this scene
  35799. * In the context of a Scene, it is not supposed to be modified manually.
  35800. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35801. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35802. * @see http://doc.babylonjs.com/how_to/transformnode
  35803. */
  35804. transformNodes: TransformNode[];
  35805. /**
  35806. * ActionManagers available on the scene.
  35807. */
  35808. actionManagers: AbstractActionManager[];
  35809. /**
  35810. * Textures to keep.
  35811. */
  35812. textures: BaseTexture[];
  35813. /**
  35814. * Environment texture for the scene
  35815. */
  35816. environmentTexture: Nullable<BaseTexture>;
  35817. }
  35818. }
  35819. declare module "babylonjs/Audio/sound" {
  35820. import { Observable } from "babylonjs/Misc/observable";
  35821. import { Vector3 } from "babylonjs/Maths/math.vector";
  35822. import { Nullable } from "babylonjs/types";
  35823. import { Scene } from "babylonjs/scene";
  35824. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35825. /**
  35826. * Interface used to define options for Sound class
  35827. */
  35828. export interface ISoundOptions {
  35829. /**
  35830. * Does the sound autoplay once loaded.
  35831. */
  35832. autoplay?: boolean;
  35833. /**
  35834. * Does the sound loop after it finishes playing once.
  35835. */
  35836. loop?: boolean;
  35837. /**
  35838. * Sound's volume
  35839. */
  35840. volume?: number;
  35841. /**
  35842. * Is it a spatial sound?
  35843. */
  35844. spatialSound?: boolean;
  35845. /**
  35846. * Maximum distance to hear that sound
  35847. */
  35848. maxDistance?: number;
  35849. /**
  35850. * Uses user defined attenuation function
  35851. */
  35852. useCustomAttenuation?: boolean;
  35853. /**
  35854. * Define the roll off factor of spatial sounds.
  35855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35856. */
  35857. rolloffFactor?: number;
  35858. /**
  35859. * Define the reference distance the sound should be heard perfectly.
  35860. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35861. */
  35862. refDistance?: number;
  35863. /**
  35864. * Define the distance attenuation model the sound will follow.
  35865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35866. */
  35867. distanceModel?: string;
  35868. /**
  35869. * Defines the playback speed (1 by default)
  35870. */
  35871. playbackRate?: number;
  35872. /**
  35873. * Defines if the sound is from a streaming source
  35874. */
  35875. streaming?: boolean;
  35876. /**
  35877. * Defines an optional length (in seconds) inside the sound file
  35878. */
  35879. length?: number;
  35880. /**
  35881. * Defines an optional offset (in seconds) inside the sound file
  35882. */
  35883. offset?: number;
  35884. /**
  35885. * If true, URLs will not be required to state the audio file codec to use.
  35886. */
  35887. skipCodecCheck?: boolean;
  35888. }
  35889. /**
  35890. * Defines a sound that can be played in the application.
  35891. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35893. */
  35894. export class Sound {
  35895. /**
  35896. * The name of the sound in the scene.
  35897. */
  35898. name: string;
  35899. /**
  35900. * Does the sound autoplay once loaded.
  35901. */
  35902. autoplay: boolean;
  35903. /**
  35904. * Does the sound loop after it finishes playing once.
  35905. */
  35906. loop: boolean;
  35907. /**
  35908. * Does the sound use a custom attenuation curve to simulate the falloff
  35909. * happening when the source gets further away from the camera.
  35910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35911. */
  35912. useCustomAttenuation: boolean;
  35913. /**
  35914. * The sound track id this sound belongs to.
  35915. */
  35916. soundTrackId: number;
  35917. /**
  35918. * Is this sound currently played.
  35919. */
  35920. isPlaying: boolean;
  35921. /**
  35922. * Is this sound currently paused.
  35923. */
  35924. isPaused: boolean;
  35925. /**
  35926. * Does this sound enables spatial sound.
  35927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35928. */
  35929. spatialSound: boolean;
  35930. /**
  35931. * Define the reference distance the sound should be heard perfectly.
  35932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35933. */
  35934. refDistance: number;
  35935. /**
  35936. * Define the roll off factor of spatial sounds.
  35937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35938. */
  35939. rolloffFactor: number;
  35940. /**
  35941. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35943. */
  35944. maxDistance: number;
  35945. /**
  35946. * Define the distance attenuation model the sound will follow.
  35947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35948. */
  35949. distanceModel: string;
  35950. /**
  35951. * @hidden
  35952. * Back Compat
  35953. **/
  35954. onended: () => any;
  35955. /**
  35956. * Observable event when the current playing sound finishes.
  35957. */
  35958. onEndedObservable: Observable<Sound>;
  35959. private _panningModel;
  35960. private _playbackRate;
  35961. private _streaming;
  35962. private _startTime;
  35963. private _startOffset;
  35964. private _position;
  35965. /** @hidden */
  35966. _positionInEmitterSpace: boolean;
  35967. private _localDirection;
  35968. private _volume;
  35969. private _isReadyToPlay;
  35970. private _isDirectional;
  35971. private _readyToPlayCallback;
  35972. private _audioBuffer;
  35973. private _soundSource;
  35974. private _streamingSource;
  35975. private _soundPanner;
  35976. private _soundGain;
  35977. private _inputAudioNode;
  35978. private _outputAudioNode;
  35979. private _coneInnerAngle;
  35980. private _coneOuterAngle;
  35981. private _coneOuterGain;
  35982. private _scene;
  35983. private _connectedTransformNode;
  35984. private _customAttenuationFunction;
  35985. private _registerFunc;
  35986. private _isOutputConnected;
  35987. private _htmlAudioElement;
  35988. private _urlType;
  35989. private _length?;
  35990. private _offset?;
  35991. /** @hidden */
  35992. static _SceneComponentInitialization: (scene: Scene) => void;
  35993. /**
  35994. * Create a sound and attach it to a scene
  35995. * @param name Name of your sound
  35996. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35997. * @param scene defines the scene the sound belongs to
  35998. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35999. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36000. */
  36001. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36002. /**
  36003. * Release the sound and its associated resources
  36004. */
  36005. dispose(): void;
  36006. /**
  36007. * Gets if the sounds is ready to be played or not.
  36008. * @returns true if ready, otherwise false
  36009. */
  36010. isReady(): boolean;
  36011. private _soundLoaded;
  36012. /**
  36013. * Sets the data of the sound from an audiobuffer
  36014. * @param audioBuffer The audioBuffer containing the data
  36015. */
  36016. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36017. /**
  36018. * Updates the current sounds options such as maxdistance, loop...
  36019. * @param options A JSON object containing values named as the object properties
  36020. */
  36021. updateOptions(options: ISoundOptions): void;
  36022. private _createSpatialParameters;
  36023. private _updateSpatialParameters;
  36024. /**
  36025. * Switch the panning model to HRTF:
  36026. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36028. */
  36029. switchPanningModelToHRTF(): void;
  36030. /**
  36031. * Switch the panning model to Equal Power:
  36032. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36034. */
  36035. switchPanningModelToEqualPower(): void;
  36036. private _switchPanningModel;
  36037. /**
  36038. * Connect this sound to a sound track audio node like gain...
  36039. * @param soundTrackAudioNode the sound track audio node to connect to
  36040. */
  36041. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36042. /**
  36043. * Transform this sound into a directional source
  36044. * @param coneInnerAngle Size of the inner cone in degree
  36045. * @param coneOuterAngle Size of the outer cone in degree
  36046. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36047. */
  36048. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36049. /**
  36050. * Gets or sets the inner angle for the directional cone.
  36051. */
  36052. /**
  36053. * Gets or sets the inner angle for the directional cone.
  36054. */
  36055. directionalConeInnerAngle: number;
  36056. /**
  36057. * Gets or sets the outer angle for the directional cone.
  36058. */
  36059. /**
  36060. * Gets or sets the outer angle for the directional cone.
  36061. */
  36062. directionalConeOuterAngle: number;
  36063. /**
  36064. * Sets the position of the emitter if spatial sound is enabled
  36065. * @param newPosition Defines the new posisiton
  36066. */
  36067. setPosition(newPosition: Vector3): void;
  36068. /**
  36069. * Sets the local direction of the emitter if spatial sound is enabled
  36070. * @param newLocalDirection Defines the new local direction
  36071. */
  36072. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36073. private _updateDirection;
  36074. /** @hidden */
  36075. updateDistanceFromListener(): void;
  36076. /**
  36077. * Sets a new custom attenuation function for the sound.
  36078. * @param callback Defines the function used for the attenuation
  36079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36080. */
  36081. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36082. /**
  36083. * Play the sound
  36084. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36085. * @param offset (optional) Start the sound at a specific time in seconds
  36086. * @param length (optional) Sound duration (in seconds)
  36087. */
  36088. play(time?: number, offset?: number, length?: number): void;
  36089. private _onended;
  36090. /**
  36091. * Stop the sound
  36092. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36093. */
  36094. stop(time?: number): void;
  36095. /**
  36096. * Put the sound in pause
  36097. */
  36098. pause(): void;
  36099. /**
  36100. * Sets a dedicated volume for this sounds
  36101. * @param newVolume Define the new volume of the sound
  36102. * @param time Define time for gradual change to new volume
  36103. */
  36104. setVolume(newVolume: number, time?: number): void;
  36105. /**
  36106. * Set the sound play back rate
  36107. * @param newPlaybackRate Define the playback rate the sound should be played at
  36108. */
  36109. setPlaybackRate(newPlaybackRate: number): void;
  36110. /**
  36111. * Gets the volume of the sound.
  36112. * @returns the volume of the sound
  36113. */
  36114. getVolume(): number;
  36115. /**
  36116. * Attach the sound to a dedicated mesh
  36117. * @param transformNode The transform node to connect the sound with
  36118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36119. */
  36120. attachToMesh(transformNode: TransformNode): void;
  36121. /**
  36122. * Detach the sound from the previously attached mesh
  36123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36124. */
  36125. detachFromMesh(): void;
  36126. private _onRegisterAfterWorldMatrixUpdate;
  36127. /**
  36128. * Clone the current sound in the scene.
  36129. * @returns the new sound clone
  36130. */
  36131. clone(): Nullable<Sound>;
  36132. /**
  36133. * Gets the current underlying audio buffer containing the data
  36134. * @returns the audio buffer
  36135. */
  36136. getAudioBuffer(): Nullable<AudioBuffer>;
  36137. /**
  36138. * Serializes the Sound in a JSON representation
  36139. * @returns the JSON representation of the sound
  36140. */
  36141. serialize(): any;
  36142. /**
  36143. * Parse a JSON representation of a sound to innstantiate in a given scene
  36144. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36145. * @param scene Define the scene the new parsed sound should be created in
  36146. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36147. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36148. * @returns the newly parsed sound
  36149. */
  36150. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36151. }
  36152. }
  36153. declare module "babylonjs/Actions/directAudioActions" {
  36154. import { Action } from "babylonjs/Actions/action";
  36155. import { Condition } from "babylonjs/Actions/condition";
  36156. import { Sound } from "babylonjs/Audio/sound";
  36157. /**
  36158. * This defines an action helpful to play a defined sound on a triggered action.
  36159. */
  36160. export class PlaySoundAction extends Action {
  36161. private _sound;
  36162. /**
  36163. * Instantiate the action
  36164. * @param triggerOptions defines the trigger options
  36165. * @param sound defines the sound to play
  36166. * @param condition defines the trigger related conditions
  36167. */
  36168. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36169. /** @hidden */
  36170. _prepare(): void;
  36171. /**
  36172. * Execute the action and play the sound.
  36173. */
  36174. execute(): void;
  36175. /**
  36176. * Serializes the actions and its related information.
  36177. * @param parent defines the object to serialize in
  36178. * @returns the serialized object
  36179. */
  36180. serialize(parent: any): any;
  36181. }
  36182. /**
  36183. * This defines an action helpful to stop a defined sound on a triggered action.
  36184. */
  36185. export class StopSoundAction extends Action {
  36186. private _sound;
  36187. /**
  36188. * Instantiate the action
  36189. * @param triggerOptions defines the trigger options
  36190. * @param sound defines the sound to stop
  36191. * @param condition defines the trigger related conditions
  36192. */
  36193. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36194. /** @hidden */
  36195. _prepare(): void;
  36196. /**
  36197. * Execute the action and stop the sound.
  36198. */
  36199. execute(): void;
  36200. /**
  36201. * Serializes the actions and its related information.
  36202. * @param parent defines the object to serialize in
  36203. * @returns the serialized object
  36204. */
  36205. serialize(parent: any): any;
  36206. }
  36207. }
  36208. declare module "babylonjs/Actions/interpolateValueAction" {
  36209. import { Action } from "babylonjs/Actions/action";
  36210. import { Condition } from "babylonjs/Actions/condition";
  36211. import { Observable } from "babylonjs/Misc/observable";
  36212. /**
  36213. * This defines an action responsible to change the value of a property
  36214. * by interpolating between its current value and the newly set one once triggered.
  36215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36216. */
  36217. export class InterpolateValueAction extends Action {
  36218. /**
  36219. * Defines the path of the property where the value should be interpolated
  36220. */
  36221. propertyPath: string;
  36222. /**
  36223. * Defines the target value at the end of the interpolation.
  36224. */
  36225. value: any;
  36226. /**
  36227. * Defines the time it will take for the property to interpolate to the value.
  36228. */
  36229. duration: number;
  36230. /**
  36231. * Defines if the other scene animations should be stopped when the action has been triggered
  36232. */
  36233. stopOtherAnimations?: boolean;
  36234. /**
  36235. * Defines a callback raised once the interpolation animation has been done.
  36236. */
  36237. onInterpolationDone?: () => void;
  36238. /**
  36239. * Observable triggered once the interpolation animation has been done.
  36240. */
  36241. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36242. private _target;
  36243. private _effectiveTarget;
  36244. private _property;
  36245. /**
  36246. * Instantiate the action
  36247. * @param triggerOptions defines the trigger options
  36248. * @param target defines the object containing the value to interpolate
  36249. * @param propertyPath defines the path to the property in the target object
  36250. * @param value defines the target value at the end of the interpolation
  36251. * @param duration deines the time it will take for the property to interpolate to the value.
  36252. * @param condition defines the trigger related conditions
  36253. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36254. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36255. */
  36256. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36257. /** @hidden */
  36258. _prepare(): void;
  36259. /**
  36260. * Execute the action starts the value interpolation.
  36261. */
  36262. execute(): void;
  36263. /**
  36264. * Serializes the actions and its related information.
  36265. * @param parent defines the object to serialize in
  36266. * @returns the serialized object
  36267. */
  36268. serialize(parent: any): any;
  36269. }
  36270. }
  36271. declare module "babylonjs/Actions/index" {
  36272. export * from "babylonjs/Actions/abstractActionManager";
  36273. export * from "babylonjs/Actions/action";
  36274. export * from "babylonjs/Actions/actionEvent";
  36275. export * from "babylonjs/Actions/actionManager";
  36276. export * from "babylonjs/Actions/condition";
  36277. export * from "babylonjs/Actions/directActions";
  36278. export * from "babylonjs/Actions/directAudioActions";
  36279. export * from "babylonjs/Actions/interpolateValueAction";
  36280. }
  36281. declare module "babylonjs/Animations/index" {
  36282. export * from "babylonjs/Animations/animatable";
  36283. export * from "babylonjs/Animations/animation";
  36284. export * from "babylonjs/Animations/animationGroup";
  36285. export * from "babylonjs/Animations/animationPropertiesOverride";
  36286. export * from "babylonjs/Animations/easing";
  36287. export * from "babylonjs/Animations/runtimeAnimation";
  36288. export * from "babylonjs/Animations/animationEvent";
  36289. export * from "babylonjs/Animations/animationGroup";
  36290. export * from "babylonjs/Animations/animationKey";
  36291. export * from "babylonjs/Animations/animationRange";
  36292. export * from "babylonjs/Animations/animatable.interface";
  36293. }
  36294. declare module "babylonjs/Audio/soundTrack" {
  36295. import { Sound } from "babylonjs/Audio/sound";
  36296. import { Analyser } from "babylonjs/Audio/analyser";
  36297. import { Scene } from "babylonjs/scene";
  36298. /**
  36299. * Options allowed during the creation of a sound track.
  36300. */
  36301. export interface ISoundTrackOptions {
  36302. /**
  36303. * The volume the sound track should take during creation
  36304. */
  36305. volume?: number;
  36306. /**
  36307. * Define if the sound track is the main sound track of the scene
  36308. */
  36309. mainTrack?: boolean;
  36310. }
  36311. /**
  36312. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36313. * It will be also used in a future release to apply effects on a specific track.
  36314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36315. */
  36316. export class SoundTrack {
  36317. /**
  36318. * The unique identifier of the sound track in the scene.
  36319. */
  36320. id: number;
  36321. /**
  36322. * The list of sounds included in the sound track.
  36323. */
  36324. soundCollection: Array<Sound>;
  36325. private _outputAudioNode;
  36326. private _scene;
  36327. private _isMainTrack;
  36328. private _connectedAnalyser;
  36329. private _options;
  36330. private _isInitialized;
  36331. /**
  36332. * Creates a new sound track.
  36333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36334. * @param scene Define the scene the sound track belongs to
  36335. * @param options
  36336. */
  36337. constructor(scene: Scene, options?: ISoundTrackOptions);
  36338. private _initializeSoundTrackAudioGraph;
  36339. /**
  36340. * Release the sound track and its associated resources
  36341. */
  36342. dispose(): void;
  36343. /**
  36344. * Adds a sound to this sound track
  36345. * @param sound define the cound to add
  36346. * @ignoreNaming
  36347. */
  36348. AddSound(sound: Sound): void;
  36349. /**
  36350. * Removes a sound to this sound track
  36351. * @param sound define the cound to remove
  36352. * @ignoreNaming
  36353. */
  36354. RemoveSound(sound: Sound): void;
  36355. /**
  36356. * Set a global volume for the full sound track.
  36357. * @param newVolume Define the new volume of the sound track
  36358. */
  36359. setVolume(newVolume: number): void;
  36360. /**
  36361. * Switch the panning model to HRTF:
  36362. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36364. */
  36365. switchPanningModelToHRTF(): void;
  36366. /**
  36367. * Switch the panning model to Equal Power:
  36368. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36370. */
  36371. switchPanningModelToEqualPower(): void;
  36372. /**
  36373. * Connect the sound track to an audio analyser allowing some amazing
  36374. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36376. * @param analyser The analyser to connect to the engine
  36377. */
  36378. connectToAnalyser(analyser: Analyser): void;
  36379. }
  36380. }
  36381. declare module "babylonjs/Audio/audioSceneComponent" {
  36382. import { Sound } from "babylonjs/Audio/sound";
  36383. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36384. import { Nullable } from "babylonjs/types";
  36385. import { Vector3 } from "babylonjs/Maths/math.vector";
  36386. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36387. import { Scene } from "babylonjs/scene";
  36388. import { AbstractScene } from "babylonjs/abstractScene";
  36389. import "babylonjs/Audio/audioEngine";
  36390. module "babylonjs/abstractScene" {
  36391. interface AbstractScene {
  36392. /**
  36393. * The list of sounds used in the scene.
  36394. */
  36395. sounds: Nullable<Array<Sound>>;
  36396. }
  36397. }
  36398. module "babylonjs/scene" {
  36399. interface Scene {
  36400. /**
  36401. * @hidden
  36402. * Backing field
  36403. */
  36404. _mainSoundTrack: SoundTrack;
  36405. /**
  36406. * The main sound track played by the scene.
  36407. * It cotains your primary collection of sounds.
  36408. */
  36409. mainSoundTrack: SoundTrack;
  36410. /**
  36411. * The list of sound tracks added to the scene
  36412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36413. */
  36414. soundTracks: Nullable<Array<SoundTrack>>;
  36415. /**
  36416. * Gets a sound using a given name
  36417. * @param name defines the name to search for
  36418. * @return the found sound or null if not found at all.
  36419. */
  36420. getSoundByName(name: string): Nullable<Sound>;
  36421. /**
  36422. * Gets or sets if audio support is enabled
  36423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36424. */
  36425. audioEnabled: boolean;
  36426. /**
  36427. * Gets or sets if audio will be output to headphones
  36428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36429. */
  36430. headphone: boolean;
  36431. /**
  36432. * Gets or sets custom audio listener position provider
  36433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36434. */
  36435. audioListenerPositionProvider: Nullable<() => Vector3>;
  36436. }
  36437. }
  36438. /**
  36439. * Defines the sound scene component responsible to manage any sounds
  36440. * in a given scene.
  36441. */
  36442. export class AudioSceneComponent implements ISceneSerializableComponent {
  36443. /**
  36444. * The component name helpfull to identify the component in the list of scene components.
  36445. */
  36446. readonly name: string;
  36447. /**
  36448. * The scene the component belongs to.
  36449. */
  36450. scene: Scene;
  36451. private _audioEnabled;
  36452. /**
  36453. * Gets whether audio is enabled or not.
  36454. * Please use related enable/disable method to switch state.
  36455. */
  36456. readonly audioEnabled: boolean;
  36457. private _headphone;
  36458. /**
  36459. * Gets whether audio is outputing to headphone or not.
  36460. * Please use the according Switch methods to change output.
  36461. */
  36462. readonly headphone: boolean;
  36463. private _audioListenerPositionProvider;
  36464. /**
  36465. * Gets the current audio listener position provider
  36466. */
  36467. /**
  36468. * Sets a custom listener position for all sounds in the scene
  36469. * By default, this is the position of the first active camera
  36470. */
  36471. audioListenerPositionProvider: Nullable<() => Vector3>;
  36472. /**
  36473. * Creates a new instance of the component for the given scene
  36474. * @param scene Defines the scene to register the component in
  36475. */
  36476. constructor(scene: Scene);
  36477. /**
  36478. * Registers the component in a given scene
  36479. */
  36480. register(): void;
  36481. /**
  36482. * Rebuilds the elements related to this component in case of
  36483. * context lost for instance.
  36484. */
  36485. rebuild(): void;
  36486. /**
  36487. * Serializes the component data to the specified json object
  36488. * @param serializationObject The object to serialize to
  36489. */
  36490. serialize(serializationObject: any): void;
  36491. /**
  36492. * Adds all the elements from the container to the scene
  36493. * @param container the container holding the elements
  36494. */
  36495. addFromContainer(container: AbstractScene): void;
  36496. /**
  36497. * Removes all the elements in the container from the scene
  36498. * @param container contains the elements to remove
  36499. * @param dispose if the removed element should be disposed (default: false)
  36500. */
  36501. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36502. /**
  36503. * Disposes the component and the associated ressources.
  36504. */
  36505. dispose(): void;
  36506. /**
  36507. * Disables audio in the associated scene.
  36508. */
  36509. disableAudio(): void;
  36510. /**
  36511. * Enables audio in the associated scene.
  36512. */
  36513. enableAudio(): void;
  36514. /**
  36515. * Switch audio to headphone output.
  36516. */
  36517. switchAudioModeForHeadphones(): void;
  36518. /**
  36519. * Switch audio to normal speakers.
  36520. */
  36521. switchAudioModeForNormalSpeakers(): void;
  36522. private _afterRender;
  36523. }
  36524. }
  36525. declare module "babylonjs/Audio/weightedsound" {
  36526. import { Sound } from "babylonjs/Audio/sound";
  36527. /**
  36528. * Wraps one or more Sound objects and selects one with random weight for playback.
  36529. */
  36530. export class WeightedSound {
  36531. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36532. loop: boolean;
  36533. private _coneInnerAngle;
  36534. private _coneOuterAngle;
  36535. private _volume;
  36536. /** A Sound is currently playing. */
  36537. isPlaying: boolean;
  36538. /** A Sound is currently paused. */
  36539. isPaused: boolean;
  36540. private _sounds;
  36541. private _weights;
  36542. private _currentIndex?;
  36543. /**
  36544. * Creates a new WeightedSound from the list of sounds given.
  36545. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36546. * @param sounds Array of Sounds that will be selected from.
  36547. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36548. */
  36549. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36550. /**
  36551. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36552. */
  36553. /**
  36554. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36555. */
  36556. directionalConeInnerAngle: number;
  36557. /**
  36558. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36559. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36560. */
  36561. /**
  36562. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36563. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36564. */
  36565. directionalConeOuterAngle: number;
  36566. /**
  36567. * Playback volume.
  36568. */
  36569. /**
  36570. * Playback volume.
  36571. */
  36572. volume: number;
  36573. private _onended;
  36574. /**
  36575. * Suspend playback
  36576. */
  36577. pause(): void;
  36578. /**
  36579. * Stop playback
  36580. */
  36581. stop(): void;
  36582. /**
  36583. * Start playback.
  36584. * @param startOffset Position the clip head at a specific time in seconds.
  36585. */
  36586. play(startOffset?: number): void;
  36587. }
  36588. }
  36589. declare module "babylonjs/Audio/index" {
  36590. export * from "babylonjs/Audio/analyser";
  36591. export * from "babylonjs/Audio/audioEngine";
  36592. export * from "babylonjs/Audio/audioSceneComponent";
  36593. export * from "babylonjs/Audio/sound";
  36594. export * from "babylonjs/Audio/soundTrack";
  36595. export * from "babylonjs/Audio/weightedsound";
  36596. }
  36597. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36598. import { Behavior } from "babylonjs/Behaviors/behavior";
  36599. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36600. import { BackEase } from "babylonjs/Animations/easing";
  36601. /**
  36602. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36603. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36604. */
  36605. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36606. /**
  36607. * Gets the name of the behavior.
  36608. */
  36609. readonly name: string;
  36610. /**
  36611. * The easing function used by animations
  36612. */
  36613. static EasingFunction: BackEase;
  36614. /**
  36615. * The easing mode used by animations
  36616. */
  36617. static EasingMode: number;
  36618. /**
  36619. * The duration of the animation, in milliseconds
  36620. */
  36621. transitionDuration: number;
  36622. /**
  36623. * Length of the distance animated by the transition when lower radius is reached
  36624. */
  36625. lowerRadiusTransitionRange: number;
  36626. /**
  36627. * Length of the distance animated by the transition when upper radius is reached
  36628. */
  36629. upperRadiusTransitionRange: number;
  36630. private _autoTransitionRange;
  36631. /**
  36632. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36633. */
  36634. /**
  36635. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36636. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36637. */
  36638. autoTransitionRange: boolean;
  36639. private _attachedCamera;
  36640. private _onAfterCheckInputsObserver;
  36641. private _onMeshTargetChangedObserver;
  36642. /**
  36643. * Initializes the behavior.
  36644. */
  36645. init(): void;
  36646. /**
  36647. * Attaches the behavior to its arc rotate camera.
  36648. * @param camera Defines the camera to attach the behavior to
  36649. */
  36650. attach(camera: ArcRotateCamera): void;
  36651. /**
  36652. * Detaches the behavior from its current arc rotate camera.
  36653. */
  36654. detach(): void;
  36655. private _radiusIsAnimating;
  36656. private _radiusBounceTransition;
  36657. private _animatables;
  36658. private _cachedWheelPrecision;
  36659. /**
  36660. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36661. * @param radiusLimit The limit to check against.
  36662. * @return Bool to indicate if at limit.
  36663. */
  36664. private _isRadiusAtLimit;
  36665. /**
  36666. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36667. * @param radiusDelta The delta by which to animate to. Can be negative.
  36668. */
  36669. private _applyBoundRadiusAnimation;
  36670. /**
  36671. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36672. */
  36673. protected _clearAnimationLocks(): void;
  36674. /**
  36675. * Stops and removes all animations that have been applied to the camera
  36676. */
  36677. stopAllAnimations(): void;
  36678. }
  36679. }
  36680. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36681. import { Behavior } from "babylonjs/Behaviors/behavior";
  36682. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36683. import { ExponentialEase } from "babylonjs/Animations/easing";
  36684. import { Nullable } from "babylonjs/types";
  36685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36686. import { Vector3 } from "babylonjs/Maths/math.vector";
  36687. /**
  36688. * 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.
  36689. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36690. */
  36691. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36692. /**
  36693. * Gets the name of the behavior.
  36694. */
  36695. readonly name: string;
  36696. private _mode;
  36697. private _radiusScale;
  36698. private _positionScale;
  36699. private _defaultElevation;
  36700. private _elevationReturnTime;
  36701. private _elevationReturnWaitTime;
  36702. private _zoomStopsAnimation;
  36703. private _framingTime;
  36704. /**
  36705. * The easing function used by animations
  36706. */
  36707. static EasingFunction: ExponentialEase;
  36708. /**
  36709. * The easing mode used by animations
  36710. */
  36711. static EasingMode: number;
  36712. /**
  36713. * Sets the current mode used by the behavior
  36714. */
  36715. /**
  36716. * Gets current mode used by the behavior.
  36717. */
  36718. mode: number;
  36719. /**
  36720. * Sets the scale applied to the radius (1 by default)
  36721. */
  36722. /**
  36723. * Gets the scale applied to the radius
  36724. */
  36725. radiusScale: number;
  36726. /**
  36727. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36728. */
  36729. /**
  36730. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36731. */
  36732. positionScale: number;
  36733. /**
  36734. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36735. * behaviour is triggered, in radians.
  36736. */
  36737. /**
  36738. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36739. * behaviour is triggered, in radians.
  36740. */
  36741. defaultElevation: number;
  36742. /**
  36743. * Sets the time (in milliseconds) taken to return to the default beta position.
  36744. * Negative value indicates camera should not return to default.
  36745. */
  36746. /**
  36747. * Gets the time (in milliseconds) taken to return to the default beta position.
  36748. * Negative value indicates camera should not return to default.
  36749. */
  36750. elevationReturnTime: number;
  36751. /**
  36752. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36753. */
  36754. /**
  36755. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36756. */
  36757. elevationReturnWaitTime: number;
  36758. /**
  36759. * Sets the flag that indicates if user zooming should stop animation.
  36760. */
  36761. /**
  36762. * Gets the flag that indicates if user zooming should stop animation.
  36763. */
  36764. zoomStopsAnimation: boolean;
  36765. /**
  36766. * Sets the transition time when framing the mesh, in milliseconds
  36767. */
  36768. /**
  36769. * Gets the transition time when framing the mesh, in milliseconds
  36770. */
  36771. framingTime: number;
  36772. /**
  36773. * Define if the behavior should automatically change the configured
  36774. * camera limits and sensibilities.
  36775. */
  36776. autoCorrectCameraLimitsAndSensibility: boolean;
  36777. private _onPrePointerObservableObserver;
  36778. private _onAfterCheckInputsObserver;
  36779. private _onMeshTargetChangedObserver;
  36780. private _attachedCamera;
  36781. private _isPointerDown;
  36782. private _lastInteractionTime;
  36783. /**
  36784. * Initializes the behavior.
  36785. */
  36786. init(): void;
  36787. /**
  36788. * Attaches the behavior to its arc rotate camera.
  36789. * @param camera Defines the camera to attach the behavior to
  36790. */
  36791. attach(camera: ArcRotateCamera): void;
  36792. /**
  36793. * Detaches the behavior from its current arc rotate camera.
  36794. */
  36795. detach(): void;
  36796. private _animatables;
  36797. private _betaIsAnimating;
  36798. private _betaTransition;
  36799. private _radiusTransition;
  36800. private _vectorTransition;
  36801. /**
  36802. * Targets the given mesh and updates zoom level accordingly.
  36803. * @param mesh The mesh to target.
  36804. * @param radius Optional. If a cached radius position already exists, overrides default.
  36805. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36806. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36807. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36808. */
  36809. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36810. /**
  36811. * Targets the given mesh with its children and updates zoom level accordingly.
  36812. * @param mesh The mesh to target.
  36813. * @param radius Optional. If a cached radius position already exists, overrides default.
  36814. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36815. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36816. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36817. */
  36818. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36819. /**
  36820. * Targets the given meshes with their children and updates zoom level accordingly.
  36821. * @param meshes The mesh to target.
  36822. * @param radius Optional. If a cached radius position already exists, overrides default.
  36823. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36824. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36825. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36826. */
  36827. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36828. /**
  36829. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36830. * @param minimumWorld Determines the smaller position of the bounding box extend
  36831. * @param maximumWorld Determines the bigger position of the bounding box extend
  36832. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36833. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36834. */
  36835. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36836. /**
  36837. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36838. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36839. * frustum width.
  36840. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36841. * to fully enclose the mesh in the viewing frustum.
  36842. */
  36843. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36844. /**
  36845. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36846. * is automatically returned to its default position (expected to be above ground plane).
  36847. */
  36848. private _maintainCameraAboveGround;
  36849. /**
  36850. * Returns the frustum slope based on the canvas ratio and camera FOV
  36851. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36852. */
  36853. private _getFrustumSlope;
  36854. /**
  36855. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36856. */
  36857. private _clearAnimationLocks;
  36858. /**
  36859. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36860. */
  36861. private _applyUserInteraction;
  36862. /**
  36863. * Stops and removes all animations that have been applied to the camera
  36864. */
  36865. stopAllAnimations(): void;
  36866. /**
  36867. * Gets a value indicating if the user is moving the camera
  36868. */
  36869. readonly isUserIsMoving: boolean;
  36870. /**
  36871. * The camera can move all the way towards the mesh.
  36872. */
  36873. static IgnoreBoundsSizeMode: number;
  36874. /**
  36875. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36876. */
  36877. static FitFrustumSidesMode: number;
  36878. }
  36879. }
  36880. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36881. import { Nullable } from "babylonjs/types";
  36882. import { Camera } from "babylonjs/Cameras/camera";
  36883. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36884. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36885. /**
  36886. * Base class for Camera Pointer Inputs.
  36887. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36888. * for example usage.
  36889. */
  36890. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36891. /**
  36892. * Defines the camera the input is attached to.
  36893. */
  36894. abstract camera: Camera;
  36895. /**
  36896. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36897. */
  36898. protected _altKey: boolean;
  36899. protected _ctrlKey: boolean;
  36900. protected _metaKey: boolean;
  36901. protected _shiftKey: boolean;
  36902. /**
  36903. * Which mouse buttons were pressed at time of last mouse event.
  36904. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36905. */
  36906. protected _buttonsPressed: number;
  36907. /**
  36908. * Defines the buttons associated with the input to handle camera move.
  36909. */
  36910. buttons: number[];
  36911. /**
  36912. * Attach the input controls to a specific dom element to get the input from.
  36913. * @param element Defines the element the controls should be listened from
  36914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36915. */
  36916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36917. /**
  36918. * Detach the current controls from the specified dom element.
  36919. * @param element Defines the element to stop listening the inputs from
  36920. */
  36921. detachControl(element: Nullable<HTMLElement>): void;
  36922. /**
  36923. * Gets the class name of the current input.
  36924. * @returns the class name
  36925. */
  36926. getClassName(): string;
  36927. /**
  36928. * Get the friendly name associated with the input class.
  36929. * @returns the input friendly name
  36930. */
  36931. getSimpleName(): string;
  36932. /**
  36933. * Called on pointer POINTERDOUBLETAP event.
  36934. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36935. */
  36936. protected onDoubleTap(type: string): void;
  36937. /**
  36938. * Called on pointer POINTERMOVE event if only a single touch is active.
  36939. * Override this method to provide functionality.
  36940. */
  36941. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36942. /**
  36943. * Called on pointer POINTERMOVE event if multiple touches are active.
  36944. * Override this method to provide functionality.
  36945. */
  36946. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36947. /**
  36948. * Called on JS contextmenu event.
  36949. * Override this method to provide functionality.
  36950. */
  36951. protected onContextMenu(evt: PointerEvent): void;
  36952. /**
  36953. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36954. * press.
  36955. * Override this method to provide functionality.
  36956. */
  36957. protected onButtonDown(evt: PointerEvent): void;
  36958. /**
  36959. * Called each time a new POINTERUP event occurs. Ie, for each button
  36960. * release.
  36961. * Override this method to provide functionality.
  36962. */
  36963. protected onButtonUp(evt: PointerEvent): void;
  36964. /**
  36965. * Called when window becomes inactive.
  36966. * Override this method to provide functionality.
  36967. */
  36968. protected onLostFocus(): void;
  36969. private _pointerInput;
  36970. private _observer;
  36971. private _onLostFocus;
  36972. private pointA;
  36973. private pointB;
  36974. }
  36975. }
  36976. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36977. import { Nullable } from "babylonjs/types";
  36978. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36979. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36980. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36981. /**
  36982. * Manage the pointers inputs to control an arc rotate camera.
  36983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36984. */
  36985. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36986. /**
  36987. * Defines the camera the input is attached to.
  36988. */
  36989. camera: ArcRotateCamera;
  36990. /**
  36991. * Gets the class name of the current input.
  36992. * @returns the class name
  36993. */
  36994. getClassName(): string;
  36995. /**
  36996. * Defines the buttons associated with the input to handle camera move.
  36997. */
  36998. buttons: number[];
  36999. /**
  37000. * Defines the pointer angular sensibility along the X axis or how fast is
  37001. * the camera rotating.
  37002. */
  37003. angularSensibilityX: number;
  37004. /**
  37005. * Defines the pointer angular sensibility along the Y axis or how fast is
  37006. * the camera rotating.
  37007. */
  37008. angularSensibilityY: number;
  37009. /**
  37010. * Defines the pointer pinch precision or how fast is the camera zooming.
  37011. */
  37012. pinchPrecision: number;
  37013. /**
  37014. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37015. * from 0.
  37016. * It defines the percentage of current camera.radius to use as delta when
  37017. * pinch zoom is used.
  37018. */
  37019. pinchDeltaPercentage: number;
  37020. /**
  37021. * Defines the pointer panning sensibility or how fast is the camera moving.
  37022. */
  37023. panningSensibility: number;
  37024. /**
  37025. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37026. */
  37027. multiTouchPanning: boolean;
  37028. /**
  37029. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37030. * zoom (pinch) through multitouch.
  37031. */
  37032. multiTouchPanAndZoom: boolean;
  37033. /**
  37034. * Revers pinch action direction.
  37035. */
  37036. pinchInwards: boolean;
  37037. private _isPanClick;
  37038. private _twoFingerActivityCount;
  37039. private _isPinching;
  37040. /**
  37041. * Called on pointer POINTERMOVE event if only a single touch is active.
  37042. */
  37043. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37044. /**
  37045. * Called on pointer POINTERDOUBLETAP event.
  37046. */
  37047. protected onDoubleTap(type: string): void;
  37048. /**
  37049. * Called on pointer POINTERMOVE event if multiple touches are active.
  37050. */
  37051. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37052. /**
  37053. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37054. * press.
  37055. */
  37056. protected onButtonDown(evt: PointerEvent): void;
  37057. /**
  37058. * Called each time a new POINTERUP event occurs. Ie, for each button
  37059. * release.
  37060. */
  37061. protected onButtonUp(evt: PointerEvent): void;
  37062. /**
  37063. * Called when window becomes inactive.
  37064. */
  37065. protected onLostFocus(): void;
  37066. }
  37067. }
  37068. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37069. import { Nullable } from "babylonjs/types";
  37070. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37071. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37072. /**
  37073. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37075. */
  37076. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37077. /**
  37078. * Defines the camera the input is attached to.
  37079. */
  37080. camera: ArcRotateCamera;
  37081. /**
  37082. * Defines the list of key codes associated with the up action (increase alpha)
  37083. */
  37084. keysUp: number[];
  37085. /**
  37086. * Defines the list of key codes associated with the down action (decrease alpha)
  37087. */
  37088. keysDown: number[];
  37089. /**
  37090. * Defines the list of key codes associated with the left action (increase beta)
  37091. */
  37092. keysLeft: number[];
  37093. /**
  37094. * Defines the list of key codes associated with the right action (decrease beta)
  37095. */
  37096. keysRight: number[];
  37097. /**
  37098. * Defines the list of key codes associated with the reset action.
  37099. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37100. */
  37101. keysReset: number[];
  37102. /**
  37103. * Defines the panning sensibility of the inputs.
  37104. * (How fast is the camera paning)
  37105. */
  37106. panningSensibility: number;
  37107. /**
  37108. * Defines the zooming sensibility of the inputs.
  37109. * (How fast is the camera zooming)
  37110. */
  37111. zoomingSensibility: number;
  37112. /**
  37113. * Defines wether maintaining the alt key down switch the movement mode from
  37114. * orientation to zoom.
  37115. */
  37116. useAltToZoom: boolean;
  37117. /**
  37118. * Rotation speed of the camera
  37119. */
  37120. angularSpeed: number;
  37121. private _keys;
  37122. private _ctrlPressed;
  37123. private _altPressed;
  37124. private _onCanvasBlurObserver;
  37125. private _onKeyboardObserver;
  37126. private _engine;
  37127. private _scene;
  37128. /**
  37129. * Attach the input controls to a specific dom element to get the input from.
  37130. * @param element Defines the element the controls should be listened from
  37131. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37132. */
  37133. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37134. /**
  37135. * Detach the current controls from the specified dom element.
  37136. * @param element Defines the element to stop listening the inputs from
  37137. */
  37138. detachControl(element: Nullable<HTMLElement>): void;
  37139. /**
  37140. * Update the current camera state depending on the inputs that have been used this frame.
  37141. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37142. */
  37143. checkInputs(): void;
  37144. /**
  37145. * Gets the class name of the current intput.
  37146. * @returns the class name
  37147. */
  37148. getClassName(): string;
  37149. /**
  37150. * Get the friendly name associated with the input class.
  37151. * @returns the input friendly name
  37152. */
  37153. getSimpleName(): string;
  37154. }
  37155. }
  37156. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37157. import { Nullable } from "babylonjs/types";
  37158. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37159. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37160. /**
  37161. * Manage the mouse wheel inputs to control an arc rotate camera.
  37162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37163. */
  37164. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37165. /**
  37166. * Defines the camera the input is attached to.
  37167. */
  37168. camera: ArcRotateCamera;
  37169. /**
  37170. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37171. */
  37172. wheelPrecision: number;
  37173. /**
  37174. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37175. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37176. */
  37177. wheelDeltaPercentage: number;
  37178. private _wheel;
  37179. private _observer;
  37180. private computeDeltaFromMouseWheelLegacyEvent;
  37181. /**
  37182. * Attach the input controls to a specific dom element to get the input from.
  37183. * @param element Defines the element the controls should be listened from
  37184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37185. */
  37186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37187. /**
  37188. * Detach the current controls from the specified dom element.
  37189. * @param element Defines the element to stop listening the inputs from
  37190. */
  37191. detachControl(element: Nullable<HTMLElement>): void;
  37192. /**
  37193. * Gets the class name of the current intput.
  37194. * @returns the class name
  37195. */
  37196. getClassName(): string;
  37197. /**
  37198. * Get the friendly name associated with the input class.
  37199. * @returns the input friendly name
  37200. */
  37201. getSimpleName(): string;
  37202. }
  37203. }
  37204. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37205. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37206. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37207. /**
  37208. * Default Inputs manager for the ArcRotateCamera.
  37209. * It groups all the default supported inputs for ease of use.
  37210. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37211. */
  37212. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37213. /**
  37214. * Instantiates a new ArcRotateCameraInputsManager.
  37215. * @param camera Defines the camera the inputs belong to
  37216. */
  37217. constructor(camera: ArcRotateCamera);
  37218. /**
  37219. * Add mouse wheel input support to the input manager.
  37220. * @returns the current input manager
  37221. */
  37222. addMouseWheel(): ArcRotateCameraInputsManager;
  37223. /**
  37224. * Add pointers input support to the input manager.
  37225. * @returns the current input manager
  37226. */
  37227. addPointers(): ArcRotateCameraInputsManager;
  37228. /**
  37229. * Add keyboard input support to the input manager.
  37230. * @returns the current input manager
  37231. */
  37232. addKeyboard(): ArcRotateCameraInputsManager;
  37233. }
  37234. }
  37235. declare module "babylonjs/Cameras/arcRotateCamera" {
  37236. import { Observable } from "babylonjs/Misc/observable";
  37237. import { Nullable } from "babylonjs/types";
  37238. import { Scene } from "babylonjs/scene";
  37239. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37241. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37242. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37243. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37244. import { Camera } from "babylonjs/Cameras/camera";
  37245. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37246. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37247. import { Collider } from "babylonjs/Collisions/collider";
  37248. /**
  37249. * This represents an orbital type of camera.
  37250. *
  37251. * 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.
  37252. * 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.
  37253. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37254. */
  37255. export class ArcRotateCamera extends TargetCamera {
  37256. /**
  37257. * Defines the rotation angle of the camera along the longitudinal axis.
  37258. */
  37259. alpha: number;
  37260. /**
  37261. * Defines the rotation angle of the camera along the latitudinal axis.
  37262. */
  37263. beta: number;
  37264. /**
  37265. * Defines the radius of the camera from it s target point.
  37266. */
  37267. radius: number;
  37268. protected _target: Vector3;
  37269. protected _targetHost: Nullable<AbstractMesh>;
  37270. /**
  37271. * Defines the target point of the camera.
  37272. * The camera looks towards it form the radius distance.
  37273. */
  37274. target: Vector3;
  37275. /**
  37276. * Define the current local position of the camera in the scene
  37277. */
  37278. position: Vector3;
  37279. protected _upVector: Vector3;
  37280. protected _upToYMatrix: Matrix;
  37281. protected _YToUpMatrix: Matrix;
  37282. /**
  37283. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37284. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37285. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37286. */
  37287. upVector: Vector3;
  37288. /**
  37289. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37290. */
  37291. setMatUp(): void;
  37292. /**
  37293. * Current inertia value on the longitudinal axis.
  37294. * The bigger this number the longer it will take for the camera to stop.
  37295. */
  37296. inertialAlphaOffset: number;
  37297. /**
  37298. * Current inertia value on the latitudinal axis.
  37299. * The bigger this number the longer it will take for the camera to stop.
  37300. */
  37301. inertialBetaOffset: number;
  37302. /**
  37303. * Current inertia value on the radius axis.
  37304. * The bigger this number the longer it will take for the camera to stop.
  37305. */
  37306. inertialRadiusOffset: number;
  37307. /**
  37308. * Minimum allowed angle on the longitudinal axis.
  37309. * This can help limiting how the Camera is able to move in the scene.
  37310. */
  37311. lowerAlphaLimit: Nullable<number>;
  37312. /**
  37313. * Maximum allowed angle on the longitudinal axis.
  37314. * This can help limiting how the Camera is able to move in the scene.
  37315. */
  37316. upperAlphaLimit: Nullable<number>;
  37317. /**
  37318. * Minimum allowed angle on the latitudinal axis.
  37319. * This can help limiting how the Camera is able to move in the scene.
  37320. */
  37321. lowerBetaLimit: number;
  37322. /**
  37323. * Maximum allowed angle on the latitudinal axis.
  37324. * This can help limiting how the Camera is able to move in the scene.
  37325. */
  37326. upperBetaLimit: number;
  37327. /**
  37328. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37329. * This can help limiting how the Camera is able to move in the scene.
  37330. */
  37331. lowerRadiusLimit: Nullable<number>;
  37332. /**
  37333. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37334. * This can help limiting how the Camera is able to move in the scene.
  37335. */
  37336. upperRadiusLimit: Nullable<number>;
  37337. /**
  37338. * Defines the current inertia value used during panning of the camera along the X axis.
  37339. */
  37340. inertialPanningX: number;
  37341. /**
  37342. * Defines the current inertia value used during panning of the camera along the Y axis.
  37343. */
  37344. inertialPanningY: number;
  37345. /**
  37346. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37347. * Basically if your fingers moves away from more than this distance you will be considered
  37348. * in pinch mode.
  37349. */
  37350. pinchToPanMaxDistance: number;
  37351. /**
  37352. * Defines the maximum distance the camera can pan.
  37353. * This could help keeping the cammera always in your scene.
  37354. */
  37355. panningDistanceLimit: Nullable<number>;
  37356. /**
  37357. * Defines the target of the camera before paning.
  37358. */
  37359. panningOriginTarget: Vector3;
  37360. /**
  37361. * Defines the value of the inertia used during panning.
  37362. * 0 would mean stop inertia and one would mean no decelleration at all.
  37363. */
  37364. panningInertia: number;
  37365. /**
  37366. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37367. */
  37368. angularSensibilityX: number;
  37369. /**
  37370. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37371. */
  37372. angularSensibilityY: number;
  37373. /**
  37374. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37375. */
  37376. pinchPrecision: number;
  37377. /**
  37378. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37379. * It will be used instead of pinchDeltaPrecision if different from 0.
  37380. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37381. */
  37382. pinchDeltaPercentage: number;
  37383. /**
  37384. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37385. */
  37386. panningSensibility: number;
  37387. /**
  37388. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37389. */
  37390. keysUp: number[];
  37391. /**
  37392. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37393. */
  37394. keysDown: number[];
  37395. /**
  37396. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37397. */
  37398. keysLeft: number[];
  37399. /**
  37400. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37401. */
  37402. keysRight: number[];
  37403. /**
  37404. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37405. */
  37406. wheelPrecision: number;
  37407. /**
  37408. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37409. * It will be used instead of pinchDeltaPrecision if different from 0.
  37410. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37411. */
  37412. wheelDeltaPercentage: number;
  37413. /**
  37414. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37415. */
  37416. zoomOnFactor: number;
  37417. /**
  37418. * Defines a screen offset for the camera position.
  37419. */
  37420. targetScreenOffset: Vector2;
  37421. /**
  37422. * Allows the camera to be completely reversed.
  37423. * If false the camera can not arrive upside down.
  37424. */
  37425. allowUpsideDown: boolean;
  37426. /**
  37427. * Define if double tap/click is used to restore the previously saved state of the camera.
  37428. */
  37429. useInputToRestoreState: boolean;
  37430. /** @hidden */
  37431. _viewMatrix: Matrix;
  37432. /** @hidden */
  37433. _useCtrlForPanning: boolean;
  37434. /** @hidden */
  37435. _panningMouseButton: number;
  37436. /**
  37437. * Defines the input associated to the camera.
  37438. */
  37439. inputs: ArcRotateCameraInputsManager;
  37440. /** @hidden */
  37441. _reset: () => void;
  37442. /**
  37443. * Defines the allowed panning axis.
  37444. */
  37445. panningAxis: Vector3;
  37446. protected _localDirection: Vector3;
  37447. protected _transformedDirection: Vector3;
  37448. private _bouncingBehavior;
  37449. /**
  37450. * Gets the bouncing behavior of the camera if it has been enabled.
  37451. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37452. */
  37453. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37454. /**
  37455. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37456. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37457. */
  37458. useBouncingBehavior: boolean;
  37459. private _framingBehavior;
  37460. /**
  37461. * Gets the framing behavior of the camera if it has been enabled.
  37462. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37463. */
  37464. readonly framingBehavior: Nullable<FramingBehavior>;
  37465. /**
  37466. * Defines if the framing behavior of the camera is enabled on the camera.
  37467. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37468. */
  37469. useFramingBehavior: boolean;
  37470. private _autoRotationBehavior;
  37471. /**
  37472. * Gets the auto rotation behavior of the camera if it has been enabled.
  37473. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37474. */
  37475. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37476. /**
  37477. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37478. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37479. */
  37480. useAutoRotationBehavior: boolean;
  37481. /**
  37482. * Observable triggered when the mesh target has been changed on the camera.
  37483. */
  37484. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37485. /**
  37486. * Event raised when the camera is colliding with a mesh.
  37487. */
  37488. onCollide: (collidedMesh: AbstractMesh) => void;
  37489. /**
  37490. * Defines whether the camera should check collision with the objects oh the scene.
  37491. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37492. */
  37493. checkCollisions: boolean;
  37494. /**
  37495. * Defines the collision radius of the camera.
  37496. * This simulates a sphere around the camera.
  37497. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37498. */
  37499. collisionRadius: Vector3;
  37500. protected _collider: Collider;
  37501. protected _previousPosition: Vector3;
  37502. protected _collisionVelocity: Vector3;
  37503. protected _newPosition: Vector3;
  37504. protected _previousAlpha: number;
  37505. protected _previousBeta: number;
  37506. protected _previousRadius: number;
  37507. protected _collisionTriggered: boolean;
  37508. protected _targetBoundingCenter: Nullable<Vector3>;
  37509. private _computationVector;
  37510. /**
  37511. * Instantiates a new ArcRotateCamera in a given scene
  37512. * @param name Defines the name of the camera
  37513. * @param alpha Defines the camera rotation along the logitudinal axis
  37514. * @param beta Defines the camera rotation along the latitudinal axis
  37515. * @param radius Defines the camera distance from its target
  37516. * @param target Defines the camera target
  37517. * @param scene Defines the scene the camera belongs to
  37518. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37519. */
  37520. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37521. /** @hidden */
  37522. _initCache(): void;
  37523. /** @hidden */
  37524. _updateCache(ignoreParentClass?: boolean): void;
  37525. protected _getTargetPosition(): Vector3;
  37526. private _storedAlpha;
  37527. private _storedBeta;
  37528. private _storedRadius;
  37529. private _storedTarget;
  37530. private _storedTargetScreenOffset;
  37531. /**
  37532. * Stores the current state of the camera (alpha, beta, radius and target)
  37533. * @returns the camera itself
  37534. */
  37535. storeState(): Camera;
  37536. /**
  37537. * @hidden
  37538. * Restored camera state. You must call storeState() first
  37539. */
  37540. _restoreStateValues(): boolean;
  37541. /** @hidden */
  37542. _isSynchronizedViewMatrix(): boolean;
  37543. /**
  37544. * Attached controls to the current camera.
  37545. * @param element Defines the element the controls should be listened from
  37546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37547. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37548. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37549. */
  37550. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37551. /**
  37552. * Detach the current controls from the camera.
  37553. * The camera will stop reacting to inputs.
  37554. * @param element Defines the element to stop listening the inputs from
  37555. */
  37556. detachControl(element: HTMLElement): void;
  37557. /** @hidden */
  37558. _checkInputs(): void;
  37559. protected _checkLimits(): void;
  37560. /**
  37561. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37562. */
  37563. rebuildAnglesAndRadius(): void;
  37564. /**
  37565. * Use a position to define the current camera related information like aplha, beta and radius
  37566. * @param position Defines the position to set the camera at
  37567. */
  37568. setPosition(position: Vector3): void;
  37569. /**
  37570. * Defines the target the camera should look at.
  37571. * This will automatically adapt alpha beta and radius to fit within the new target.
  37572. * @param target Defines the new target as a Vector or a mesh
  37573. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37574. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37575. */
  37576. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37577. /** @hidden */
  37578. _getViewMatrix(): Matrix;
  37579. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37580. /**
  37581. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37582. * @param meshes Defines the mesh to zoom on
  37583. * @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)
  37584. */
  37585. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37586. /**
  37587. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37588. * The target will be changed but the radius
  37589. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37590. * @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)
  37591. */
  37592. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37593. min: Vector3;
  37594. max: Vector3;
  37595. distance: number;
  37596. }, doNotUpdateMaxZ?: boolean): void;
  37597. /**
  37598. * @override
  37599. * Override Camera.createRigCamera
  37600. */
  37601. createRigCamera(name: string, cameraIndex: number): Camera;
  37602. /**
  37603. * @hidden
  37604. * @override
  37605. * Override Camera._updateRigCameras
  37606. */
  37607. _updateRigCameras(): void;
  37608. /**
  37609. * Destroy the camera and release the current resources hold by it.
  37610. */
  37611. dispose(): void;
  37612. /**
  37613. * Gets the current object class name.
  37614. * @return the class name
  37615. */
  37616. getClassName(): string;
  37617. }
  37618. }
  37619. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37620. import { Behavior } from "babylonjs/Behaviors/behavior";
  37621. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37622. /**
  37623. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37624. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37625. */
  37626. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37627. /**
  37628. * Gets the name of the behavior.
  37629. */
  37630. readonly name: string;
  37631. private _zoomStopsAnimation;
  37632. private _idleRotationSpeed;
  37633. private _idleRotationWaitTime;
  37634. private _idleRotationSpinupTime;
  37635. /**
  37636. * Sets the flag that indicates if user zooming should stop animation.
  37637. */
  37638. /**
  37639. * Gets the flag that indicates if user zooming should stop animation.
  37640. */
  37641. zoomStopsAnimation: boolean;
  37642. /**
  37643. * Sets the default speed at which the camera rotates around the model.
  37644. */
  37645. /**
  37646. * Gets the default speed at which the camera rotates around the model.
  37647. */
  37648. idleRotationSpeed: number;
  37649. /**
  37650. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37651. */
  37652. /**
  37653. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37654. */
  37655. idleRotationWaitTime: number;
  37656. /**
  37657. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37658. */
  37659. /**
  37660. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37661. */
  37662. idleRotationSpinupTime: number;
  37663. /**
  37664. * Gets a value indicating if the camera is currently rotating because of this behavior
  37665. */
  37666. readonly rotationInProgress: boolean;
  37667. private _onPrePointerObservableObserver;
  37668. private _onAfterCheckInputsObserver;
  37669. private _attachedCamera;
  37670. private _isPointerDown;
  37671. private _lastFrameTime;
  37672. private _lastInteractionTime;
  37673. private _cameraRotationSpeed;
  37674. /**
  37675. * Initializes the behavior.
  37676. */
  37677. init(): void;
  37678. /**
  37679. * Attaches the behavior to its arc rotate camera.
  37680. * @param camera Defines the camera to attach the behavior to
  37681. */
  37682. attach(camera: ArcRotateCamera): void;
  37683. /**
  37684. * Detaches the behavior from its current arc rotate camera.
  37685. */
  37686. detach(): void;
  37687. /**
  37688. * Returns true if user is scrolling.
  37689. * @return true if user is scrolling.
  37690. */
  37691. private _userIsZooming;
  37692. private _lastFrameRadius;
  37693. private _shouldAnimationStopForInteraction;
  37694. /**
  37695. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37696. */
  37697. private _applyUserInteraction;
  37698. private _userIsMoving;
  37699. }
  37700. }
  37701. declare module "babylonjs/Behaviors/Cameras/index" {
  37702. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37703. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37704. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37705. }
  37706. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37707. import { Mesh } from "babylonjs/Meshes/mesh";
  37708. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37709. import { Behavior } from "babylonjs/Behaviors/behavior";
  37710. /**
  37711. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37712. */
  37713. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37714. private ui;
  37715. /**
  37716. * The name of the behavior
  37717. */
  37718. name: string;
  37719. /**
  37720. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37721. */
  37722. distanceAwayFromFace: number;
  37723. /**
  37724. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37725. */
  37726. distanceAwayFromBottomOfFace: number;
  37727. private _faceVectors;
  37728. private _target;
  37729. private _scene;
  37730. private _onRenderObserver;
  37731. private _tmpMatrix;
  37732. private _tmpVector;
  37733. /**
  37734. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37735. * @param ui The transform node that should be attched to the mesh
  37736. */
  37737. constructor(ui: TransformNode);
  37738. /**
  37739. * Initializes the behavior
  37740. */
  37741. init(): void;
  37742. private _closestFace;
  37743. private _zeroVector;
  37744. private _lookAtTmpMatrix;
  37745. private _lookAtToRef;
  37746. /**
  37747. * Attaches the AttachToBoxBehavior to the passed in mesh
  37748. * @param target The mesh that the specified node will be attached to
  37749. */
  37750. attach(target: Mesh): void;
  37751. /**
  37752. * Detaches the behavior from the mesh
  37753. */
  37754. detach(): void;
  37755. }
  37756. }
  37757. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37758. import { Behavior } from "babylonjs/Behaviors/behavior";
  37759. import { Mesh } from "babylonjs/Meshes/mesh";
  37760. /**
  37761. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37762. */
  37763. export class FadeInOutBehavior implements Behavior<Mesh> {
  37764. /**
  37765. * Time in milliseconds to delay before fading in (Default: 0)
  37766. */
  37767. delay: number;
  37768. /**
  37769. * Time in milliseconds for the mesh to fade in (Default: 300)
  37770. */
  37771. fadeInTime: number;
  37772. private _millisecondsPerFrame;
  37773. private _hovered;
  37774. private _hoverValue;
  37775. private _ownerNode;
  37776. /**
  37777. * Instatiates the FadeInOutBehavior
  37778. */
  37779. constructor();
  37780. /**
  37781. * The name of the behavior
  37782. */
  37783. readonly name: string;
  37784. /**
  37785. * Initializes the behavior
  37786. */
  37787. init(): void;
  37788. /**
  37789. * Attaches the fade behavior on the passed in mesh
  37790. * @param ownerNode The mesh that will be faded in/out once attached
  37791. */
  37792. attach(ownerNode: Mesh): void;
  37793. /**
  37794. * Detaches the behavior from the mesh
  37795. */
  37796. detach(): void;
  37797. /**
  37798. * Triggers the mesh to begin fading in or out
  37799. * @param value if the object should fade in or out (true to fade in)
  37800. */
  37801. fadeIn(value: boolean): void;
  37802. private _update;
  37803. private _setAllVisibility;
  37804. }
  37805. }
  37806. declare module "babylonjs/Misc/pivotTools" {
  37807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37808. /**
  37809. * Class containing a set of static utilities functions for managing Pivots
  37810. * @hidden
  37811. */
  37812. export class PivotTools {
  37813. private static _PivotCached;
  37814. private static _OldPivotPoint;
  37815. private static _PivotTranslation;
  37816. private static _PivotTmpVector;
  37817. /** @hidden */
  37818. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37819. /** @hidden */
  37820. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37821. }
  37822. }
  37823. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37824. import { Scene } from "babylonjs/scene";
  37825. import { Vector4 } from "babylonjs/Maths/math.vector";
  37826. import { Mesh } from "babylonjs/Meshes/mesh";
  37827. import { Nullable } from "babylonjs/types";
  37828. import { Plane } from "babylonjs/Maths/math.plane";
  37829. /**
  37830. * Class containing static functions to help procedurally build meshes
  37831. */
  37832. export class PlaneBuilder {
  37833. /**
  37834. * Creates a plane mesh
  37835. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37836. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37837. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37839. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37841. * @param name defines the name of the mesh
  37842. * @param options defines the options used to create the mesh
  37843. * @param scene defines the hosting scene
  37844. * @returns the plane mesh
  37845. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37846. */
  37847. static CreatePlane(name: string, options: {
  37848. size?: number;
  37849. width?: number;
  37850. height?: number;
  37851. sideOrientation?: number;
  37852. frontUVs?: Vector4;
  37853. backUVs?: Vector4;
  37854. updatable?: boolean;
  37855. sourcePlane?: Plane;
  37856. }, scene?: Nullable<Scene>): Mesh;
  37857. }
  37858. }
  37859. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37860. import { Behavior } from "babylonjs/Behaviors/behavior";
  37861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37862. import { Observable } from "babylonjs/Misc/observable";
  37863. import { Vector3 } from "babylonjs/Maths/math.vector";
  37864. import { Ray } from "babylonjs/Culling/ray";
  37865. import "babylonjs/Meshes/Builders/planeBuilder";
  37866. /**
  37867. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37868. */
  37869. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37870. private static _AnyMouseID;
  37871. /**
  37872. * Abstract mesh the behavior is set on
  37873. */
  37874. attachedNode: AbstractMesh;
  37875. private _dragPlane;
  37876. private _scene;
  37877. private _pointerObserver;
  37878. private _beforeRenderObserver;
  37879. private static _planeScene;
  37880. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37881. /**
  37882. * 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)
  37883. */
  37884. maxDragAngle: number;
  37885. /**
  37886. * @hidden
  37887. */
  37888. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37889. /**
  37890. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37891. */
  37892. currentDraggingPointerID: number;
  37893. /**
  37894. * The last position where the pointer hit the drag plane in world space
  37895. */
  37896. lastDragPosition: Vector3;
  37897. /**
  37898. * If the behavior is currently in a dragging state
  37899. */
  37900. dragging: boolean;
  37901. /**
  37902. * 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)
  37903. */
  37904. dragDeltaRatio: number;
  37905. /**
  37906. * If the drag plane orientation should be updated during the dragging (Default: true)
  37907. */
  37908. updateDragPlane: boolean;
  37909. private _debugMode;
  37910. private _moving;
  37911. /**
  37912. * Fires each time the attached mesh is dragged with the pointer
  37913. * * delta between last drag position and current drag position in world space
  37914. * * dragDistance along the drag axis
  37915. * * dragPlaneNormal normal of the current drag plane used during the drag
  37916. * * dragPlanePoint in world space where the drag intersects the drag plane
  37917. */
  37918. onDragObservable: Observable<{
  37919. delta: Vector3;
  37920. dragPlanePoint: Vector3;
  37921. dragPlaneNormal: Vector3;
  37922. dragDistance: number;
  37923. pointerId: number;
  37924. }>;
  37925. /**
  37926. * Fires each time a drag begins (eg. mouse down on mesh)
  37927. */
  37928. onDragStartObservable: Observable<{
  37929. dragPlanePoint: Vector3;
  37930. pointerId: number;
  37931. }>;
  37932. /**
  37933. * Fires each time a drag ends (eg. mouse release after drag)
  37934. */
  37935. onDragEndObservable: Observable<{
  37936. dragPlanePoint: Vector3;
  37937. pointerId: number;
  37938. }>;
  37939. /**
  37940. * If the attached mesh should be moved when dragged
  37941. */
  37942. moveAttached: boolean;
  37943. /**
  37944. * If the drag behavior will react to drag events (Default: true)
  37945. */
  37946. enabled: boolean;
  37947. /**
  37948. * If pointer events should start and release the drag (Default: true)
  37949. */
  37950. startAndReleaseDragOnPointerEvents: boolean;
  37951. /**
  37952. * If camera controls should be detached during the drag
  37953. */
  37954. detachCameraControls: boolean;
  37955. /**
  37956. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37957. */
  37958. useObjectOrienationForDragging: boolean;
  37959. private _options;
  37960. /**
  37961. * Creates a pointer drag behavior that can be attached to a mesh
  37962. * @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)
  37963. */
  37964. constructor(options?: {
  37965. dragAxis?: Vector3;
  37966. dragPlaneNormal?: Vector3;
  37967. });
  37968. /**
  37969. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37970. */
  37971. validateDrag: (targetPosition: Vector3) => boolean;
  37972. /**
  37973. * The name of the behavior
  37974. */
  37975. readonly name: string;
  37976. /**
  37977. * Initializes the behavior
  37978. */
  37979. init(): void;
  37980. private _tmpVector;
  37981. private _alternatePickedPoint;
  37982. private _worldDragAxis;
  37983. private _targetPosition;
  37984. private _attachedElement;
  37985. /**
  37986. * Attaches the drag behavior the passed in mesh
  37987. * @param ownerNode The mesh that will be dragged around once attached
  37988. * @param predicate Predicate to use for pick filtering
  37989. */
  37990. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37991. /**
  37992. * Force relase the drag action by code.
  37993. */
  37994. releaseDrag(): void;
  37995. private _startDragRay;
  37996. private _lastPointerRay;
  37997. /**
  37998. * Simulates the start of a pointer drag event on the behavior
  37999. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38000. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38001. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38002. */
  38003. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38004. private _startDrag;
  38005. private _dragDelta;
  38006. private _moveDrag;
  38007. private _pickWithRayOnDragPlane;
  38008. private _pointA;
  38009. private _pointB;
  38010. private _pointC;
  38011. private _lineA;
  38012. private _lineB;
  38013. private _localAxis;
  38014. private _lookAt;
  38015. private _updateDragPlanePosition;
  38016. /**
  38017. * Detaches the behavior from the mesh
  38018. */
  38019. detach(): void;
  38020. }
  38021. }
  38022. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38023. import { Mesh } from "babylonjs/Meshes/mesh";
  38024. import { Behavior } from "babylonjs/Behaviors/behavior";
  38025. /**
  38026. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38027. */
  38028. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38029. private _dragBehaviorA;
  38030. private _dragBehaviorB;
  38031. private _startDistance;
  38032. private _initialScale;
  38033. private _targetScale;
  38034. private _ownerNode;
  38035. private _sceneRenderObserver;
  38036. /**
  38037. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38038. */
  38039. constructor();
  38040. /**
  38041. * The name of the behavior
  38042. */
  38043. readonly name: string;
  38044. /**
  38045. * Initializes the behavior
  38046. */
  38047. init(): void;
  38048. private _getCurrentDistance;
  38049. /**
  38050. * Attaches the scale behavior the passed in mesh
  38051. * @param ownerNode The mesh that will be scaled around once attached
  38052. */
  38053. attach(ownerNode: Mesh): void;
  38054. /**
  38055. * Detaches the behavior from the mesh
  38056. */
  38057. detach(): void;
  38058. }
  38059. }
  38060. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38061. import { Behavior } from "babylonjs/Behaviors/behavior";
  38062. import { Mesh } from "babylonjs/Meshes/mesh";
  38063. import { Observable } from "babylonjs/Misc/observable";
  38064. /**
  38065. * 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
  38066. */
  38067. export class SixDofDragBehavior implements Behavior<Mesh> {
  38068. private static _virtualScene;
  38069. private _ownerNode;
  38070. private _sceneRenderObserver;
  38071. private _scene;
  38072. private _targetPosition;
  38073. private _virtualOriginMesh;
  38074. private _virtualDragMesh;
  38075. private _pointerObserver;
  38076. private _moving;
  38077. private _startingOrientation;
  38078. /**
  38079. * 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)
  38080. */
  38081. private zDragFactor;
  38082. /**
  38083. * If the object should rotate to face the drag origin
  38084. */
  38085. rotateDraggedObject: boolean;
  38086. /**
  38087. * If the behavior is currently in a dragging state
  38088. */
  38089. dragging: boolean;
  38090. /**
  38091. * 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)
  38092. */
  38093. dragDeltaRatio: number;
  38094. /**
  38095. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38096. */
  38097. currentDraggingPointerID: number;
  38098. /**
  38099. * If camera controls should be detached during the drag
  38100. */
  38101. detachCameraControls: boolean;
  38102. /**
  38103. * Fires each time a drag starts
  38104. */
  38105. onDragStartObservable: Observable<{}>;
  38106. /**
  38107. * Fires each time a drag ends (eg. mouse release after drag)
  38108. */
  38109. onDragEndObservable: Observable<{}>;
  38110. /**
  38111. * 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
  38112. */
  38113. constructor();
  38114. /**
  38115. * The name of the behavior
  38116. */
  38117. readonly name: string;
  38118. /**
  38119. * Initializes the behavior
  38120. */
  38121. init(): void;
  38122. /**
  38123. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38124. */
  38125. private readonly _pointerCamera;
  38126. /**
  38127. * Attaches the scale behavior the passed in mesh
  38128. * @param ownerNode The mesh that will be scaled around once attached
  38129. */
  38130. attach(ownerNode: Mesh): void;
  38131. /**
  38132. * Detaches the behavior from the mesh
  38133. */
  38134. detach(): void;
  38135. }
  38136. }
  38137. declare module "babylonjs/Behaviors/Meshes/index" {
  38138. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38139. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38140. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38141. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38142. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38143. }
  38144. declare module "babylonjs/Behaviors/index" {
  38145. export * from "babylonjs/Behaviors/behavior";
  38146. export * from "babylonjs/Behaviors/Cameras/index";
  38147. export * from "babylonjs/Behaviors/Meshes/index";
  38148. }
  38149. declare module "babylonjs/Bones/boneIKController" {
  38150. import { Bone } from "babylonjs/Bones/bone";
  38151. import { Vector3 } from "babylonjs/Maths/math.vector";
  38152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38153. import { Nullable } from "babylonjs/types";
  38154. /**
  38155. * Class used to apply inverse kinematics to bones
  38156. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38157. */
  38158. export class BoneIKController {
  38159. private static _tmpVecs;
  38160. private static _tmpQuat;
  38161. private static _tmpMats;
  38162. /**
  38163. * Gets or sets the target mesh
  38164. */
  38165. targetMesh: AbstractMesh;
  38166. /** Gets or sets the mesh used as pole */
  38167. poleTargetMesh: AbstractMesh;
  38168. /**
  38169. * Gets or sets the bone used as pole
  38170. */
  38171. poleTargetBone: Nullable<Bone>;
  38172. /**
  38173. * Gets or sets the target position
  38174. */
  38175. targetPosition: Vector3;
  38176. /**
  38177. * Gets or sets the pole target position
  38178. */
  38179. poleTargetPosition: Vector3;
  38180. /**
  38181. * Gets or sets the pole target local offset
  38182. */
  38183. poleTargetLocalOffset: Vector3;
  38184. /**
  38185. * Gets or sets the pole angle
  38186. */
  38187. poleAngle: number;
  38188. /**
  38189. * Gets or sets the mesh associated with the controller
  38190. */
  38191. mesh: AbstractMesh;
  38192. /**
  38193. * 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)
  38194. */
  38195. slerpAmount: number;
  38196. private _bone1Quat;
  38197. private _bone1Mat;
  38198. private _bone2Ang;
  38199. private _bone1;
  38200. private _bone2;
  38201. private _bone1Length;
  38202. private _bone2Length;
  38203. private _maxAngle;
  38204. private _maxReach;
  38205. private _rightHandedSystem;
  38206. private _bendAxis;
  38207. private _slerping;
  38208. private _adjustRoll;
  38209. /**
  38210. * Gets or sets maximum allowed angle
  38211. */
  38212. maxAngle: number;
  38213. /**
  38214. * Creates a new BoneIKController
  38215. * @param mesh defines the mesh to control
  38216. * @param bone defines the bone to control
  38217. * @param options defines options to set up the controller
  38218. */
  38219. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38220. targetMesh?: AbstractMesh;
  38221. poleTargetMesh?: AbstractMesh;
  38222. poleTargetBone?: Bone;
  38223. poleTargetLocalOffset?: Vector3;
  38224. poleAngle?: number;
  38225. bendAxis?: Vector3;
  38226. maxAngle?: number;
  38227. slerpAmount?: number;
  38228. });
  38229. private _setMaxAngle;
  38230. /**
  38231. * Force the controller to update the bones
  38232. */
  38233. update(): void;
  38234. }
  38235. }
  38236. declare module "babylonjs/Bones/boneLookController" {
  38237. import { Vector3 } from "babylonjs/Maths/math.vector";
  38238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38239. import { Bone } from "babylonjs/Bones/bone";
  38240. import { Space } from "babylonjs/Maths/math.axis";
  38241. /**
  38242. * Class used to make a bone look toward a point in space
  38243. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38244. */
  38245. export class BoneLookController {
  38246. private static _tmpVecs;
  38247. private static _tmpQuat;
  38248. private static _tmpMats;
  38249. /**
  38250. * The target Vector3 that the bone will look at
  38251. */
  38252. target: Vector3;
  38253. /**
  38254. * The mesh that the bone is attached to
  38255. */
  38256. mesh: AbstractMesh;
  38257. /**
  38258. * The bone that will be looking to the target
  38259. */
  38260. bone: Bone;
  38261. /**
  38262. * The up axis of the coordinate system that is used when the bone is rotated
  38263. */
  38264. upAxis: Vector3;
  38265. /**
  38266. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38267. */
  38268. upAxisSpace: Space;
  38269. /**
  38270. * Used to make an adjustment to the yaw of the bone
  38271. */
  38272. adjustYaw: number;
  38273. /**
  38274. * Used to make an adjustment to the pitch of the bone
  38275. */
  38276. adjustPitch: number;
  38277. /**
  38278. * Used to make an adjustment to the roll of the bone
  38279. */
  38280. adjustRoll: number;
  38281. /**
  38282. * 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)
  38283. */
  38284. slerpAmount: number;
  38285. private _minYaw;
  38286. private _maxYaw;
  38287. private _minPitch;
  38288. private _maxPitch;
  38289. private _minYawSin;
  38290. private _minYawCos;
  38291. private _maxYawSin;
  38292. private _maxYawCos;
  38293. private _midYawConstraint;
  38294. private _minPitchTan;
  38295. private _maxPitchTan;
  38296. private _boneQuat;
  38297. private _slerping;
  38298. private _transformYawPitch;
  38299. private _transformYawPitchInv;
  38300. private _firstFrameSkipped;
  38301. private _yawRange;
  38302. private _fowardAxis;
  38303. /**
  38304. * Gets or sets the minimum yaw angle that the bone can look to
  38305. */
  38306. minYaw: number;
  38307. /**
  38308. * Gets or sets the maximum yaw angle that the bone can look to
  38309. */
  38310. maxYaw: number;
  38311. /**
  38312. * Gets or sets the minimum pitch angle that the bone can look to
  38313. */
  38314. minPitch: number;
  38315. /**
  38316. * Gets or sets the maximum pitch angle that the bone can look to
  38317. */
  38318. maxPitch: number;
  38319. /**
  38320. * Create a BoneLookController
  38321. * @param mesh the mesh that the bone belongs to
  38322. * @param bone the bone that will be looking to the target
  38323. * @param target the target Vector3 to look at
  38324. * @param options optional settings:
  38325. * * maxYaw: the maximum angle the bone will yaw to
  38326. * * minYaw: the minimum angle the bone will yaw to
  38327. * * maxPitch: the maximum angle the bone will pitch to
  38328. * * minPitch: the minimum angle the bone will yaw to
  38329. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38330. * * upAxis: the up axis of the coordinate system
  38331. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38332. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38333. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38334. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38335. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38336. * * adjustRoll: used to make an adjustment to the roll of the bone
  38337. **/
  38338. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38339. maxYaw?: number;
  38340. minYaw?: number;
  38341. maxPitch?: number;
  38342. minPitch?: number;
  38343. slerpAmount?: number;
  38344. upAxis?: Vector3;
  38345. upAxisSpace?: Space;
  38346. yawAxis?: Vector3;
  38347. pitchAxis?: Vector3;
  38348. adjustYaw?: number;
  38349. adjustPitch?: number;
  38350. adjustRoll?: number;
  38351. });
  38352. /**
  38353. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38354. */
  38355. update(): void;
  38356. private _getAngleDiff;
  38357. private _getAngleBetween;
  38358. private _isAngleBetween;
  38359. }
  38360. }
  38361. declare module "babylonjs/Bones/index" {
  38362. export * from "babylonjs/Bones/bone";
  38363. export * from "babylonjs/Bones/boneIKController";
  38364. export * from "babylonjs/Bones/boneLookController";
  38365. export * from "babylonjs/Bones/skeleton";
  38366. }
  38367. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38368. import { Nullable } from "babylonjs/types";
  38369. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38370. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38371. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38372. /**
  38373. * Manage the gamepad inputs to control an arc rotate camera.
  38374. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38375. */
  38376. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38377. /**
  38378. * Defines the camera the input is attached to.
  38379. */
  38380. camera: ArcRotateCamera;
  38381. /**
  38382. * Defines the gamepad the input is gathering event from.
  38383. */
  38384. gamepad: Nullable<Gamepad>;
  38385. /**
  38386. * Defines the gamepad rotation sensiblity.
  38387. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38388. */
  38389. gamepadRotationSensibility: number;
  38390. /**
  38391. * Defines the gamepad move sensiblity.
  38392. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38393. */
  38394. gamepadMoveSensibility: number;
  38395. private _onGamepadConnectedObserver;
  38396. private _onGamepadDisconnectedObserver;
  38397. /**
  38398. * Attach the input controls to a specific dom element to get the input from.
  38399. * @param element Defines the element the controls should be listened from
  38400. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38401. */
  38402. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38403. /**
  38404. * Detach the current controls from the specified dom element.
  38405. * @param element Defines the element to stop listening the inputs from
  38406. */
  38407. detachControl(element: Nullable<HTMLElement>): void;
  38408. /**
  38409. * Update the current camera state depending on the inputs that have been used this frame.
  38410. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38411. */
  38412. checkInputs(): void;
  38413. /**
  38414. * Gets the class name of the current intput.
  38415. * @returns the class name
  38416. */
  38417. getClassName(): string;
  38418. /**
  38419. * Get the friendly name associated with the input class.
  38420. * @returns the input friendly name
  38421. */
  38422. getSimpleName(): string;
  38423. }
  38424. }
  38425. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38426. import { Nullable } from "babylonjs/types";
  38427. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38428. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38429. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38430. interface ArcRotateCameraInputsManager {
  38431. /**
  38432. * Add orientation input support to the input manager.
  38433. * @returns the current input manager
  38434. */
  38435. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38436. }
  38437. }
  38438. /**
  38439. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38440. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38441. */
  38442. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38443. /**
  38444. * Defines the camera the input is attached to.
  38445. */
  38446. camera: ArcRotateCamera;
  38447. /**
  38448. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38449. */
  38450. alphaCorrection: number;
  38451. /**
  38452. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38453. */
  38454. gammaCorrection: number;
  38455. private _alpha;
  38456. private _gamma;
  38457. private _dirty;
  38458. private _deviceOrientationHandler;
  38459. /**
  38460. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38461. */
  38462. constructor();
  38463. /**
  38464. * Attach the input controls to a specific dom element to get the input from.
  38465. * @param element Defines the element the controls should be listened from
  38466. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38467. */
  38468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38469. /** @hidden */
  38470. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38471. /**
  38472. * Update the current camera state depending on the inputs that have been used this frame.
  38473. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38474. */
  38475. checkInputs(): void;
  38476. /**
  38477. * Detach the current controls from the specified dom element.
  38478. * @param element Defines the element to stop listening the inputs from
  38479. */
  38480. detachControl(element: Nullable<HTMLElement>): void;
  38481. /**
  38482. * Gets the class name of the current intput.
  38483. * @returns the class name
  38484. */
  38485. getClassName(): string;
  38486. /**
  38487. * Get the friendly name associated with the input class.
  38488. * @returns the input friendly name
  38489. */
  38490. getSimpleName(): string;
  38491. }
  38492. }
  38493. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38494. import { Nullable } from "babylonjs/types";
  38495. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38496. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38497. /**
  38498. * Listen to mouse events to control the camera.
  38499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38500. */
  38501. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38502. /**
  38503. * Defines the camera the input is attached to.
  38504. */
  38505. camera: FlyCamera;
  38506. /**
  38507. * Defines if touch is enabled. (Default is true.)
  38508. */
  38509. touchEnabled: boolean;
  38510. /**
  38511. * Defines the buttons associated with the input to handle camera rotation.
  38512. */
  38513. buttons: number[];
  38514. /**
  38515. * Assign buttons for Yaw control.
  38516. */
  38517. buttonsYaw: number[];
  38518. /**
  38519. * Assign buttons for Pitch control.
  38520. */
  38521. buttonsPitch: number[];
  38522. /**
  38523. * Assign buttons for Roll control.
  38524. */
  38525. buttonsRoll: number[];
  38526. /**
  38527. * Detect if any button is being pressed while mouse is moved.
  38528. * -1 = Mouse locked.
  38529. * 0 = Left button.
  38530. * 1 = Middle Button.
  38531. * 2 = Right Button.
  38532. */
  38533. activeButton: number;
  38534. /**
  38535. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38536. * Higher values reduce its sensitivity.
  38537. */
  38538. angularSensibility: number;
  38539. private _mousemoveCallback;
  38540. private _observer;
  38541. private _rollObserver;
  38542. private previousPosition;
  38543. private noPreventDefault;
  38544. private element;
  38545. /**
  38546. * Listen to mouse events to control the camera.
  38547. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38549. */
  38550. constructor(touchEnabled?: boolean);
  38551. /**
  38552. * Attach the mouse control to the HTML DOM element.
  38553. * @param element Defines the element that listens to the input events.
  38554. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38555. */
  38556. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38557. /**
  38558. * Detach the current controls from the specified dom element.
  38559. * @param element Defines the element to stop listening the inputs from
  38560. */
  38561. detachControl(element: Nullable<HTMLElement>): void;
  38562. /**
  38563. * Gets the class name of the current input.
  38564. * @returns the class name.
  38565. */
  38566. getClassName(): string;
  38567. /**
  38568. * Get the friendly name associated with the input class.
  38569. * @returns the input's friendly name.
  38570. */
  38571. getSimpleName(): string;
  38572. private _pointerInput;
  38573. private _onMouseMove;
  38574. /**
  38575. * Rotate camera by mouse offset.
  38576. */
  38577. private rotateCamera;
  38578. }
  38579. }
  38580. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38581. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38582. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38583. /**
  38584. * Default Inputs manager for the FlyCamera.
  38585. * It groups all the default supported inputs for ease of use.
  38586. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38587. */
  38588. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38589. /**
  38590. * Instantiates a new FlyCameraInputsManager.
  38591. * @param camera Defines the camera the inputs belong to.
  38592. */
  38593. constructor(camera: FlyCamera);
  38594. /**
  38595. * Add keyboard input support to the input manager.
  38596. * @returns the new FlyCameraKeyboardMoveInput().
  38597. */
  38598. addKeyboard(): FlyCameraInputsManager;
  38599. /**
  38600. * Add mouse input support to the input manager.
  38601. * @param touchEnabled Enable touch screen support.
  38602. * @returns the new FlyCameraMouseInput().
  38603. */
  38604. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38605. }
  38606. }
  38607. declare module "babylonjs/Cameras/flyCamera" {
  38608. import { Scene } from "babylonjs/scene";
  38609. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38611. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38612. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38613. /**
  38614. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38615. * such as in a 3D Space Shooter or a Flight Simulator.
  38616. */
  38617. export class FlyCamera extends TargetCamera {
  38618. /**
  38619. * Define the collision ellipsoid of the camera.
  38620. * This is helpful for simulating a camera body, like a player's body.
  38621. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38622. */
  38623. ellipsoid: Vector3;
  38624. /**
  38625. * Define an offset for the position of the ellipsoid around the camera.
  38626. * This can be helpful if the camera is attached away from the player's body center,
  38627. * such as at its head.
  38628. */
  38629. ellipsoidOffset: Vector3;
  38630. /**
  38631. * Enable or disable collisions of the camera with the rest of the scene objects.
  38632. */
  38633. checkCollisions: boolean;
  38634. /**
  38635. * Enable or disable gravity on the camera.
  38636. */
  38637. applyGravity: boolean;
  38638. /**
  38639. * Define the current direction the camera is moving to.
  38640. */
  38641. cameraDirection: Vector3;
  38642. /**
  38643. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38644. * This overrides and empties cameraRotation.
  38645. */
  38646. rotationQuaternion: Quaternion;
  38647. /**
  38648. * Track Roll to maintain the wanted Rolling when looking around.
  38649. */
  38650. _trackRoll: number;
  38651. /**
  38652. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38653. */
  38654. rollCorrect: number;
  38655. /**
  38656. * Mimic a banked turn, Rolling the camera when Yawing.
  38657. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38658. */
  38659. bankedTurn: boolean;
  38660. /**
  38661. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38662. */
  38663. bankedTurnLimit: number;
  38664. /**
  38665. * Value of 0 disables the banked Roll.
  38666. * Value of 1 is equal to the Yaw angle in radians.
  38667. */
  38668. bankedTurnMultiplier: number;
  38669. /**
  38670. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38671. */
  38672. inputs: FlyCameraInputsManager;
  38673. /**
  38674. * Gets the input sensibility for mouse input.
  38675. * Higher values reduce sensitivity.
  38676. */
  38677. /**
  38678. * Sets the input sensibility for a mouse input.
  38679. * Higher values reduce sensitivity.
  38680. */
  38681. angularSensibility: number;
  38682. /**
  38683. * Get the keys for camera movement forward.
  38684. */
  38685. /**
  38686. * Set the keys for camera movement forward.
  38687. */
  38688. keysForward: number[];
  38689. /**
  38690. * Get the keys for camera movement backward.
  38691. */
  38692. keysBackward: number[];
  38693. /**
  38694. * Get the keys for camera movement up.
  38695. */
  38696. /**
  38697. * Set the keys for camera movement up.
  38698. */
  38699. keysUp: number[];
  38700. /**
  38701. * Get the keys for camera movement down.
  38702. */
  38703. /**
  38704. * Set the keys for camera movement down.
  38705. */
  38706. keysDown: number[];
  38707. /**
  38708. * Get the keys for camera movement left.
  38709. */
  38710. /**
  38711. * Set the keys for camera movement left.
  38712. */
  38713. keysLeft: number[];
  38714. /**
  38715. * Set the keys for camera movement right.
  38716. */
  38717. /**
  38718. * Set the keys for camera movement right.
  38719. */
  38720. keysRight: number[];
  38721. /**
  38722. * Event raised when the camera collides with a mesh in the scene.
  38723. */
  38724. onCollide: (collidedMesh: AbstractMesh) => void;
  38725. private _collider;
  38726. private _needMoveForGravity;
  38727. private _oldPosition;
  38728. private _diffPosition;
  38729. private _newPosition;
  38730. /** @hidden */
  38731. _localDirection: Vector3;
  38732. /** @hidden */
  38733. _transformedDirection: Vector3;
  38734. /**
  38735. * Instantiates a FlyCamera.
  38736. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38737. * such as in a 3D Space Shooter or a Flight Simulator.
  38738. * @param name Define the name of the camera in the scene.
  38739. * @param position Define the starting position of the camera in the scene.
  38740. * @param scene Define the scene the camera belongs to.
  38741. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38742. */
  38743. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38744. /**
  38745. * Attach a control to the HTML DOM element.
  38746. * @param element Defines the element that listens to the input events.
  38747. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38748. */
  38749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38750. /**
  38751. * Detach a control from the HTML DOM element.
  38752. * The camera will stop reacting to that input.
  38753. * @param element Defines the element that listens to the input events.
  38754. */
  38755. detachControl(element: HTMLElement): void;
  38756. private _collisionMask;
  38757. /**
  38758. * Get the mask that the camera ignores in collision events.
  38759. */
  38760. /**
  38761. * Set the mask that the camera ignores in collision events.
  38762. */
  38763. collisionMask: number;
  38764. /** @hidden */
  38765. _collideWithWorld(displacement: Vector3): void;
  38766. /** @hidden */
  38767. private _onCollisionPositionChange;
  38768. /** @hidden */
  38769. _checkInputs(): void;
  38770. /** @hidden */
  38771. _decideIfNeedsToMove(): boolean;
  38772. /** @hidden */
  38773. _updatePosition(): void;
  38774. /**
  38775. * Restore the Roll to its target value at the rate specified.
  38776. * @param rate - Higher means slower restoring.
  38777. * @hidden
  38778. */
  38779. restoreRoll(rate: number): void;
  38780. /**
  38781. * Destroy the camera and release the current resources held by it.
  38782. */
  38783. dispose(): void;
  38784. /**
  38785. * Get the current object class name.
  38786. * @returns the class name.
  38787. */
  38788. getClassName(): string;
  38789. }
  38790. }
  38791. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38792. import { Nullable } from "babylonjs/types";
  38793. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38794. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38795. /**
  38796. * Listen to keyboard events to control the camera.
  38797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38798. */
  38799. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38800. /**
  38801. * Defines the camera the input is attached to.
  38802. */
  38803. camera: FlyCamera;
  38804. /**
  38805. * The list of keyboard keys used to control the forward move of the camera.
  38806. */
  38807. keysForward: number[];
  38808. /**
  38809. * The list of keyboard keys used to control the backward move of the camera.
  38810. */
  38811. keysBackward: number[];
  38812. /**
  38813. * The list of keyboard keys used to control the forward move of the camera.
  38814. */
  38815. keysUp: number[];
  38816. /**
  38817. * The list of keyboard keys used to control the backward move of the camera.
  38818. */
  38819. keysDown: number[];
  38820. /**
  38821. * The list of keyboard keys used to control the right strafe move of the camera.
  38822. */
  38823. keysRight: number[];
  38824. /**
  38825. * The list of keyboard keys used to control the left strafe move of the camera.
  38826. */
  38827. keysLeft: number[];
  38828. private _keys;
  38829. private _onCanvasBlurObserver;
  38830. private _onKeyboardObserver;
  38831. private _engine;
  38832. private _scene;
  38833. /**
  38834. * Attach the input controls to a specific dom element to get the input from.
  38835. * @param element Defines the element the controls should be listened from
  38836. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38837. */
  38838. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38839. /**
  38840. * Detach the current controls from the specified dom element.
  38841. * @param element Defines the element to stop listening the inputs from
  38842. */
  38843. detachControl(element: Nullable<HTMLElement>): void;
  38844. /**
  38845. * Gets the class name of the current intput.
  38846. * @returns the class name
  38847. */
  38848. getClassName(): string;
  38849. /** @hidden */
  38850. _onLostFocus(e: FocusEvent): void;
  38851. /**
  38852. * Get the friendly name associated with the input class.
  38853. * @returns the input friendly name
  38854. */
  38855. getSimpleName(): string;
  38856. /**
  38857. * Update the current camera state depending on the inputs that have been used this frame.
  38858. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38859. */
  38860. checkInputs(): void;
  38861. }
  38862. }
  38863. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38864. import { Nullable } from "babylonjs/types";
  38865. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38866. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38867. /**
  38868. * Manage the mouse wheel inputs to control a follow camera.
  38869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38870. */
  38871. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38872. /**
  38873. * Defines the camera the input is attached to.
  38874. */
  38875. camera: FollowCamera;
  38876. /**
  38877. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38878. */
  38879. axisControlRadius: boolean;
  38880. /**
  38881. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38882. */
  38883. axisControlHeight: boolean;
  38884. /**
  38885. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38886. */
  38887. axisControlRotation: boolean;
  38888. /**
  38889. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38890. * relation to mouseWheel events.
  38891. */
  38892. wheelPrecision: number;
  38893. /**
  38894. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38895. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38896. */
  38897. wheelDeltaPercentage: number;
  38898. private _wheel;
  38899. private _observer;
  38900. /**
  38901. * Attach the input controls to a specific dom element to get the input from.
  38902. * @param element Defines the element the controls should be listened from
  38903. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38904. */
  38905. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38906. /**
  38907. * Detach the current controls from the specified dom element.
  38908. * @param element Defines the element to stop listening the inputs from
  38909. */
  38910. detachControl(element: Nullable<HTMLElement>): void;
  38911. /**
  38912. * Gets the class name of the current intput.
  38913. * @returns the class name
  38914. */
  38915. getClassName(): string;
  38916. /**
  38917. * Get the friendly name associated with the input class.
  38918. * @returns the input friendly name
  38919. */
  38920. getSimpleName(): string;
  38921. }
  38922. }
  38923. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38924. import { Nullable } from "babylonjs/types";
  38925. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38926. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38927. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38928. /**
  38929. * Manage the pointers inputs to control an follow camera.
  38930. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38931. */
  38932. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38933. /**
  38934. * Defines the camera the input is attached to.
  38935. */
  38936. camera: FollowCamera;
  38937. /**
  38938. * Gets the class name of the current input.
  38939. * @returns the class name
  38940. */
  38941. getClassName(): string;
  38942. /**
  38943. * Defines the pointer angular sensibility along the X axis or how fast is
  38944. * the camera rotating.
  38945. * A negative number will reverse the axis direction.
  38946. */
  38947. angularSensibilityX: number;
  38948. /**
  38949. * Defines the pointer angular sensibility along the Y axis or how fast is
  38950. * the camera rotating.
  38951. * A negative number will reverse the axis direction.
  38952. */
  38953. angularSensibilityY: number;
  38954. /**
  38955. * Defines the pointer pinch precision or how fast is the camera zooming.
  38956. * A negative number will reverse the axis direction.
  38957. */
  38958. pinchPrecision: number;
  38959. /**
  38960. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38961. * from 0.
  38962. * It defines the percentage of current camera.radius to use as delta when
  38963. * pinch zoom is used.
  38964. */
  38965. pinchDeltaPercentage: number;
  38966. /**
  38967. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38968. */
  38969. axisXControlRadius: boolean;
  38970. /**
  38971. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38972. */
  38973. axisXControlHeight: boolean;
  38974. /**
  38975. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38976. */
  38977. axisXControlRotation: boolean;
  38978. /**
  38979. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38980. */
  38981. axisYControlRadius: boolean;
  38982. /**
  38983. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38984. */
  38985. axisYControlHeight: boolean;
  38986. /**
  38987. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38988. */
  38989. axisYControlRotation: boolean;
  38990. /**
  38991. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38992. */
  38993. axisPinchControlRadius: boolean;
  38994. /**
  38995. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38996. */
  38997. axisPinchControlHeight: boolean;
  38998. /**
  38999. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39000. */
  39001. axisPinchControlRotation: boolean;
  39002. /**
  39003. * Log error messages if basic misconfiguration has occurred.
  39004. */
  39005. warningEnable: boolean;
  39006. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39007. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39008. private _warningCounter;
  39009. private _warning;
  39010. }
  39011. }
  39012. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39013. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39014. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39015. /**
  39016. * Default Inputs manager for the FollowCamera.
  39017. * It groups all the default supported inputs for ease of use.
  39018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39019. */
  39020. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39021. /**
  39022. * Instantiates a new FollowCameraInputsManager.
  39023. * @param camera Defines the camera the inputs belong to
  39024. */
  39025. constructor(camera: FollowCamera);
  39026. /**
  39027. * Add keyboard input support to the input manager.
  39028. * @returns the current input manager
  39029. */
  39030. addKeyboard(): FollowCameraInputsManager;
  39031. /**
  39032. * Add mouse wheel input support to the input manager.
  39033. * @returns the current input manager
  39034. */
  39035. addMouseWheel(): FollowCameraInputsManager;
  39036. /**
  39037. * Add pointers input support to the input manager.
  39038. * @returns the current input manager
  39039. */
  39040. addPointers(): FollowCameraInputsManager;
  39041. /**
  39042. * Add orientation input support to the input manager.
  39043. * @returns the current input manager
  39044. */
  39045. addVRDeviceOrientation(): FollowCameraInputsManager;
  39046. }
  39047. }
  39048. declare module "babylonjs/Cameras/followCamera" {
  39049. import { Nullable } from "babylonjs/types";
  39050. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39051. import { Scene } from "babylonjs/scene";
  39052. import { Vector3 } from "babylonjs/Maths/math.vector";
  39053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39054. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39055. /**
  39056. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39057. * an arc rotate version arcFollowCamera are available.
  39058. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39059. */
  39060. export class FollowCamera extends TargetCamera {
  39061. /**
  39062. * Distance the follow camera should follow an object at
  39063. */
  39064. radius: number;
  39065. /**
  39066. * Minimum allowed distance of the camera to the axis of rotation
  39067. * (The camera can not get closer).
  39068. * This can help limiting how the Camera is able to move in the scene.
  39069. */
  39070. lowerRadiusLimit: Nullable<number>;
  39071. /**
  39072. * Maximum allowed distance of the camera to the axis of rotation
  39073. * (The camera can not get further).
  39074. * This can help limiting how the Camera is able to move in the scene.
  39075. */
  39076. upperRadiusLimit: Nullable<number>;
  39077. /**
  39078. * Define a rotation offset between the camera and the object it follows
  39079. */
  39080. rotationOffset: number;
  39081. /**
  39082. * Minimum allowed angle to camera position relative to target object.
  39083. * This can help limiting how the Camera is able to move in the scene.
  39084. */
  39085. lowerRotationOffsetLimit: Nullable<number>;
  39086. /**
  39087. * Maximum allowed angle to camera position relative to target object.
  39088. * This can help limiting how the Camera is able to move in the scene.
  39089. */
  39090. upperRotationOffsetLimit: Nullable<number>;
  39091. /**
  39092. * Define a height offset between the camera and the object it follows.
  39093. * It can help following an object from the top (like a car chaing a plane)
  39094. */
  39095. heightOffset: number;
  39096. /**
  39097. * Minimum allowed height of camera position relative to target object.
  39098. * This can help limiting how the Camera is able to move in the scene.
  39099. */
  39100. lowerHeightOffsetLimit: Nullable<number>;
  39101. /**
  39102. * Maximum allowed height of camera position relative to target object.
  39103. * This can help limiting how the Camera is able to move in the scene.
  39104. */
  39105. upperHeightOffsetLimit: Nullable<number>;
  39106. /**
  39107. * Define how fast the camera can accelerate to follow it s target.
  39108. */
  39109. cameraAcceleration: number;
  39110. /**
  39111. * Define the speed limit of the camera following an object.
  39112. */
  39113. maxCameraSpeed: number;
  39114. /**
  39115. * Define the target of the camera.
  39116. */
  39117. lockedTarget: Nullable<AbstractMesh>;
  39118. /**
  39119. * Defines the input associated with the camera.
  39120. */
  39121. inputs: FollowCameraInputsManager;
  39122. /**
  39123. * Instantiates the follow camera.
  39124. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39125. * @param name Define the name of the camera in the scene
  39126. * @param position Define the position of the camera
  39127. * @param scene Define the scene the camera belong to
  39128. * @param lockedTarget Define the target of the camera
  39129. */
  39130. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39131. private _follow;
  39132. /**
  39133. * Attached controls to the current camera.
  39134. * @param element Defines the element the controls should be listened from
  39135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39136. */
  39137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39138. /**
  39139. * Detach the current controls from the camera.
  39140. * The camera will stop reacting to inputs.
  39141. * @param element Defines the element to stop listening the inputs from
  39142. */
  39143. detachControl(element: HTMLElement): void;
  39144. /** @hidden */
  39145. _checkInputs(): void;
  39146. private _checkLimits;
  39147. /**
  39148. * Gets the camera class name.
  39149. * @returns the class name
  39150. */
  39151. getClassName(): string;
  39152. }
  39153. /**
  39154. * Arc Rotate version of the follow camera.
  39155. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39156. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39157. */
  39158. export class ArcFollowCamera extends TargetCamera {
  39159. /** The longitudinal angle of the camera */
  39160. alpha: number;
  39161. /** The latitudinal angle of the camera */
  39162. beta: number;
  39163. /** The radius of the camera from its target */
  39164. radius: number;
  39165. /** Define the camera target (the messh it should follow) */
  39166. target: Nullable<AbstractMesh>;
  39167. private _cartesianCoordinates;
  39168. /**
  39169. * Instantiates a new ArcFollowCamera
  39170. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39171. * @param name Define the name of the camera
  39172. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39173. * @param beta Define the rotation angle of the camera around the elevation axis
  39174. * @param radius Define the radius of the camera from its target point
  39175. * @param target Define the target of the camera
  39176. * @param scene Define the scene the camera belongs to
  39177. */
  39178. constructor(name: string,
  39179. /** The longitudinal angle of the camera */
  39180. alpha: number,
  39181. /** The latitudinal angle of the camera */
  39182. beta: number,
  39183. /** The radius of the camera from its target */
  39184. radius: number,
  39185. /** Define the camera target (the messh it should follow) */
  39186. target: Nullable<AbstractMesh>, scene: Scene);
  39187. private _follow;
  39188. /** @hidden */
  39189. _checkInputs(): void;
  39190. /**
  39191. * Returns the class name of the object.
  39192. * It is mostly used internally for serialization purposes.
  39193. */
  39194. getClassName(): string;
  39195. }
  39196. }
  39197. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39198. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39199. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39200. import { Nullable } from "babylonjs/types";
  39201. /**
  39202. * Manage the keyboard inputs to control the movement of a follow camera.
  39203. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39204. */
  39205. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39206. /**
  39207. * Defines the camera the input is attached to.
  39208. */
  39209. camera: FollowCamera;
  39210. /**
  39211. * Defines the list of key codes associated with the up action (increase heightOffset)
  39212. */
  39213. keysHeightOffsetIncr: number[];
  39214. /**
  39215. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39216. */
  39217. keysHeightOffsetDecr: number[];
  39218. /**
  39219. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39220. */
  39221. keysHeightOffsetModifierAlt: boolean;
  39222. /**
  39223. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39224. */
  39225. keysHeightOffsetModifierCtrl: boolean;
  39226. /**
  39227. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39228. */
  39229. keysHeightOffsetModifierShift: boolean;
  39230. /**
  39231. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39232. */
  39233. keysRotationOffsetIncr: number[];
  39234. /**
  39235. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39236. */
  39237. keysRotationOffsetDecr: number[];
  39238. /**
  39239. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39240. */
  39241. keysRotationOffsetModifierAlt: boolean;
  39242. /**
  39243. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39244. */
  39245. keysRotationOffsetModifierCtrl: boolean;
  39246. /**
  39247. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39248. */
  39249. keysRotationOffsetModifierShift: boolean;
  39250. /**
  39251. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39252. */
  39253. keysRadiusIncr: number[];
  39254. /**
  39255. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39256. */
  39257. keysRadiusDecr: number[];
  39258. /**
  39259. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39260. */
  39261. keysRadiusModifierAlt: boolean;
  39262. /**
  39263. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39264. */
  39265. keysRadiusModifierCtrl: boolean;
  39266. /**
  39267. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39268. */
  39269. keysRadiusModifierShift: boolean;
  39270. /**
  39271. * Defines the rate of change of heightOffset.
  39272. */
  39273. heightSensibility: number;
  39274. /**
  39275. * Defines the rate of change of rotationOffset.
  39276. */
  39277. rotationSensibility: number;
  39278. /**
  39279. * Defines the rate of change of radius.
  39280. */
  39281. radiusSensibility: number;
  39282. private _keys;
  39283. private _ctrlPressed;
  39284. private _altPressed;
  39285. private _shiftPressed;
  39286. private _onCanvasBlurObserver;
  39287. private _onKeyboardObserver;
  39288. private _engine;
  39289. private _scene;
  39290. /**
  39291. * Attach the input controls to a specific dom element to get the input from.
  39292. * @param element Defines the element the controls should be listened from
  39293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39294. */
  39295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39296. /**
  39297. * Detach the current controls from the specified dom element.
  39298. * @param element Defines the element to stop listening the inputs from
  39299. */
  39300. detachControl(element: Nullable<HTMLElement>): void;
  39301. /**
  39302. * Update the current camera state depending on the inputs that have been used this frame.
  39303. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39304. */
  39305. checkInputs(): void;
  39306. /**
  39307. * Gets the class name of the current input.
  39308. * @returns the class name
  39309. */
  39310. getClassName(): string;
  39311. /**
  39312. * Get the friendly name associated with the input class.
  39313. * @returns the input friendly name
  39314. */
  39315. getSimpleName(): string;
  39316. /**
  39317. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39318. * allow modification of the heightOffset value.
  39319. */
  39320. private _modifierHeightOffset;
  39321. /**
  39322. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39323. * allow modification of the rotationOffset value.
  39324. */
  39325. private _modifierRotationOffset;
  39326. /**
  39327. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39328. * allow modification of the radius value.
  39329. */
  39330. private _modifierRadius;
  39331. }
  39332. }
  39333. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39334. import { Nullable } from "babylonjs/types";
  39335. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39336. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39337. import { Observable } from "babylonjs/Misc/observable";
  39338. module "babylonjs/Cameras/freeCameraInputsManager" {
  39339. interface FreeCameraInputsManager {
  39340. /**
  39341. * @hidden
  39342. */
  39343. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39344. /**
  39345. * Add orientation input support to the input manager.
  39346. * @returns the current input manager
  39347. */
  39348. addDeviceOrientation(): FreeCameraInputsManager;
  39349. }
  39350. }
  39351. /**
  39352. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39353. * Screen rotation is taken into account.
  39354. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39355. */
  39356. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39357. private _camera;
  39358. private _screenOrientationAngle;
  39359. private _constantTranform;
  39360. private _screenQuaternion;
  39361. private _alpha;
  39362. private _beta;
  39363. private _gamma;
  39364. /**
  39365. * Can be used to detect if a device orientation sensor is availible on a device
  39366. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39367. * @returns a promise that will resolve on orientation change
  39368. */
  39369. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39370. /**
  39371. * @hidden
  39372. */
  39373. _onDeviceOrientationChangedObservable: Observable<void>;
  39374. /**
  39375. * Instantiates a new input
  39376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39377. */
  39378. constructor();
  39379. /**
  39380. * Define the camera controlled by the input.
  39381. */
  39382. camera: FreeCamera;
  39383. /**
  39384. * Attach the input controls to a specific dom element to get the input from.
  39385. * @param element Defines the element the controls should be listened from
  39386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39387. */
  39388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39389. private _orientationChanged;
  39390. private _deviceOrientation;
  39391. /**
  39392. * Detach the current controls from the specified dom element.
  39393. * @param element Defines the element to stop listening the inputs from
  39394. */
  39395. detachControl(element: Nullable<HTMLElement>): void;
  39396. /**
  39397. * Update the current camera state depending on the inputs that have been used this frame.
  39398. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39399. */
  39400. checkInputs(): void;
  39401. /**
  39402. * Gets the class name of the current intput.
  39403. * @returns the class name
  39404. */
  39405. getClassName(): string;
  39406. /**
  39407. * Get the friendly name associated with the input class.
  39408. * @returns the input friendly name
  39409. */
  39410. getSimpleName(): string;
  39411. }
  39412. }
  39413. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39414. import { Nullable } from "babylonjs/types";
  39415. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39416. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39417. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39418. /**
  39419. * Manage the gamepad inputs to control a free camera.
  39420. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39421. */
  39422. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39423. /**
  39424. * Define the camera the input is attached to.
  39425. */
  39426. camera: FreeCamera;
  39427. /**
  39428. * Define the Gamepad controlling the input
  39429. */
  39430. gamepad: Nullable<Gamepad>;
  39431. /**
  39432. * Defines the gamepad rotation sensiblity.
  39433. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39434. */
  39435. gamepadAngularSensibility: number;
  39436. /**
  39437. * Defines the gamepad move sensiblity.
  39438. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39439. */
  39440. gamepadMoveSensibility: number;
  39441. private _onGamepadConnectedObserver;
  39442. private _onGamepadDisconnectedObserver;
  39443. private _cameraTransform;
  39444. private _deltaTransform;
  39445. private _vector3;
  39446. private _vector2;
  39447. /**
  39448. * Attach the input controls to a specific dom element to get the input from.
  39449. * @param element Defines the element the controls should be listened from
  39450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39451. */
  39452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39453. /**
  39454. * Detach the current controls from the specified dom element.
  39455. * @param element Defines the element to stop listening the inputs from
  39456. */
  39457. detachControl(element: Nullable<HTMLElement>): void;
  39458. /**
  39459. * Update the current camera state depending on the inputs that have been used this frame.
  39460. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39461. */
  39462. checkInputs(): void;
  39463. /**
  39464. * Gets the class name of the current intput.
  39465. * @returns the class name
  39466. */
  39467. getClassName(): string;
  39468. /**
  39469. * Get the friendly name associated with the input class.
  39470. * @returns the input friendly name
  39471. */
  39472. getSimpleName(): string;
  39473. }
  39474. }
  39475. declare module "babylonjs/Misc/virtualJoystick" {
  39476. import { Nullable } from "babylonjs/types";
  39477. import { Vector3 } from "babylonjs/Maths/math.vector";
  39478. /**
  39479. * Defines the potential axis of a Joystick
  39480. */
  39481. export enum JoystickAxis {
  39482. /** X axis */
  39483. X = 0,
  39484. /** Y axis */
  39485. Y = 1,
  39486. /** Z axis */
  39487. Z = 2
  39488. }
  39489. /**
  39490. * Class used to define virtual joystick (used in touch mode)
  39491. */
  39492. export class VirtualJoystick {
  39493. /**
  39494. * Gets or sets a boolean indicating that left and right values must be inverted
  39495. */
  39496. reverseLeftRight: boolean;
  39497. /**
  39498. * Gets or sets a boolean indicating that up and down values must be inverted
  39499. */
  39500. reverseUpDown: boolean;
  39501. /**
  39502. * Gets the offset value for the position (ie. the change of the position value)
  39503. */
  39504. deltaPosition: Vector3;
  39505. /**
  39506. * Gets a boolean indicating if the virtual joystick was pressed
  39507. */
  39508. pressed: boolean;
  39509. /**
  39510. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39511. */
  39512. static Canvas: Nullable<HTMLCanvasElement>;
  39513. private static _globalJoystickIndex;
  39514. private static vjCanvasContext;
  39515. private static vjCanvasWidth;
  39516. private static vjCanvasHeight;
  39517. private static halfWidth;
  39518. private _action;
  39519. private _axisTargetedByLeftAndRight;
  39520. private _axisTargetedByUpAndDown;
  39521. private _joystickSensibility;
  39522. private _inversedSensibility;
  39523. private _joystickPointerID;
  39524. private _joystickColor;
  39525. private _joystickPointerPos;
  39526. private _joystickPreviousPointerPos;
  39527. private _joystickPointerStartPos;
  39528. private _deltaJoystickVector;
  39529. private _leftJoystick;
  39530. private _touches;
  39531. private _onPointerDownHandlerRef;
  39532. private _onPointerMoveHandlerRef;
  39533. private _onPointerUpHandlerRef;
  39534. private _onResize;
  39535. /**
  39536. * Creates a new virtual joystick
  39537. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39538. */
  39539. constructor(leftJoystick?: boolean);
  39540. /**
  39541. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39542. * @param newJoystickSensibility defines the new sensibility
  39543. */
  39544. setJoystickSensibility(newJoystickSensibility: number): void;
  39545. private _onPointerDown;
  39546. private _onPointerMove;
  39547. private _onPointerUp;
  39548. /**
  39549. * Change the color of the virtual joystick
  39550. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39551. */
  39552. setJoystickColor(newColor: string): void;
  39553. /**
  39554. * Defines a callback to call when the joystick is touched
  39555. * @param action defines the callback
  39556. */
  39557. setActionOnTouch(action: () => any): void;
  39558. /**
  39559. * Defines which axis you'd like to control for left & right
  39560. * @param axis defines the axis to use
  39561. */
  39562. setAxisForLeftRight(axis: JoystickAxis): void;
  39563. /**
  39564. * Defines which axis you'd like to control for up & down
  39565. * @param axis defines the axis to use
  39566. */
  39567. setAxisForUpDown(axis: JoystickAxis): void;
  39568. private _drawVirtualJoystick;
  39569. /**
  39570. * Release internal HTML canvas
  39571. */
  39572. releaseCanvas(): void;
  39573. }
  39574. }
  39575. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39576. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39577. import { Nullable } from "babylonjs/types";
  39578. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39579. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39580. module "babylonjs/Cameras/freeCameraInputsManager" {
  39581. interface FreeCameraInputsManager {
  39582. /**
  39583. * Add virtual joystick input support to the input manager.
  39584. * @returns the current input manager
  39585. */
  39586. addVirtualJoystick(): FreeCameraInputsManager;
  39587. }
  39588. }
  39589. /**
  39590. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39591. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39592. */
  39593. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39594. /**
  39595. * Defines the camera the input is attached to.
  39596. */
  39597. camera: FreeCamera;
  39598. private _leftjoystick;
  39599. private _rightjoystick;
  39600. /**
  39601. * Gets the left stick of the virtual joystick.
  39602. * @returns The virtual Joystick
  39603. */
  39604. getLeftJoystick(): VirtualJoystick;
  39605. /**
  39606. * Gets the right stick of the virtual joystick.
  39607. * @returns The virtual Joystick
  39608. */
  39609. getRightJoystick(): VirtualJoystick;
  39610. /**
  39611. * Update the current camera state depending on the inputs that have been used this frame.
  39612. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39613. */
  39614. checkInputs(): void;
  39615. /**
  39616. * Attach the input controls to a specific dom element to get the input from.
  39617. * @param element Defines the element the controls should be listened from
  39618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39619. */
  39620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39621. /**
  39622. * Detach the current controls from the specified dom element.
  39623. * @param element Defines the element to stop listening the inputs from
  39624. */
  39625. detachControl(element: Nullable<HTMLElement>): void;
  39626. /**
  39627. * Gets the class name of the current intput.
  39628. * @returns the class name
  39629. */
  39630. getClassName(): string;
  39631. /**
  39632. * Get the friendly name associated with the input class.
  39633. * @returns the input friendly name
  39634. */
  39635. getSimpleName(): string;
  39636. }
  39637. }
  39638. declare module "babylonjs/Cameras/Inputs/index" {
  39639. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39640. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39641. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39642. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39643. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39644. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39645. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39646. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39647. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39648. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39649. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39650. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39651. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39652. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39653. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39654. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39655. }
  39656. declare module "babylonjs/Cameras/touchCamera" {
  39657. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39658. import { Scene } from "babylonjs/scene";
  39659. import { Vector3 } from "babylonjs/Maths/math.vector";
  39660. /**
  39661. * This represents a FPS type of camera controlled by touch.
  39662. * This is like a universal camera minus the Gamepad controls.
  39663. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39664. */
  39665. export class TouchCamera extends FreeCamera {
  39666. /**
  39667. * Defines the touch sensibility for rotation.
  39668. * The higher the faster.
  39669. */
  39670. touchAngularSensibility: number;
  39671. /**
  39672. * Defines the touch sensibility for move.
  39673. * The higher the faster.
  39674. */
  39675. touchMoveSensibility: number;
  39676. /**
  39677. * Instantiates a new touch camera.
  39678. * This represents a FPS type of camera controlled by touch.
  39679. * This is like a universal camera minus the Gamepad controls.
  39680. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39681. * @param name Define the name of the camera in the scene
  39682. * @param position Define the start position of the camera in the scene
  39683. * @param scene Define the scene the camera belongs to
  39684. */
  39685. constructor(name: string, position: Vector3, scene: Scene);
  39686. /**
  39687. * Gets the current object class name.
  39688. * @return the class name
  39689. */
  39690. getClassName(): string;
  39691. /** @hidden */
  39692. _setupInputs(): void;
  39693. }
  39694. }
  39695. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39696. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39697. import { Scene } from "babylonjs/scene";
  39698. import { Vector3 } from "babylonjs/Maths/math.vector";
  39699. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39700. import { Axis } from "babylonjs/Maths/math.axis";
  39701. /**
  39702. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39703. * being tilted forward or back and left or right.
  39704. */
  39705. export class DeviceOrientationCamera extends FreeCamera {
  39706. private _initialQuaternion;
  39707. private _quaternionCache;
  39708. private _tmpDragQuaternion;
  39709. private _disablePointerInputWhenUsingDeviceOrientation;
  39710. /**
  39711. * Creates a new device orientation camera
  39712. * @param name The name of the camera
  39713. * @param position The start position camera
  39714. * @param scene The scene the camera belongs to
  39715. */
  39716. constructor(name: string, position: Vector3, scene: Scene);
  39717. /**
  39718. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39719. */
  39720. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39721. private _dragFactor;
  39722. /**
  39723. * Enabled turning on the y axis when the orientation sensor is active
  39724. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39725. */
  39726. enableHorizontalDragging(dragFactor?: number): void;
  39727. /**
  39728. * Gets the current instance class name ("DeviceOrientationCamera").
  39729. * This helps avoiding instanceof at run time.
  39730. * @returns the class name
  39731. */
  39732. getClassName(): string;
  39733. /**
  39734. * @hidden
  39735. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39736. */
  39737. _checkInputs(): void;
  39738. /**
  39739. * Reset the camera to its default orientation on the specified axis only.
  39740. * @param axis The axis to reset
  39741. */
  39742. resetToCurrentRotation(axis?: Axis): void;
  39743. }
  39744. }
  39745. declare module "babylonjs/Gamepads/xboxGamepad" {
  39746. import { Observable } from "babylonjs/Misc/observable";
  39747. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39748. /**
  39749. * Defines supported buttons for XBox360 compatible gamepads
  39750. */
  39751. export enum Xbox360Button {
  39752. /** A */
  39753. A = 0,
  39754. /** B */
  39755. B = 1,
  39756. /** X */
  39757. X = 2,
  39758. /** Y */
  39759. Y = 3,
  39760. /** Start */
  39761. Start = 4,
  39762. /** Back */
  39763. Back = 5,
  39764. /** Left button */
  39765. LB = 6,
  39766. /** Right button */
  39767. RB = 7,
  39768. /** Left stick */
  39769. LeftStick = 8,
  39770. /** Right stick */
  39771. RightStick = 9
  39772. }
  39773. /** Defines values for XBox360 DPad */
  39774. export enum Xbox360Dpad {
  39775. /** Up */
  39776. Up = 0,
  39777. /** Down */
  39778. Down = 1,
  39779. /** Left */
  39780. Left = 2,
  39781. /** Right */
  39782. Right = 3
  39783. }
  39784. /**
  39785. * Defines a XBox360 gamepad
  39786. */
  39787. export class Xbox360Pad extends Gamepad {
  39788. private _leftTrigger;
  39789. private _rightTrigger;
  39790. private _onlefttriggerchanged;
  39791. private _onrighttriggerchanged;
  39792. private _onbuttondown;
  39793. private _onbuttonup;
  39794. private _ondpaddown;
  39795. private _ondpadup;
  39796. /** Observable raised when a button is pressed */
  39797. onButtonDownObservable: Observable<Xbox360Button>;
  39798. /** Observable raised when a button is released */
  39799. onButtonUpObservable: Observable<Xbox360Button>;
  39800. /** Observable raised when a pad is pressed */
  39801. onPadDownObservable: Observable<Xbox360Dpad>;
  39802. /** Observable raised when a pad is released */
  39803. onPadUpObservable: Observable<Xbox360Dpad>;
  39804. private _buttonA;
  39805. private _buttonB;
  39806. private _buttonX;
  39807. private _buttonY;
  39808. private _buttonBack;
  39809. private _buttonStart;
  39810. private _buttonLB;
  39811. private _buttonRB;
  39812. private _buttonLeftStick;
  39813. private _buttonRightStick;
  39814. private _dPadUp;
  39815. private _dPadDown;
  39816. private _dPadLeft;
  39817. private _dPadRight;
  39818. private _isXboxOnePad;
  39819. /**
  39820. * Creates a new XBox360 gamepad object
  39821. * @param id defines the id of this gamepad
  39822. * @param index defines its index
  39823. * @param gamepad defines the internal HTML gamepad object
  39824. * @param xboxOne defines if it is a XBox One gamepad
  39825. */
  39826. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39827. /**
  39828. * Defines the callback to call when left trigger is pressed
  39829. * @param callback defines the callback to use
  39830. */
  39831. onlefttriggerchanged(callback: (value: number) => void): void;
  39832. /**
  39833. * Defines the callback to call when right trigger is pressed
  39834. * @param callback defines the callback to use
  39835. */
  39836. onrighttriggerchanged(callback: (value: number) => void): void;
  39837. /**
  39838. * Gets the left trigger value
  39839. */
  39840. /**
  39841. * Sets the left trigger value
  39842. */
  39843. leftTrigger: number;
  39844. /**
  39845. * Gets the right trigger value
  39846. */
  39847. /**
  39848. * Sets the right trigger value
  39849. */
  39850. rightTrigger: number;
  39851. /**
  39852. * Defines the callback to call when a button is pressed
  39853. * @param callback defines the callback to use
  39854. */
  39855. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39856. /**
  39857. * Defines the callback to call when a button is released
  39858. * @param callback defines the callback to use
  39859. */
  39860. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39861. /**
  39862. * Defines the callback to call when a pad is pressed
  39863. * @param callback defines the callback to use
  39864. */
  39865. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39866. /**
  39867. * Defines the callback to call when a pad is released
  39868. * @param callback defines the callback to use
  39869. */
  39870. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39871. private _setButtonValue;
  39872. private _setDPadValue;
  39873. /**
  39874. * Gets the value of the `A` button
  39875. */
  39876. /**
  39877. * Sets the value of the `A` button
  39878. */
  39879. buttonA: number;
  39880. /**
  39881. * Gets the value of the `B` button
  39882. */
  39883. /**
  39884. * Sets the value of the `B` button
  39885. */
  39886. buttonB: number;
  39887. /**
  39888. * Gets the value of the `X` button
  39889. */
  39890. /**
  39891. * Sets the value of the `X` button
  39892. */
  39893. buttonX: number;
  39894. /**
  39895. * Gets the value of the `Y` button
  39896. */
  39897. /**
  39898. * Sets the value of the `Y` button
  39899. */
  39900. buttonY: number;
  39901. /**
  39902. * Gets the value of the `Start` button
  39903. */
  39904. /**
  39905. * Sets the value of the `Start` button
  39906. */
  39907. buttonStart: number;
  39908. /**
  39909. * Gets the value of the `Back` button
  39910. */
  39911. /**
  39912. * Sets the value of the `Back` button
  39913. */
  39914. buttonBack: number;
  39915. /**
  39916. * Gets the value of the `Left` button
  39917. */
  39918. /**
  39919. * Sets the value of the `Left` button
  39920. */
  39921. buttonLB: number;
  39922. /**
  39923. * Gets the value of the `Right` button
  39924. */
  39925. /**
  39926. * Sets the value of the `Right` button
  39927. */
  39928. buttonRB: number;
  39929. /**
  39930. * Gets the value of the Left joystick
  39931. */
  39932. /**
  39933. * Sets the value of the Left joystick
  39934. */
  39935. buttonLeftStick: number;
  39936. /**
  39937. * Gets the value of the Right joystick
  39938. */
  39939. /**
  39940. * Sets the value of the Right joystick
  39941. */
  39942. buttonRightStick: number;
  39943. /**
  39944. * Gets the value of D-pad up
  39945. */
  39946. /**
  39947. * Sets the value of D-pad up
  39948. */
  39949. dPadUp: number;
  39950. /**
  39951. * Gets the value of D-pad down
  39952. */
  39953. /**
  39954. * Sets the value of D-pad down
  39955. */
  39956. dPadDown: number;
  39957. /**
  39958. * Gets the value of D-pad left
  39959. */
  39960. /**
  39961. * Sets the value of D-pad left
  39962. */
  39963. dPadLeft: number;
  39964. /**
  39965. * Gets the value of D-pad right
  39966. */
  39967. /**
  39968. * Sets the value of D-pad right
  39969. */
  39970. dPadRight: number;
  39971. /**
  39972. * Force the gamepad to synchronize with device values
  39973. */
  39974. update(): void;
  39975. /**
  39976. * Disposes the gamepad
  39977. */
  39978. dispose(): void;
  39979. }
  39980. }
  39981. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39982. import { Observable } from "babylonjs/Misc/observable";
  39983. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39984. /**
  39985. * Defines supported buttons for DualShock compatible gamepads
  39986. */
  39987. export enum DualShockButton {
  39988. /** Cross */
  39989. Cross = 0,
  39990. /** Circle */
  39991. Circle = 1,
  39992. /** Square */
  39993. Square = 2,
  39994. /** Triangle */
  39995. Triangle = 3,
  39996. /** Options */
  39997. Options = 4,
  39998. /** Share */
  39999. Share = 5,
  40000. /** L1 */
  40001. L1 = 6,
  40002. /** R1 */
  40003. R1 = 7,
  40004. /** Left stick */
  40005. LeftStick = 8,
  40006. /** Right stick */
  40007. RightStick = 9
  40008. }
  40009. /** Defines values for DualShock DPad */
  40010. export enum DualShockDpad {
  40011. /** Up */
  40012. Up = 0,
  40013. /** Down */
  40014. Down = 1,
  40015. /** Left */
  40016. Left = 2,
  40017. /** Right */
  40018. Right = 3
  40019. }
  40020. /**
  40021. * Defines a DualShock gamepad
  40022. */
  40023. export class DualShockPad extends Gamepad {
  40024. private _leftTrigger;
  40025. private _rightTrigger;
  40026. private _onlefttriggerchanged;
  40027. private _onrighttriggerchanged;
  40028. private _onbuttondown;
  40029. private _onbuttonup;
  40030. private _ondpaddown;
  40031. private _ondpadup;
  40032. /** Observable raised when a button is pressed */
  40033. onButtonDownObservable: Observable<DualShockButton>;
  40034. /** Observable raised when a button is released */
  40035. onButtonUpObservable: Observable<DualShockButton>;
  40036. /** Observable raised when a pad is pressed */
  40037. onPadDownObservable: Observable<DualShockDpad>;
  40038. /** Observable raised when a pad is released */
  40039. onPadUpObservable: Observable<DualShockDpad>;
  40040. private _buttonCross;
  40041. private _buttonCircle;
  40042. private _buttonSquare;
  40043. private _buttonTriangle;
  40044. private _buttonShare;
  40045. private _buttonOptions;
  40046. private _buttonL1;
  40047. private _buttonR1;
  40048. private _buttonLeftStick;
  40049. private _buttonRightStick;
  40050. private _dPadUp;
  40051. private _dPadDown;
  40052. private _dPadLeft;
  40053. private _dPadRight;
  40054. /**
  40055. * Creates a new DualShock gamepad object
  40056. * @param id defines the id of this gamepad
  40057. * @param index defines its index
  40058. * @param gamepad defines the internal HTML gamepad object
  40059. */
  40060. constructor(id: string, index: number, gamepad: any);
  40061. /**
  40062. * Defines the callback to call when left trigger is pressed
  40063. * @param callback defines the callback to use
  40064. */
  40065. onlefttriggerchanged(callback: (value: number) => void): void;
  40066. /**
  40067. * Defines the callback to call when right trigger is pressed
  40068. * @param callback defines the callback to use
  40069. */
  40070. onrighttriggerchanged(callback: (value: number) => void): void;
  40071. /**
  40072. * Gets the left trigger value
  40073. */
  40074. /**
  40075. * Sets the left trigger value
  40076. */
  40077. leftTrigger: number;
  40078. /**
  40079. * Gets the right trigger value
  40080. */
  40081. /**
  40082. * Sets the right trigger value
  40083. */
  40084. rightTrigger: number;
  40085. /**
  40086. * Defines the callback to call when a button is pressed
  40087. * @param callback defines the callback to use
  40088. */
  40089. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40090. /**
  40091. * Defines the callback to call when a button is released
  40092. * @param callback defines the callback to use
  40093. */
  40094. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40095. /**
  40096. * Defines the callback to call when a pad is pressed
  40097. * @param callback defines the callback to use
  40098. */
  40099. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40100. /**
  40101. * Defines the callback to call when a pad is released
  40102. * @param callback defines the callback to use
  40103. */
  40104. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40105. private _setButtonValue;
  40106. private _setDPadValue;
  40107. /**
  40108. * Gets the value of the `Cross` button
  40109. */
  40110. /**
  40111. * Sets the value of the `Cross` button
  40112. */
  40113. buttonCross: number;
  40114. /**
  40115. * Gets the value of the `Circle` button
  40116. */
  40117. /**
  40118. * Sets the value of the `Circle` button
  40119. */
  40120. buttonCircle: number;
  40121. /**
  40122. * Gets the value of the `Square` button
  40123. */
  40124. /**
  40125. * Sets the value of the `Square` button
  40126. */
  40127. buttonSquare: number;
  40128. /**
  40129. * Gets the value of the `Triangle` button
  40130. */
  40131. /**
  40132. * Sets the value of the `Triangle` button
  40133. */
  40134. buttonTriangle: number;
  40135. /**
  40136. * Gets the value of the `Options` button
  40137. */
  40138. /**
  40139. * Sets the value of the `Options` button
  40140. */
  40141. buttonOptions: number;
  40142. /**
  40143. * Gets the value of the `Share` button
  40144. */
  40145. /**
  40146. * Sets the value of the `Share` button
  40147. */
  40148. buttonShare: number;
  40149. /**
  40150. * Gets the value of the `L1` button
  40151. */
  40152. /**
  40153. * Sets the value of the `L1` button
  40154. */
  40155. buttonL1: number;
  40156. /**
  40157. * Gets the value of the `R1` button
  40158. */
  40159. /**
  40160. * Sets the value of the `R1` button
  40161. */
  40162. buttonR1: number;
  40163. /**
  40164. * Gets the value of the Left joystick
  40165. */
  40166. /**
  40167. * Sets the value of the Left joystick
  40168. */
  40169. buttonLeftStick: number;
  40170. /**
  40171. * Gets the value of the Right joystick
  40172. */
  40173. /**
  40174. * Sets the value of the Right joystick
  40175. */
  40176. buttonRightStick: number;
  40177. /**
  40178. * Gets the value of D-pad up
  40179. */
  40180. /**
  40181. * Sets the value of D-pad up
  40182. */
  40183. dPadUp: number;
  40184. /**
  40185. * Gets the value of D-pad down
  40186. */
  40187. /**
  40188. * Sets the value of D-pad down
  40189. */
  40190. dPadDown: number;
  40191. /**
  40192. * Gets the value of D-pad left
  40193. */
  40194. /**
  40195. * Sets the value of D-pad left
  40196. */
  40197. dPadLeft: number;
  40198. /**
  40199. * Gets the value of D-pad right
  40200. */
  40201. /**
  40202. * Sets the value of D-pad right
  40203. */
  40204. dPadRight: number;
  40205. /**
  40206. * Force the gamepad to synchronize with device values
  40207. */
  40208. update(): void;
  40209. /**
  40210. * Disposes the gamepad
  40211. */
  40212. dispose(): void;
  40213. }
  40214. }
  40215. declare module "babylonjs/Gamepads/gamepadManager" {
  40216. import { Observable } from "babylonjs/Misc/observable";
  40217. import { Nullable } from "babylonjs/types";
  40218. import { Scene } from "babylonjs/scene";
  40219. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40220. /**
  40221. * Manager for handling gamepads
  40222. */
  40223. export class GamepadManager {
  40224. private _scene?;
  40225. private _babylonGamepads;
  40226. private _oneGamepadConnected;
  40227. /** @hidden */
  40228. _isMonitoring: boolean;
  40229. private _gamepadEventSupported;
  40230. private _gamepadSupport;
  40231. /**
  40232. * observable to be triggered when the gamepad controller has been connected
  40233. */
  40234. onGamepadConnectedObservable: Observable<Gamepad>;
  40235. /**
  40236. * observable to be triggered when the gamepad controller has been disconnected
  40237. */
  40238. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40239. private _onGamepadConnectedEvent;
  40240. private _onGamepadDisconnectedEvent;
  40241. /**
  40242. * Initializes the gamepad manager
  40243. * @param _scene BabylonJS scene
  40244. */
  40245. constructor(_scene?: Scene | undefined);
  40246. /**
  40247. * The gamepads in the game pad manager
  40248. */
  40249. readonly gamepads: Gamepad[];
  40250. /**
  40251. * Get the gamepad controllers based on type
  40252. * @param type The type of gamepad controller
  40253. * @returns Nullable gamepad
  40254. */
  40255. getGamepadByType(type?: number): Nullable<Gamepad>;
  40256. /**
  40257. * Disposes the gamepad manager
  40258. */
  40259. dispose(): void;
  40260. private _addNewGamepad;
  40261. private _startMonitoringGamepads;
  40262. private _stopMonitoringGamepads;
  40263. /** @hidden */
  40264. _checkGamepadsStatus(): void;
  40265. private _updateGamepadObjects;
  40266. }
  40267. }
  40268. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40269. import { Nullable } from "babylonjs/types";
  40270. import { Scene } from "babylonjs/scene";
  40271. import { ISceneComponent } from "babylonjs/sceneComponent";
  40272. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40273. module "babylonjs/scene" {
  40274. interface Scene {
  40275. /** @hidden */
  40276. _gamepadManager: Nullable<GamepadManager>;
  40277. /**
  40278. * Gets the gamepad manager associated with the scene
  40279. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40280. */
  40281. gamepadManager: GamepadManager;
  40282. }
  40283. }
  40284. module "babylonjs/Cameras/freeCameraInputsManager" {
  40285. /**
  40286. * Interface representing a free camera inputs manager
  40287. */
  40288. interface FreeCameraInputsManager {
  40289. /**
  40290. * Adds gamepad input support to the FreeCameraInputsManager.
  40291. * @returns the FreeCameraInputsManager
  40292. */
  40293. addGamepad(): FreeCameraInputsManager;
  40294. }
  40295. }
  40296. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40297. /**
  40298. * Interface representing an arc rotate camera inputs manager
  40299. */
  40300. interface ArcRotateCameraInputsManager {
  40301. /**
  40302. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40303. * @returns the camera inputs manager
  40304. */
  40305. addGamepad(): ArcRotateCameraInputsManager;
  40306. }
  40307. }
  40308. /**
  40309. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40310. */
  40311. export class GamepadSystemSceneComponent implements ISceneComponent {
  40312. /**
  40313. * The component name helpfull to identify the component in the list of scene components.
  40314. */
  40315. readonly name: string;
  40316. /**
  40317. * The scene the component belongs to.
  40318. */
  40319. scene: Scene;
  40320. /**
  40321. * Creates a new instance of the component for the given scene
  40322. * @param scene Defines the scene to register the component in
  40323. */
  40324. constructor(scene: Scene);
  40325. /**
  40326. * Registers the component in a given scene
  40327. */
  40328. register(): void;
  40329. /**
  40330. * Rebuilds the elements related to this component in case of
  40331. * context lost for instance.
  40332. */
  40333. rebuild(): void;
  40334. /**
  40335. * Disposes the component and the associated ressources
  40336. */
  40337. dispose(): void;
  40338. private _beforeCameraUpdate;
  40339. }
  40340. }
  40341. declare module "babylonjs/Cameras/universalCamera" {
  40342. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40343. import { Scene } from "babylonjs/scene";
  40344. import { Vector3 } from "babylonjs/Maths/math.vector";
  40345. import "babylonjs/Gamepads/gamepadSceneComponent";
  40346. /**
  40347. * 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,
  40348. * which still works and will still be found in many Playgrounds.
  40349. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40350. */
  40351. export class UniversalCamera extends TouchCamera {
  40352. /**
  40353. * Defines the gamepad rotation sensiblity.
  40354. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40355. */
  40356. gamepadAngularSensibility: number;
  40357. /**
  40358. * Defines the gamepad move sensiblity.
  40359. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40360. */
  40361. gamepadMoveSensibility: number;
  40362. /**
  40363. * 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,
  40364. * which still works and will still be found in many Playgrounds.
  40365. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40366. * @param name Define the name of the camera in the scene
  40367. * @param position Define the start position of the camera in the scene
  40368. * @param scene Define the scene the camera belongs to
  40369. */
  40370. constructor(name: string, position: Vector3, scene: Scene);
  40371. /**
  40372. * Gets the current object class name.
  40373. * @return the class name
  40374. */
  40375. getClassName(): string;
  40376. }
  40377. }
  40378. declare module "babylonjs/Cameras/gamepadCamera" {
  40379. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40380. import { Scene } from "babylonjs/scene";
  40381. import { Vector3 } from "babylonjs/Maths/math.vector";
  40382. /**
  40383. * This represents a FPS type of camera. This is only here for back compat purpose.
  40384. * Please use the UniversalCamera instead as both are identical.
  40385. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40386. */
  40387. export class GamepadCamera extends UniversalCamera {
  40388. /**
  40389. * Instantiates a new Gamepad Camera
  40390. * This represents a FPS type of camera. This is only here for back compat purpose.
  40391. * Please use the UniversalCamera instead as both are identical.
  40392. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40393. * @param name Define the name of the camera in the scene
  40394. * @param position Define the start position of the camera in the scene
  40395. * @param scene Define the scene the camera belongs to
  40396. */
  40397. constructor(name: string, position: Vector3, scene: Scene);
  40398. /**
  40399. * Gets the current object class name.
  40400. * @return the class name
  40401. */
  40402. getClassName(): string;
  40403. }
  40404. }
  40405. declare module "babylonjs/Shaders/pass.fragment" {
  40406. /** @hidden */
  40407. export var passPixelShader: {
  40408. name: string;
  40409. shader: string;
  40410. };
  40411. }
  40412. declare module "babylonjs/Shaders/passCube.fragment" {
  40413. /** @hidden */
  40414. export var passCubePixelShader: {
  40415. name: string;
  40416. shader: string;
  40417. };
  40418. }
  40419. declare module "babylonjs/PostProcesses/passPostProcess" {
  40420. import { Nullable } from "babylonjs/types";
  40421. import { Camera } from "babylonjs/Cameras/camera";
  40422. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40423. import { Engine } from "babylonjs/Engines/engine";
  40424. import "babylonjs/Shaders/pass.fragment";
  40425. import "babylonjs/Shaders/passCube.fragment";
  40426. /**
  40427. * PassPostProcess which produces an output the same as it's input
  40428. */
  40429. export class PassPostProcess extends PostProcess {
  40430. /**
  40431. * Creates the PassPostProcess
  40432. * @param name The name of the effect.
  40433. * @param options The required width/height ratio to downsize to before computing the render pass.
  40434. * @param camera The camera to apply the render pass to.
  40435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40436. * @param engine The engine which the post process will be applied. (default: current engine)
  40437. * @param reusable If the post process can be reused on the same frame. (default: false)
  40438. * @param textureType The type of texture to be used when performing the post processing.
  40439. * @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)
  40440. */
  40441. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40442. }
  40443. /**
  40444. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40445. */
  40446. export class PassCubePostProcess extends PostProcess {
  40447. private _face;
  40448. /**
  40449. * Gets or sets the cube face to display.
  40450. * * 0 is +X
  40451. * * 1 is -X
  40452. * * 2 is +Y
  40453. * * 3 is -Y
  40454. * * 4 is +Z
  40455. * * 5 is -Z
  40456. */
  40457. face: number;
  40458. /**
  40459. * Creates the PassCubePostProcess
  40460. * @param name The name of the effect.
  40461. * @param options The required width/height ratio to downsize to before computing the render pass.
  40462. * @param camera The camera to apply the render pass to.
  40463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40464. * @param engine The engine which the post process will be applied. (default: current engine)
  40465. * @param reusable If the post process can be reused on the same frame. (default: false)
  40466. * @param textureType The type of texture to be used when performing the post processing.
  40467. * @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)
  40468. */
  40469. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40470. }
  40471. }
  40472. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40473. /** @hidden */
  40474. export var anaglyphPixelShader: {
  40475. name: string;
  40476. shader: string;
  40477. };
  40478. }
  40479. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40480. import { Engine } from "babylonjs/Engines/engine";
  40481. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40482. import { Camera } from "babylonjs/Cameras/camera";
  40483. import "babylonjs/Shaders/anaglyph.fragment";
  40484. /**
  40485. * Postprocess used to generate anaglyphic rendering
  40486. */
  40487. export class AnaglyphPostProcess extends PostProcess {
  40488. private _passedProcess;
  40489. /**
  40490. * Creates a new AnaglyphPostProcess
  40491. * @param name defines postprocess name
  40492. * @param options defines creation options or target ratio scale
  40493. * @param rigCameras defines cameras using this postprocess
  40494. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40495. * @param engine defines hosting engine
  40496. * @param reusable defines if the postprocess will be reused multiple times per frame
  40497. */
  40498. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40499. }
  40500. }
  40501. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40502. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40503. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40504. import { Scene } from "babylonjs/scene";
  40505. import { Vector3 } from "babylonjs/Maths/math.vector";
  40506. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40507. /**
  40508. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40509. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40510. */
  40511. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40512. /**
  40513. * Creates a new AnaglyphArcRotateCamera
  40514. * @param name defines camera name
  40515. * @param alpha defines alpha angle (in radians)
  40516. * @param beta defines beta angle (in radians)
  40517. * @param radius defines radius
  40518. * @param target defines camera target
  40519. * @param interaxialDistance defines distance between each color axis
  40520. * @param scene defines the hosting scene
  40521. */
  40522. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40523. /**
  40524. * Gets camera class name
  40525. * @returns AnaglyphArcRotateCamera
  40526. */
  40527. getClassName(): string;
  40528. }
  40529. }
  40530. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40531. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40532. import { Scene } from "babylonjs/scene";
  40533. import { Vector3 } from "babylonjs/Maths/math.vector";
  40534. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40535. /**
  40536. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40537. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40538. */
  40539. export class AnaglyphFreeCamera extends FreeCamera {
  40540. /**
  40541. * Creates a new AnaglyphFreeCamera
  40542. * @param name defines camera name
  40543. * @param position defines initial position
  40544. * @param interaxialDistance defines distance between each color axis
  40545. * @param scene defines the hosting scene
  40546. */
  40547. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40548. /**
  40549. * Gets camera class name
  40550. * @returns AnaglyphFreeCamera
  40551. */
  40552. getClassName(): string;
  40553. }
  40554. }
  40555. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40556. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40557. import { Scene } from "babylonjs/scene";
  40558. import { Vector3 } from "babylonjs/Maths/math.vector";
  40559. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40560. /**
  40561. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40562. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40563. */
  40564. export class AnaglyphGamepadCamera extends GamepadCamera {
  40565. /**
  40566. * Creates a new AnaglyphGamepadCamera
  40567. * @param name defines camera name
  40568. * @param position defines initial position
  40569. * @param interaxialDistance defines distance between each color axis
  40570. * @param scene defines the hosting scene
  40571. */
  40572. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40573. /**
  40574. * Gets camera class name
  40575. * @returns AnaglyphGamepadCamera
  40576. */
  40577. getClassName(): string;
  40578. }
  40579. }
  40580. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40581. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40582. import { Scene } from "babylonjs/scene";
  40583. import { Vector3 } from "babylonjs/Maths/math.vector";
  40584. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40585. /**
  40586. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40587. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40588. */
  40589. export class AnaglyphUniversalCamera extends UniversalCamera {
  40590. /**
  40591. * Creates a new AnaglyphUniversalCamera
  40592. * @param name defines camera name
  40593. * @param position defines initial position
  40594. * @param interaxialDistance defines distance between each color axis
  40595. * @param scene defines the hosting scene
  40596. */
  40597. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40598. /**
  40599. * Gets camera class name
  40600. * @returns AnaglyphUniversalCamera
  40601. */
  40602. getClassName(): string;
  40603. }
  40604. }
  40605. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40606. /** @hidden */
  40607. export var stereoscopicInterlacePixelShader: {
  40608. name: string;
  40609. shader: string;
  40610. };
  40611. }
  40612. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40613. import { Camera } from "babylonjs/Cameras/camera";
  40614. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40615. import { Engine } from "babylonjs/Engines/engine";
  40616. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40617. /**
  40618. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40619. */
  40620. export class StereoscopicInterlacePostProcess extends PostProcess {
  40621. private _stepSize;
  40622. private _passedProcess;
  40623. /**
  40624. * Initializes a StereoscopicInterlacePostProcess
  40625. * @param name The name of the effect.
  40626. * @param rigCameras The rig cameras to be appled to the post process
  40627. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40629. * @param engine The engine which the post process will be applied. (default: current engine)
  40630. * @param reusable If the post process can be reused on the same frame. (default: false)
  40631. */
  40632. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40633. }
  40634. }
  40635. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40636. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40637. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40638. import { Scene } from "babylonjs/scene";
  40639. import { Vector3 } from "babylonjs/Maths/math.vector";
  40640. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40641. /**
  40642. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40643. * @see http://doc.babylonjs.com/features/cameras
  40644. */
  40645. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40646. /**
  40647. * Creates a new StereoscopicArcRotateCamera
  40648. * @param name defines camera name
  40649. * @param alpha defines alpha angle (in radians)
  40650. * @param beta defines beta angle (in radians)
  40651. * @param radius defines radius
  40652. * @param target defines camera target
  40653. * @param interaxialDistance defines distance between each color axis
  40654. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40655. * @param scene defines the hosting scene
  40656. */
  40657. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40658. /**
  40659. * Gets camera class name
  40660. * @returns StereoscopicArcRotateCamera
  40661. */
  40662. getClassName(): string;
  40663. }
  40664. }
  40665. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40666. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40667. import { Scene } from "babylonjs/scene";
  40668. import { Vector3 } from "babylonjs/Maths/math.vector";
  40669. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40670. /**
  40671. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40672. * @see http://doc.babylonjs.com/features/cameras
  40673. */
  40674. export class StereoscopicFreeCamera extends FreeCamera {
  40675. /**
  40676. * Creates a new StereoscopicFreeCamera
  40677. * @param name defines camera name
  40678. * @param position defines initial position
  40679. * @param interaxialDistance defines distance between each color axis
  40680. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40681. * @param scene defines the hosting scene
  40682. */
  40683. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40684. /**
  40685. * Gets camera class name
  40686. * @returns StereoscopicFreeCamera
  40687. */
  40688. getClassName(): string;
  40689. }
  40690. }
  40691. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40692. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40693. import { Scene } from "babylonjs/scene";
  40694. import { Vector3 } from "babylonjs/Maths/math.vector";
  40695. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40696. /**
  40697. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40698. * @see http://doc.babylonjs.com/features/cameras
  40699. */
  40700. export class StereoscopicGamepadCamera extends GamepadCamera {
  40701. /**
  40702. * Creates a new StereoscopicGamepadCamera
  40703. * @param name defines camera name
  40704. * @param position defines initial position
  40705. * @param interaxialDistance defines distance between each color axis
  40706. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40707. * @param scene defines the hosting scene
  40708. */
  40709. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40710. /**
  40711. * Gets camera class name
  40712. * @returns StereoscopicGamepadCamera
  40713. */
  40714. getClassName(): string;
  40715. }
  40716. }
  40717. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40718. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40719. import { Scene } from "babylonjs/scene";
  40720. import { Vector3 } from "babylonjs/Maths/math.vector";
  40721. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40722. /**
  40723. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40724. * @see http://doc.babylonjs.com/features/cameras
  40725. */
  40726. export class StereoscopicUniversalCamera extends UniversalCamera {
  40727. /**
  40728. * Creates a new StereoscopicUniversalCamera
  40729. * @param name defines camera name
  40730. * @param position defines initial position
  40731. * @param interaxialDistance defines distance between each color axis
  40732. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40733. * @param scene defines the hosting scene
  40734. */
  40735. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40736. /**
  40737. * Gets camera class name
  40738. * @returns StereoscopicUniversalCamera
  40739. */
  40740. getClassName(): string;
  40741. }
  40742. }
  40743. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40744. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40745. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40746. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40747. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40748. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40749. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40750. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40751. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40752. }
  40753. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40754. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40755. import { Scene } from "babylonjs/scene";
  40756. import { Vector3 } from "babylonjs/Maths/math.vector";
  40757. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40758. /**
  40759. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40760. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40761. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40762. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40763. */
  40764. export class VirtualJoysticksCamera extends FreeCamera {
  40765. /**
  40766. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40767. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40768. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40769. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40770. * @param name Define the name of the camera in the scene
  40771. * @param position Define the start position of the camera in the scene
  40772. * @param scene Define the scene the camera belongs to
  40773. */
  40774. constructor(name: string, position: Vector3, scene: Scene);
  40775. /**
  40776. * Gets the current object class name.
  40777. * @return the class name
  40778. */
  40779. getClassName(): string;
  40780. }
  40781. }
  40782. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40783. import { Matrix } from "babylonjs/Maths/math.vector";
  40784. /**
  40785. * This represents all the required metrics to create a VR camera.
  40786. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40787. */
  40788. export class VRCameraMetrics {
  40789. /**
  40790. * Define the horizontal resolution off the screen.
  40791. */
  40792. hResolution: number;
  40793. /**
  40794. * Define the vertical resolution off the screen.
  40795. */
  40796. vResolution: number;
  40797. /**
  40798. * Define the horizontal screen size.
  40799. */
  40800. hScreenSize: number;
  40801. /**
  40802. * Define the vertical screen size.
  40803. */
  40804. vScreenSize: number;
  40805. /**
  40806. * Define the vertical screen center position.
  40807. */
  40808. vScreenCenter: number;
  40809. /**
  40810. * Define the distance of the eyes to the screen.
  40811. */
  40812. eyeToScreenDistance: number;
  40813. /**
  40814. * Define the distance between both lenses
  40815. */
  40816. lensSeparationDistance: number;
  40817. /**
  40818. * Define the distance between both viewer's eyes.
  40819. */
  40820. interpupillaryDistance: number;
  40821. /**
  40822. * Define the distortion factor of the VR postprocess.
  40823. * Please, touch with care.
  40824. */
  40825. distortionK: number[];
  40826. /**
  40827. * Define the chromatic aberration correction factors for the VR post process.
  40828. */
  40829. chromaAbCorrection: number[];
  40830. /**
  40831. * Define the scale factor of the post process.
  40832. * The smaller the better but the slower.
  40833. */
  40834. postProcessScaleFactor: number;
  40835. /**
  40836. * Define an offset for the lens center.
  40837. */
  40838. lensCenterOffset: number;
  40839. /**
  40840. * Define if the current vr camera should compensate the distortion of the lense or not.
  40841. */
  40842. compensateDistortion: boolean;
  40843. /**
  40844. * Defines if multiview should be enabled when rendering (Default: false)
  40845. */
  40846. multiviewEnabled: boolean;
  40847. /**
  40848. * Gets the rendering aspect ratio based on the provided resolutions.
  40849. */
  40850. readonly aspectRatio: number;
  40851. /**
  40852. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40853. */
  40854. readonly aspectRatioFov: number;
  40855. /**
  40856. * @hidden
  40857. */
  40858. readonly leftHMatrix: Matrix;
  40859. /**
  40860. * @hidden
  40861. */
  40862. readonly rightHMatrix: Matrix;
  40863. /**
  40864. * @hidden
  40865. */
  40866. readonly leftPreViewMatrix: Matrix;
  40867. /**
  40868. * @hidden
  40869. */
  40870. readonly rightPreViewMatrix: Matrix;
  40871. /**
  40872. * Get the default VRMetrics based on the most generic setup.
  40873. * @returns the default vr metrics
  40874. */
  40875. static GetDefault(): VRCameraMetrics;
  40876. }
  40877. }
  40878. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40879. /** @hidden */
  40880. export var vrDistortionCorrectionPixelShader: {
  40881. name: string;
  40882. shader: string;
  40883. };
  40884. }
  40885. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40886. import { Camera } from "babylonjs/Cameras/camera";
  40887. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40888. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40889. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40890. /**
  40891. * VRDistortionCorrectionPostProcess used for mobile VR
  40892. */
  40893. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40894. private _isRightEye;
  40895. private _distortionFactors;
  40896. private _postProcessScaleFactor;
  40897. private _lensCenterOffset;
  40898. private _scaleIn;
  40899. private _scaleFactor;
  40900. private _lensCenter;
  40901. /**
  40902. * Initializes the VRDistortionCorrectionPostProcess
  40903. * @param name The name of the effect.
  40904. * @param camera The camera to apply the render pass to.
  40905. * @param isRightEye If this is for the right eye distortion
  40906. * @param vrMetrics All the required metrics for the VR camera
  40907. */
  40908. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40909. }
  40910. }
  40911. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40912. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40913. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40914. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40915. import { Scene } from "babylonjs/scene";
  40916. import { Vector3 } from "babylonjs/Maths/math.vector";
  40917. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40918. import "babylonjs/Cameras/RigModes/vrRigMode";
  40919. /**
  40920. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40921. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40922. */
  40923. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40924. /**
  40925. * Creates a new VRDeviceOrientationArcRotateCamera
  40926. * @param name defines camera name
  40927. * @param alpha defines the camera rotation along the logitudinal axis
  40928. * @param beta defines the camera rotation along the latitudinal axis
  40929. * @param radius defines the camera distance from its target
  40930. * @param target defines the camera target
  40931. * @param scene defines the scene the camera belongs to
  40932. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40933. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40934. */
  40935. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40936. /**
  40937. * Gets camera class name
  40938. * @returns VRDeviceOrientationArcRotateCamera
  40939. */
  40940. getClassName(): string;
  40941. }
  40942. }
  40943. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40944. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40945. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40946. import { Scene } from "babylonjs/scene";
  40947. import { Vector3 } from "babylonjs/Maths/math.vector";
  40948. import "babylonjs/Cameras/RigModes/vrRigMode";
  40949. /**
  40950. * Camera used to simulate VR rendering (based on FreeCamera)
  40951. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40952. */
  40953. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40954. /**
  40955. * Creates a new VRDeviceOrientationFreeCamera
  40956. * @param name defines camera name
  40957. * @param position defines the start position of the camera
  40958. * @param scene defines the scene the camera belongs to
  40959. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40960. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40961. */
  40962. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40963. /**
  40964. * Gets camera class name
  40965. * @returns VRDeviceOrientationFreeCamera
  40966. */
  40967. getClassName(): string;
  40968. }
  40969. }
  40970. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40971. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40972. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40973. import { Scene } from "babylonjs/scene";
  40974. import { Vector3 } from "babylonjs/Maths/math.vector";
  40975. import "babylonjs/Gamepads/gamepadSceneComponent";
  40976. /**
  40977. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40978. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40979. */
  40980. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40981. /**
  40982. * Creates a new VRDeviceOrientationGamepadCamera
  40983. * @param name defines camera name
  40984. * @param position defines the start position of the camera
  40985. * @param scene defines the scene the camera belongs to
  40986. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40987. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40988. */
  40989. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40990. /**
  40991. * Gets camera class name
  40992. * @returns VRDeviceOrientationGamepadCamera
  40993. */
  40994. getClassName(): string;
  40995. }
  40996. }
  40997. declare module "babylonjs/Materials/pushMaterial" {
  40998. import { Nullable } from "babylonjs/types";
  40999. import { Scene } from "babylonjs/scene";
  41000. import { Matrix } from "babylonjs/Maths/math.vector";
  41001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41002. import { Mesh } from "babylonjs/Meshes/mesh";
  41003. import { Material } from "babylonjs/Materials/material";
  41004. import { Effect } from "babylonjs/Materials/effect";
  41005. /**
  41006. * Base class of materials working in push mode in babylon JS
  41007. * @hidden
  41008. */
  41009. export class PushMaterial extends Material {
  41010. protected _activeEffect: Effect;
  41011. protected _normalMatrix: Matrix;
  41012. /**
  41013. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41014. * This means that the material can keep using a previous shader while a new one is being compiled.
  41015. * This is mostly used when shader parallel compilation is supported (true by default)
  41016. */
  41017. allowShaderHotSwapping: boolean;
  41018. constructor(name: string, scene: Scene);
  41019. getEffect(): Effect;
  41020. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41021. /**
  41022. * Binds the given world matrix to the active effect
  41023. *
  41024. * @param world the matrix to bind
  41025. */
  41026. bindOnlyWorldMatrix(world: Matrix): void;
  41027. /**
  41028. * Binds the given normal matrix to the active effect
  41029. *
  41030. * @param normalMatrix the matrix to bind
  41031. */
  41032. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41033. bind(world: Matrix, mesh?: Mesh): void;
  41034. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41035. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41036. }
  41037. }
  41038. declare module "babylonjs/Materials/materialFlags" {
  41039. /**
  41040. * This groups all the flags used to control the materials channel.
  41041. */
  41042. export class MaterialFlags {
  41043. private static _DiffuseTextureEnabled;
  41044. /**
  41045. * Are diffuse textures enabled in the application.
  41046. */
  41047. static DiffuseTextureEnabled: boolean;
  41048. private static _AmbientTextureEnabled;
  41049. /**
  41050. * Are ambient textures enabled in the application.
  41051. */
  41052. static AmbientTextureEnabled: boolean;
  41053. private static _OpacityTextureEnabled;
  41054. /**
  41055. * Are opacity textures enabled in the application.
  41056. */
  41057. static OpacityTextureEnabled: boolean;
  41058. private static _ReflectionTextureEnabled;
  41059. /**
  41060. * Are reflection textures enabled in the application.
  41061. */
  41062. static ReflectionTextureEnabled: boolean;
  41063. private static _EmissiveTextureEnabled;
  41064. /**
  41065. * Are emissive textures enabled in the application.
  41066. */
  41067. static EmissiveTextureEnabled: boolean;
  41068. private static _SpecularTextureEnabled;
  41069. /**
  41070. * Are specular textures enabled in the application.
  41071. */
  41072. static SpecularTextureEnabled: boolean;
  41073. private static _BumpTextureEnabled;
  41074. /**
  41075. * Are bump textures enabled in the application.
  41076. */
  41077. static BumpTextureEnabled: boolean;
  41078. private static _LightmapTextureEnabled;
  41079. /**
  41080. * Are lightmap textures enabled in the application.
  41081. */
  41082. static LightmapTextureEnabled: boolean;
  41083. private static _RefractionTextureEnabled;
  41084. /**
  41085. * Are refraction textures enabled in the application.
  41086. */
  41087. static RefractionTextureEnabled: boolean;
  41088. private static _ColorGradingTextureEnabled;
  41089. /**
  41090. * Are color grading textures enabled in the application.
  41091. */
  41092. static ColorGradingTextureEnabled: boolean;
  41093. private static _FresnelEnabled;
  41094. /**
  41095. * Are fresnels enabled in the application.
  41096. */
  41097. static FresnelEnabled: boolean;
  41098. private static _ClearCoatTextureEnabled;
  41099. /**
  41100. * Are clear coat textures enabled in the application.
  41101. */
  41102. static ClearCoatTextureEnabled: boolean;
  41103. private static _ClearCoatBumpTextureEnabled;
  41104. /**
  41105. * Are clear coat bump textures enabled in the application.
  41106. */
  41107. static ClearCoatBumpTextureEnabled: boolean;
  41108. private static _ClearCoatTintTextureEnabled;
  41109. /**
  41110. * Are clear coat tint textures enabled in the application.
  41111. */
  41112. static ClearCoatTintTextureEnabled: boolean;
  41113. private static _SheenTextureEnabled;
  41114. /**
  41115. * Are sheen textures enabled in the application.
  41116. */
  41117. static SheenTextureEnabled: boolean;
  41118. private static _AnisotropicTextureEnabled;
  41119. /**
  41120. * Are anisotropic textures enabled in the application.
  41121. */
  41122. static AnisotropicTextureEnabled: boolean;
  41123. private static _ThicknessTextureEnabled;
  41124. /**
  41125. * Are thickness textures enabled in the application.
  41126. */
  41127. static ThicknessTextureEnabled: boolean;
  41128. }
  41129. }
  41130. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41131. /** @hidden */
  41132. export var defaultFragmentDeclaration: {
  41133. name: string;
  41134. shader: string;
  41135. };
  41136. }
  41137. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41138. /** @hidden */
  41139. export var defaultUboDeclaration: {
  41140. name: string;
  41141. shader: string;
  41142. };
  41143. }
  41144. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41145. /** @hidden */
  41146. export var lightFragmentDeclaration: {
  41147. name: string;
  41148. shader: string;
  41149. };
  41150. }
  41151. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41152. /** @hidden */
  41153. export var lightUboDeclaration: {
  41154. name: string;
  41155. shader: string;
  41156. };
  41157. }
  41158. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41159. /** @hidden */
  41160. export var lightsFragmentFunctions: {
  41161. name: string;
  41162. shader: string;
  41163. };
  41164. }
  41165. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41166. /** @hidden */
  41167. export var shadowsFragmentFunctions: {
  41168. name: string;
  41169. shader: string;
  41170. };
  41171. }
  41172. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41173. /** @hidden */
  41174. export var fresnelFunction: {
  41175. name: string;
  41176. shader: string;
  41177. };
  41178. }
  41179. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41180. /** @hidden */
  41181. export var reflectionFunction: {
  41182. name: string;
  41183. shader: string;
  41184. };
  41185. }
  41186. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41187. /** @hidden */
  41188. export var bumpFragmentFunctions: {
  41189. name: string;
  41190. shader: string;
  41191. };
  41192. }
  41193. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41194. /** @hidden */
  41195. export var logDepthDeclaration: {
  41196. name: string;
  41197. shader: string;
  41198. };
  41199. }
  41200. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41201. /** @hidden */
  41202. export var bumpFragment: {
  41203. name: string;
  41204. shader: string;
  41205. };
  41206. }
  41207. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41208. /** @hidden */
  41209. export var depthPrePass: {
  41210. name: string;
  41211. shader: string;
  41212. };
  41213. }
  41214. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41215. /** @hidden */
  41216. export var lightFragment: {
  41217. name: string;
  41218. shader: string;
  41219. };
  41220. }
  41221. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41222. /** @hidden */
  41223. export var logDepthFragment: {
  41224. name: string;
  41225. shader: string;
  41226. };
  41227. }
  41228. declare module "babylonjs/Shaders/default.fragment" {
  41229. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41230. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41231. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41232. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41233. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41234. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41235. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41236. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41237. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41238. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41239. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41240. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41241. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41242. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41243. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41244. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41245. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41246. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41247. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41248. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41249. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41250. /** @hidden */
  41251. export var defaultPixelShader: {
  41252. name: string;
  41253. shader: string;
  41254. };
  41255. }
  41256. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41257. /** @hidden */
  41258. export var defaultVertexDeclaration: {
  41259. name: string;
  41260. shader: string;
  41261. };
  41262. }
  41263. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41264. /** @hidden */
  41265. export var bumpVertexDeclaration: {
  41266. name: string;
  41267. shader: string;
  41268. };
  41269. }
  41270. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41271. /** @hidden */
  41272. export var bumpVertex: {
  41273. name: string;
  41274. shader: string;
  41275. };
  41276. }
  41277. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41278. /** @hidden */
  41279. export var fogVertex: {
  41280. name: string;
  41281. shader: string;
  41282. };
  41283. }
  41284. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41285. /** @hidden */
  41286. export var shadowsVertex: {
  41287. name: string;
  41288. shader: string;
  41289. };
  41290. }
  41291. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41292. /** @hidden */
  41293. export var pointCloudVertex: {
  41294. name: string;
  41295. shader: string;
  41296. };
  41297. }
  41298. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41299. /** @hidden */
  41300. export var logDepthVertex: {
  41301. name: string;
  41302. shader: string;
  41303. };
  41304. }
  41305. declare module "babylonjs/Shaders/default.vertex" {
  41306. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41307. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41308. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41309. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41310. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41311. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41312. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41313. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41314. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41315. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41316. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41317. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41318. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41319. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41320. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41321. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41322. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41323. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41324. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41325. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41326. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41327. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41328. /** @hidden */
  41329. export var defaultVertexShader: {
  41330. name: string;
  41331. shader: string;
  41332. };
  41333. }
  41334. declare module "babylonjs/Materials/standardMaterial" {
  41335. import { SmartArray } from "babylonjs/Misc/smartArray";
  41336. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41337. import { Nullable } from "babylonjs/types";
  41338. import { Scene } from "babylonjs/scene";
  41339. import { Matrix } from "babylonjs/Maths/math.vector";
  41340. import { Color3 } from "babylonjs/Maths/math.color";
  41341. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41343. import { Mesh } from "babylonjs/Meshes/mesh";
  41344. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41345. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41346. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41347. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41348. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41350. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41351. import "babylonjs/Shaders/default.fragment";
  41352. import "babylonjs/Shaders/default.vertex";
  41353. /** @hidden */
  41354. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41355. MAINUV1: boolean;
  41356. MAINUV2: boolean;
  41357. DIFFUSE: boolean;
  41358. DIFFUSEDIRECTUV: number;
  41359. AMBIENT: boolean;
  41360. AMBIENTDIRECTUV: number;
  41361. OPACITY: boolean;
  41362. OPACITYDIRECTUV: number;
  41363. OPACITYRGB: boolean;
  41364. REFLECTION: boolean;
  41365. EMISSIVE: boolean;
  41366. EMISSIVEDIRECTUV: number;
  41367. SPECULAR: boolean;
  41368. SPECULARDIRECTUV: number;
  41369. BUMP: boolean;
  41370. BUMPDIRECTUV: number;
  41371. PARALLAX: boolean;
  41372. PARALLAXOCCLUSION: boolean;
  41373. SPECULAROVERALPHA: boolean;
  41374. CLIPPLANE: boolean;
  41375. CLIPPLANE2: boolean;
  41376. CLIPPLANE3: boolean;
  41377. CLIPPLANE4: boolean;
  41378. ALPHATEST: boolean;
  41379. DEPTHPREPASS: boolean;
  41380. ALPHAFROMDIFFUSE: boolean;
  41381. POINTSIZE: boolean;
  41382. FOG: boolean;
  41383. SPECULARTERM: boolean;
  41384. DIFFUSEFRESNEL: boolean;
  41385. OPACITYFRESNEL: boolean;
  41386. REFLECTIONFRESNEL: boolean;
  41387. REFRACTIONFRESNEL: boolean;
  41388. EMISSIVEFRESNEL: boolean;
  41389. FRESNEL: boolean;
  41390. NORMAL: boolean;
  41391. UV1: boolean;
  41392. UV2: boolean;
  41393. VERTEXCOLOR: boolean;
  41394. VERTEXALPHA: boolean;
  41395. NUM_BONE_INFLUENCERS: number;
  41396. BonesPerMesh: number;
  41397. BONETEXTURE: boolean;
  41398. INSTANCES: boolean;
  41399. GLOSSINESS: boolean;
  41400. ROUGHNESS: boolean;
  41401. EMISSIVEASILLUMINATION: boolean;
  41402. LINKEMISSIVEWITHDIFFUSE: boolean;
  41403. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41404. LIGHTMAP: boolean;
  41405. LIGHTMAPDIRECTUV: number;
  41406. OBJECTSPACE_NORMALMAP: boolean;
  41407. USELIGHTMAPASSHADOWMAP: boolean;
  41408. REFLECTIONMAP_3D: boolean;
  41409. REFLECTIONMAP_SPHERICAL: boolean;
  41410. REFLECTIONMAP_PLANAR: boolean;
  41411. REFLECTIONMAP_CUBIC: boolean;
  41412. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41413. REFLECTIONMAP_PROJECTION: boolean;
  41414. REFLECTIONMAP_SKYBOX: boolean;
  41415. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41416. REFLECTIONMAP_EXPLICIT: boolean;
  41417. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41418. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41419. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41420. INVERTCUBICMAP: boolean;
  41421. LOGARITHMICDEPTH: boolean;
  41422. REFRACTION: boolean;
  41423. REFRACTIONMAP_3D: boolean;
  41424. REFLECTIONOVERALPHA: boolean;
  41425. TWOSIDEDLIGHTING: boolean;
  41426. SHADOWFLOAT: boolean;
  41427. MORPHTARGETS: boolean;
  41428. MORPHTARGETS_NORMAL: boolean;
  41429. MORPHTARGETS_TANGENT: boolean;
  41430. MORPHTARGETS_UV: boolean;
  41431. NUM_MORPH_INFLUENCERS: number;
  41432. NONUNIFORMSCALING: boolean;
  41433. PREMULTIPLYALPHA: boolean;
  41434. IMAGEPROCESSING: boolean;
  41435. VIGNETTE: boolean;
  41436. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41437. VIGNETTEBLENDMODEOPAQUE: boolean;
  41438. TONEMAPPING: boolean;
  41439. TONEMAPPING_ACES: boolean;
  41440. CONTRAST: boolean;
  41441. COLORCURVES: boolean;
  41442. COLORGRADING: boolean;
  41443. COLORGRADING3D: boolean;
  41444. SAMPLER3DGREENDEPTH: boolean;
  41445. SAMPLER3DBGRMAP: boolean;
  41446. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41447. MULTIVIEW: boolean;
  41448. /**
  41449. * If the reflection texture on this material is in linear color space
  41450. * @hidden
  41451. */
  41452. IS_REFLECTION_LINEAR: boolean;
  41453. /**
  41454. * If the refraction texture on this material is in linear color space
  41455. * @hidden
  41456. */
  41457. IS_REFRACTION_LINEAR: boolean;
  41458. EXPOSURE: boolean;
  41459. constructor();
  41460. setReflectionMode(modeToEnable: string): void;
  41461. }
  41462. /**
  41463. * This is the default material used in Babylon. It is the best trade off between quality
  41464. * and performances.
  41465. * @see http://doc.babylonjs.com/babylon101/materials
  41466. */
  41467. export class StandardMaterial extends PushMaterial {
  41468. private _diffuseTexture;
  41469. /**
  41470. * The basic texture of the material as viewed under a light.
  41471. */
  41472. diffuseTexture: Nullable<BaseTexture>;
  41473. private _ambientTexture;
  41474. /**
  41475. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41476. */
  41477. ambientTexture: Nullable<BaseTexture>;
  41478. private _opacityTexture;
  41479. /**
  41480. * Define the transparency of the material from a texture.
  41481. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41482. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41483. */
  41484. opacityTexture: Nullable<BaseTexture>;
  41485. private _reflectionTexture;
  41486. /**
  41487. * Define the texture used to display the reflection.
  41488. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41489. */
  41490. reflectionTexture: Nullable<BaseTexture>;
  41491. private _emissiveTexture;
  41492. /**
  41493. * Define texture of the material as if self lit.
  41494. * This will be mixed in the final result even in the absence of light.
  41495. */
  41496. emissiveTexture: Nullable<BaseTexture>;
  41497. private _specularTexture;
  41498. /**
  41499. * Define how the color and intensity of the highlight given by the light in the material.
  41500. */
  41501. specularTexture: Nullable<BaseTexture>;
  41502. private _bumpTexture;
  41503. /**
  41504. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41505. * 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.
  41506. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41507. */
  41508. bumpTexture: Nullable<BaseTexture>;
  41509. private _lightmapTexture;
  41510. /**
  41511. * Complex lighting can be computationally expensive to compute at runtime.
  41512. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41513. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41514. */
  41515. lightmapTexture: Nullable<BaseTexture>;
  41516. private _refractionTexture;
  41517. /**
  41518. * Define the texture used to display the refraction.
  41519. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41520. */
  41521. refractionTexture: Nullable<BaseTexture>;
  41522. /**
  41523. * The color of the material lit by the environmental background lighting.
  41524. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41525. */
  41526. ambientColor: Color3;
  41527. /**
  41528. * The basic color of the material as viewed under a light.
  41529. */
  41530. diffuseColor: Color3;
  41531. /**
  41532. * Define how the color and intensity of the highlight given by the light in the material.
  41533. */
  41534. specularColor: Color3;
  41535. /**
  41536. * Define the color of the material as if self lit.
  41537. * This will be mixed in the final result even in the absence of light.
  41538. */
  41539. emissiveColor: Color3;
  41540. /**
  41541. * Defines how sharp are the highlights in the material.
  41542. * The bigger the value the sharper giving a more glossy feeling to the result.
  41543. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41544. */
  41545. specularPower: number;
  41546. private _useAlphaFromDiffuseTexture;
  41547. /**
  41548. * Does the transparency come from the diffuse texture alpha channel.
  41549. */
  41550. useAlphaFromDiffuseTexture: boolean;
  41551. private _useEmissiveAsIllumination;
  41552. /**
  41553. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41554. */
  41555. useEmissiveAsIllumination: boolean;
  41556. private _linkEmissiveWithDiffuse;
  41557. /**
  41558. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41559. * the emissive level when the final color is close to one.
  41560. */
  41561. linkEmissiveWithDiffuse: boolean;
  41562. private _useSpecularOverAlpha;
  41563. /**
  41564. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41565. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41566. */
  41567. useSpecularOverAlpha: boolean;
  41568. private _useReflectionOverAlpha;
  41569. /**
  41570. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41571. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41572. */
  41573. useReflectionOverAlpha: boolean;
  41574. private _disableLighting;
  41575. /**
  41576. * Does lights from the scene impacts this material.
  41577. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41578. */
  41579. disableLighting: boolean;
  41580. private _useObjectSpaceNormalMap;
  41581. /**
  41582. * Allows using an object space normal map (instead of tangent space).
  41583. */
  41584. useObjectSpaceNormalMap: boolean;
  41585. private _useParallax;
  41586. /**
  41587. * Is parallax enabled or not.
  41588. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41589. */
  41590. useParallax: boolean;
  41591. private _useParallaxOcclusion;
  41592. /**
  41593. * Is parallax occlusion enabled or not.
  41594. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41595. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41596. */
  41597. useParallaxOcclusion: boolean;
  41598. /**
  41599. * 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.
  41600. */
  41601. parallaxScaleBias: number;
  41602. private _roughness;
  41603. /**
  41604. * Helps to define how blurry the reflections should appears in the material.
  41605. */
  41606. roughness: number;
  41607. /**
  41608. * In case of refraction, define the value of the index of refraction.
  41609. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41610. */
  41611. indexOfRefraction: number;
  41612. /**
  41613. * Invert the refraction texture alongside the y axis.
  41614. * It can be useful with procedural textures or probe for instance.
  41615. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41616. */
  41617. invertRefractionY: boolean;
  41618. /**
  41619. * Defines the alpha limits in alpha test mode.
  41620. */
  41621. alphaCutOff: number;
  41622. private _useLightmapAsShadowmap;
  41623. /**
  41624. * In case of light mapping, define whether the map contains light or shadow informations.
  41625. */
  41626. useLightmapAsShadowmap: boolean;
  41627. private _diffuseFresnelParameters;
  41628. /**
  41629. * Define the diffuse fresnel parameters of the material.
  41630. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41631. */
  41632. diffuseFresnelParameters: FresnelParameters;
  41633. private _opacityFresnelParameters;
  41634. /**
  41635. * Define the opacity fresnel parameters of the material.
  41636. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41637. */
  41638. opacityFresnelParameters: FresnelParameters;
  41639. private _reflectionFresnelParameters;
  41640. /**
  41641. * Define the reflection fresnel parameters of the material.
  41642. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41643. */
  41644. reflectionFresnelParameters: FresnelParameters;
  41645. private _refractionFresnelParameters;
  41646. /**
  41647. * Define the refraction fresnel parameters of the material.
  41648. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41649. */
  41650. refractionFresnelParameters: FresnelParameters;
  41651. private _emissiveFresnelParameters;
  41652. /**
  41653. * Define the emissive fresnel parameters of the material.
  41654. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41655. */
  41656. emissiveFresnelParameters: FresnelParameters;
  41657. private _useReflectionFresnelFromSpecular;
  41658. /**
  41659. * If true automatically deducts the fresnels values from the material specularity.
  41660. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41661. */
  41662. useReflectionFresnelFromSpecular: boolean;
  41663. private _useGlossinessFromSpecularMapAlpha;
  41664. /**
  41665. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41666. */
  41667. useGlossinessFromSpecularMapAlpha: boolean;
  41668. private _maxSimultaneousLights;
  41669. /**
  41670. * Defines the maximum number of lights that can be used in the material
  41671. */
  41672. maxSimultaneousLights: number;
  41673. private _invertNormalMapX;
  41674. /**
  41675. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41676. */
  41677. invertNormalMapX: boolean;
  41678. private _invertNormalMapY;
  41679. /**
  41680. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41681. */
  41682. invertNormalMapY: boolean;
  41683. private _twoSidedLighting;
  41684. /**
  41685. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41686. */
  41687. twoSidedLighting: boolean;
  41688. /**
  41689. * Default configuration related to image processing available in the standard Material.
  41690. */
  41691. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41692. /**
  41693. * Gets the image processing configuration used either in this material.
  41694. */
  41695. /**
  41696. * Sets the Default image processing configuration used either in the this material.
  41697. *
  41698. * If sets to null, the scene one is in use.
  41699. */
  41700. imageProcessingConfiguration: ImageProcessingConfiguration;
  41701. /**
  41702. * Keep track of the image processing observer to allow dispose and replace.
  41703. */
  41704. private _imageProcessingObserver;
  41705. /**
  41706. * Attaches a new image processing configuration to the Standard Material.
  41707. * @param configuration
  41708. */
  41709. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41710. /**
  41711. * Gets wether the color curves effect is enabled.
  41712. */
  41713. /**
  41714. * Sets wether the color curves effect is enabled.
  41715. */
  41716. cameraColorCurvesEnabled: boolean;
  41717. /**
  41718. * Gets wether the color grading effect is enabled.
  41719. */
  41720. /**
  41721. * Gets wether the color grading effect is enabled.
  41722. */
  41723. cameraColorGradingEnabled: boolean;
  41724. /**
  41725. * Gets wether tonemapping is enabled or not.
  41726. */
  41727. /**
  41728. * Sets wether tonemapping is enabled or not
  41729. */
  41730. cameraToneMappingEnabled: boolean;
  41731. /**
  41732. * The camera exposure used on this material.
  41733. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41734. * This corresponds to a photographic exposure.
  41735. */
  41736. /**
  41737. * The camera exposure used on this material.
  41738. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41739. * This corresponds to a photographic exposure.
  41740. */
  41741. cameraExposure: number;
  41742. /**
  41743. * Gets The camera contrast used on this material.
  41744. */
  41745. /**
  41746. * Sets The camera contrast used on this material.
  41747. */
  41748. cameraContrast: number;
  41749. /**
  41750. * Gets the Color Grading 2D Lookup Texture.
  41751. */
  41752. /**
  41753. * Sets the Color Grading 2D Lookup Texture.
  41754. */
  41755. cameraColorGradingTexture: Nullable<BaseTexture>;
  41756. /**
  41757. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41758. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41759. * 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;
  41760. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41761. */
  41762. /**
  41763. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41764. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41765. * 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;
  41766. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41767. */
  41768. cameraColorCurves: Nullable<ColorCurves>;
  41769. /**
  41770. * Custom callback helping to override the default shader used in the material.
  41771. */
  41772. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41773. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41774. protected _worldViewProjectionMatrix: Matrix;
  41775. protected _globalAmbientColor: Color3;
  41776. protected _useLogarithmicDepth: boolean;
  41777. protected _rebuildInParallel: boolean;
  41778. /**
  41779. * Instantiates a new standard material.
  41780. * This is the default material used in Babylon. It is the best trade off between quality
  41781. * and performances.
  41782. * @see http://doc.babylonjs.com/babylon101/materials
  41783. * @param name Define the name of the material in the scene
  41784. * @param scene Define the scene the material belong to
  41785. */
  41786. constructor(name: string, scene: Scene);
  41787. /**
  41788. * Gets a boolean indicating that current material needs to register RTT
  41789. */
  41790. readonly hasRenderTargetTextures: boolean;
  41791. /**
  41792. * Gets the current class name of the material e.g. "StandardMaterial"
  41793. * Mainly use in serialization.
  41794. * @returns the class name
  41795. */
  41796. getClassName(): string;
  41797. /**
  41798. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41799. * You can try switching to logarithmic depth.
  41800. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41801. */
  41802. useLogarithmicDepth: boolean;
  41803. /**
  41804. * Specifies if the material will require alpha blending
  41805. * @returns a boolean specifying if alpha blending is needed
  41806. */
  41807. needAlphaBlending(): boolean;
  41808. /**
  41809. * Specifies if this material should be rendered in alpha test mode
  41810. * @returns a boolean specifying if an alpha test is needed.
  41811. */
  41812. needAlphaTesting(): boolean;
  41813. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41814. /**
  41815. * Get the texture used for alpha test purpose.
  41816. * @returns the diffuse texture in case of the standard material.
  41817. */
  41818. getAlphaTestTexture(): Nullable<BaseTexture>;
  41819. /**
  41820. * Get if the submesh is ready to be used and all its information available.
  41821. * Child classes can use it to update shaders
  41822. * @param mesh defines the mesh to check
  41823. * @param subMesh defines which submesh to check
  41824. * @param useInstances specifies that instances should be used
  41825. * @returns a boolean indicating that the submesh is ready or not
  41826. */
  41827. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41828. /**
  41829. * Builds the material UBO layouts.
  41830. * Used internally during the effect preparation.
  41831. */
  41832. buildUniformLayout(): void;
  41833. /**
  41834. * Unbinds the material from the mesh
  41835. */
  41836. unbind(): void;
  41837. /**
  41838. * Binds the submesh to this material by preparing the effect and shader to draw
  41839. * @param world defines the world transformation matrix
  41840. * @param mesh defines the mesh containing the submesh
  41841. * @param subMesh defines the submesh to bind the material to
  41842. */
  41843. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41844. /**
  41845. * Get the list of animatables in the material.
  41846. * @returns the list of animatables object used in the material
  41847. */
  41848. getAnimatables(): IAnimatable[];
  41849. /**
  41850. * Gets the active textures from the material
  41851. * @returns an array of textures
  41852. */
  41853. getActiveTextures(): BaseTexture[];
  41854. /**
  41855. * Specifies if the material uses a texture
  41856. * @param texture defines the texture to check against the material
  41857. * @returns a boolean specifying if the material uses the texture
  41858. */
  41859. hasTexture(texture: BaseTexture): boolean;
  41860. /**
  41861. * Disposes the material
  41862. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41863. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41864. */
  41865. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41866. /**
  41867. * Makes a duplicate of the material, and gives it a new name
  41868. * @param name defines the new name for the duplicated material
  41869. * @returns the cloned material
  41870. */
  41871. clone(name: string): StandardMaterial;
  41872. /**
  41873. * Serializes this material in a JSON representation
  41874. * @returns the serialized material object
  41875. */
  41876. serialize(): any;
  41877. /**
  41878. * Creates a standard material from parsed material data
  41879. * @param source defines the JSON representation of the material
  41880. * @param scene defines the hosting scene
  41881. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41882. * @returns a new standard material
  41883. */
  41884. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41885. /**
  41886. * Are diffuse textures enabled in the application.
  41887. */
  41888. static DiffuseTextureEnabled: boolean;
  41889. /**
  41890. * Are ambient textures enabled in the application.
  41891. */
  41892. static AmbientTextureEnabled: boolean;
  41893. /**
  41894. * Are opacity textures enabled in the application.
  41895. */
  41896. static OpacityTextureEnabled: boolean;
  41897. /**
  41898. * Are reflection textures enabled in the application.
  41899. */
  41900. static ReflectionTextureEnabled: boolean;
  41901. /**
  41902. * Are emissive textures enabled in the application.
  41903. */
  41904. static EmissiveTextureEnabled: boolean;
  41905. /**
  41906. * Are specular textures enabled in the application.
  41907. */
  41908. static SpecularTextureEnabled: boolean;
  41909. /**
  41910. * Are bump textures enabled in the application.
  41911. */
  41912. static BumpTextureEnabled: boolean;
  41913. /**
  41914. * Are lightmap textures enabled in the application.
  41915. */
  41916. static LightmapTextureEnabled: boolean;
  41917. /**
  41918. * Are refraction textures enabled in the application.
  41919. */
  41920. static RefractionTextureEnabled: boolean;
  41921. /**
  41922. * Are color grading textures enabled in the application.
  41923. */
  41924. static ColorGradingTextureEnabled: boolean;
  41925. /**
  41926. * Are fresnels enabled in the application.
  41927. */
  41928. static FresnelEnabled: boolean;
  41929. }
  41930. }
  41931. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41932. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41933. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41934. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41935. /** @hidden */
  41936. export var imageProcessingPixelShader: {
  41937. name: string;
  41938. shader: string;
  41939. };
  41940. }
  41941. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41942. import { Nullable } from "babylonjs/types";
  41943. import { Color4 } from "babylonjs/Maths/math.color";
  41944. import { Camera } from "babylonjs/Cameras/camera";
  41945. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41946. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41947. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41948. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41949. import { Engine } from "babylonjs/Engines/engine";
  41950. import "babylonjs/Shaders/imageProcessing.fragment";
  41951. import "babylonjs/Shaders/postprocess.vertex";
  41952. /**
  41953. * ImageProcessingPostProcess
  41954. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41955. */
  41956. export class ImageProcessingPostProcess extends PostProcess {
  41957. /**
  41958. * Default configuration related to image processing available in the PBR Material.
  41959. */
  41960. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41961. /**
  41962. * Gets the image processing configuration used either in this material.
  41963. */
  41964. /**
  41965. * Sets the Default image processing configuration used either in the this material.
  41966. *
  41967. * If sets to null, the scene one is in use.
  41968. */
  41969. imageProcessingConfiguration: ImageProcessingConfiguration;
  41970. /**
  41971. * Keep track of the image processing observer to allow dispose and replace.
  41972. */
  41973. private _imageProcessingObserver;
  41974. /**
  41975. * Attaches a new image processing configuration to the PBR Material.
  41976. * @param configuration
  41977. */
  41978. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41979. /**
  41980. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41981. */
  41982. /**
  41983. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41984. */
  41985. colorCurves: Nullable<ColorCurves>;
  41986. /**
  41987. * Gets wether the color curves effect is enabled.
  41988. */
  41989. /**
  41990. * Sets wether the color curves effect is enabled.
  41991. */
  41992. colorCurvesEnabled: boolean;
  41993. /**
  41994. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41995. */
  41996. /**
  41997. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41998. */
  41999. colorGradingTexture: Nullable<BaseTexture>;
  42000. /**
  42001. * Gets wether the color grading effect is enabled.
  42002. */
  42003. /**
  42004. * Gets wether the color grading effect is enabled.
  42005. */
  42006. colorGradingEnabled: boolean;
  42007. /**
  42008. * Gets exposure used in the effect.
  42009. */
  42010. /**
  42011. * Sets exposure used in the effect.
  42012. */
  42013. exposure: number;
  42014. /**
  42015. * Gets wether tonemapping is enabled or not.
  42016. */
  42017. /**
  42018. * Sets wether tonemapping is enabled or not
  42019. */
  42020. toneMappingEnabled: boolean;
  42021. /**
  42022. * Gets the type of tone mapping effect.
  42023. */
  42024. /**
  42025. * Sets the type of tone mapping effect.
  42026. */
  42027. toneMappingType: number;
  42028. /**
  42029. * Gets contrast used in the effect.
  42030. */
  42031. /**
  42032. * Sets contrast used in the effect.
  42033. */
  42034. contrast: number;
  42035. /**
  42036. * Gets Vignette stretch size.
  42037. */
  42038. /**
  42039. * Sets Vignette stretch size.
  42040. */
  42041. vignetteStretch: number;
  42042. /**
  42043. * Gets Vignette centre X Offset.
  42044. */
  42045. /**
  42046. * Sets Vignette centre X Offset.
  42047. */
  42048. vignetteCentreX: number;
  42049. /**
  42050. * Gets Vignette centre Y Offset.
  42051. */
  42052. /**
  42053. * Sets Vignette centre Y Offset.
  42054. */
  42055. vignetteCentreY: number;
  42056. /**
  42057. * Gets Vignette weight or intensity of the vignette effect.
  42058. */
  42059. /**
  42060. * Sets Vignette weight or intensity of the vignette effect.
  42061. */
  42062. vignetteWeight: number;
  42063. /**
  42064. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42065. * if vignetteEnabled is set to true.
  42066. */
  42067. /**
  42068. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42069. * if vignetteEnabled is set to true.
  42070. */
  42071. vignetteColor: Color4;
  42072. /**
  42073. * Gets Camera field of view used by the Vignette effect.
  42074. */
  42075. /**
  42076. * Sets Camera field of view used by the Vignette effect.
  42077. */
  42078. vignetteCameraFov: number;
  42079. /**
  42080. * Gets the vignette blend mode allowing different kind of effect.
  42081. */
  42082. /**
  42083. * Sets the vignette blend mode allowing different kind of effect.
  42084. */
  42085. vignetteBlendMode: number;
  42086. /**
  42087. * Gets wether the vignette effect is enabled.
  42088. */
  42089. /**
  42090. * Sets wether the vignette effect is enabled.
  42091. */
  42092. vignetteEnabled: boolean;
  42093. private _fromLinearSpace;
  42094. /**
  42095. * Gets wether the input of the processing is in Gamma or Linear Space.
  42096. */
  42097. /**
  42098. * Sets wether the input of the processing is in Gamma or Linear Space.
  42099. */
  42100. fromLinearSpace: boolean;
  42101. /**
  42102. * Defines cache preventing GC.
  42103. */
  42104. private _defines;
  42105. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42106. /**
  42107. * "ImageProcessingPostProcess"
  42108. * @returns "ImageProcessingPostProcess"
  42109. */
  42110. getClassName(): string;
  42111. protected _updateParameters(): void;
  42112. dispose(camera?: Camera): void;
  42113. }
  42114. }
  42115. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42116. import { Scene } from "babylonjs/scene";
  42117. import { Color3 } from "babylonjs/Maths/math.color";
  42118. import { Mesh } from "babylonjs/Meshes/mesh";
  42119. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42120. import { Nullable } from "babylonjs/types";
  42121. /**
  42122. * Class containing static functions to help procedurally build meshes
  42123. */
  42124. export class GroundBuilder {
  42125. /**
  42126. * Creates a ground mesh
  42127. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42128. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42130. * @param name defines the name of the mesh
  42131. * @param options defines the options used to create the mesh
  42132. * @param scene defines the hosting scene
  42133. * @returns the ground mesh
  42134. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42135. */
  42136. static CreateGround(name: string, options: {
  42137. width?: number;
  42138. height?: number;
  42139. subdivisions?: number;
  42140. subdivisionsX?: number;
  42141. subdivisionsY?: number;
  42142. updatable?: boolean;
  42143. }, scene: any): Mesh;
  42144. /**
  42145. * Creates a tiled ground mesh
  42146. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42147. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42148. * * 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
  42149. * * 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
  42150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42151. * @param name defines the name of the mesh
  42152. * @param options defines the options used to create the mesh
  42153. * @param scene defines the hosting scene
  42154. * @returns the tiled ground mesh
  42155. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42156. */
  42157. static CreateTiledGround(name: string, options: {
  42158. xmin: number;
  42159. zmin: number;
  42160. xmax: number;
  42161. zmax: number;
  42162. subdivisions?: {
  42163. w: number;
  42164. h: number;
  42165. };
  42166. precision?: {
  42167. w: number;
  42168. h: number;
  42169. };
  42170. updatable?: boolean;
  42171. }, scene?: Nullable<Scene>): Mesh;
  42172. /**
  42173. * Creates a ground mesh from a height map
  42174. * * The parameter `url` sets the URL of the height map image resource.
  42175. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42176. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42177. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42178. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42179. * * 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.
  42180. * * 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).
  42181. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42183. * @param name defines the name of the mesh
  42184. * @param url defines the url to the height map
  42185. * @param options defines the options used to create the mesh
  42186. * @param scene defines the hosting scene
  42187. * @returns the ground mesh
  42188. * @see https://doc.babylonjs.com/babylon101/height_map
  42189. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42190. */
  42191. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42192. width?: number;
  42193. height?: number;
  42194. subdivisions?: number;
  42195. minHeight?: number;
  42196. maxHeight?: number;
  42197. colorFilter?: Color3;
  42198. alphaFilter?: number;
  42199. updatable?: boolean;
  42200. onReady?: (mesh: GroundMesh) => void;
  42201. }, scene?: Nullable<Scene>): GroundMesh;
  42202. }
  42203. }
  42204. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42205. import { Vector4 } from "babylonjs/Maths/math.vector";
  42206. import { Mesh } from "babylonjs/Meshes/mesh";
  42207. /**
  42208. * Class containing static functions to help procedurally build meshes
  42209. */
  42210. export class TorusBuilder {
  42211. /**
  42212. * Creates a torus mesh
  42213. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42214. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42215. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42219. * @param name defines the name of the mesh
  42220. * @param options defines the options used to create the mesh
  42221. * @param scene defines the hosting scene
  42222. * @returns the torus mesh
  42223. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42224. */
  42225. static CreateTorus(name: string, options: {
  42226. diameter?: number;
  42227. thickness?: number;
  42228. tessellation?: number;
  42229. updatable?: boolean;
  42230. sideOrientation?: number;
  42231. frontUVs?: Vector4;
  42232. backUVs?: Vector4;
  42233. }, scene: any): Mesh;
  42234. }
  42235. }
  42236. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42237. import { Vector4 } from "babylonjs/Maths/math.vector";
  42238. import { Color4 } from "babylonjs/Maths/math.color";
  42239. import { Mesh } from "babylonjs/Meshes/mesh";
  42240. /**
  42241. * Class containing static functions to help procedurally build meshes
  42242. */
  42243. export class CylinderBuilder {
  42244. /**
  42245. * Creates a cylinder or a cone mesh
  42246. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42247. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42248. * * 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.
  42249. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42250. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42251. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42252. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42253. * * 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).
  42254. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42255. * * 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).
  42256. * * 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
  42257. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42258. * * 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
  42259. * * 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.
  42260. * * If `enclose` is false, a ring surface is one element.
  42261. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42262. * * 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
  42263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42266. * @param name defines the name of the mesh
  42267. * @param options defines the options used to create the mesh
  42268. * @param scene defines the hosting scene
  42269. * @returns the cylinder mesh
  42270. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42271. */
  42272. static CreateCylinder(name: string, options: {
  42273. height?: number;
  42274. diameterTop?: number;
  42275. diameterBottom?: number;
  42276. diameter?: number;
  42277. tessellation?: number;
  42278. subdivisions?: number;
  42279. arc?: number;
  42280. faceColors?: Color4[];
  42281. faceUV?: Vector4[];
  42282. updatable?: boolean;
  42283. hasRings?: boolean;
  42284. enclose?: boolean;
  42285. cap?: number;
  42286. sideOrientation?: number;
  42287. frontUVs?: Vector4;
  42288. backUVs?: Vector4;
  42289. }, scene: any): Mesh;
  42290. }
  42291. }
  42292. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42293. import { Observable } from "babylonjs/Misc/observable";
  42294. import { Nullable } from "babylonjs/types";
  42295. import { Camera } from "babylonjs/Cameras/camera";
  42296. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42297. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42298. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42299. import { Scene } from "babylonjs/scene";
  42300. import { Vector3 } from "babylonjs/Maths/math.vector";
  42301. import { Color3 } from "babylonjs/Maths/math.color";
  42302. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42304. import { Mesh } from "babylonjs/Meshes/mesh";
  42305. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42306. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42307. import "babylonjs/Meshes/Builders/groundBuilder";
  42308. import "babylonjs/Meshes/Builders/torusBuilder";
  42309. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42310. import "babylonjs/Gamepads/gamepadSceneComponent";
  42311. import "babylonjs/Animations/animatable";
  42312. /**
  42313. * Options to modify the vr teleportation behavior.
  42314. */
  42315. export interface VRTeleportationOptions {
  42316. /**
  42317. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42318. */
  42319. floorMeshName?: string;
  42320. /**
  42321. * A list of meshes to be used as the teleportation floor. (default: empty)
  42322. */
  42323. floorMeshes?: Mesh[];
  42324. }
  42325. /**
  42326. * Options to modify the vr experience helper's behavior.
  42327. */
  42328. export interface VRExperienceHelperOptions extends WebVROptions {
  42329. /**
  42330. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42331. */
  42332. createDeviceOrientationCamera?: boolean;
  42333. /**
  42334. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42335. */
  42336. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42337. /**
  42338. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42339. */
  42340. laserToggle?: boolean;
  42341. /**
  42342. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42343. */
  42344. floorMeshes?: Mesh[];
  42345. /**
  42346. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42347. */
  42348. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42349. }
  42350. /**
  42351. * Event containing information after VR has been entered
  42352. */
  42353. export class OnAfterEnteringVRObservableEvent {
  42354. /**
  42355. * If entering vr was successful
  42356. */
  42357. success: boolean;
  42358. }
  42359. /**
  42360. * Helps to quickly add VR support to an existing scene.
  42361. * See http://doc.babylonjs.com/how_to/webvr_helper
  42362. */
  42363. export class VRExperienceHelper {
  42364. /** Options to modify the vr experience helper's behavior. */
  42365. webVROptions: VRExperienceHelperOptions;
  42366. private _scene;
  42367. private _position;
  42368. private _btnVR;
  42369. private _btnVRDisplayed;
  42370. private _webVRsupported;
  42371. private _webVRready;
  42372. private _webVRrequesting;
  42373. private _webVRpresenting;
  42374. private _hasEnteredVR;
  42375. private _fullscreenVRpresenting;
  42376. private _canvas;
  42377. private _webVRCamera;
  42378. private _vrDeviceOrientationCamera;
  42379. private _deviceOrientationCamera;
  42380. private _existingCamera;
  42381. private _onKeyDown;
  42382. private _onVrDisplayPresentChange;
  42383. private _onVRDisplayChanged;
  42384. private _onVRRequestPresentStart;
  42385. private _onVRRequestPresentComplete;
  42386. /**
  42387. * 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)
  42388. */
  42389. enableGazeEvenWhenNoPointerLock: boolean;
  42390. /**
  42391. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42392. */
  42393. exitVROnDoubleTap: boolean;
  42394. /**
  42395. * Observable raised right before entering VR.
  42396. */
  42397. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42398. /**
  42399. * Observable raised when entering VR has completed.
  42400. */
  42401. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42402. /**
  42403. * Observable raised when exiting VR.
  42404. */
  42405. onExitingVRObservable: Observable<VRExperienceHelper>;
  42406. /**
  42407. * Observable raised when controller mesh is loaded.
  42408. */
  42409. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42410. /** Return this.onEnteringVRObservable
  42411. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42412. */
  42413. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42414. /** Return this.onExitingVRObservable
  42415. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42416. */
  42417. readonly onExitingVR: Observable<VRExperienceHelper>;
  42418. /** Return this.onControllerMeshLoadedObservable
  42419. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42420. */
  42421. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42422. private _rayLength;
  42423. private _useCustomVRButton;
  42424. private _teleportationRequested;
  42425. private _teleportActive;
  42426. private _floorMeshName;
  42427. private _floorMeshesCollection;
  42428. private _rotationAllowed;
  42429. private _teleportBackwardsVector;
  42430. private _teleportationTarget;
  42431. private _isDefaultTeleportationTarget;
  42432. private _postProcessMove;
  42433. private _teleportationFillColor;
  42434. private _teleportationBorderColor;
  42435. private _rotationAngle;
  42436. private _haloCenter;
  42437. private _cameraGazer;
  42438. private _padSensibilityUp;
  42439. private _padSensibilityDown;
  42440. private _leftController;
  42441. private _rightController;
  42442. /**
  42443. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42444. */
  42445. onNewMeshSelected: Observable<AbstractMesh>;
  42446. /**
  42447. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42448. * This observable will provide the mesh and the controller used to select the mesh
  42449. */
  42450. onMeshSelectedWithController: Observable<{
  42451. mesh: AbstractMesh;
  42452. controller: WebVRController;
  42453. }>;
  42454. /**
  42455. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42456. */
  42457. onNewMeshPicked: Observable<PickingInfo>;
  42458. private _circleEase;
  42459. /**
  42460. * Observable raised before camera teleportation
  42461. */
  42462. onBeforeCameraTeleport: Observable<Vector3>;
  42463. /**
  42464. * Observable raised after camera teleportation
  42465. */
  42466. onAfterCameraTeleport: Observable<Vector3>;
  42467. /**
  42468. * Observable raised when current selected mesh gets unselected
  42469. */
  42470. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42471. private _raySelectionPredicate;
  42472. /**
  42473. * To be optionaly changed by user to define custom ray selection
  42474. */
  42475. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42476. /**
  42477. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42478. */
  42479. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42480. /**
  42481. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42482. */
  42483. teleportationEnabled: boolean;
  42484. private _defaultHeight;
  42485. private _teleportationInitialized;
  42486. private _interactionsEnabled;
  42487. private _interactionsRequested;
  42488. private _displayGaze;
  42489. private _displayLaserPointer;
  42490. /**
  42491. * The mesh used to display where the user is going to teleport.
  42492. */
  42493. /**
  42494. * Sets the mesh to be used to display where the user is going to teleport.
  42495. */
  42496. teleportationTarget: Mesh;
  42497. /**
  42498. * 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
  42499. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42500. * See http://doc.babylonjs.com/resources/baking_transformations
  42501. */
  42502. gazeTrackerMesh: Mesh;
  42503. /**
  42504. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42505. */
  42506. updateGazeTrackerScale: boolean;
  42507. /**
  42508. * If the gaze trackers color should be updated when selecting meshes
  42509. */
  42510. updateGazeTrackerColor: boolean;
  42511. /**
  42512. * If the controller laser color should be updated when selecting meshes
  42513. */
  42514. updateControllerLaserColor: boolean;
  42515. /**
  42516. * The gaze tracking mesh corresponding to the left controller
  42517. */
  42518. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42519. /**
  42520. * The gaze tracking mesh corresponding to the right controller
  42521. */
  42522. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42523. /**
  42524. * If the ray of the gaze should be displayed.
  42525. */
  42526. /**
  42527. * Sets if the ray of the gaze should be displayed.
  42528. */
  42529. displayGaze: boolean;
  42530. /**
  42531. * If the ray of the LaserPointer should be displayed.
  42532. */
  42533. /**
  42534. * Sets if the ray of the LaserPointer should be displayed.
  42535. */
  42536. displayLaserPointer: boolean;
  42537. /**
  42538. * The deviceOrientationCamera used as the camera when not in VR.
  42539. */
  42540. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42541. /**
  42542. * Based on the current WebVR support, returns the current VR camera used.
  42543. */
  42544. readonly currentVRCamera: Nullable<Camera>;
  42545. /**
  42546. * The webVRCamera which is used when in VR.
  42547. */
  42548. readonly webVRCamera: WebVRFreeCamera;
  42549. /**
  42550. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42551. */
  42552. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42553. /**
  42554. * The html button that is used to trigger entering into VR.
  42555. */
  42556. readonly vrButton: Nullable<HTMLButtonElement>;
  42557. private readonly _teleportationRequestInitiated;
  42558. /**
  42559. * Defines wether or not Pointer lock should be requested when switching to
  42560. * full screen.
  42561. */
  42562. requestPointerLockOnFullScreen: boolean;
  42563. /**
  42564. * Instantiates a VRExperienceHelper.
  42565. * Helps to quickly add VR support to an existing scene.
  42566. * @param scene The scene the VRExperienceHelper belongs to.
  42567. * @param webVROptions Options to modify the vr experience helper's behavior.
  42568. */
  42569. constructor(scene: Scene,
  42570. /** Options to modify the vr experience helper's behavior. */
  42571. webVROptions?: VRExperienceHelperOptions);
  42572. private _onDefaultMeshLoaded;
  42573. private _onResize;
  42574. private _onFullscreenChange;
  42575. /**
  42576. * Gets a value indicating if we are currently in VR mode.
  42577. */
  42578. readonly isInVRMode: boolean;
  42579. private onVrDisplayPresentChange;
  42580. private onVRDisplayChanged;
  42581. private moveButtonToBottomRight;
  42582. private displayVRButton;
  42583. private updateButtonVisibility;
  42584. private _cachedAngularSensibility;
  42585. /**
  42586. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42587. * Otherwise, will use the fullscreen API.
  42588. */
  42589. enterVR(): void;
  42590. /**
  42591. * Attempt to exit VR, or fullscreen.
  42592. */
  42593. exitVR(): void;
  42594. /**
  42595. * The position of the vr experience helper.
  42596. */
  42597. /**
  42598. * Sets the position of the vr experience helper.
  42599. */
  42600. position: Vector3;
  42601. /**
  42602. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42603. */
  42604. enableInteractions(): void;
  42605. private readonly _noControllerIsActive;
  42606. private beforeRender;
  42607. private _isTeleportationFloor;
  42608. /**
  42609. * Adds a floor mesh to be used for teleportation.
  42610. * @param floorMesh the mesh to be used for teleportation.
  42611. */
  42612. addFloorMesh(floorMesh: Mesh): void;
  42613. /**
  42614. * Removes a floor mesh from being used for teleportation.
  42615. * @param floorMesh the mesh to be removed.
  42616. */
  42617. removeFloorMesh(floorMesh: Mesh): void;
  42618. /**
  42619. * Enables interactions and teleportation using the VR controllers and gaze.
  42620. * @param vrTeleportationOptions options to modify teleportation behavior.
  42621. */
  42622. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42623. private _onNewGamepadConnected;
  42624. private _tryEnableInteractionOnController;
  42625. private _onNewGamepadDisconnected;
  42626. private _enableInteractionOnController;
  42627. private _checkTeleportWithRay;
  42628. private _checkRotate;
  42629. private _checkTeleportBackwards;
  42630. private _enableTeleportationOnController;
  42631. private _createTeleportationCircles;
  42632. private _displayTeleportationTarget;
  42633. private _hideTeleportationTarget;
  42634. private _rotateCamera;
  42635. private _moveTeleportationSelectorTo;
  42636. private _workingVector;
  42637. private _workingQuaternion;
  42638. private _workingMatrix;
  42639. /**
  42640. * Teleports the users feet to the desired location
  42641. * @param location The location where the user's feet should be placed
  42642. */
  42643. teleportCamera(location: Vector3): void;
  42644. private _convertNormalToDirectionOfRay;
  42645. private _castRayAndSelectObject;
  42646. private _notifySelectedMeshUnselected;
  42647. /**
  42648. * Sets the color of the laser ray from the vr controllers.
  42649. * @param color new color for the ray.
  42650. */
  42651. changeLaserColor(color: Color3): void;
  42652. /**
  42653. * Sets the color of the ray from the vr headsets gaze.
  42654. * @param color new color for the ray.
  42655. */
  42656. changeGazeColor(color: Color3): void;
  42657. /**
  42658. * Exits VR and disposes of the vr experience helper
  42659. */
  42660. dispose(): void;
  42661. /**
  42662. * Gets the name of the VRExperienceHelper class
  42663. * @returns "VRExperienceHelper"
  42664. */
  42665. getClassName(): string;
  42666. }
  42667. }
  42668. declare module "babylonjs/Cameras/VR/index" {
  42669. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42670. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42671. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42672. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42673. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42674. export * from "babylonjs/Cameras/VR/webVRCamera";
  42675. }
  42676. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42677. import { Observable } from "babylonjs/Misc/observable";
  42678. import { Nullable } from "babylonjs/types";
  42679. import { IDisposable, Scene } from "babylonjs/scene";
  42680. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42681. /**
  42682. * Manages an XRSession to work with Babylon's engine
  42683. * @see https://doc.babylonjs.com/how_to/webxr
  42684. */
  42685. export class WebXRSessionManager implements IDisposable {
  42686. private scene;
  42687. /**
  42688. * Fires every time a new xrFrame arrives which can be used to update the camera
  42689. */
  42690. onXRFrameObservable: Observable<any>;
  42691. /**
  42692. * Fires when the xr session is ended either by the device or manually done
  42693. */
  42694. onXRSessionEnded: Observable<any>;
  42695. /**
  42696. * Underlying xr session
  42697. */
  42698. session: XRSession;
  42699. /**
  42700. * Type of reference space used when creating the session
  42701. */
  42702. referenceSpace: XRReferenceSpace;
  42703. /** @hidden */
  42704. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42705. /**
  42706. * Current XR frame
  42707. */
  42708. currentFrame: Nullable<XRFrame>;
  42709. private _xrNavigator;
  42710. private baseLayer;
  42711. /**
  42712. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42713. * @param scene The scene which the session should be created for
  42714. */
  42715. constructor(scene: Scene);
  42716. /**
  42717. * Initializes the manager
  42718. * After initialization enterXR can be called to start an XR session
  42719. * @returns Promise which resolves after it is initialized
  42720. */
  42721. initializeAsync(): Promise<void>;
  42722. /**
  42723. * Initializes an xr session
  42724. * @param xrSessionMode mode to initialize
  42725. * @returns a promise which will resolve once the session has been initialized
  42726. */
  42727. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42728. /**
  42729. * Sets the reference space on the xr session
  42730. * @param referenceSpace space to set
  42731. * @returns a promise that will resolve once the reference space has been set
  42732. */
  42733. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42734. /**
  42735. * Updates the render state of the session
  42736. * @param state state to set
  42737. * @returns a promise that resolves once the render state has been updated
  42738. */
  42739. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42740. /**
  42741. * Starts rendering to the xr layer
  42742. * @returns a promise that will resolve once rendering has started
  42743. */
  42744. startRenderingToXRAsync(): Promise<void>;
  42745. /**
  42746. * Stops the xrSession and restores the renderloop
  42747. * @returns Promise which resolves after it exits XR
  42748. */
  42749. exitXRAsync(): Promise<unknown>;
  42750. /**
  42751. * Checks if a session would be supported for the creation options specified
  42752. * @param sessionMode session mode to check if supported eg. immersive-vr
  42753. * @returns true if supported
  42754. */
  42755. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42756. /**
  42757. * @hidden
  42758. * Converts the render layer of xrSession to a render target
  42759. * @param session session to create render target for
  42760. * @param scene scene the new render target should be created for
  42761. */
  42762. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42763. /**
  42764. * Disposes of the session manager
  42765. */
  42766. dispose(): void;
  42767. }
  42768. }
  42769. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42770. import { Scene } from "babylonjs/scene";
  42771. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42772. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42773. /**
  42774. * WebXR Camera which holds the views for the xrSession
  42775. * @see https://doc.babylonjs.com/how_to/webxr
  42776. */
  42777. export class WebXRCamera extends FreeCamera {
  42778. private static _TmpMatrix;
  42779. /**
  42780. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42781. * @param name the name of the camera
  42782. * @param scene the scene to add the camera to
  42783. */
  42784. constructor(name: string, scene: Scene);
  42785. private _updateNumberOfRigCameras;
  42786. /** @hidden */
  42787. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42788. /**
  42789. * Updates the cameras position from the current pose information of the XR session
  42790. * @param xrSessionManager the session containing pose information
  42791. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42792. */
  42793. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42794. }
  42795. }
  42796. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42797. import { Nullable } from "babylonjs/types";
  42798. import { IDisposable } from "babylonjs/scene";
  42799. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42800. /**
  42801. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42802. */
  42803. export class WebXRManagedOutputCanvas implements IDisposable {
  42804. private helper;
  42805. private _canvas;
  42806. /**
  42807. * xrpresent context of the canvas which can be used to display/mirror xr content
  42808. */
  42809. canvasContext: WebGLRenderingContext;
  42810. /**
  42811. * xr layer for the canvas
  42812. */
  42813. xrLayer: Nullable<XRWebGLLayer>;
  42814. /**
  42815. * Initializes the xr layer for the session
  42816. * @param xrSession xr session
  42817. * @returns a promise that will resolve once the XR Layer has been created
  42818. */
  42819. initializeXRLayerAsync(xrSession: any): any;
  42820. /**
  42821. * Initializes the canvas to be added/removed upon entering/exiting xr
  42822. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42823. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42824. */
  42825. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42826. /**
  42827. * Disposes of the object
  42828. */
  42829. dispose(): void;
  42830. private _setManagedOutputCanvas;
  42831. private _addCanvas;
  42832. private _removeCanvas;
  42833. }
  42834. }
  42835. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42836. import { Observable } from "babylonjs/Misc/observable";
  42837. import { IDisposable, Scene } from "babylonjs/scene";
  42838. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42840. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42841. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42842. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42843. /**
  42844. * States of the webXR experience
  42845. */
  42846. export enum WebXRState {
  42847. /**
  42848. * Transitioning to being in XR mode
  42849. */
  42850. ENTERING_XR = 0,
  42851. /**
  42852. * Transitioning to non XR mode
  42853. */
  42854. EXITING_XR = 1,
  42855. /**
  42856. * In XR mode and presenting
  42857. */
  42858. IN_XR = 2,
  42859. /**
  42860. * Not entered XR mode
  42861. */
  42862. NOT_IN_XR = 3
  42863. }
  42864. /**
  42865. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42866. * @see https://doc.babylonjs.com/how_to/webxr
  42867. */
  42868. export class WebXRExperienceHelper implements IDisposable {
  42869. private scene;
  42870. /**
  42871. * 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
  42872. */
  42873. container: AbstractMesh;
  42874. /**
  42875. * Camera used to render xr content
  42876. */
  42877. camera: WebXRCamera;
  42878. /**
  42879. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42880. */
  42881. state: WebXRState;
  42882. private _setState;
  42883. private static _TmpVector;
  42884. /**
  42885. * Fires when the state of the experience helper has changed
  42886. */
  42887. onStateChangedObservable: Observable<WebXRState>;
  42888. /** Session manager used to keep track of xr session */
  42889. sessionManager: WebXRSessionManager;
  42890. private _nonVRCamera;
  42891. private _originalSceneAutoClear;
  42892. private _supported;
  42893. /**
  42894. * Creates the experience helper
  42895. * @param scene the scene to attach the experience helper to
  42896. * @returns a promise for the experience helper
  42897. */
  42898. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42899. /**
  42900. * Creates a WebXRExperienceHelper
  42901. * @param scene The scene the helper should be created in
  42902. */
  42903. private constructor();
  42904. /**
  42905. * Exits XR mode and returns the scene to its original state
  42906. * @returns promise that resolves after xr mode has exited
  42907. */
  42908. exitXRAsync(): Promise<unknown>;
  42909. /**
  42910. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42911. * @param sessionCreationOptions options for the XR session
  42912. * @param referenceSpaceType frame of reference of the XR session
  42913. * @param outputCanvas the output canvas that will be used to enter XR mode
  42914. * @returns promise that resolves after xr mode has entered
  42915. */
  42916. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42917. /**
  42918. * Updates the global position of the camera by moving the camera's container
  42919. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42920. * @param position The desired global position of the camera
  42921. */
  42922. setPositionOfCameraUsingContainer(position: Vector3): void;
  42923. /**
  42924. * Rotates the xr camera by rotating the camera's container around the camera's position
  42925. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42926. * @param rotation the desired quaternion rotation to apply to the camera
  42927. */
  42928. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42929. /**
  42930. * Disposes of the experience helper
  42931. */
  42932. dispose(): void;
  42933. }
  42934. }
  42935. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42936. import { Nullable } from "babylonjs/types";
  42937. import { Observable } from "babylonjs/Misc/observable";
  42938. import { IDisposable, Scene } from "babylonjs/scene";
  42939. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42940. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42941. /**
  42942. * Button which can be used to enter a different mode of XR
  42943. */
  42944. export class WebXREnterExitUIButton {
  42945. /** button element */
  42946. element: HTMLElement;
  42947. /** XR initialization options for the button */
  42948. sessionMode: XRSessionMode;
  42949. /** Reference space type */
  42950. referenceSpaceType: XRReferenceSpaceType;
  42951. /**
  42952. * Creates a WebXREnterExitUIButton
  42953. * @param element button element
  42954. * @param sessionMode XR initialization session mode
  42955. * @param referenceSpaceType the type of reference space to be used
  42956. */
  42957. constructor(
  42958. /** button element */
  42959. element: HTMLElement,
  42960. /** XR initialization options for the button */
  42961. sessionMode: XRSessionMode,
  42962. /** Reference space type */
  42963. referenceSpaceType: XRReferenceSpaceType);
  42964. /**
  42965. * Overwritable function which can be used to update the button's visuals when the state changes
  42966. * @param activeButton the current active button in the UI
  42967. */
  42968. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42969. }
  42970. /**
  42971. * Options to create the webXR UI
  42972. */
  42973. export class WebXREnterExitUIOptions {
  42974. /**
  42975. * Context to enter xr with
  42976. */
  42977. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42978. /**
  42979. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42980. */
  42981. customButtons?: Array<WebXREnterExitUIButton>;
  42982. }
  42983. /**
  42984. * UI to allow the user to enter/exit XR mode
  42985. */
  42986. export class WebXREnterExitUI implements IDisposable {
  42987. private scene;
  42988. private _overlay;
  42989. private _buttons;
  42990. private _activeButton;
  42991. /**
  42992. * Fired every time the active button is changed.
  42993. *
  42994. * When xr is entered via a button that launches xr that button will be the callback parameter
  42995. *
  42996. * When exiting xr the callback parameter will be null)
  42997. */
  42998. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42999. /**
  43000. * Creates UI to allow the user to enter/exit XR mode
  43001. * @param scene the scene to add the ui to
  43002. * @param helper the xr experience helper to enter/exit xr with
  43003. * @param options options to configure the UI
  43004. * @returns the created ui
  43005. */
  43006. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43007. private constructor();
  43008. private _updateButtons;
  43009. /**
  43010. * Disposes of the object
  43011. */
  43012. dispose(): void;
  43013. }
  43014. }
  43015. declare module "babylonjs/Cameras/XR/webXRController" {
  43016. import { Nullable } from "babylonjs/types";
  43017. import { Observable } from "babylonjs/Misc/observable";
  43018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43019. import { Ray } from "babylonjs/Culling/ray";
  43020. import { Scene } from "babylonjs/scene";
  43021. /**
  43022. * Represents an XR input
  43023. */
  43024. export class WebXRController {
  43025. private scene;
  43026. /** The underlying input source for the controller */
  43027. inputSource: XRInputSource;
  43028. private parentContainer;
  43029. /**
  43030. * 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
  43031. */
  43032. grip?: AbstractMesh;
  43033. /**
  43034. * Pointer which can be used to select objects or attach a visible laser to
  43035. */
  43036. pointer: AbstractMesh;
  43037. /**
  43038. * Event that fires when the controller is removed/disposed
  43039. */
  43040. onDisposeObservable: Observable<{}>;
  43041. private _tmpMatrix;
  43042. private _tmpQuaternion;
  43043. private _tmpVector;
  43044. /**
  43045. * Creates the controller
  43046. * @see https://doc.babylonjs.com/how_to/webxr
  43047. * @param scene the scene which the controller should be associated to
  43048. * @param inputSource the underlying input source for the controller
  43049. * @param parentContainer parent that the controller meshes should be children of
  43050. */
  43051. constructor(scene: Scene,
  43052. /** The underlying input source for the controller */
  43053. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43054. /**
  43055. * Updates the controller pose based on the given XRFrame
  43056. * @param xrFrame xr frame to update the pose with
  43057. * @param referenceSpace reference space to use
  43058. */
  43059. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43060. /**
  43061. * Gets a world space ray coming from the controller
  43062. * @param result the resulting ray
  43063. */
  43064. getWorldPointerRayToRef(result: Ray): void;
  43065. /**
  43066. * Disposes of the object
  43067. */
  43068. dispose(): void;
  43069. }
  43070. }
  43071. declare module "babylonjs/Cameras/XR/webXRInput" {
  43072. import { Observable } from "babylonjs/Misc/observable";
  43073. import { IDisposable } from "babylonjs/scene";
  43074. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43075. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43076. /**
  43077. * XR input used to track XR inputs such as controllers/rays
  43078. */
  43079. export class WebXRInput implements IDisposable {
  43080. /**
  43081. * Base experience the input listens to
  43082. */
  43083. baseExperience: WebXRExperienceHelper;
  43084. /**
  43085. * XR controllers being tracked
  43086. */
  43087. controllers: Array<WebXRController>;
  43088. private _frameObserver;
  43089. private _stateObserver;
  43090. /**
  43091. * Event when a controller has been connected/added
  43092. */
  43093. onControllerAddedObservable: Observable<WebXRController>;
  43094. /**
  43095. * Event when a controller has been removed/disconnected
  43096. */
  43097. onControllerRemovedObservable: Observable<WebXRController>;
  43098. /**
  43099. * Initializes the WebXRInput
  43100. * @param baseExperience experience helper which the input should be created for
  43101. */
  43102. constructor(
  43103. /**
  43104. * Base experience the input listens to
  43105. */
  43106. baseExperience: WebXRExperienceHelper);
  43107. private _onInputSourcesChange;
  43108. private _addAndRemoveControllers;
  43109. /**
  43110. * Disposes of the object
  43111. */
  43112. dispose(): void;
  43113. }
  43114. }
  43115. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43117. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43118. /**
  43119. * Enables teleportation
  43120. */
  43121. export class WebXRControllerTeleportation {
  43122. private _teleportationFillColor;
  43123. private _teleportationBorderColor;
  43124. private _tmpRay;
  43125. private _tmpVector;
  43126. /**
  43127. * Creates a WebXRControllerTeleportation
  43128. * @param input input manager to add teleportation to
  43129. * @param floorMeshes floormeshes which can be teleported to
  43130. */
  43131. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43132. }
  43133. }
  43134. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43135. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43136. /**
  43137. * Handles pointer input automatically for the pointer of XR controllers
  43138. */
  43139. export class WebXRControllerPointerSelection {
  43140. private static _idCounter;
  43141. private _tmpRay;
  43142. /**
  43143. * Creates a WebXRControllerPointerSelection
  43144. * @param input input manager to setup pointer selection
  43145. */
  43146. constructor(input: WebXRInput);
  43147. private _convertNormalToDirectionOfRay;
  43148. private _updatePointerDistance;
  43149. }
  43150. }
  43151. declare module "babylonjs/Loading/sceneLoader" {
  43152. import { Observable } from "babylonjs/Misc/observable";
  43153. import { Nullable } from "babylonjs/types";
  43154. import { Scene } from "babylonjs/scene";
  43155. import { Engine } from "babylonjs/Engines/engine";
  43156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43157. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43158. import { AssetContainer } from "babylonjs/assetContainer";
  43159. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43160. import { Skeleton } from "babylonjs/Bones/skeleton";
  43161. /**
  43162. * Class used to represent data loading progression
  43163. */
  43164. export class SceneLoaderProgressEvent {
  43165. /** defines if data length to load can be evaluated */
  43166. readonly lengthComputable: boolean;
  43167. /** defines the loaded data length */
  43168. readonly loaded: number;
  43169. /** defines the data length to load */
  43170. readonly total: number;
  43171. /**
  43172. * Create a new progress event
  43173. * @param lengthComputable defines if data length to load can be evaluated
  43174. * @param loaded defines the loaded data length
  43175. * @param total defines the data length to load
  43176. */
  43177. constructor(
  43178. /** defines if data length to load can be evaluated */
  43179. lengthComputable: boolean,
  43180. /** defines the loaded data length */
  43181. loaded: number,
  43182. /** defines the data length to load */
  43183. total: number);
  43184. /**
  43185. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43186. * @param event defines the source event
  43187. * @returns a new SceneLoaderProgressEvent
  43188. */
  43189. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43190. }
  43191. /**
  43192. * Interface used by SceneLoader plugins to define supported file extensions
  43193. */
  43194. export interface ISceneLoaderPluginExtensions {
  43195. /**
  43196. * Defines the list of supported extensions
  43197. */
  43198. [extension: string]: {
  43199. isBinary: boolean;
  43200. };
  43201. }
  43202. /**
  43203. * Interface used by SceneLoader plugin factory
  43204. */
  43205. export interface ISceneLoaderPluginFactory {
  43206. /**
  43207. * Defines the name of the factory
  43208. */
  43209. name: string;
  43210. /**
  43211. * Function called to create a new plugin
  43212. * @return the new plugin
  43213. */
  43214. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43215. /**
  43216. * Boolean indicating if the plugin can direct load specific data
  43217. */
  43218. canDirectLoad?: (data: string) => boolean;
  43219. }
  43220. /**
  43221. * Interface used to define a SceneLoader plugin
  43222. */
  43223. export interface ISceneLoaderPlugin {
  43224. /**
  43225. * The friendly name of this plugin.
  43226. */
  43227. name: string;
  43228. /**
  43229. * The file extensions supported by this plugin.
  43230. */
  43231. extensions: string | ISceneLoaderPluginExtensions;
  43232. /**
  43233. * Import meshes into a scene.
  43234. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43235. * @param scene The scene to import into
  43236. * @param data The data to import
  43237. * @param rootUrl The root url for scene and resources
  43238. * @param meshes The meshes array to import into
  43239. * @param particleSystems The particle systems array to import into
  43240. * @param skeletons The skeletons array to import into
  43241. * @param onError The callback when import fails
  43242. * @returns True if successful or false otherwise
  43243. */
  43244. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43245. /**
  43246. * Load into a scene.
  43247. * @param scene The scene to load into
  43248. * @param data The data to import
  43249. * @param rootUrl The root url for scene and resources
  43250. * @param onError The callback when import fails
  43251. * @returns true if successful or false otherwise
  43252. */
  43253. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43254. /**
  43255. * The callback that returns true if the data can be directly loaded.
  43256. */
  43257. canDirectLoad?: (data: string) => boolean;
  43258. /**
  43259. * The callback that allows custom handling of the root url based on the response url.
  43260. */
  43261. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43262. /**
  43263. * Load into an asset container.
  43264. * @param scene The scene to load into
  43265. * @param data The data to import
  43266. * @param rootUrl The root url for scene and resources
  43267. * @param onError The callback when import fails
  43268. * @returns The loaded asset container
  43269. */
  43270. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43271. }
  43272. /**
  43273. * Interface used to define an async SceneLoader plugin
  43274. */
  43275. export interface ISceneLoaderPluginAsync {
  43276. /**
  43277. * The friendly name of this plugin.
  43278. */
  43279. name: string;
  43280. /**
  43281. * The file extensions supported by this plugin.
  43282. */
  43283. extensions: string | ISceneLoaderPluginExtensions;
  43284. /**
  43285. * Import meshes into a scene.
  43286. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43287. * @param scene The scene to import into
  43288. * @param data The data to import
  43289. * @param rootUrl The root url for scene and resources
  43290. * @param onProgress The callback when the load progresses
  43291. * @param fileName Defines the name of the file to load
  43292. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43293. */
  43294. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43295. meshes: AbstractMesh[];
  43296. particleSystems: IParticleSystem[];
  43297. skeletons: Skeleton[];
  43298. animationGroups: AnimationGroup[];
  43299. }>;
  43300. /**
  43301. * Load into a scene.
  43302. * @param scene The scene to load into
  43303. * @param data The data to import
  43304. * @param rootUrl The root url for scene and resources
  43305. * @param onProgress The callback when the load progresses
  43306. * @param fileName Defines the name of the file to load
  43307. * @returns Nothing
  43308. */
  43309. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43310. /**
  43311. * The callback that returns true if the data can be directly loaded.
  43312. */
  43313. canDirectLoad?: (data: string) => boolean;
  43314. /**
  43315. * The callback that allows custom handling of the root url based on the response url.
  43316. */
  43317. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43318. /**
  43319. * Load into an asset container.
  43320. * @param scene The scene to load into
  43321. * @param data The data to import
  43322. * @param rootUrl The root url for scene and resources
  43323. * @param onProgress The callback when the load progresses
  43324. * @param fileName Defines the name of the file to load
  43325. * @returns The loaded asset container
  43326. */
  43327. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43328. }
  43329. /**
  43330. * Class used to load scene from various file formats using registered plugins
  43331. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43332. */
  43333. export class SceneLoader {
  43334. /**
  43335. * No logging while loading
  43336. */
  43337. static readonly NO_LOGGING: number;
  43338. /**
  43339. * Minimal logging while loading
  43340. */
  43341. static readonly MINIMAL_LOGGING: number;
  43342. /**
  43343. * Summary logging while loading
  43344. */
  43345. static readonly SUMMARY_LOGGING: number;
  43346. /**
  43347. * Detailled logging while loading
  43348. */
  43349. static readonly DETAILED_LOGGING: number;
  43350. /**
  43351. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43352. */
  43353. static ForceFullSceneLoadingForIncremental: boolean;
  43354. /**
  43355. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43356. */
  43357. static ShowLoadingScreen: boolean;
  43358. /**
  43359. * Defines the current logging level (while loading the scene)
  43360. * @ignorenaming
  43361. */
  43362. static loggingLevel: number;
  43363. /**
  43364. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43365. */
  43366. static CleanBoneMatrixWeights: boolean;
  43367. /**
  43368. * Event raised when a plugin is used to load a scene
  43369. */
  43370. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43371. private static _registeredPlugins;
  43372. private static _getDefaultPlugin;
  43373. private static _getPluginForExtension;
  43374. private static _getPluginForDirectLoad;
  43375. private static _getPluginForFilename;
  43376. private static _getDirectLoad;
  43377. private static _loadData;
  43378. private static _getFileInfo;
  43379. /**
  43380. * Gets a plugin that can load the given extension
  43381. * @param extension defines the extension to load
  43382. * @returns a plugin or null if none works
  43383. */
  43384. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43385. /**
  43386. * Gets a boolean indicating that the given extension can be loaded
  43387. * @param extension defines the extension to load
  43388. * @returns true if the extension is supported
  43389. */
  43390. static IsPluginForExtensionAvailable(extension: string): boolean;
  43391. /**
  43392. * Adds a new plugin to the list of registered plugins
  43393. * @param plugin defines the plugin to add
  43394. */
  43395. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43396. /**
  43397. * Import meshes into a scene
  43398. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43399. * @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)
  43400. * @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)
  43401. * @param scene the instance of BABYLON.Scene to append to
  43402. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43403. * @param onProgress a callback with a progress event for each file being loaded
  43404. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43405. * @param pluginExtension the extension used to determine the plugin
  43406. * @returns The loaded plugin
  43407. */
  43408. 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>;
  43409. /**
  43410. * Import meshes into a scene
  43411. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43412. * @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)
  43413. * @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)
  43414. * @param scene the instance of BABYLON.Scene to append to
  43415. * @param onProgress a callback with a progress event for each file being loaded
  43416. * @param pluginExtension the extension used to determine the plugin
  43417. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43418. */
  43419. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43420. meshes: AbstractMesh[];
  43421. particleSystems: IParticleSystem[];
  43422. skeletons: Skeleton[];
  43423. animationGroups: AnimationGroup[];
  43424. }>;
  43425. /**
  43426. * Load a scene
  43427. * @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)
  43428. * @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)
  43429. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43430. * @param onSuccess a callback with the scene when import succeeds
  43431. * @param onProgress a callback with a progress event for each file being loaded
  43432. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43433. * @param pluginExtension the extension used to determine the plugin
  43434. * @returns The loaded plugin
  43435. */
  43436. 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>;
  43437. /**
  43438. * Load a scene
  43439. * @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)
  43440. * @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)
  43441. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43442. * @param onProgress a callback with a progress event for each file being loaded
  43443. * @param pluginExtension the extension used to determine the plugin
  43444. * @returns The loaded scene
  43445. */
  43446. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43447. /**
  43448. * Append a scene
  43449. * @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)
  43450. * @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)
  43451. * @param scene is the instance of BABYLON.Scene to append to
  43452. * @param onSuccess a callback with the scene when import succeeds
  43453. * @param onProgress a callback with a progress event for each file being loaded
  43454. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43455. * @param pluginExtension the extension used to determine the plugin
  43456. * @returns The loaded plugin
  43457. */
  43458. 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>;
  43459. /**
  43460. * Append a scene
  43461. * @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)
  43462. * @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)
  43463. * @param scene is the instance of BABYLON.Scene to append to
  43464. * @param onProgress a callback with a progress event for each file being loaded
  43465. * @param pluginExtension the extension used to determine the plugin
  43466. * @returns The given scene
  43467. */
  43468. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43469. /**
  43470. * Load a scene into an asset container
  43471. * @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)
  43472. * @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)
  43473. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43474. * @param onSuccess a callback with the scene when import succeeds
  43475. * @param onProgress a callback with a progress event for each file being loaded
  43476. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43477. * @param pluginExtension the extension used to determine the plugin
  43478. * @returns The loaded plugin
  43479. */
  43480. 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>;
  43481. /**
  43482. * Load a scene into an asset container
  43483. * @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)
  43484. * @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)
  43485. * @param scene is the instance of Scene to append to
  43486. * @param onProgress a callback with a progress event for each file being loaded
  43487. * @param pluginExtension the extension used to determine the plugin
  43488. * @returns The loaded asset container
  43489. */
  43490. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43491. }
  43492. }
  43493. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43494. import { Scene } from "babylonjs/scene";
  43495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43496. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43497. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43498. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43499. /**
  43500. * Generic Controller
  43501. */
  43502. export class GenericController extends WebVRController {
  43503. /**
  43504. * Base Url for the controller model.
  43505. */
  43506. static readonly MODEL_BASE_URL: string;
  43507. /**
  43508. * File name for the controller model.
  43509. */
  43510. static readonly MODEL_FILENAME: string;
  43511. /**
  43512. * Creates a new GenericController from a gamepad
  43513. * @param vrGamepad the gamepad that the controller should be created from
  43514. */
  43515. constructor(vrGamepad: any);
  43516. /**
  43517. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43518. * @param scene scene in which to add meshes
  43519. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43520. */
  43521. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43522. /**
  43523. * Called once for each button that changed state since the last frame
  43524. * @param buttonIdx Which button index changed
  43525. * @param state New state of the button
  43526. * @param changes Which properties on the state changed since last frame
  43527. */
  43528. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43529. }
  43530. }
  43531. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43532. import { Observable } from "babylonjs/Misc/observable";
  43533. import { Scene } from "babylonjs/scene";
  43534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43535. import { Ray } from "babylonjs/Culling/ray";
  43536. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43537. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43538. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43539. /**
  43540. * Defines the WindowsMotionController object that the state of the windows motion controller
  43541. */
  43542. export class WindowsMotionController extends WebVRController {
  43543. /**
  43544. * The base url used to load the left and right controller models
  43545. */
  43546. static MODEL_BASE_URL: string;
  43547. /**
  43548. * The name of the left controller model file
  43549. */
  43550. static MODEL_LEFT_FILENAME: string;
  43551. /**
  43552. * The name of the right controller model file
  43553. */
  43554. static MODEL_RIGHT_FILENAME: string;
  43555. /**
  43556. * The controller name prefix for this controller type
  43557. */
  43558. static readonly GAMEPAD_ID_PREFIX: string;
  43559. /**
  43560. * The controller id pattern for this controller type
  43561. */
  43562. private static readonly GAMEPAD_ID_PATTERN;
  43563. private _loadedMeshInfo;
  43564. private readonly _mapping;
  43565. /**
  43566. * Fired when the trackpad on this controller is clicked
  43567. */
  43568. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43569. /**
  43570. * Fired when the trackpad on this controller is modified
  43571. */
  43572. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43573. /**
  43574. * The current x and y values of this controller's trackpad
  43575. */
  43576. trackpad: StickValues;
  43577. /**
  43578. * Creates a new WindowsMotionController from a gamepad
  43579. * @param vrGamepad the gamepad that the controller should be created from
  43580. */
  43581. constructor(vrGamepad: any);
  43582. /**
  43583. * Fired when the trigger on this controller is modified
  43584. */
  43585. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43586. /**
  43587. * Fired when the menu button on this controller is modified
  43588. */
  43589. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43590. /**
  43591. * Fired when the grip button on this controller is modified
  43592. */
  43593. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43594. /**
  43595. * Fired when the thumbstick button on this controller is modified
  43596. */
  43597. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43598. /**
  43599. * Fired when the touchpad button on this controller is modified
  43600. */
  43601. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43602. /**
  43603. * Fired when the touchpad values on this controller are modified
  43604. */
  43605. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43606. private _updateTrackpad;
  43607. /**
  43608. * Called once per frame by the engine.
  43609. */
  43610. update(): void;
  43611. /**
  43612. * Called once for each button that changed state since the last frame
  43613. * @param buttonIdx Which button index changed
  43614. * @param state New state of the button
  43615. * @param changes Which properties on the state changed since last frame
  43616. */
  43617. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43618. /**
  43619. * Moves the buttons on the controller mesh based on their current state
  43620. * @param buttonName the name of the button to move
  43621. * @param buttonValue the value of the button which determines the buttons new position
  43622. */
  43623. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43624. /**
  43625. * Moves the axis on the controller mesh based on its current state
  43626. * @param axis the index of the axis
  43627. * @param axisValue the value of the axis which determines the meshes new position
  43628. * @hidden
  43629. */
  43630. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43631. /**
  43632. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43633. * @param scene scene in which to add meshes
  43634. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43635. */
  43636. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43637. /**
  43638. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43639. * can be transformed by button presses and axes values, based on this._mapping.
  43640. *
  43641. * @param scene scene in which the meshes exist
  43642. * @param meshes list of meshes that make up the controller model to process
  43643. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43644. */
  43645. private processModel;
  43646. private createMeshInfo;
  43647. /**
  43648. * Gets the ray of the controller in the direction the controller is pointing
  43649. * @param length the length the resulting ray should be
  43650. * @returns a ray in the direction the controller is pointing
  43651. */
  43652. getForwardRay(length?: number): Ray;
  43653. /**
  43654. * Disposes of the controller
  43655. */
  43656. dispose(): void;
  43657. }
  43658. }
  43659. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43660. import { Observable } from "babylonjs/Misc/observable";
  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. * Oculus Touch Controller
  43668. */
  43669. export class OculusTouchController extends WebVRController {
  43670. /**
  43671. * Base Url for the controller model.
  43672. */
  43673. static MODEL_BASE_URL: string;
  43674. /**
  43675. * File name for the left controller model.
  43676. */
  43677. static MODEL_LEFT_FILENAME: string;
  43678. /**
  43679. * File name for the right controller model.
  43680. */
  43681. static MODEL_RIGHT_FILENAME: string;
  43682. /**
  43683. * Base Url for the Quest controller model.
  43684. */
  43685. static QUEST_MODEL_BASE_URL: string;
  43686. /**
  43687. * @hidden
  43688. * If the controllers are running on a device that needs the updated Quest controller models
  43689. */
  43690. static _IsQuest: boolean;
  43691. /**
  43692. * Fired when the secondary trigger on this controller is modified
  43693. */
  43694. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43695. /**
  43696. * Fired when the thumb rest on this controller is modified
  43697. */
  43698. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43699. /**
  43700. * Creates a new OculusTouchController from a gamepad
  43701. * @param vrGamepad the gamepad that the controller should be created from
  43702. */
  43703. constructor(vrGamepad: any);
  43704. /**
  43705. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43706. * @param scene scene in which to add meshes
  43707. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43708. */
  43709. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43710. /**
  43711. * Fired when the A button on this controller is modified
  43712. */
  43713. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43714. /**
  43715. * Fired when the B button on this controller is modified
  43716. */
  43717. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43718. /**
  43719. * Fired when the X button on this controller is modified
  43720. */
  43721. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43722. /**
  43723. * Fired when the Y button on this controller is modified
  43724. */
  43725. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43726. /**
  43727. * Called once for each button that changed state since the last frame
  43728. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43729. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43730. * 2) secondary trigger (same)
  43731. * 3) A (right) X (left), touch, pressed = value
  43732. * 4) B / Y
  43733. * 5) thumb rest
  43734. * @param buttonIdx Which button index changed
  43735. * @param state New state of the button
  43736. * @param changes Which properties on the state changed since last frame
  43737. */
  43738. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43739. }
  43740. }
  43741. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43742. import { Scene } from "babylonjs/scene";
  43743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43744. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43745. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43746. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43747. import { Observable } from "babylonjs/Misc/observable";
  43748. /**
  43749. * Vive Controller
  43750. */
  43751. export class ViveController extends WebVRController {
  43752. /**
  43753. * Base Url for the controller model.
  43754. */
  43755. static MODEL_BASE_URL: string;
  43756. /**
  43757. * File name for the controller model.
  43758. */
  43759. static MODEL_FILENAME: string;
  43760. /**
  43761. * Creates a new ViveController from a gamepad
  43762. * @param vrGamepad the gamepad that the controller should be created from
  43763. */
  43764. constructor(vrGamepad: any);
  43765. /**
  43766. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43767. * @param scene scene in which to add meshes
  43768. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43769. */
  43770. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43771. /**
  43772. * Fired when the left button on this controller is modified
  43773. */
  43774. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43775. /**
  43776. * Fired when the right button on this controller is modified
  43777. */
  43778. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43779. /**
  43780. * Fired when the menu button on this controller is modified
  43781. */
  43782. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43783. /**
  43784. * Called once for each button that changed state since the last frame
  43785. * Vive mapping:
  43786. * 0: touchpad
  43787. * 1: trigger
  43788. * 2: left AND right buttons
  43789. * 3: menu button
  43790. * @param buttonIdx Which button index changed
  43791. * @param state New state of the button
  43792. * @param changes Which properties on the state changed since last frame
  43793. */
  43794. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43795. }
  43796. }
  43797. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43798. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43799. /**
  43800. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43801. */
  43802. export class WebXRControllerModelLoader {
  43803. /**
  43804. * Creates the WebXRControllerModelLoader
  43805. * @param input xr input that creates the controllers
  43806. */
  43807. constructor(input: WebXRInput);
  43808. }
  43809. }
  43810. declare module "babylonjs/Cameras/XR/index" {
  43811. export * from "babylonjs/Cameras/XR/webXRCamera";
  43812. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43813. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43814. export * from "babylonjs/Cameras/XR/webXRInput";
  43815. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43816. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43817. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43818. export * from "babylonjs/Cameras/XR/webXRController";
  43819. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43820. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43821. }
  43822. declare module "babylonjs/Cameras/RigModes/index" {
  43823. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43824. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43825. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43826. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43827. }
  43828. declare module "babylonjs/Cameras/index" {
  43829. export * from "babylonjs/Cameras/Inputs/index";
  43830. export * from "babylonjs/Cameras/cameraInputsManager";
  43831. export * from "babylonjs/Cameras/camera";
  43832. export * from "babylonjs/Cameras/targetCamera";
  43833. export * from "babylonjs/Cameras/freeCamera";
  43834. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43835. export * from "babylonjs/Cameras/touchCamera";
  43836. export * from "babylonjs/Cameras/arcRotateCamera";
  43837. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43838. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43839. export * from "babylonjs/Cameras/flyCamera";
  43840. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43841. export * from "babylonjs/Cameras/followCamera";
  43842. export * from "babylonjs/Cameras/followCameraInputsManager";
  43843. export * from "babylonjs/Cameras/gamepadCamera";
  43844. export * from "babylonjs/Cameras/Stereoscopic/index";
  43845. export * from "babylonjs/Cameras/universalCamera";
  43846. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43847. export * from "babylonjs/Cameras/VR/index";
  43848. export * from "babylonjs/Cameras/XR/index";
  43849. export * from "babylonjs/Cameras/RigModes/index";
  43850. }
  43851. declare module "babylonjs/Collisions/index" {
  43852. export * from "babylonjs/Collisions/collider";
  43853. export * from "babylonjs/Collisions/collisionCoordinator";
  43854. export * from "babylonjs/Collisions/pickingInfo";
  43855. export * from "babylonjs/Collisions/intersectionInfo";
  43856. export * from "babylonjs/Collisions/meshCollisionData";
  43857. }
  43858. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43859. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43860. import { Vector3 } from "babylonjs/Maths/math.vector";
  43861. import { Ray } from "babylonjs/Culling/ray";
  43862. import { Plane } from "babylonjs/Maths/math.plane";
  43863. /**
  43864. * Contains an array of blocks representing the octree
  43865. */
  43866. export interface IOctreeContainer<T> {
  43867. /**
  43868. * Blocks within the octree
  43869. */
  43870. blocks: Array<OctreeBlock<T>>;
  43871. }
  43872. /**
  43873. * Class used to store a cell in an octree
  43874. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43875. */
  43876. export class OctreeBlock<T> {
  43877. /**
  43878. * Gets the content of the current block
  43879. */
  43880. entries: T[];
  43881. /**
  43882. * Gets the list of block children
  43883. */
  43884. blocks: Array<OctreeBlock<T>>;
  43885. private _depth;
  43886. private _maxDepth;
  43887. private _capacity;
  43888. private _minPoint;
  43889. private _maxPoint;
  43890. private _boundingVectors;
  43891. private _creationFunc;
  43892. /**
  43893. * Creates a new block
  43894. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43895. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43896. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43897. * @param depth defines the current depth of this block in the octree
  43898. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43899. * @param creationFunc defines a callback to call when an element is added to the block
  43900. */
  43901. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43902. /**
  43903. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43904. */
  43905. readonly capacity: number;
  43906. /**
  43907. * Gets the minimum vector (in world space) of the block's bounding box
  43908. */
  43909. readonly minPoint: Vector3;
  43910. /**
  43911. * Gets the maximum vector (in world space) of the block's bounding box
  43912. */
  43913. readonly maxPoint: Vector3;
  43914. /**
  43915. * Add a new element to this block
  43916. * @param entry defines the element to add
  43917. */
  43918. addEntry(entry: T): void;
  43919. /**
  43920. * Remove an element from this block
  43921. * @param entry defines the element to remove
  43922. */
  43923. removeEntry(entry: T): void;
  43924. /**
  43925. * Add an array of elements to this block
  43926. * @param entries defines the array of elements to add
  43927. */
  43928. addEntries(entries: T[]): void;
  43929. /**
  43930. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43931. * @param frustumPlanes defines the frustum planes to test
  43932. * @param selection defines the array to store current content if selection is positive
  43933. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43934. */
  43935. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43936. /**
  43937. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43938. * @param sphereCenter defines the bounding sphere center
  43939. * @param sphereRadius defines the bounding sphere radius
  43940. * @param selection defines the array to store current content if selection is positive
  43941. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43942. */
  43943. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43944. /**
  43945. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43946. * @param ray defines the ray to test with
  43947. * @param selection defines the array to store current content if selection is positive
  43948. */
  43949. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43950. /**
  43951. * Subdivide the content into child blocks (this block will then be empty)
  43952. */
  43953. createInnerBlocks(): void;
  43954. /**
  43955. * @hidden
  43956. */
  43957. 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;
  43958. }
  43959. }
  43960. declare module "babylonjs/Culling/Octrees/octree" {
  43961. import { SmartArray } from "babylonjs/Misc/smartArray";
  43962. import { Vector3 } from "babylonjs/Maths/math.vector";
  43963. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43965. import { Ray } from "babylonjs/Culling/ray";
  43966. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43967. import { Plane } from "babylonjs/Maths/math.plane";
  43968. /**
  43969. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43970. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43971. */
  43972. export class Octree<T> {
  43973. /** 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.) */
  43974. maxDepth: number;
  43975. /**
  43976. * Blocks within the octree containing objects
  43977. */
  43978. blocks: Array<OctreeBlock<T>>;
  43979. /**
  43980. * Content stored in the octree
  43981. */
  43982. dynamicContent: T[];
  43983. private _maxBlockCapacity;
  43984. private _selectionContent;
  43985. private _creationFunc;
  43986. /**
  43987. * Creates a octree
  43988. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43989. * @param creationFunc function to be used to instatiate the octree
  43990. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43991. * @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.)
  43992. */
  43993. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43994. /** 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.) */
  43995. maxDepth?: number);
  43996. /**
  43997. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43998. * @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);
  43999. * @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);
  44000. * @param entries meshes to be added to the octree blocks
  44001. */
  44002. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44003. /**
  44004. * Adds a mesh to the octree
  44005. * @param entry Mesh to add to the octree
  44006. */
  44007. addMesh(entry: T): void;
  44008. /**
  44009. * Remove an element from the octree
  44010. * @param entry defines the element to remove
  44011. */
  44012. removeMesh(entry: T): void;
  44013. /**
  44014. * Selects an array of meshes within the frustum
  44015. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44016. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44017. * @returns array of meshes within the frustum
  44018. */
  44019. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44020. /**
  44021. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44022. * @param sphereCenter defines the bounding sphere center
  44023. * @param sphereRadius defines the bounding sphere radius
  44024. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44025. * @returns an array of objects that intersect the sphere
  44026. */
  44027. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44028. /**
  44029. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44030. * @param ray defines the ray to test with
  44031. * @returns array of intersected objects
  44032. */
  44033. intersectsRay(ray: Ray): SmartArray<T>;
  44034. /**
  44035. * Adds a mesh into the octree block if it intersects the block
  44036. */
  44037. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44038. /**
  44039. * Adds a submesh into the octree block if it intersects the block
  44040. */
  44041. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44042. }
  44043. }
  44044. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44045. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44046. import { Scene } from "babylonjs/scene";
  44047. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44049. import { Ray } from "babylonjs/Culling/ray";
  44050. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44051. import { Collider } from "babylonjs/Collisions/collider";
  44052. module "babylonjs/scene" {
  44053. interface Scene {
  44054. /**
  44055. * @hidden
  44056. * Backing Filed
  44057. */
  44058. _selectionOctree: Octree<AbstractMesh>;
  44059. /**
  44060. * Gets the octree used to boost mesh selection (picking)
  44061. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44062. */
  44063. selectionOctree: Octree<AbstractMesh>;
  44064. /**
  44065. * Creates or updates the octree used to boost selection (picking)
  44066. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44067. * @param maxCapacity defines the maximum capacity per leaf
  44068. * @param maxDepth defines the maximum depth of the octree
  44069. * @returns an octree of AbstractMesh
  44070. */
  44071. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44072. }
  44073. }
  44074. module "babylonjs/Meshes/abstractMesh" {
  44075. interface AbstractMesh {
  44076. /**
  44077. * @hidden
  44078. * Backing Field
  44079. */
  44080. _submeshesOctree: Octree<SubMesh>;
  44081. /**
  44082. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44083. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44084. * @param maxCapacity defines the maximum size of each block (64 by default)
  44085. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44086. * @returns the new octree
  44087. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44088. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44089. */
  44090. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44091. }
  44092. }
  44093. /**
  44094. * Defines the octree scene component responsible to manage any octrees
  44095. * in a given scene.
  44096. */
  44097. export class OctreeSceneComponent {
  44098. /**
  44099. * The component name help to identify the component in the list of scene components.
  44100. */
  44101. readonly name: string;
  44102. /**
  44103. * The scene the component belongs to.
  44104. */
  44105. scene: Scene;
  44106. /**
  44107. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44108. */
  44109. readonly checksIsEnabled: boolean;
  44110. /**
  44111. * Creates a new instance of the component for the given scene
  44112. * @param scene Defines the scene to register the component in
  44113. */
  44114. constructor(scene: Scene);
  44115. /**
  44116. * Registers the component in a given scene
  44117. */
  44118. register(): void;
  44119. /**
  44120. * Return the list of active meshes
  44121. * @returns the list of active meshes
  44122. */
  44123. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44124. /**
  44125. * Return the list of active sub meshes
  44126. * @param mesh The mesh to get the candidates sub meshes from
  44127. * @returns the list of active sub meshes
  44128. */
  44129. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44130. private _tempRay;
  44131. /**
  44132. * Return the list of sub meshes intersecting with a given local ray
  44133. * @param mesh defines the mesh to find the submesh for
  44134. * @param localRay defines the ray in local space
  44135. * @returns the list of intersecting sub meshes
  44136. */
  44137. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44138. /**
  44139. * Return the list of sub meshes colliding with a collider
  44140. * @param mesh defines the mesh to find the submesh for
  44141. * @param collider defines the collider to evaluate the collision against
  44142. * @returns the list of colliding sub meshes
  44143. */
  44144. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44145. /**
  44146. * Rebuilds the elements related to this component in case of
  44147. * context lost for instance.
  44148. */
  44149. rebuild(): void;
  44150. /**
  44151. * Disposes the component and the associated ressources.
  44152. */
  44153. dispose(): void;
  44154. }
  44155. }
  44156. declare module "babylonjs/Culling/Octrees/index" {
  44157. export * from "babylonjs/Culling/Octrees/octree";
  44158. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44159. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44160. }
  44161. declare module "babylonjs/Culling/index" {
  44162. export * from "babylonjs/Culling/boundingBox";
  44163. export * from "babylonjs/Culling/boundingInfo";
  44164. export * from "babylonjs/Culling/boundingSphere";
  44165. export * from "babylonjs/Culling/Octrees/index";
  44166. export * from "babylonjs/Culling/ray";
  44167. }
  44168. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44169. import { IDisposable, Scene } from "babylonjs/scene";
  44170. import { Nullable } from "babylonjs/types";
  44171. import { Observable } from "babylonjs/Misc/observable";
  44172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44173. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44174. import { Camera } from "babylonjs/Cameras/camera";
  44175. /**
  44176. * Renders a layer on top of an existing scene
  44177. */
  44178. export class UtilityLayerRenderer implements IDisposable {
  44179. /** the original scene that will be rendered on top of */
  44180. originalScene: Scene;
  44181. private _pointerCaptures;
  44182. private _lastPointerEvents;
  44183. private static _DefaultUtilityLayer;
  44184. private static _DefaultKeepDepthUtilityLayer;
  44185. private _sharedGizmoLight;
  44186. private _renderCamera;
  44187. /**
  44188. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44189. * @returns the camera that is used when rendering the utility layer
  44190. */
  44191. getRenderCamera(): Nullable<Camera>;
  44192. /**
  44193. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44194. * @param cam the camera that should be used when rendering the utility layer
  44195. */
  44196. setRenderCamera(cam: Nullable<Camera>): void;
  44197. /**
  44198. * @hidden
  44199. * Light which used by gizmos to get light shading
  44200. */
  44201. _getSharedGizmoLight(): HemisphericLight;
  44202. /**
  44203. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44204. */
  44205. pickUtilitySceneFirst: boolean;
  44206. /**
  44207. * 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)
  44208. */
  44209. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44210. /**
  44211. * 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)
  44212. */
  44213. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44214. /**
  44215. * The scene that is rendered on top of the original scene
  44216. */
  44217. utilityLayerScene: Scene;
  44218. /**
  44219. * If the utility layer should automatically be rendered on top of existing scene
  44220. */
  44221. shouldRender: boolean;
  44222. /**
  44223. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44224. */
  44225. onlyCheckPointerDownEvents: boolean;
  44226. /**
  44227. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44228. */
  44229. processAllEvents: boolean;
  44230. /**
  44231. * Observable raised when the pointer move from the utility layer scene to the main scene
  44232. */
  44233. onPointerOutObservable: Observable<number>;
  44234. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44235. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44236. private _afterRenderObserver;
  44237. private _sceneDisposeObserver;
  44238. private _originalPointerObserver;
  44239. /**
  44240. * Instantiates a UtilityLayerRenderer
  44241. * @param originalScene the original scene that will be rendered on top of
  44242. * @param handleEvents boolean indicating if the utility layer should handle events
  44243. */
  44244. constructor(
  44245. /** the original scene that will be rendered on top of */
  44246. originalScene: Scene, handleEvents?: boolean);
  44247. private _notifyObservers;
  44248. /**
  44249. * Renders the utility layers scene on top of the original scene
  44250. */
  44251. render(): void;
  44252. /**
  44253. * Disposes of the renderer
  44254. */
  44255. dispose(): void;
  44256. private _updateCamera;
  44257. }
  44258. }
  44259. declare module "babylonjs/Gizmos/gizmo" {
  44260. import { Nullable } from "babylonjs/types";
  44261. import { IDisposable } from "babylonjs/scene";
  44262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44263. import { Mesh } from "babylonjs/Meshes/mesh";
  44264. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44265. /**
  44266. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44267. */
  44268. export class Gizmo implements IDisposable {
  44269. /** The utility layer the gizmo will be added to */
  44270. gizmoLayer: UtilityLayerRenderer;
  44271. /**
  44272. * The root mesh of the gizmo
  44273. */
  44274. _rootMesh: Mesh;
  44275. private _attachedMesh;
  44276. /**
  44277. * Ratio for the scale of the gizmo (Default: 1)
  44278. */
  44279. scaleRatio: number;
  44280. /**
  44281. * If a custom mesh has been set (Default: false)
  44282. */
  44283. protected _customMeshSet: boolean;
  44284. /**
  44285. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44286. * * When set, interactions will be enabled
  44287. */
  44288. attachedMesh: Nullable<AbstractMesh>;
  44289. /**
  44290. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44291. * @param mesh The mesh to replace the default mesh of the gizmo
  44292. */
  44293. setCustomMesh(mesh: Mesh): void;
  44294. /**
  44295. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44296. */
  44297. updateGizmoRotationToMatchAttachedMesh: boolean;
  44298. /**
  44299. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44300. */
  44301. updateGizmoPositionToMatchAttachedMesh: boolean;
  44302. /**
  44303. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44304. */
  44305. updateScale: boolean;
  44306. protected _interactionsEnabled: boolean;
  44307. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44308. private _beforeRenderObserver;
  44309. private _tempVector;
  44310. /**
  44311. * Creates a gizmo
  44312. * @param gizmoLayer The utility layer the gizmo will be added to
  44313. */
  44314. constructor(
  44315. /** The utility layer the gizmo will be added to */
  44316. gizmoLayer?: UtilityLayerRenderer);
  44317. /**
  44318. * Updates the gizmo to match the attached mesh's position/rotation
  44319. */
  44320. protected _update(): void;
  44321. /**
  44322. * Disposes of the gizmo
  44323. */
  44324. dispose(): void;
  44325. }
  44326. }
  44327. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44328. import { Observable } from "babylonjs/Misc/observable";
  44329. import { Nullable } from "babylonjs/types";
  44330. import { Vector3 } from "babylonjs/Maths/math.vector";
  44331. import { Color3 } from "babylonjs/Maths/math.color";
  44332. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44334. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44335. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44336. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44337. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44338. import { Scene } from "babylonjs/scene";
  44339. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44340. /**
  44341. * Single plane drag gizmo
  44342. */
  44343. export class PlaneDragGizmo extends Gizmo {
  44344. /**
  44345. * Drag behavior responsible for the gizmos dragging interactions
  44346. */
  44347. dragBehavior: PointerDragBehavior;
  44348. private _pointerObserver;
  44349. /**
  44350. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44351. */
  44352. snapDistance: number;
  44353. /**
  44354. * Event that fires each time the gizmo snaps to a new location.
  44355. * * snapDistance is the the change in distance
  44356. */
  44357. onSnapObservable: Observable<{
  44358. snapDistance: number;
  44359. }>;
  44360. private _plane;
  44361. private _coloredMaterial;
  44362. private _hoverMaterial;
  44363. private _isEnabled;
  44364. private _parent;
  44365. /** @hidden */
  44366. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44367. /** @hidden */
  44368. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44369. /**
  44370. * Creates a PlaneDragGizmo
  44371. * @param gizmoLayer The utility layer the gizmo will be added to
  44372. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44373. * @param color The color of the gizmo
  44374. */
  44375. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44376. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44377. /**
  44378. * If the gizmo is enabled
  44379. */
  44380. isEnabled: boolean;
  44381. /**
  44382. * Disposes of the gizmo
  44383. */
  44384. dispose(): void;
  44385. }
  44386. }
  44387. declare module "babylonjs/Gizmos/positionGizmo" {
  44388. import { Observable } from "babylonjs/Misc/observable";
  44389. import { Nullable } from "babylonjs/types";
  44390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44391. import { Mesh } from "babylonjs/Meshes/mesh";
  44392. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44393. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44394. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44395. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44396. /**
  44397. * Gizmo that enables dragging a mesh along 3 axis
  44398. */
  44399. export class PositionGizmo extends Gizmo {
  44400. /**
  44401. * Internal gizmo used for interactions on the x axis
  44402. */
  44403. xGizmo: AxisDragGizmo;
  44404. /**
  44405. * Internal gizmo used for interactions on the y axis
  44406. */
  44407. yGizmo: AxisDragGizmo;
  44408. /**
  44409. * Internal gizmo used for interactions on the z axis
  44410. */
  44411. zGizmo: AxisDragGizmo;
  44412. /**
  44413. * Internal gizmo used for interactions on the yz plane
  44414. */
  44415. xPlaneGizmo: PlaneDragGizmo;
  44416. /**
  44417. * Internal gizmo used for interactions on the xz plane
  44418. */
  44419. yPlaneGizmo: PlaneDragGizmo;
  44420. /**
  44421. * Internal gizmo used for interactions on the xy plane
  44422. */
  44423. zPlaneGizmo: PlaneDragGizmo;
  44424. /**
  44425. * private variables
  44426. */
  44427. private _meshAttached;
  44428. private _updateGizmoRotationToMatchAttachedMesh;
  44429. private _snapDistance;
  44430. private _scaleRatio;
  44431. /** Fires an event when any of it's sub gizmos are dragged */
  44432. onDragStartObservable: Observable<unknown>;
  44433. /** Fires an event when any of it's sub gizmos are released from dragging */
  44434. onDragEndObservable: Observable<unknown>;
  44435. /**
  44436. * If set to true, planar drag is enabled
  44437. */
  44438. private _planarGizmoEnabled;
  44439. attachedMesh: Nullable<AbstractMesh>;
  44440. /**
  44441. * Creates a PositionGizmo
  44442. * @param gizmoLayer The utility layer the gizmo will be added to
  44443. */
  44444. constructor(gizmoLayer?: UtilityLayerRenderer);
  44445. /**
  44446. * If the planar drag gizmo is enabled
  44447. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44448. */
  44449. planarGizmoEnabled: boolean;
  44450. updateGizmoRotationToMatchAttachedMesh: boolean;
  44451. /**
  44452. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44453. */
  44454. snapDistance: number;
  44455. /**
  44456. * Ratio for the scale of the gizmo (Default: 1)
  44457. */
  44458. scaleRatio: number;
  44459. /**
  44460. * Disposes of the gizmo
  44461. */
  44462. dispose(): void;
  44463. /**
  44464. * CustomMeshes are not supported by this gizmo
  44465. * @param mesh The mesh to replace the default mesh of the gizmo
  44466. */
  44467. setCustomMesh(mesh: Mesh): void;
  44468. }
  44469. }
  44470. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44471. import { Observable } from "babylonjs/Misc/observable";
  44472. import { Nullable } from "babylonjs/types";
  44473. import { Vector3 } from "babylonjs/Maths/math.vector";
  44474. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44476. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44477. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44478. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44479. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44480. import { Scene } from "babylonjs/scene";
  44481. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44482. import { Color3 } from "babylonjs/Maths/math.color";
  44483. /**
  44484. * Single axis drag gizmo
  44485. */
  44486. export class AxisDragGizmo extends Gizmo {
  44487. /**
  44488. * Drag behavior responsible for the gizmos dragging interactions
  44489. */
  44490. dragBehavior: PointerDragBehavior;
  44491. private _pointerObserver;
  44492. /**
  44493. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44494. */
  44495. snapDistance: number;
  44496. /**
  44497. * Event that fires each time the gizmo snaps to a new location.
  44498. * * snapDistance is the the change in distance
  44499. */
  44500. onSnapObservable: Observable<{
  44501. snapDistance: number;
  44502. }>;
  44503. private _isEnabled;
  44504. private _parent;
  44505. private _arrow;
  44506. private _coloredMaterial;
  44507. private _hoverMaterial;
  44508. /** @hidden */
  44509. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44510. /** @hidden */
  44511. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44512. /**
  44513. * Creates an AxisDragGizmo
  44514. * @param gizmoLayer The utility layer the gizmo will be added to
  44515. * @param dragAxis The axis which the gizmo will be able to drag on
  44516. * @param color The color of the gizmo
  44517. */
  44518. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44519. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44520. /**
  44521. * If the gizmo is enabled
  44522. */
  44523. isEnabled: boolean;
  44524. /**
  44525. * Disposes of the gizmo
  44526. */
  44527. dispose(): void;
  44528. }
  44529. }
  44530. declare module "babylonjs/Debug/axesViewer" {
  44531. import { Vector3 } from "babylonjs/Maths/math.vector";
  44532. import { Nullable } from "babylonjs/types";
  44533. import { Scene } from "babylonjs/scene";
  44534. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44535. /**
  44536. * The Axes viewer will show 3 axes in a specific point in space
  44537. */
  44538. export class AxesViewer {
  44539. private _xAxis;
  44540. private _yAxis;
  44541. private _zAxis;
  44542. private _scaleLinesFactor;
  44543. private _instanced;
  44544. /**
  44545. * Gets the hosting scene
  44546. */
  44547. scene: Scene;
  44548. /**
  44549. * Gets or sets a number used to scale line length
  44550. */
  44551. scaleLines: number;
  44552. /** Gets the node hierarchy used to render x-axis */
  44553. readonly xAxis: TransformNode;
  44554. /** Gets the node hierarchy used to render y-axis */
  44555. readonly yAxis: TransformNode;
  44556. /** Gets the node hierarchy used to render z-axis */
  44557. readonly zAxis: TransformNode;
  44558. /**
  44559. * Creates a new AxesViewer
  44560. * @param scene defines the hosting scene
  44561. * @param scaleLines defines a number used to scale line length (1 by default)
  44562. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44563. * @param xAxis defines the node hierarchy used to render the x-axis
  44564. * @param yAxis defines the node hierarchy used to render the y-axis
  44565. * @param zAxis defines the node hierarchy used to render the z-axis
  44566. */
  44567. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44568. /**
  44569. * Force the viewer to update
  44570. * @param position defines the position of the viewer
  44571. * @param xaxis defines the x axis of the viewer
  44572. * @param yaxis defines the y axis of the viewer
  44573. * @param zaxis defines the z axis of the viewer
  44574. */
  44575. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44576. /**
  44577. * Creates an instance of this axes viewer.
  44578. * @returns a new axes viewer with instanced meshes
  44579. */
  44580. createInstance(): AxesViewer;
  44581. /** Releases resources */
  44582. dispose(): void;
  44583. private static _SetRenderingGroupId;
  44584. }
  44585. }
  44586. declare module "babylonjs/Debug/boneAxesViewer" {
  44587. import { Nullable } from "babylonjs/types";
  44588. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44589. import { Vector3 } from "babylonjs/Maths/math.vector";
  44590. import { Mesh } from "babylonjs/Meshes/mesh";
  44591. import { Bone } from "babylonjs/Bones/bone";
  44592. import { Scene } from "babylonjs/scene";
  44593. /**
  44594. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44595. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44596. */
  44597. export class BoneAxesViewer extends AxesViewer {
  44598. /**
  44599. * Gets or sets the target mesh where to display the axes viewer
  44600. */
  44601. mesh: Nullable<Mesh>;
  44602. /**
  44603. * Gets or sets the target bone where to display the axes viewer
  44604. */
  44605. bone: Nullable<Bone>;
  44606. /** Gets current position */
  44607. pos: Vector3;
  44608. /** Gets direction of X axis */
  44609. xaxis: Vector3;
  44610. /** Gets direction of Y axis */
  44611. yaxis: Vector3;
  44612. /** Gets direction of Z axis */
  44613. zaxis: Vector3;
  44614. /**
  44615. * Creates a new BoneAxesViewer
  44616. * @param scene defines the hosting scene
  44617. * @param bone defines the target bone
  44618. * @param mesh defines the target mesh
  44619. * @param scaleLines defines a scaling factor for line length (1 by default)
  44620. */
  44621. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44622. /**
  44623. * Force the viewer to update
  44624. */
  44625. update(): void;
  44626. /** Releases resources */
  44627. dispose(): void;
  44628. }
  44629. }
  44630. declare module "babylonjs/Debug/debugLayer" {
  44631. import { Scene } from "babylonjs/scene";
  44632. /**
  44633. * Interface used to define scene explorer extensibility option
  44634. */
  44635. export interface IExplorerExtensibilityOption {
  44636. /**
  44637. * Define the option label
  44638. */
  44639. label: string;
  44640. /**
  44641. * Defines the action to execute on click
  44642. */
  44643. action: (entity: any) => void;
  44644. }
  44645. /**
  44646. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44647. */
  44648. export interface IExplorerExtensibilityGroup {
  44649. /**
  44650. * Defines a predicate to test if a given type mut be extended
  44651. */
  44652. predicate: (entity: any) => boolean;
  44653. /**
  44654. * Gets the list of options added to a type
  44655. */
  44656. entries: IExplorerExtensibilityOption[];
  44657. }
  44658. /**
  44659. * Interface used to define the options to use to create the Inspector
  44660. */
  44661. export interface IInspectorOptions {
  44662. /**
  44663. * Display in overlay mode (default: false)
  44664. */
  44665. overlay?: boolean;
  44666. /**
  44667. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44668. */
  44669. globalRoot?: HTMLElement;
  44670. /**
  44671. * Display the Scene explorer
  44672. */
  44673. showExplorer?: boolean;
  44674. /**
  44675. * Display the property inspector
  44676. */
  44677. showInspector?: boolean;
  44678. /**
  44679. * Display in embed mode (both panes on the right)
  44680. */
  44681. embedMode?: boolean;
  44682. /**
  44683. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44684. */
  44685. handleResize?: boolean;
  44686. /**
  44687. * Allow the panes to popup (default: true)
  44688. */
  44689. enablePopup?: boolean;
  44690. /**
  44691. * Allow the panes to be closed by users (default: true)
  44692. */
  44693. enableClose?: boolean;
  44694. /**
  44695. * Optional list of extensibility entries
  44696. */
  44697. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44698. /**
  44699. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44700. */
  44701. inspectorURL?: string;
  44702. }
  44703. module "babylonjs/scene" {
  44704. interface Scene {
  44705. /**
  44706. * @hidden
  44707. * Backing field
  44708. */
  44709. _debugLayer: DebugLayer;
  44710. /**
  44711. * Gets the debug layer (aka Inspector) associated with the scene
  44712. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44713. */
  44714. debugLayer: DebugLayer;
  44715. }
  44716. }
  44717. /**
  44718. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44719. * what is happening in your scene
  44720. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44721. */
  44722. export class DebugLayer {
  44723. /**
  44724. * Define the url to get the inspector script from.
  44725. * By default it uses the babylonjs CDN.
  44726. * @ignoreNaming
  44727. */
  44728. static InspectorURL: string;
  44729. private _scene;
  44730. private BJSINSPECTOR;
  44731. private _onPropertyChangedObservable?;
  44732. /**
  44733. * Observable triggered when a property is changed through the inspector.
  44734. */
  44735. readonly onPropertyChangedObservable: any;
  44736. /**
  44737. * Instantiates a new debug layer.
  44738. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44739. * what is happening in your scene
  44740. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44741. * @param scene Defines the scene to inspect
  44742. */
  44743. constructor(scene: Scene);
  44744. /** Creates the inspector window. */
  44745. private _createInspector;
  44746. /**
  44747. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44748. * @param entity defines the entity to select
  44749. * @param lineContainerTitle defines the specific block to highlight
  44750. */
  44751. select(entity: any, lineContainerTitle?: string): void;
  44752. /** Get the inspector from bundle or global */
  44753. private _getGlobalInspector;
  44754. /**
  44755. * Get if the inspector is visible or not.
  44756. * @returns true if visible otherwise, false
  44757. */
  44758. isVisible(): boolean;
  44759. /**
  44760. * Hide the inspector and close its window.
  44761. */
  44762. hide(): void;
  44763. /**
  44764. * Launch the debugLayer.
  44765. * @param config Define the configuration of the inspector
  44766. * @return a promise fulfilled when the debug layer is visible
  44767. */
  44768. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44769. }
  44770. }
  44771. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44772. import { Nullable } from "babylonjs/types";
  44773. import { Scene } from "babylonjs/scene";
  44774. import { Vector4 } from "babylonjs/Maths/math.vector";
  44775. import { Color4 } from "babylonjs/Maths/math.color";
  44776. import { Mesh } from "babylonjs/Meshes/mesh";
  44777. /**
  44778. * Class containing static functions to help procedurally build meshes
  44779. */
  44780. export class BoxBuilder {
  44781. /**
  44782. * Creates a box mesh
  44783. * * The parameter `size` sets the size (float) of each box side (default 1)
  44784. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44785. * * 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)
  44786. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44790. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44791. * @param name defines the name of the mesh
  44792. * @param options defines the options used to create the mesh
  44793. * @param scene defines the hosting scene
  44794. * @returns the box mesh
  44795. */
  44796. static CreateBox(name: string, options: {
  44797. size?: number;
  44798. width?: number;
  44799. height?: number;
  44800. depth?: number;
  44801. faceUV?: Vector4[];
  44802. faceColors?: Color4[];
  44803. sideOrientation?: number;
  44804. frontUVs?: Vector4;
  44805. backUVs?: Vector4;
  44806. wrap?: boolean;
  44807. topBaseAt?: number;
  44808. bottomBaseAt?: number;
  44809. updatable?: boolean;
  44810. }, scene?: Nullable<Scene>): Mesh;
  44811. }
  44812. }
  44813. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44814. import { Vector4 } from "babylonjs/Maths/math.vector";
  44815. import { Mesh } from "babylonjs/Meshes/mesh";
  44816. import { Scene } from "babylonjs/scene";
  44817. import { Nullable } from "babylonjs/types";
  44818. /**
  44819. * Class containing static functions to help procedurally build meshes
  44820. */
  44821. export class SphereBuilder {
  44822. /**
  44823. * Creates a sphere mesh
  44824. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44825. * * 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`)
  44826. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44827. * * 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
  44828. * * 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)
  44829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44832. * @param name defines the name of the mesh
  44833. * @param options defines the options used to create the mesh
  44834. * @param scene defines the hosting scene
  44835. * @returns the sphere mesh
  44836. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44837. */
  44838. static CreateSphere(name: string, options: {
  44839. segments?: number;
  44840. diameter?: number;
  44841. diameterX?: number;
  44842. diameterY?: number;
  44843. diameterZ?: number;
  44844. arc?: number;
  44845. slice?: number;
  44846. sideOrientation?: number;
  44847. frontUVs?: Vector4;
  44848. backUVs?: Vector4;
  44849. updatable?: boolean;
  44850. }, scene?: Nullable<Scene>): Mesh;
  44851. }
  44852. }
  44853. declare module "babylonjs/Debug/physicsViewer" {
  44854. import { Nullable } from "babylonjs/types";
  44855. import { Scene } from "babylonjs/scene";
  44856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44857. import { Mesh } from "babylonjs/Meshes/mesh";
  44858. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44859. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44860. /**
  44861. * Used to show the physics impostor around the specific mesh
  44862. */
  44863. export class PhysicsViewer {
  44864. /** @hidden */
  44865. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44866. /** @hidden */
  44867. protected _meshes: Array<Nullable<AbstractMesh>>;
  44868. /** @hidden */
  44869. protected _scene: Nullable<Scene>;
  44870. /** @hidden */
  44871. protected _numMeshes: number;
  44872. /** @hidden */
  44873. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44874. private _renderFunction;
  44875. private _utilityLayer;
  44876. private _debugBoxMesh;
  44877. private _debugSphereMesh;
  44878. private _debugCylinderMesh;
  44879. private _debugMaterial;
  44880. private _debugMeshMeshes;
  44881. /**
  44882. * Creates a new PhysicsViewer
  44883. * @param scene defines the hosting scene
  44884. */
  44885. constructor(scene: Scene);
  44886. /** @hidden */
  44887. protected _updateDebugMeshes(): void;
  44888. /**
  44889. * Renders a specified physic impostor
  44890. * @param impostor defines the impostor to render
  44891. * @param targetMesh defines the mesh represented by the impostor
  44892. * @returns the new debug mesh used to render the impostor
  44893. */
  44894. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44895. /**
  44896. * Hides a specified physic impostor
  44897. * @param impostor defines the impostor to hide
  44898. */
  44899. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44900. private _getDebugMaterial;
  44901. private _getDebugBoxMesh;
  44902. private _getDebugSphereMesh;
  44903. private _getDebugCylinderMesh;
  44904. private _getDebugMeshMesh;
  44905. private _getDebugMesh;
  44906. /** Releases all resources */
  44907. dispose(): void;
  44908. }
  44909. }
  44910. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44911. import { Vector3 } from "babylonjs/Maths/math.vector";
  44912. import { Color4 } from "babylonjs/Maths/math.color";
  44913. import { Nullable } from "babylonjs/types";
  44914. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44915. import { Scene } from "babylonjs/scene";
  44916. /**
  44917. * Class containing static functions to help procedurally build meshes
  44918. */
  44919. export class LinesBuilder {
  44920. /**
  44921. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44922. * * 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
  44923. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44924. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44925. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44926. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44927. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44928. * * 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
  44929. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44931. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44932. * @param name defines the name of the new line system
  44933. * @param options defines the options used to create the line system
  44934. * @param scene defines the hosting scene
  44935. * @returns a new line system mesh
  44936. */
  44937. static CreateLineSystem(name: string, options: {
  44938. lines: Vector3[][];
  44939. updatable?: boolean;
  44940. instance?: Nullable<LinesMesh>;
  44941. colors?: Nullable<Color4[][]>;
  44942. useVertexAlpha?: boolean;
  44943. }, scene: Nullable<Scene>): LinesMesh;
  44944. /**
  44945. * Creates a line mesh
  44946. * 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
  44947. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44948. * * The parameter `points` is an array successive Vector3
  44949. * * 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
  44950. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44951. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44952. * * When updating an instance, remember that only point positions can change, not the number of points
  44953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44954. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44955. * @param name defines the name of the new line system
  44956. * @param options defines the options used to create the line system
  44957. * @param scene defines the hosting scene
  44958. * @returns a new line mesh
  44959. */
  44960. static CreateLines(name: string, options: {
  44961. points: Vector3[];
  44962. updatable?: boolean;
  44963. instance?: Nullable<LinesMesh>;
  44964. colors?: Color4[];
  44965. useVertexAlpha?: boolean;
  44966. }, scene?: Nullable<Scene>): LinesMesh;
  44967. /**
  44968. * Creates a dashed line mesh
  44969. * * 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
  44970. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44971. * * The parameter `points` is an array successive Vector3
  44972. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44973. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44974. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44975. * * 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
  44976. * * When updating an instance, remember that only point positions can change, not the number of points
  44977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44978. * @param name defines the name of the mesh
  44979. * @param options defines the options used to create the mesh
  44980. * @param scene defines the hosting scene
  44981. * @returns the dashed line mesh
  44982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44983. */
  44984. static CreateDashedLines(name: string, options: {
  44985. points: Vector3[];
  44986. dashSize?: number;
  44987. gapSize?: number;
  44988. dashNb?: number;
  44989. updatable?: boolean;
  44990. instance?: LinesMesh;
  44991. }, scene?: Nullable<Scene>): LinesMesh;
  44992. }
  44993. }
  44994. declare module "babylonjs/Debug/rayHelper" {
  44995. import { Nullable } from "babylonjs/types";
  44996. import { Ray } from "babylonjs/Culling/ray";
  44997. import { Vector3 } from "babylonjs/Maths/math.vector";
  44998. import { Color3 } from "babylonjs/Maths/math.color";
  44999. import { Scene } from "babylonjs/scene";
  45000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45001. import "babylonjs/Meshes/Builders/linesBuilder";
  45002. /**
  45003. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45004. * in order to better appreciate the issue one might have.
  45005. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45006. */
  45007. export class RayHelper {
  45008. /**
  45009. * Defines the ray we are currently tryin to visualize.
  45010. */
  45011. ray: Nullable<Ray>;
  45012. private _renderPoints;
  45013. private _renderLine;
  45014. private _renderFunction;
  45015. private _scene;
  45016. private _updateToMeshFunction;
  45017. private _attachedToMesh;
  45018. private _meshSpaceDirection;
  45019. private _meshSpaceOrigin;
  45020. /**
  45021. * Helper function to create a colored helper in a scene in one line.
  45022. * @param ray Defines the ray we are currently tryin to visualize
  45023. * @param scene Defines the scene the ray is used in
  45024. * @param color Defines the color we want to see the ray in
  45025. * @returns The newly created ray helper.
  45026. */
  45027. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45028. /**
  45029. * Instantiate a new ray helper.
  45030. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45031. * in order to better appreciate the issue one might have.
  45032. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45033. * @param ray Defines the ray we are currently tryin to visualize
  45034. */
  45035. constructor(ray: Ray);
  45036. /**
  45037. * Shows the ray we are willing to debug.
  45038. * @param scene Defines the scene the ray needs to be rendered in
  45039. * @param color Defines the color the ray needs to be rendered in
  45040. */
  45041. show(scene: Scene, color?: Color3): void;
  45042. /**
  45043. * Hides the ray we are debugging.
  45044. */
  45045. hide(): void;
  45046. private _render;
  45047. /**
  45048. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45049. * @param mesh Defines the mesh we want the helper attached to
  45050. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45051. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45052. * @param length Defines the length of the ray
  45053. */
  45054. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45055. /**
  45056. * Detach the ray helper from the mesh it has previously been attached to.
  45057. */
  45058. detachFromMesh(): void;
  45059. private _updateToMesh;
  45060. /**
  45061. * Dispose the helper and release its associated resources.
  45062. */
  45063. dispose(): void;
  45064. }
  45065. }
  45066. declare module "babylonjs/Debug/skeletonViewer" {
  45067. import { Color3 } from "babylonjs/Maths/math.color";
  45068. import { Scene } from "babylonjs/scene";
  45069. import { Nullable } from "babylonjs/types";
  45070. import { Skeleton } from "babylonjs/Bones/skeleton";
  45071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45072. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45073. /**
  45074. * Class used to render a debug view of a given skeleton
  45075. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45076. */
  45077. export class SkeletonViewer {
  45078. /** defines the skeleton to render */
  45079. skeleton: Skeleton;
  45080. /** defines the mesh attached to the skeleton */
  45081. mesh: AbstractMesh;
  45082. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45083. autoUpdateBonesMatrices: boolean;
  45084. /** defines the rendering group id to use with the viewer */
  45085. renderingGroupId: number;
  45086. /** Gets or sets the color used to render the skeleton */
  45087. color: Color3;
  45088. private _scene;
  45089. private _debugLines;
  45090. private _debugMesh;
  45091. private _isEnabled;
  45092. private _renderFunction;
  45093. private _utilityLayer;
  45094. /**
  45095. * Returns the mesh used to render the bones
  45096. */
  45097. readonly debugMesh: Nullable<LinesMesh>;
  45098. /**
  45099. * Creates a new SkeletonViewer
  45100. * @param skeleton defines the skeleton to render
  45101. * @param mesh defines the mesh attached to the skeleton
  45102. * @param scene defines the hosting scene
  45103. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45104. * @param renderingGroupId defines the rendering group id to use with the viewer
  45105. */
  45106. constructor(
  45107. /** defines the skeleton to render */
  45108. skeleton: Skeleton,
  45109. /** defines the mesh attached to the skeleton */
  45110. mesh: AbstractMesh, scene: Scene,
  45111. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45112. autoUpdateBonesMatrices?: boolean,
  45113. /** defines the rendering group id to use with the viewer */
  45114. renderingGroupId?: number);
  45115. /** Gets or sets a boolean indicating if the viewer is enabled */
  45116. isEnabled: boolean;
  45117. private _getBonePosition;
  45118. private _getLinesForBonesWithLength;
  45119. private _getLinesForBonesNoLength;
  45120. /** Update the viewer to sync with current skeleton state */
  45121. update(): void;
  45122. /** Release associated resources */
  45123. dispose(): void;
  45124. }
  45125. }
  45126. declare module "babylonjs/Debug/index" {
  45127. export * from "babylonjs/Debug/axesViewer";
  45128. export * from "babylonjs/Debug/boneAxesViewer";
  45129. export * from "babylonjs/Debug/debugLayer";
  45130. export * from "babylonjs/Debug/physicsViewer";
  45131. export * from "babylonjs/Debug/rayHelper";
  45132. export * from "babylonjs/Debug/skeletonViewer";
  45133. }
  45134. declare module "babylonjs/Engines/nullEngine" {
  45135. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45136. import { Scene } from "babylonjs/scene";
  45137. import { Engine } from "babylonjs/Engines/engine";
  45138. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45139. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45140. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45141. import { Effect } from "babylonjs/Materials/effect";
  45142. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45143. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45144. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45145. /**
  45146. * Options to create the null engine
  45147. */
  45148. export class NullEngineOptions {
  45149. /**
  45150. * Render width (Default: 512)
  45151. */
  45152. renderWidth: number;
  45153. /**
  45154. * Render height (Default: 256)
  45155. */
  45156. renderHeight: number;
  45157. /**
  45158. * Texture size (Default: 512)
  45159. */
  45160. textureSize: number;
  45161. /**
  45162. * If delta time between frames should be constant
  45163. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45164. */
  45165. deterministicLockstep: boolean;
  45166. /**
  45167. * Maximum about of steps between frames (Default: 4)
  45168. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45169. */
  45170. lockstepMaxSteps: number;
  45171. }
  45172. /**
  45173. * The null engine class provides support for headless version of babylon.js.
  45174. * This can be used in server side scenario or for testing purposes
  45175. */
  45176. export class NullEngine extends Engine {
  45177. private _options;
  45178. /**
  45179. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45180. */
  45181. isDeterministicLockStep(): boolean;
  45182. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45183. getLockstepMaxSteps(): number;
  45184. /**
  45185. * Sets hardware scaling, used to save performance if needed
  45186. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45187. */
  45188. getHardwareScalingLevel(): number;
  45189. constructor(options?: NullEngineOptions);
  45190. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45191. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45192. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45193. getRenderWidth(useScreen?: boolean): number;
  45194. getRenderHeight(useScreen?: boolean): number;
  45195. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45196. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45197. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45198. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45199. bindSamplers(effect: Effect): void;
  45200. enableEffect(effect: Effect): void;
  45201. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45202. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45203. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45204. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45205. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45206. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45207. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45208. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45209. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45210. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45211. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45212. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45213. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45214. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45215. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45216. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45217. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45218. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45219. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45220. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45221. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45222. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45223. bindBuffers(vertexBuffers: {
  45224. [key: string]: VertexBuffer;
  45225. }, indexBuffer: DataBuffer, effect: Effect): void;
  45226. wipeCaches(bruteForce?: boolean): void;
  45227. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45228. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45229. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45230. /** @hidden */
  45231. _createTexture(): WebGLTexture;
  45232. /** @hidden */
  45233. _releaseTexture(texture: InternalTexture): void;
  45234. 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;
  45235. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45236. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45237. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45238. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45239. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45240. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45241. areAllEffectsReady(): boolean;
  45242. /**
  45243. * @hidden
  45244. * Get the current error code of the webGL context
  45245. * @returns the error code
  45246. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45247. */
  45248. getError(): number;
  45249. /** @hidden */
  45250. _getUnpackAlignement(): number;
  45251. /** @hidden */
  45252. _unpackFlipY(value: boolean): void;
  45253. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45254. /**
  45255. * Updates a dynamic vertex buffer.
  45256. * @param vertexBuffer the vertex buffer to update
  45257. * @param data the data used to update the vertex buffer
  45258. * @param byteOffset the byte offset of the data (optional)
  45259. * @param byteLength the byte length of the data (optional)
  45260. */
  45261. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45262. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45263. /** @hidden */
  45264. _bindTexture(channel: number, texture: InternalTexture): void;
  45265. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45266. releaseEffects(): void;
  45267. displayLoadingUI(): void;
  45268. hideLoadingUI(): void;
  45269. /** @hidden */
  45270. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45271. /** @hidden */
  45272. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45273. /** @hidden */
  45274. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45275. /** @hidden */
  45276. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45277. }
  45278. }
  45279. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45280. import { Nullable, int } from "babylonjs/types";
  45281. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45282. /** @hidden */
  45283. export class _OcclusionDataStorage {
  45284. /** @hidden */
  45285. occlusionInternalRetryCounter: number;
  45286. /** @hidden */
  45287. isOcclusionQueryInProgress: boolean;
  45288. /** @hidden */
  45289. isOccluded: boolean;
  45290. /** @hidden */
  45291. occlusionRetryCount: number;
  45292. /** @hidden */
  45293. occlusionType: number;
  45294. /** @hidden */
  45295. occlusionQueryAlgorithmType: number;
  45296. }
  45297. module "babylonjs/Engines/engine" {
  45298. interface Engine {
  45299. /**
  45300. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45301. * @return the new query
  45302. */
  45303. createQuery(): WebGLQuery;
  45304. /**
  45305. * Delete and release a webGL query
  45306. * @param query defines the query to delete
  45307. * @return the current engine
  45308. */
  45309. deleteQuery(query: WebGLQuery): Engine;
  45310. /**
  45311. * Check if a given query has resolved and got its value
  45312. * @param query defines the query to check
  45313. * @returns true if the query got its value
  45314. */
  45315. isQueryResultAvailable(query: WebGLQuery): boolean;
  45316. /**
  45317. * Gets the value of a given query
  45318. * @param query defines the query to check
  45319. * @returns the value of the query
  45320. */
  45321. getQueryResult(query: WebGLQuery): number;
  45322. /**
  45323. * Initiates an occlusion query
  45324. * @param algorithmType defines the algorithm to use
  45325. * @param query defines the query to use
  45326. * @returns the current engine
  45327. * @see http://doc.babylonjs.com/features/occlusionquery
  45328. */
  45329. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45330. /**
  45331. * Ends an occlusion query
  45332. * @see http://doc.babylonjs.com/features/occlusionquery
  45333. * @param algorithmType defines the algorithm to use
  45334. * @returns the current engine
  45335. */
  45336. endOcclusionQuery(algorithmType: number): Engine;
  45337. /**
  45338. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45339. * Please note that only one query can be issued at a time
  45340. * @returns a time token used to track the time span
  45341. */
  45342. startTimeQuery(): Nullable<_TimeToken>;
  45343. /**
  45344. * Ends a time query
  45345. * @param token defines the token used to measure the time span
  45346. * @returns the time spent (in ns)
  45347. */
  45348. endTimeQuery(token: _TimeToken): int;
  45349. /** @hidden */
  45350. _currentNonTimestampToken: Nullable<_TimeToken>;
  45351. /** @hidden */
  45352. _createTimeQuery(): WebGLQuery;
  45353. /** @hidden */
  45354. _deleteTimeQuery(query: WebGLQuery): void;
  45355. /** @hidden */
  45356. _getGlAlgorithmType(algorithmType: number): number;
  45357. /** @hidden */
  45358. _getTimeQueryResult(query: WebGLQuery): any;
  45359. /** @hidden */
  45360. _getTimeQueryAvailability(query: WebGLQuery): any;
  45361. }
  45362. }
  45363. module "babylonjs/Meshes/abstractMesh" {
  45364. interface AbstractMesh {
  45365. /**
  45366. * Backing filed
  45367. * @hidden
  45368. */
  45369. __occlusionDataStorage: _OcclusionDataStorage;
  45370. /**
  45371. * Access property
  45372. * @hidden
  45373. */
  45374. _occlusionDataStorage: _OcclusionDataStorage;
  45375. /**
  45376. * 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.
  45377. * The default value is -1 which means don't break the query and wait till the result
  45378. * @see http://doc.babylonjs.com/features/occlusionquery
  45379. */
  45380. occlusionRetryCount: number;
  45381. /**
  45382. * 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:
  45383. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45384. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45385. * * 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.
  45386. * @see http://doc.babylonjs.com/features/occlusionquery
  45387. */
  45388. occlusionType: number;
  45389. /**
  45390. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45391. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45392. * * 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.
  45393. * @see http://doc.babylonjs.com/features/occlusionquery
  45394. */
  45395. occlusionQueryAlgorithmType: number;
  45396. /**
  45397. * 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
  45398. * @see http://doc.babylonjs.com/features/occlusionquery
  45399. */
  45400. isOccluded: boolean;
  45401. /**
  45402. * Flag to check the progress status of the query
  45403. * @see http://doc.babylonjs.com/features/occlusionquery
  45404. */
  45405. isOcclusionQueryInProgress: boolean;
  45406. }
  45407. }
  45408. }
  45409. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45410. import { Nullable } from "babylonjs/types";
  45411. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45412. /** @hidden */
  45413. export var _forceTransformFeedbackToBundle: boolean;
  45414. module "babylonjs/Engines/engine" {
  45415. interface Engine {
  45416. /**
  45417. * Creates a webGL transform feedback object
  45418. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45419. * @returns the webGL transform feedback object
  45420. */
  45421. createTransformFeedback(): WebGLTransformFeedback;
  45422. /**
  45423. * Delete a webGL transform feedback object
  45424. * @param value defines the webGL transform feedback object to delete
  45425. */
  45426. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45427. /**
  45428. * Bind a webGL transform feedback object to the webgl context
  45429. * @param value defines the webGL transform feedback object to bind
  45430. */
  45431. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45432. /**
  45433. * Begins a transform feedback operation
  45434. * @param usePoints defines if points or triangles must be used
  45435. */
  45436. beginTransformFeedback(usePoints: boolean): void;
  45437. /**
  45438. * Ends a transform feedback operation
  45439. */
  45440. endTransformFeedback(): void;
  45441. /**
  45442. * Specify the varyings to use with transform feedback
  45443. * @param program defines the associated webGL program
  45444. * @param value defines the list of strings representing the varying names
  45445. */
  45446. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45447. /**
  45448. * Bind a webGL buffer for a transform feedback operation
  45449. * @param value defines the webGL buffer to bind
  45450. */
  45451. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45452. }
  45453. }
  45454. }
  45455. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45456. import { Scene } from "babylonjs/scene";
  45457. import { Engine } from "babylonjs/Engines/engine";
  45458. import { Texture } from "babylonjs/Materials/Textures/texture";
  45459. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45460. import "babylonjs/Engines/Extensions/engine.multiRender";
  45461. /**
  45462. * Creation options of the multi render target texture.
  45463. */
  45464. export interface IMultiRenderTargetOptions {
  45465. /**
  45466. * Define if the texture needs to create mip maps after render.
  45467. */
  45468. generateMipMaps?: boolean;
  45469. /**
  45470. * Define the types of all the draw buffers we want to create
  45471. */
  45472. types?: number[];
  45473. /**
  45474. * Define the sampling modes of all the draw buffers we want to create
  45475. */
  45476. samplingModes?: number[];
  45477. /**
  45478. * Define if a depth buffer is required
  45479. */
  45480. generateDepthBuffer?: boolean;
  45481. /**
  45482. * Define if a stencil buffer is required
  45483. */
  45484. generateStencilBuffer?: boolean;
  45485. /**
  45486. * Define if a depth texture is required instead of a depth buffer
  45487. */
  45488. generateDepthTexture?: boolean;
  45489. /**
  45490. * Define the number of desired draw buffers
  45491. */
  45492. textureCount?: number;
  45493. /**
  45494. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45495. */
  45496. doNotChangeAspectRatio?: boolean;
  45497. /**
  45498. * Define the default type of the buffers we are creating
  45499. */
  45500. defaultType?: number;
  45501. }
  45502. /**
  45503. * A multi render target, like a render target provides the ability to render to a texture.
  45504. * Unlike the render target, it can render to several draw buffers in one draw.
  45505. * This is specially interesting in deferred rendering or for any effects requiring more than
  45506. * just one color from a single pass.
  45507. */
  45508. export class MultiRenderTarget extends RenderTargetTexture {
  45509. private _internalTextures;
  45510. private _textures;
  45511. private _multiRenderTargetOptions;
  45512. /**
  45513. * Get if draw buffers are currently supported by the used hardware and browser.
  45514. */
  45515. readonly isSupported: boolean;
  45516. /**
  45517. * Get the list of textures generated by the multi render target.
  45518. */
  45519. readonly textures: Texture[];
  45520. /**
  45521. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45522. */
  45523. readonly depthTexture: Texture;
  45524. /**
  45525. * Set the wrapping mode on U of all the textures we are rendering to.
  45526. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45527. */
  45528. wrapU: number;
  45529. /**
  45530. * Set the wrapping mode on V of all the textures we are rendering to.
  45531. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45532. */
  45533. wrapV: number;
  45534. /**
  45535. * Instantiate a new multi render target texture.
  45536. * A multi render target, like a render target provides the ability to render to a texture.
  45537. * Unlike the render target, it can render to several draw buffers in one draw.
  45538. * This is specially interesting in deferred rendering or for any effects requiring more than
  45539. * just one color from a single pass.
  45540. * @param name Define the name of the texture
  45541. * @param size Define the size of the buffers to render to
  45542. * @param count Define the number of target we are rendering into
  45543. * @param scene Define the scene the texture belongs to
  45544. * @param options Define the options used to create the multi render target
  45545. */
  45546. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45547. /** @hidden */
  45548. _rebuild(): void;
  45549. private _createInternalTextures;
  45550. private _createTextures;
  45551. /**
  45552. * Define the number of samples used if MSAA is enabled.
  45553. */
  45554. samples: number;
  45555. /**
  45556. * Resize all the textures in the multi render target.
  45557. * Be carrefull as it will recreate all the data in the new texture.
  45558. * @param size Define the new size
  45559. */
  45560. resize(size: any): void;
  45561. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45562. /**
  45563. * Dispose the render targets and their associated resources
  45564. */
  45565. dispose(): void;
  45566. /**
  45567. * Release all the underlying texture used as draw buffers.
  45568. */
  45569. releaseInternalTextures(): void;
  45570. }
  45571. }
  45572. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45573. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45574. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45575. import { Nullable } from "babylonjs/types";
  45576. module "babylonjs/Engines/engine" {
  45577. interface Engine {
  45578. /**
  45579. * Unbind a list of render target textures from the webGL context
  45580. * This is used only when drawBuffer extension or webGL2 are active
  45581. * @param textures defines the render target textures to unbind
  45582. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45583. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45584. */
  45585. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45586. /**
  45587. * Create a multi render target texture
  45588. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45589. * @param size defines the size of the texture
  45590. * @param options defines the creation options
  45591. * @returns the cube texture as an InternalTexture
  45592. */
  45593. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45594. /**
  45595. * Update the sample count for a given multiple render target texture
  45596. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45597. * @param textures defines the textures to update
  45598. * @param samples defines the sample count to set
  45599. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45600. */
  45601. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45602. }
  45603. }
  45604. }
  45605. declare module "babylonjs/Engines/Extensions/index" {
  45606. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45607. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45608. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45609. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45610. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45611. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45612. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45613. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45614. }
  45615. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  45616. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45617. /** @hidden */
  45618. export var rgbdEncodePixelShader: {
  45619. name: string;
  45620. shader: string;
  45621. };
  45622. }
  45623. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45624. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45625. /** @hidden */
  45626. export var rgbdDecodePixelShader: {
  45627. name: string;
  45628. shader: string;
  45629. };
  45630. }
  45631. declare module "babylonjs/Misc/environmentTextureTools" {
  45632. import { Nullable } from "babylonjs/types";
  45633. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45634. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45635. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  45636. import "babylonjs/Engines/Extensions/engine.renderTarget";
  45637. import "babylonjs/Shaders/rgbdEncode.fragment";
  45638. import "babylonjs/Shaders/rgbdDecode.fragment";
  45639. /**
  45640. * Raw texture data and descriptor sufficient for WebGL texture upload
  45641. */
  45642. export interface EnvironmentTextureInfo {
  45643. /**
  45644. * Version of the environment map
  45645. */
  45646. version: number;
  45647. /**
  45648. * Width of image
  45649. */
  45650. width: number;
  45651. /**
  45652. * Irradiance information stored in the file.
  45653. */
  45654. irradiance: any;
  45655. /**
  45656. * Specular information stored in the file.
  45657. */
  45658. specular: any;
  45659. }
  45660. /**
  45661. * Defines One Image in the file. It requires only the position in the file
  45662. * as well as the length.
  45663. */
  45664. interface BufferImageData {
  45665. /**
  45666. * Length of the image data.
  45667. */
  45668. length: number;
  45669. /**
  45670. * Position of the data from the null terminator delimiting the end of the JSON.
  45671. */
  45672. position: number;
  45673. }
  45674. /**
  45675. * Defines the specular data enclosed in the file.
  45676. * This corresponds to the version 1 of the data.
  45677. */
  45678. export interface EnvironmentTextureSpecularInfoV1 {
  45679. /**
  45680. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45681. */
  45682. specularDataPosition?: number;
  45683. /**
  45684. * This contains all the images data needed to reconstruct the cubemap.
  45685. */
  45686. mipmaps: Array<BufferImageData>;
  45687. /**
  45688. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45689. */
  45690. lodGenerationScale: number;
  45691. }
  45692. /**
  45693. * Sets of helpers addressing the serialization and deserialization of environment texture
  45694. * stored in a BabylonJS env file.
  45695. * Those files are usually stored as .env files.
  45696. */
  45697. export class EnvironmentTextureTools {
  45698. /**
  45699. * Magic number identifying the env file.
  45700. */
  45701. private static _MagicBytes;
  45702. /**
  45703. * Gets the environment info from an env file.
  45704. * @param data The array buffer containing the .env bytes.
  45705. * @returns the environment file info (the json header) if successfully parsed.
  45706. */
  45707. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45708. /**
  45709. * Creates an environment texture from a loaded cube texture.
  45710. * @param texture defines the cube texture to convert in env file
  45711. * @return a promise containing the environment data if succesfull.
  45712. */
  45713. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45714. /**
  45715. * Creates a JSON representation of the spherical data.
  45716. * @param texture defines the texture containing the polynomials
  45717. * @return the JSON representation of the spherical info
  45718. */
  45719. private static _CreateEnvTextureIrradiance;
  45720. /**
  45721. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45722. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45723. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45724. * @return the views described by info providing access to the underlying buffer
  45725. */
  45726. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45727. /**
  45728. * Uploads the texture info contained in the env file to the GPU.
  45729. * @param texture defines the internal texture to upload to
  45730. * @param arrayBuffer defines the buffer cotaining the data to load
  45731. * @param info defines the texture info retrieved through the GetEnvInfo method
  45732. * @returns a promise
  45733. */
  45734. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45735. /**
  45736. * Uploads the levels of image data to the GPU.
  45737. * @param texture defines the internal texture to upload to
  45738. * @param imageData defines the array buffer views of image data [mipmap][face]
  45739. * @returns a promise
  45740. */
  45741. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45742. /**
  45743. * Uploads spherical polynomials information to the texture.
  45744. * @param texture defines the texture we are trying to upload the information to
  45745. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45746. */
  45747. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45748. /** @hidden */
  45749. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45750. }
  45751. }
  45752. declare module "babylonjs/Maths/math.vertexFormat" {
  45753. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  45754. /**
  45755. * Contains position and normal vectors for a vertex
  45756. */
  45757. export class PositionNormalVertex {
  45758. /** the position of the vertex (defaut: 0,0,0) */
  45759. position: Vector3;
  45760. /** the normal of the vertex (defaut: 0,1,0) */
  45761. normal: Vector3;
  45762. /**
  45763. * Creates a PositionNormalVertex
  45764. * @param position the position of the vertex (defaut: 0,0,0)
  45765. * @param normal the normal of the vertex (defaut: 0,1,0)
  45766. */
  45767. constructor(
  45768. /** the position of the vertex (defaut: 0,0,0) */
  45769. position?: Vector3,
  45770. /** the normal of the vertex (defaut: 0,1,0) */
  45771. normal?: Vector3);
  45772. /**
  45773. * Clones the PositionNormalVertex
  45774. * @returns the cloned PositionNormalVertex
  45775. */
  45776. clone(): PositionNormalVertex;
  45777. }
  45778. /**
  45779. * Contains position, normal and uv vectors for a vertex
  45780. */
  45781. export class PositionNormalTextureVertex {
  45782. /** the position of the vertex (defaut: 0,0,0) */
  45783. position: Vector3;
  45784. /** the normal of the vertex (defaut: 0,1,0) */
  45785. normal: Vector3;
  45786. /** the uv of the vertex (default: 0,0) */
  45787. uv: Vector2;
  45788. /**
  45789. * Creates a PositionNormalTextureVertex
  45790. * @param position the position of the vertex (defaut: 0,0,0)
  45791. * @param normal the normal of the vertex (defaut: 0,1,0)
  45792. * @param uv the uv of the vertex (default: 0,0)
  45793. */
  45794. constructor(
  45795. /** the position of the vertex (defaut: 0,0,0) */
  45796. position?: Vector3,
  45797. /** the normal of the vertex (defaut: 0,1,0) */
  45798. normal?: Vector3,
  45799. /** the uv of the vertex (default: 0,0) */
  45800. uv?: Vector2);
  45801. /**
  45802. * Clones the PositionNormalTextureVertex
  45803. * @returns the cloned PositionNormalTextureVertex
  45804. */
  45805. clone(): PositionNormalTextureVertex;
  45806. }
  45807. }
  45808. declare module "babylonjs/Maths/math" {
  45809. export * from "babylonjs/Maths/math.axis";
  45810. export * from "babylonjs/Maths/math.color";
  45811. export * from "babylonjs/Maths/math.constants";
  45812. export * from "babylonjs/Maths/math.frustum";
  45813. export * from "babylonjs/Maths/math.path";
  45814. export * from "babylonjs/Maths/math.plane";
  45815. export * from "babylonjs/Maths/math.size";
  45816. export * from "babylonjs/Maths/math.vector";
  45817. export * from "babylonjs/Maths/math.vertexFormat";
  45818. export * from "babylonjs/Maths/math.viewport";
  45819. }
  45820. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  45821. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45822. /** @hidden */
  45823. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45824. private _genericAttributeLocation;
  45825. private _varyingLocationCount;
  45826. private _varyingLocationMap;
  45827. private _replacements;
  45828. private _textureCount;
  45829. private _uniforms;
  45830. lineProcessor(line: string): string;
  45831. attributeProcessor(attribute: string): string;
  45832. varyingProcessor(varying: string, isFragment: boolean): string;
  45833. uniformProcessor(uniform: string): string;
  45834. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45835. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45836. }
  45837. }
  45838. declare module "babylonjs/Engines/nativeEngine" {
  45839. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  45840. import { Engine } from "babylonjs/Engines/engine";
  45841. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45843. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45844. import { Effect } from "babylonjs/Materials/effect";
  45845. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45846. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  45847. import { Scene } from "babylonjs/scene";
  45848. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45849. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45850. /**
  45851. * Container for accessors for natively-stored mesh data buffers.
  45852. */
  45853. class NativeDataBuffer extends DataBuffer {
  45854. /**
  45855. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45856. */
  45857. nativeIndexBuffer?: any;
  45858. /**
  45859. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45860. */
  45861. nativeVertexBuffer?: any;
  45862. }
  45863. /** @hidden */
  45864. export class NativeEngine extends Engine {
  45865. private readonly _native;
  45866. getHardwareScalingLevel(): number;
  45867. constructor();
  45868. /**
  45869. * Can be used to override the current requestAnimationFrame requester.
  45870. * @hidden
  45871. */
  45872. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  45873. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45874. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45875. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45876. recordVertexArrayObject(vertexBuffers: {
  45877. [key: string]: VertexBuffer;
  45878. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45879. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45880. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45881. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45882. /**
  45883. * Draw a list of indexed primitives
  45884. * @param fillMode defines the primitive to use
  45885. * @param indexStart defines the starting index
  45886. * @param indexCount defines the number of index to draw
  45887. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45888. */
  45889. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45890. /**
  45891. * Draw a list of unindexed primitives
  45892. * @param fillMode defines the primitive to use
  45893. * @param verticesStart defines the index of first vertex to draw
  45894. * @param verticesCount defines the count of vertices to draw
  45895. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45896. */
  45897. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45898. createPipelineContext(): IPipelineContext;
  45899. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45900. /** @hidden */
  45901. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45902. /** @hidden */
  45903. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45904. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45905. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45906. protected _setProgram(program: WebGLProgram): void;
  45907. _releaseEffect(effect: Effect): void;
  45908. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45909. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45910. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45911. bindSamplers(effect: Effect): void;
  45912. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45913. getRenderWidth(useScreen?: boolean): number;
  45914. getRenderHeight(useScreen?: boolean): number;
  45915. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45916. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45917. /**
  45918. * Set the z offset to apply to current rendering
  45919. * @param value defines the offset to apply
  45920. */
  45921. setZOffset(value: number): void;
  45922. /**
  45923. * Gets the current value of the zOffset
  45924. * @returns the current zOffset state
  45925. */
  45926. getZOffset(): number;
  45927. /**
  45928. * Enable or disable depth buffering
  45929. * @param enable defines the state to set
  45930. */
  45931. setDepthBuffer(enable: boolean): void;
  45932. /**
  45933. * Gets a boolean indicating if depth writing is enabled
  45934. * @returns the current depth writing state
  45935. */
  45936. getDepthWrite(): boolean;
  45937. /**
  45938. * Enable or disable depth writing
  45939. * @param enable defines the state to set
  45940. */
  45941. setDepthWrite(enable: boolean): void;
  45942. /**
  45943. * Enable or disable color writing
  45944. * @param enable defines the state to set
  45945. */
  45946. setColorWrite(enable: boolean): void;
  45947. /**
  45948. * Gets a boolean indicating if color writing is enabled
  45949. * @returns the current color writing state
  45950. */
  45951. getColorWrite(): boolean;
  45952. /**
  45953. * Sets alpha constants used by some alpha blending modes
  45954. * @param r defines the red component
  45955. * @param g defines the green component
  45956. * @param b defines the blue component
  45957. * @param a defines the alpha component
  45958. */
  45959. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45960. /**
  45961. * Sets the current alpha mode
  45962. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  45963. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45964. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45965. */
  45966. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45967. /**
  45968. * Gets the current alpha mode
  45969. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45970. * @returns the current alpha mode
  45971. */
  45972. getAlphaMode(): number;
  45973. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45974. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45975. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45976. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45977. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45978. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45979. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45980. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45981. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45982. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45983. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45984. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45985. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45986. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45987. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45988. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45989. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45990. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45991. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45992. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45993. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45994. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45995. wipeCaches(bruteForce?: boolean): void;
  45996. _createTexture(): WebGLTexture;
  45997. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45998. /**
  45999. * Usually called from BABYLON.Texture.ts.
  46000. * Passed information to create a WebGLTexture
  46001. * @param urlArg defines a value which contains one of the following:
  46002. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46003. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46004. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46005. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46006. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46007. * @param scene needed for loading to the correct scene
  46008. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46009. * @param onLoad optional callback to be called upon successful completion
  46010. * @param onError optional callback to be called upon failure
  46011. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46012. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46013. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46014. * @param forcedExtension defines the extension to use to pick the right loader
  46015. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46016. */
  46017. 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;
  46018. /**
  46019. * Creates a cube texture
  46020. * @param rootUrl defines the url where the files to load is located
  46021. * @param scene defines the current scene
  46022. * @param files defines the list of files to load (1 per face)
  46023. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46024. * @param onLoad defines an optional callback raised when the texture is loaded
  46025. * @param onError defines an optional callback raised if there is an issue to load the texture
  46026. * @param format defines the format of the data
  46027. * @param forcedExtension defines the extension to use to pick the right loader
  46028. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46029. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46030. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46031. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46032. * @returns the cube texture as an InternalTexture
  46033. */
  46034. 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;
  46035. private _getSamplingFilter;
  46036. private static _GetNativeTextureFormat;
  46037. createRenderTargetTexture(size: number | {
  46038. width: number;
  46039. height: number;
  46040. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46041. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46042. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46043. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46044. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46045. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46046. /**
  46047. * Updates a dynamic vertex buffer.
  46048. * @param vertexBuffer the vertex buffer to update
  46049. * @param data the data used to update the vertex buffer
  46050. * @param byteOffset the byte offset of the data (optional)
  46051. * @param byteLength the byte length of the data (optional)
  46052. */
  46053. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46054. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46055. private _updateAnisotropicLevel;
  46056. private _getAddressMode;
  46057. /** @hidden */
  46058. _bindTexture(channel: number, texture: InternalTexture): void;
  46059. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46060. releaseEffects(): void;
  46061. /** @hidden */
  46062. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46063. /** @hidden */
  46064. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46065. /** @hidden */
  46066. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46067. /** @hidden */
  46068. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46069. }
  46070. }
  46071. declare module "babylonjs/Engines/index" {
  46072. export * from "babylonjs/Engines/constants";
  46073. export * from "babylonjs/Engines/engine";
  46074. export * from "babylonjs/Engines/engineStore";
  46075. export * from "babylonjs/Engines/nullEngine";
  46076. export * from "babylonjs/Engines/Extensions/index";
  46077. export * from "babylonjs/Engines/IPipelineContext";
  46078. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46079. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46080. export * from "babylonjs/Engines/nativeEngine";
  46081. }
  46082. declare module "babylonjs/Events/clipboardEvents" {
  46083. /**
  46084. * Gather the list of clipboard event types as constants.
  46085. */
  46086. export class ClipboardEventTypes {
  46087. /**
  46088. * The clipboard event is fired when a copy command is active (pressed).
  46089. */
  46090. static readonly COPY: number;
  46091. /**
  46092. * The clipboard event is fired when a cut command is active (pressed).
  46093. */
  46094. static readonly CUT: number;
  46095. /**
  46096. * The clipboard event is fired when a paste command is active (pressed).
  46097. */
  46098. static readonly PASTE: number;
  46099. }
  46100. /**
  46101. * This class is used to store clipboard related info for the onClipboardObservable event.
  46102. */
  46103. export class ClipboardInfo {
  46104. /**
  46105. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46106. */
  46107. type: number;
  46108. /**
  46109. * Defines the related dom event
  46110. */
  46111. event: ClipboardEvent;
  46112. /**
  46113. *Creates an instance of ClipboardInfo.
  46114. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46115. * @param event Defines the related dom event
  46116. */
  46117. constructor(
  46118. /**
  46119. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46120. */
  46121. type: number,
  46122. /**
  46123. * Defines the related dom event
  46124. */
  46125. event: ClipboardEvent);
  46126. /**
  46127. * Get the clipboard event's type from the keycode.
  46128. * @param keyCode Defines the keyCode for the current keyboard event.
  46129. * @return {number}
  46130. */
  46131. static GetTypeFromCharacter(keyCode: number): number;
  46132. }
  46133. }
  46134. declare module "babylonjs/Events/index" {
  46135. export * from "babylonjs/Events/keyboardEvents";
  46136. export * from "babylonjs/Events/pointerEvents";
  46137. export * from "babylonjs/Events/clipboardEvents";
  46138. }
  46139. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46140. import { Scene } from "babylonjs/scene";
  46141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46142. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46143. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46144. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46145. /**
  46146. * Google Daydream controller
  46147. */
  46148. export class DaydreamController extends WebVRController {
  46149. /**
  46150. * Base Url for the controller model.
  46151. */
  46152. static MODEL_BASE_URL: string;
  46153. /**
  46154. * File name for the controller model.
  46155. */
  46156. static MODEL_FILENAME: string;
  46157. /**
  46158. * Gamepad Id prefix used to identify Daydream Controller.
  46159. */
  46160. static readonly GAMEPAD_ID_PREFIX: string;
  46161. /**
  46162. * Creates a new DaydreamController from a gamepad
  46163. * @param vrGamepad the gamepad that the controller should be created from
  46164. */
  46165. constructor(vrGamepad: any);
  46166. /**
  46167. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46168. * @param scene scene in which to add meshes
  46169. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46170. */
  46171. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46172. /**
  46173. * Called once for each button that changed state since the last frame
  46174. * @param buttonIdx Which button index changed
  46175. * @param state New state of the button
  46176. * @param changes Which properties on the state changed since last frame
  46177. */
  46178. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46179. }
  46180. }
  46181. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46182. import { Scene } from "babylonjs/scene";
  46183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46184. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46185. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46186. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46187. /**
  46188. * Gear VR Controller
  46189. */
  46190. export class GearVRController extends WebVRController {
  46191. /**
  46192. * Base Url for the controller model.
  46193. */
  46194. static MODEL_BASE_URL: string;
  46195. /**
  46196. * File name for the controller model.
  46197. */
  46198. static MODEL_FILENAME: string;
  46199. /**
  46200. * Gamepad Id prefix used to identify this controller.
  46201. */
  46202. static readonly GAMEPAD_ID_PREFIX: string;
  46203. private readonly _buttonIndexToObservableNameMap;
  46204. /**
  46205. * Creates a new GearVRController from a gamepad
  46206. * @param vrGamepad the gamepad that the controller should be created from
  46207. */
  46208. constructor(vrGamepad: any);
  46209. /**
  46210. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46211. * @param scene scene in which to add meshes
  46212. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46213. */
  46214. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46215. /**
  46216. * Called once for each button that changed state since the last frame
  46217. * @param buttonIdx Which button index changed
  46218. * @param state New state of the button
  46219. * @param changes Which properties on the state changed since last frame
  46220. */
  46221. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46222. }
  46223. }
  46224. declare module "babylonjs/Gamepads/Controllers/index" {
  46225. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46226. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46227. export * from "babylonjs/Gamepads/Controllers/genericController";
  46228. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46229. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46230. export * from "babylonjs/Gamepads/Controllers/viveController";
  46231. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46232. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46233. }
  46234. declare module "babylonjs/Gamepads/index" {
  46235. export * from "babylonjs/Gamepads/Controllers/index";
  46236. export * from "babylonjs/Gamepads/gamepad";
  46237. export * from "babylonjs/Gamepads/gamepadManager";
  46238. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46239. export * from "babylonjs/Gamepads/xboxGamepad";
  46240. export * from "babylonjs/Gamepads/dualShockGamepad";
  46241. }
  46242. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46243. import { Scene } from "babylonjs/scene";
  46244. import { Vector4 } from "babylonjs/Maths/math.vector";
  46245. import { Color4 } from "babylonjs/Maths/math.color";
  46246. import { Mesh } from "babylonjs/Meshes/mesh";
  46247. import { Nullable } from "babylonjs/types";
  46248. /**
  46249. * Class containing static functions to help procedurally build meshes
  46250. */
  46251. export class PolyhedronBuilder {
  46252. /**
  46253. * Creates a polyhedron mesh
  46254. * * 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
  46255. * * The parameter `size` (positive float, default 1) sets the polygon size
  46256. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46257. * * 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`
  46258. * * 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
  46259. * * 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)`)
  46260. * * 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
  46261. * * 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
  46262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46265. * @param name defines the name of the mesh
  46266. * @param options defines the options used to create the mesh
  46267. * @param scene defines the hosting scene
  46268. * @returns the polyhedron mesh
  46269. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46270. */
  46271. static CreatePolyhedron(name: string, options: {
  46272. type?: number;
  46273. size?: number;
  46274. sizeX?: number;
  46275. sizeY?: number;
  46276. sizeZ?: number;
  46277. custom?: any;
  46278. faceUV?: Vector4[];
  46279. faceColors?: Color4[];
  46280. flat?: boolean;
  46281. updatable?: boolean;
  46282. sideOrientation?: number;
  46283. frontUVs?: Vector4;
  46284. backUVs?: Vector4;
  46285. }, scene?: Nullable<Scene>): Mesh;
  46286. }
  46287. }
  46288. declare module "babylonjs/Gizmos/scaleGizmo" {
  46289. import { Observable } from "babylonjs/Misc/observable";
  46290. import { Nullable } from "babylonjs/types";
  46291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46292. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46293. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46294. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46295. /**
  46296. * Gizmo that enables scaling a mesh along 3 axis
  46297. */
  46298. export class ScaleGizmo extends Gizmo {
  46299. /**
  46300. * Internal gizmo used for interactions on the x axis
  46301. */
  46302. xGizmo: AxisScaleGizmo;
  46303. /**
  46304. * Internal gizmo used for interactions on the y axis
  46305. */
  46306. yGizmo: AxisScaleGizmo;
  46307. /**
  46308. * Internal gizmo used for interactions on the z axis
  46309. */
  46310. zGizmo: AxisScaleGizmo;
  46311. /**
  46312. * Internal gizmo used to scale all axis equally
  46313. */
  46314. uniformScaleGizmo: AxisScaleGizmo;
  46315. private _meshAttached;
  46316. private _updateGizmoRotationToMatchAttachedMesh;
  46317. private _snapDistance;
  46318. private _scaleRatio;
  46319. private _uniformScalingMesh;
  46320. private _octahedron;
  46321. /** Fires an event when any of it's sub gizmos are dragged */
  46322. onDragStartObservable: Observable<unknown>;
  46323. /** Fires an event when any of it's sub gizmos are released from dragging */
  46324. onDragEndObservable: Observable<unknown>;
  46325. attachedMesh: Nullable<AbstractMesh>;
  46326. /**
  46327. * Creates a ScaleGizmo
  46328. * @param gizmoLayer The utility layer the gizmo will be added to
  46329. */
  46330. constructor(gizmoLayer?: UtilityLayerRenderer);
  46331. updateGizmoRotationToMatchAttachedMesh: boolean;
  46332. /**
  46333. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46334. */
  46335. snapDistance: number;
  46336. /**
  46337. * Ratio for the scale of the gizmo (Default: 1)
  46338. */
  46339. scaleRatio: number;
  46340. /**
  46341. * Disposes of the gizmo
  46342. */
  46343. dispose(): void;
  46344. }
  46345. }
  46346. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46347. import { Observable } from "babylonjs/Misc/observable";
  46348. import { Nullable } from "babylonjs/types";
  46349. import { Vector3 } from "babylonjs/Maths/math.vector";
  46350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46351. import { Mesh } from "babylonjs/Meshes/mesh";
  46352. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46353. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46354. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46355. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46356. import { Color3 } from "babylonjs/Maths/math.color";
  46357. /**
  46358. * Single axis scale gizmo
  46359. */
  46360. export class AxisScaleGizmo extends Gizmo {
  46361. /**
  46362. * Drag behavior responsible for the gizmos dragging interactions
  46363. */
  46364. dragBehavior: PointerDragBehavior;
  46365. private _pointerObserver;
  46366. /**
  46367. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46368. */
  46369. snapDistance: number;
  46370. /**
  46371. * Event that fires each time the gizmo snaps to a new location.
  46372. * * snapDistance is the the change in distance
  46373. */
  46374. onSnapObservable: Observable<{
  46375. snapDistance: number;
  46376. }>;
  46377. /**
  46378. * If the scaling operation should be done on all axis (default: false)
  46379. */
  46380. uniformScaling: boolean;
  46381. private _isEnabled;
  46382. private _parent;
  46383. private _arrow;
  46384. private _coloredMaterial;
  46385. private _hoverMaterial;
  46386. /**
  46387. * Creates an AxisScaleGizmo
  46388. * @param gizmoLayer The utility layer the gizmo will be added to
  46389. * @param dragAxis The axis which the gizmo will be able to scale on
  46390. * @param color The color of the gizmo
  46391. */
  46392. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46393. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46394. /**
  46395. * If the gizmo is enabled
  46396. */
  46397. isEnabled: boolean;
  46398. /**
  46399. * Disposes of the gizmo
  46400. */
  46401. dispose(): void;
  46402. /**
  46403. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46404. * @param mesh The mesh to replace the default mesh of the gizmo
  46405. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46406. */
  46407. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46408. }
  46409. }
  46410. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46411. import { Observable } from "babylonjs/Misc/observable";
  46412. import { Nullable } from "babylonjs/types";
  46413. import { Vector3 } from "babylonjs/Maths/math.vector";
  46414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46415. import { Mesh } from "babylonjs/Meshes/mesh";
  46416. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46417. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46418. import { Color3 } from "babylonjs/Maths/math.color";
  46419. import "babylonjs/Meshes/Builders/boxBuilder";
  46420. /**
  46421. * Bounding box gizmo
  46422. */
  46423. export class BoundingBoxGizmo extends Gizmo {
  46424. private _lineBoundingBox;
  46425. private _rotateSpheresParent;
  46426. private _scaleBoxesParent;
  46427. private _boundingDimensions;
  46428. private _renderObserver;
  46429. private _pointerObserver;
  46430. private _scaleDragSpeed;
  46431. private _tmpQuaternion;
  46432. private _tmpVector;
  46433. private _tmpRotationMatrix;
  46434. /**
  46435. * 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)
  46436. */
  46437. ignoreChildren: boolean;
  46438. /**
  46439. * 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)
  46440. */
  46441. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46442. /**
  46443. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46444. */
  46445. rotationSphereSize: number;
  46446. /**
  46447. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46448. */
  46449. scaleBoxSize: number;
  46450. /**
  46451. * 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)
  46452. */
  46453. fixedDragMeshScreenSize: boolean;
  46454. /**
  46455. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46456. */
  46457. fixedDragMeshScreenSizeDistanceFactor: number;
  46458. /**
  46459. * Fired when a rotation sphere or scale box is dragged
  46460. */
  46461. onDragStartObservable: Observable<{}>;
  46462. /**
  46463. * Fired when a scale box is dragged
  46464. */
  46465. onScaleBoxDragObservable: Observable<{}>;
  46466. /**
  46467. * Fired when a scale box drag is ended
  46468. */
  46469. onScaleBoxDragEndObservable: Observable<{}>;
  46470. /**
  46471. * Fired when a rotation sphere is dragged
  46472. */
  46473. onRotationSphereDragObservable: Observable<{}>;
  46474. /**
  46475. * Fired when a rotation sphere drag is ended
  46476. */
  46477. onRotationSphereDragEndObservable: Observable<{}>;
  46478. /**
  46479. * 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)
  46480. */
  46481. scalePivot: Nullable<Vector3>;
  46482. /**
  46483. * Mesh used as a pivot to rotate the attached mesh
  46484. */
  46485. private _anchorMesh;
  46486. private _existingMeshScale;
  46487. private _dragMesh;
  46488. private pointerDragBehavior;
  46489. private coloredMaterial;
  46490. private hoverColoredMaterial;
  46491. /**
  46492. * Sets the color of the bounding box gizmo
  46493. * @param color the color to set
  46494. */
  46495. setColor(color: Color3): void;
  46496. /**
  46497. * Creates an BoundingBoxGizmo
  46498. * @param gizmoLayer The utility layer the gizmo will be added to
  46499. * @param color The color of the gizmo
  46500. */
  46501. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46502. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46503. private _selectNode;
  46504. /**
  46505. * Updates the bounding box information for the Gizmo
  46506. */
  46507. updateBoundingBox(): void;
  46508. private _updateRotationSpheres;
  46509. private _updateScaleBoxes;
  46510. /**
  46511. * Enables rotation on the specified axis and disables rotation on the others
  46512. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46513. */
  46514. setEnabledRotationAxis(axis: string): void;
  46515. /**
  46516. * Enables/disables scaling
  46517. * @param enable if scaling should be enabled
  46518. */
  46519. setEnabledScaling(enable: boolean): void;
  46520. private _updateDummy;
  46521. /**
  46522. * Enables a pointer drag behavior on the bounding box of the gizmo
  46523. */
  46524. enableDragBehavior(): void;
  46525. /**
  46526. * Disposes of the gizmo
  46527. */
  46528. dispose(): void;
  46529. /**
  46530. * 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)
  46531. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46532. * @returns the bounding box mesh with the passed in mesh as a child
  46533. */
  46534. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46535. /**
  46536. * CustomMeshes are not supported by this gizmo
  46537. * @param mesh The mesh to replace the default mesh of the gizmo
  46538. */
  46539. setCustomMesh(mesh: Mesh): void;
  46540. }
  46541. }
  46542. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  46543. import { Observable } from "babylonjs/Misc/observable";
  46544. import { Nullable } from "babylonjs/types";
  46545. import { Vector3 } from "babylonjs/Maths/math.vector";
  46546. import { Color3 } from "babylonjs/Maths/math.color";
  46547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46548. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46549. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46550. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46551. import "babylonjs/Meshes/Builders/linesBuilder";
  46552. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46553. /**
  46554. * Single plane rotation gizmo
  46555. */
  46556. export class PlaneRotationGizmo extends Gizmo {
  46557. /**
  46558. * Drag behavior responsible for the gizmos dragging interactions
  46559. */
  46560. dragBehavior: PointerDragBehavior;
  46561. private _pointerObserver;
  46562. /**
  46563. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46564. */
  46565. snapDistance: number;
  46566. /**
  46567. * Event that fires each time the gizmo snaps to a new location.
  46568. * * snapDistance is the the change in distance
  46569. */
  46570. onSnapObservable: Observable<{
  46571. snapDistance: number;
  46572. }>;
  46573. private _isEnabled;
  46574. private _parent;
  46575. /**
  46576. * Creates a PlaneRotationGizmo
  46577. * @param gizmoLayer The utility layer the gizmo will be added to
  46578. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46579. * @param color The color of the gizmo
  46580. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46581. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46582. */
  46583. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46584. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46585. /**
  46586. * If the gizmo is enabled
  46587. */
  46588. isEnabled: boolean;
  46589. /**
  46590. * Disposes of the gizmo
  46591. */
  46592. dispose(): void;
  46593. }
  46594. }
  46595. declare module "babylonjs/Gizmos/rotationGizmo" {
  46596. import { Observable } from "babylonjs/Misc/observable";
  46597. import { Nullable } from "babylonjs/types";
  46598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46599. import { Mesh } from "babylonjs/Meshes/mesh";
  46600. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46601. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46602. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46603. /**
  46604. * Gizmo that enables rotating a mesh along 3 axis
  46605. */
  46606. export class RotationGizmo extends Gizmo {
  46607. /**
  46608. * Internal gizmo used for interactions on the x axis
  46609. */
  46610. xGizmo: PlaneRotationGizmo;
  46611. /**
  46612. * Internal gizmo used for interactions on the y axis
  46613. */
  46614. yGizmo: PlaneRotationGizmo;
  46615. /**
  46616. * Internal gizmo used for interactions on the z axis
  46617. */
  46618. zGizmo: PlaneRotationGizmo;
  46619. /** Fires an event when any of it's sub gizmos are dragged */
  46620. onDragStartObservable: Observable<unknown>;
  46621. /** Fires an event when any of it's sub gizmos are released from dragging */
  46622. onDragEndObservable: Observable<unknown>;
  46623. private _meshAttached;
  46624. attachedMesh: Nullable<AbstractMesh>;
  46625. /**
  46626. * Creates a RotationGizmo
  46627. * @param gizmoLayer The utility layer the gizmo will be added to
  46628. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46629. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46630. */
  46631. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46632. updateGizmoRotationToMatchAttachedMesh: boolean;
  46633. /**
  46634. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46635. */
  46636. snapDistance: number;
  46637. /**
  46638. * Ratio for the scale of the gizmo (Default: 1)
  46639. */
  46640. scaleRatio: number;
  46641. /**
  46642. * Disposes of the gizmo
  46643. */
  46644. dispose(): void;
  46645. /**
  46646. * CustomMeshes are not supported by this gizmo
  46647. * @param mesh The mesh to replace the default mesh of the gizmo
  46648. */
  46649. setCustomMesh(mesh: Mesh): void;
  46650. }
  46651. }
  46652. declare module "babylonjs/Gizmos/gizmoManager" {
  46653. import { Observable } from "babylonjs/Misc/observable";
  46654. import { Nullable } from "babylonjs/types";
  46655. import { Scene, IDisposable } from "babylonjs/scene";
  46656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46657. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46658. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46659. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46660. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46661. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46662. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46663. /**
  46664. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46665. */
  46666. export class GizmoManager implements IDisposable {
  46667. private scene;
  46668. /**
  46669. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46670. */
  46671. gizmos: {
  46672. positionGizmo: Nullable<PositionGizmo>;
  46673. rotationGizmo: Nullable<RotationGizmo>;
  46674. scaleGizmo: Nullable<ScaleGizmo>;
  46675. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46676. };
  46677. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46678. clearGizmoOnEmptyPointerEvent: boolean;
  46679. /** Fires an event when the manager is attached to a mesh */
  46680. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46681. private _gizmosEnabled;
  46682. private _pointerObserver;
  46683. private _attachedMesh;
  46684. private _boundingBoxColor;
  46685. private _defaultUtilityLayer;
  46686. private _defaultKeepDepthUtilityLayer;
  46687. /**
  46688. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46689. */
  46690. boundingBoxDragBehavior: SixDofDragBehavior;
  46691. /**
  46692. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46693. */
  46694. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46695. /**
  46696. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46697. */
  46698. usePointerToAttachGizmos: boolean;
  46699. /**
  46700. * Utility layer that the bounding box gizmo belongs to
  46701. */
  46702. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46703. /**
  46704. * Utility layer that all gizmos besides bounding box belong to
  46705. */
  46706. readonly utilityLayer: UtilityLayerRenderer;
  46707. /**
  46708. * Instatiates a gizmo manager
  46709. * @param scene the scene to overlay the gizmos on top of
  46710. */
  46711. constructor(scene: Scene);
  46712. /**
  46713. * Attaches a set of gizmos to the specified mesh
  46714. * @param mesh The mesh the gizmo's should be attached to
  46715. */
  46716. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46717. /**
  46718. * If the position gizmo is enabled
  46719. */
  46720. positionGizmoEnabled: boolean;
  46721. /**
  46722. * If the rotation gizmo is enabled
  46723. */
  46724. rotationGizmoEnabled: boolean;
  46725. /**
  46726. * If the scale gizmo is enabled
  46727. */
  46728. scaleGizmoEnabled: boolean;
  46729. /**
  46730. * If the boundingBox gizmo is enabled
  46731. */
  46732. boundingBoxGizmoEnabled: boolean;
  46733. /**
  46734. * Disposes of the gizmo manager
  46735. */
  46736. dispose(): void;
  46737. }
  46738. }
  46739. declare module "babylonjs/Lights/directionalLight" {
  46740. import { Camera } from "babylonjs/Cameras/camera";
  46741. import { Scene } from "babylonjs/scene";
  46742. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46744. import { Light } from "babylonjs/Lights/light";
  46745. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46746. import { Effect } from "babylonjs/Materials/effect";
  46747. /**
  46748. * A directional light is defined by a direction (what a surprise!).
  46749. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46750. * 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.
  46751. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46752. */
  46753. export class DirectionalLight extends ShadowLight {
  46754. private _shadowFrustumSize;
  46755. /**
  46756. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46757. */
  46758. /**
  46759. * Specifies a fix frustum size for the shadow generation.
  46760. */
  46761. shadowFrustumSize: number;
  46762. private _shadowOrthoScale;
  46763. /**
  46764. * Gets the shadow projection scale against the optimal computed one.
  46765. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46766. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46767. */
  46768. /**
  46769. * Sets the shadow projection scale against the optimal computed one.
  46770. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46771. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46772. */
  46773. shadowOrthoScale: number;
  46774. /**
  46775. * Automatically compute the projection matrix to best fit (including all the casters)
  46776. * on each frame.
  46777. */
  46778. autoUpdateExtends: boolean;
  46779. private _orthoLeft;
  46780. private _orthoRight;
  46781. private _orthoTop;
  46782. private _orthoBottom;
  46783. /**
  46784. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46785. * The directional light is emitted from everywhere in the given direction.
  46786. * It can cast shadows.
  46787. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46788. * @param name The friendly name of the light
  46789. * @param direction The direction of the light
  46790. * @param scene The scene the light belongs to
  46791. */
  46792. constructor(name: string, direction: Vector3, scene: Scene);
  46793. /**
  46794. * Returns the string "DirectionalLight".
  46795. * @return The class name
  46796. */
  46797. getClassName(): string;
  46798. /**
  46799. * Returns the integer 1.
  46800. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46801. */
  46802. getTypeID(): number;
  46803. /**
  46804. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46805. * Returns the DirectionalLight Shadow projection matrix.
  46806. */
  46807. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46808. /**
  46809. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46810. * Returns the DirectionalLight Shadow projection matrix.
  46811. */
  46812. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46813. /**
  46814. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46815. * Returns the DirectionalLight Shadow projection matrix.
  46816. */
  46817. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46818. protected _buildUniformLayout(): void;
  46819. /**
  46820. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46821. * @param effect The effect to update
  46822. * @param lightIndex The index of the light in the effect to update
  46823. * @returns The directional light
  46824. */
  46825. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46826. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46827. /**
  46828. * Gets the minZ used for shadow according to both the scene and the light.
  46829. *
  46830. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46831. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46832. * @param activeCamera The camera we are returning the min for
  46833. * @returns the depth min z
  46834. */
  46835. getDepthMinZ(activeCamera: Camera): number;
  46836. /**
  46837. * Gets the maxZ used for shadow according to both the scene and the light.
  46838. *
  46839. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46840. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46841. * @param activeCamera The camera we are returning the max for
  46842. * @returns the depth max z
  46843. */
  46844. getDepthMaxZ(activeCamera: Camera): number;
  46845. /**
  46846. * Prepares the list of defines specific to the light type.
  46847. * @param defines the list of defines
  46848. * @param lightIndex defines the index of the light for the effect
  46849. */
  46850. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46851. }
  46852. }
  46853. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46854. import { Mesh } from "babylonjs/Meshes/mesh";
  46855. /**
  46856. * Class containing static functions to help procedurally build meshes
  46857. */
  46858. export class HemisphereBuilder {
  46859. /**
  46860. * Creates a hemisphere mesh
  46861. * @param name defines the name of the mesh
  46862. * @param options defines the options used to create the mesh
  46863. * @param scene defines the hosting scene
  46864. * @returns the hemisphere mesh
  46865. */
  46866. static CreateHemisphere(name: string, options: {
  46867. segments?: number;
  46868. diameter?: number;
  46869. sideOrientation?: number;
  46870. }, scene: any): Mesh;
  46871. }
  46872. }
  46873. declare module "babylonjs/Lights/spotLight" {
  46874. import { Nullable } from "babylonjs/types";
  46875. import { Scene } from "babylonjs/scene";
  46876. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46878. import { Effect } from "babylonjs/Materials/effect";
  46879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46880. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46881. /**
  46882. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46883. * These values define a cone of light starting from the position, emitting toward the direction.
  46884. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46885. * and the exponent defines the speed of the decay of the light with distance (reach).
  46886. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46887. */
  46888. export class SpotLight extends ShadowLight {
  46889. private _angle;
  46890. private _innerAngle;
  46891. private _cosHalfAngle;
  46892. private _lightAngleScale;
  46893. private _lightAngleOffset;
  46894. /**
  46895. * Gets the cone angle of the spot light in Radians.
  46896. */
  46897. /**
  46898. * Sets the cone angle of the spot light in Radians.
  46899. */
  46900. angle: number;
  46901. /**
  46902. * Only used in gltf falloff mode, this defines the angle where
  46903. * the directional falloff will start before cutting at angle which could be seen
  46904. * as outer angle.
  46905. */
  46906. /**
  46907. * Only used in gltf falloff mode, this defines the angle where
  46908. * the directional falloff will start before cutting at angle which could be seen
  46909. * as outer angle.
  46910. */
  46911. innerAngle: number;
  46912. private _shadowAngleScale;
  46913. /**
  46914. * Allows scaling the angle of the light for shadow generation only.
  46915. */
  46916. /**
  46917. * Allows scaling the angle of the light for shadow generation only.
  46918. */
  46919. shadowAngleScale: number;
  46920. /**
  46921. * The light decay speed with the distance from the emission spot.
  46922. */
  46923. exponent: number;
  46924. private _projectionTextureMatrix;
  46925. /**
  46926. * Allows reading the projecton texture
  46927. */
  46928. readonly projectionTextureMatrix: Matrix;
  46929. protected _projectionTextureLightNear: number;
  46930. /**
  46931. * Gets the near clip of the Spotlight for texture projection.
  46932. */
  46933. /**
  46934. * Sets the near clip of the Spotlight for texture projection.
  46935. */
  46936. projectionTextureLightNear: number;
  46937. protected _projectionTextureLightFar: number;
  46938. /**
  46939. * Gets the far clip of the Spotlight for texture projection.
  46940. */
  46941. /**
  46942. * Sets the far clip of the Spotlight for texture projection.
  46943. */
  46944. projectionTextureLightFar: number;
  46945. protected _projectionTextureUpDirection: Vector3;
  46946. /**
  46947. * Gets the Up vector of the Spotlight for texture projection.
  46948. */
  46949. /**
  46950. * Sets the Up vector of the Spotlight for texture projection.
  46951. */
  46952. projectionTextureUpDirection: Vector3;
  46953. private _projectionTexture;
  46954. /**
  46955. * Gets the projection texture of the light.
  46956. */
  46957. /**
  46958. * Sets the projection texture of the light.
  46959. */
  46960. projectionTexture: Nullable<BaseTexture>;
  46961. private _projectionTextureViewLightDirty;
  46962. private _projectionTextureProjectionLightDirty;
  46963. private _projectionTextureDirty;
  46964. private _projectionTextureViewTargetVector;
  46965. private _projectionTextureViewLightMatrix;
  46966. private _projectionTextureProjectionLightMatrix;
  46967. private _projectionTextureScalingMatrix;
  46968. /**
  46969. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46970. * It can cast shadows.
  46971. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46972. * @param name The light friendly name
  46973. * @param position The position of the spot light in the scene
  46974. * @param direction The direction of the light in the scene
  46975. * @param angle The cone angle of the light in Radians
  46976. * @param exponent The light decay speed with the distance from the emission spot
  46977. * @param scene The scene the lights belongs to
  46978. */
  46979. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46980. /**
  46981. * Returns the string "SpotLight".
  46982. * @returns the class name
  46983. */
  46984. getClassName(): string;
  46985. /**
  46986. * Returns the integer 2.
  46987. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46988. */
  46989. getTypeID(): number;
  46990. /**
  46991. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46992. */
  46993. protected _setDirection(value: Vector3): void;
  46994. /**
  46995. * Overrides the position setter to recompute the projection texture view light Matrix.
  46996. */
  46997. protected _setPosition(value: Vector3): void;
  46998. /**
  46999. * 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.
  47000. * Returns the SpotLight.
  47001. */
  47002. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47003. protected _computeProjectionTextureViewLightMatrix(): void;
  47004. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47005. /**
  47006. * Main function for light texture projection matrix computing.
  47007. */
  47008. protected _computeProjectionTextureMatrix(): void;
  47009. protected _buildUniformLayout(): void;
  47010. private _computeAngleValues;
  47011. /**
  47012. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47013. * @param effect The effect to update
  47014. * @param lightIndex The index of the light in the effect to update
  47015. * @returns The spot light
  47016. */
  47017. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47018. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47019. /**
  47020. * Disposes the light and the associated resources.
  47021. */
  47022. dispose(): void;
  47023. /**
  47024. * Prepares the list of defines specific to the light type.
  47025. * @param defines the list of defines
  47026. * @param lightIndex defines the index of the light for the effect
  47027. */
  47028. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47029. }
  47030. }
  47031. declare module "babylonjs/Gizmos/lightGizmo" {
  47032. import { Nullable } from "babylonjs/types";
  47033. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47034. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47035. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47036. import { Light } from "babylonjs/Lights/light";
  47037. /**
  47038. * Gizmo that enables viewing a light
  47039. */
  47040. export class LightGizmo extends Gizmo {
  47041. private _lightMesh;
  47042. private _material;
  47043. private cachedPosition;
  47044. private cachedForward;
  47045. /**
  47046. * Creates a LightGizmo
  47047. * @param gizmoLayer The utility layer the gizmo will be added to
  47048. */
  47049. constructor(gizmoLayer?: UtilityLayerRenderer);
  47050. private _light;
  47051. /**
  47052. * The light that the gizmo is attached to
  47053. */
  47054. light: Nullable<Light>;
  47055. /**
  47056. * Gets the material used to render the light gizmo
  47057. */
  47058. readonly material: StandardMaterial;
  47059. /**
  47060. * @hidden
  47061. * Updates the gizmo to match the attached mesh's position/rotation
  47062. */
  47063. protected _update(): void;
  47064. private static _Scale;
  47065. /**
  47066. * Creates the lines for a light mesh
  47067. */
  47068. private static _createLightLines;
  47069. /**
  47070. * Disposes of the light gizmo
  47071. */
  47072. dispose(): void;
  47073. private static _CreateHemisphericLightMesh;
  47074. private static _CreatePointLightMesh;
  47075. private static _CreateSpotLightMesh;
  47076. private static _CreateDirectionalLightMesh;
  47077. }
  47078. }
  47079. declare module "babylonjs/Gizmos/index" {
  47080. export * from "babylonjs/Gizmos/axisDragGizmo";
  47081. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47082. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47083. export * from "babylonjs/Gizmos/gizmo";
  47084. export * from "babylonjs/Gizmos/gizmoManager";
  47085. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47086. export * from "babylonjs/Gizmos/positionGizmo";
  47087. export * from "babylonjs/Gizmos/rotationGizmo";
  47088. export * from "babylonjs/Gizmos/scaleGizmo";
  47089. export * from "babylonjs/Gizmos/lightGizmo";
  47090. export * from "babylonjs/Gizmos/planeDragGizmo";
  47091. }
  47092. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47093. /** @hidden */
  47094. export var backgroundFragmentDeclaration: {
  47095. name: string;
  47096. shader: string;
  47097. };
  47098. }
  47099. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47100. /** @hidden */
  47101. export var backgroundUboDeclaration: {
  47102. name: string;
  47103. shader: string;
  47104. };
  47105. }
  47106. declare module "babylonjs/Shaders/background.fragment" {
  47107. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47108. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47109. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47110. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47111. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47112. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47113. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47114. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47115. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47116. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47117. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47118. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47119. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47120. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47121. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47122. /** @hidden */
  47123. export var backgroundPixelShader: {
  47124. name: string;
  47125. shader: string;
  47126. };
  47127. }
  47128. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47129. /** @hidden */
  47130. export var backgroundVertexDeclaration: {
  47131. name: string;
  47132. shader: string;
  47133. };
  47134. }
  47135. declare module "babylonjs/Shaders/background.vertex" {
  47136. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47137. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47138. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47139. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47140. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47141. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47142. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47143. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47144. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47145. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47146. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47147. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47148. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47149. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47150. /** @hidden */
  47151. export var backgroundVertexShader: {
  47152. name: string;
  47153. shader: string;
  47154. };
  47155. }
  47156. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47157. import { Nullable, int, float } from "babylonjs/types";
  47158. import { Scene } from "babylonjs/scene";
  47159. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47160. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47162. import { Mesh } from "babylonjs/Meshes/mesh";
  47163. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47164. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47165. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47166. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47167. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47168. import { Color3 } from "babylonjs/Maths/math.color";
  47169. import "babylonjs/Shaders/background.fragment";
  47170. import "babylonjs/Shaders/background.vertex";
  47171. /**
  47172. * Background material used to create an efficient environement around your scene.
  47173. */
  47174. export class BackgroundMaterial extends PushMaterial {
  47175. /**
  47176. * Standard reflectance value at parallel view angle.
  47177. */
  47178. static StandardReflectance0: number;
  47179. /**
  47180. * Standard reflectance value at grazing angle.
  47181. */
  47182. static StandardReflectance90: number;
  47183. protected _primaryColor: Color3;
  47184. /**
  47185. * Key light Color (multiply against the environement texture)
  47186. */
  47187. primaryColor: Color3;
  47188. protected __perceptualColor: Nullable<Color3>;
  47189. /**
  47190. * Experimental Internal Use Only.
  47191. *
  47192. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47193. * This acts as a helper to set the primary color to a more "human friendly" value.
  47194. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47195. * output color as close as possible from the chosen value.
  47196. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47197. * part of lighting setup.)
  47198. */
  47199. _perceptualColor: Nullable<Color3>;
  47200. protected _primaryColorShadowLevel: float;
  47201. /**
  47202. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47203. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47204. */
  47205. primaryColorShadowLevel: float;
  47206. protected _primaryColorHighlightLevel: float;
  47207. /**
  47208. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47209. * The primary color is used at the level chosen to define what the white area would look.
  47210. */
  47211. primaryColorHighlightLevel: float;
  47212. protected _reflectionTexture: Nullable<BaseTexture>;
  47213. /**
  47214. * Reflection Texture used in the material.
  47215. * Should be author in a specific way for the best result (refer to the documentation).
  47216. */
  47217. reflectionTexture: Nullable<BaseTexture>;
  47218. protected _reflectionBlur: float;
  47219. /**
  47220. * Reflection Texture level of blur.
  47221. *
  47222. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47223. * texture twice.
  47224. */
  47225. reflectionBlur: float;
  47226. protected _diffuseTexture: Nullable<BaseTexture>;
  47227. /**
  47228. * Diffuse Texture used in the material.
  47229. * Should be author in a specific way for the best result (refer to the documentation).
  47230. */
  47231. diffuseTexture: Nullable<BaseTexture>;
  47232. protected _shadowLights: Nullable<IShadowLight[]>;
  47233. /**
  47234. * Specify the list of lights casting shadow on the material.
  47235. * All scene shadow lights will be included if null.
  47236. */
  47237. shadowLights: Nullable<IShadowLight[]>;
  47238. protected _shadowLevel: float;
  47239. /**
  47240. * Helps adjusting the shadow to a softer level if required.
  47241. * 0 means black shadows and 1 means no shadows.
  47242. */
  47243. shadowLevel: float;
  47244. protected _sceneCenter: Vector3;
  47245. /**
  47246. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47247. * It is usually zero but might be interesting to modify according to your setup.
  47248. */
  47249. sceneCenter: Vector3;
  47250. protected _opacityFresnel: boolean;
  47251. /**
  47252. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47253. * This helps ensuring a nice transition when the camera goes under the ground.
  47254. */
  47255. opacityFresnel: boolean;
  47256. protected _reflectionFresnel: boolean;
  47257. /**
  47258. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47259. * This helps adding a mirror texture on the ground.
  47260. */
  47261. reflectionFresnel: boolean;
  47262. protected _reflectionFalloffDistance: number;
  47263. /**
  47264. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47265. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47266. */
  47267. reflectionFalloffDistance: number;
  47268. protected _reflectionAmount: number;
  47269. /**
  47270. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47271. */
  47272. reflectionAmount: number;
  47273. protected _reflectionReflectance0: number;
  47274. /**
  47275. * This specifies the weight of the reflection at grazing angle.
  47276. */
  47277. reflectionReflectance0: number;
  47278. protected _reflectionReflectance90: number;
  47279. /**
  47280. * This specifies the weight of the reflection at a perpendicular point of view.
  47281. */
  47282. reflectionReflectance90: number;
  47283. /**
  47284. * Sets the reflection reflectance fresnel values according to the default standard
  47285. * empirically know to work well :-)
  47286. */
  47287. reflectionStandardFresnelWeight: number;
  47288. protected _useRGBColor: boolean;
  47289. /**
  47290. * Helps to directly use the maps channels instead of their level.
  47291. */
  47292. useRGBColor: boolean;
  47293. protected _enableNoise: boolean;
  47294. /**
  47295. * This helps reducing the banding effect that could occur on the background.
  47296. */
  47297. enableNoise: boolean;
  47298. /**
  47299. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47300. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47301. * Recommended to be keep at 1.0 except for special cases.
  47302. */
  47303. fovMultiplier: number;
  47304. private _fovMultiplier;
  47305. /**
  47306. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47307. */
  47308. useEquirectangularFOV: boolean;
  47309. private _maxSimultaneousLights;
  47310. /**
  47311. * Number of Simultaneous lights allowed on the material.
  47312. */
  47313. maxSimultaneousLights: int;
  47314. /**
  47315. * Default configuration related to image processing available in the Background Material.
  47316. */
  47317. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47318. /**
  47319. * Keep track of the image processing observer to allow dispose and replace.
  47320. */
  47321. private _imageProcessingObserver;
  47322. /**
  47323. * Attaches a new image processing configuration to the PBR Material.
  47324. * @param configuration (if null the scene configuration will be use)
  47325. */
  47326. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47327. /**
  47328. * Gets the image processing configuration used either in this material.
  47329. */
  47330. /**
  47331. * Sets the Default image processing configuration used either in the this material.
  47332. *
  47333. * If sets to null, the scene one is in use.
  47334. */
  47335. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47336. /**
  47337. * Gets wether the color curves effect is enabled.
  47338. */
  47339. /**
  47340. * Sets wether the color curves effect is enabled.
  47341. */
  47342. cameraColorCurvesEnabled: boolean;
  47343. /**
  47344. * Gets wether the color grading effect is enabled.
  47345. */
  47346. /**
  47347. * Gets wether the color grading effect is enabled.
  47348. */
  47349. cameraColorGradingEnabled: boolean;
  47350. /**
  47351. * Gets wether tonemapping is enabled or not.
  47352. */
  47353. /**
  47354. * Sets wether tonemapping is enabled or not
  47355. */
  47356. cameraToneMappingEnabled: boolean;
  47357. /**
  47358. * The camera exposure used on this material.
  47359. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47360. * This corresponds to a photographic exposure.
  47361. */
  47362. /**
  47363. * The camera exposure used on this material.
  47364. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47365. * This corresponds to a photographic exposure.
  47366. */
  47367. cameraExposure: float;
  47368. /**
  47369. * Gets The camera contrast used on this material.
  47370. */
  47371. /**
  47372. * Sets The camera contrast used on this material.
  47373. */
  47374. cameraContrast: float;
  47375. /**
  47376. * Gets the Color Grading 2D Lookup Texture.
  47377. */
  47378. /**
  47379. * Sets the Color Grading 2D Lookup Texture.
  47380. */
  47381. cameraColorGradingTexture: Nullable<BaseTexture>;
  47382. /**
  47383. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47384. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47385. * 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;
  47386. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47387. */
  47388. /**
  47389. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47390. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47391. * 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;
  47392. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47393. */
  47394. cameraColorCurves: Nullable<ColorCurves>;
  47395. /**
  47396. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47397. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47398. */
  47399. switchToBGR: boolean;
  47400. private _renderTargets;
  47401. private _reflectionControls;
  47402. private _white;
  47403. private _primaryShadowColor;
  47404. private _primaryHighlightColor;
  47405. /**
  47406. * Instantiates a Background Material in the given scene
  47407. * @param name The friendly name of the material
  47408. * @param scene The scene to add the material to
  47409. */
  47410. constructor(name: string, scene: Scene);
  47411. /**
  47412. * Gets a boolean indicating that current material needs to register RTT
  47413. */
  47414. readonly hasRenderTargetTextures: boolean;
  47415. /**
  47416. * The entire material has been created in order to prevent overdraw.
  47417. * @returns false
  47418. */
  47419. needAlphaTesting(): boolean;
  47420. /**
  47421. * The entire material has been created in order to prevent overdraw.
  47422. * @returns true if blending is enable
  47423. */
  47424. needAlphaBlending(): boolean;
  47425. /**
  47426. * Checks wether the material is ready to be rendered for a given mesh.
  47427. * @param mesh The mesh to render
  47428. * @param subMesh The submesh to check against
  47429. * @param useInstances Specify wether or not the material is used with instances
  47430. * @returns true if all the dependencies are ready (Textures, Effects...)
  47431. */
  47432. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47433. /**
  47434. * Compute the primary color according to the chosen perceptual color.
  47435. */
  47436. private _computePrimaryColorFromPerceptualColor;
  47437. /**
  47438. * Compute the highlights and shadow colors according to their chosen levels.
  47439. */
  47440. private _computePrimaryColors;
  47441. /**
  47442. * Build the uniform buffer used in the material.
  47443. */
  47444. buildUniformLayout(): void;
  47445. /**
  47446. * Unbind the material.
  47447. */
  47448. unbind(): void;
  47449. /**
  47450. * Bind only the world matrix to the material.
  47451. * @param world The world matrix to bind.
  47452. */
  47453. bindOnlyWorldMatrix(world: Matrix): void;
  47454. /**
  47455. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47456. * @param world The world matrix to bind.
  47457. * @param subMesh The submesh to bind for.
  47458. */
  47459. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47460. /**
  47461. * Checks to see if a texture is used in the material.
  47462. * @param texture - Base texture to use.
  47463. * @returns - Boolean specifying if a texture is used in the material.
  47464. */
  47465. hasTexture(texture: BaseTexture): boolean;
  47466. /**
  47467. * Dispose the material.
  47468. * @param forceDisposeEffect Force disposal of the associated effect.
  47469. * @param forceDisposeTextures Force disposal of the associated textures.
  47470. */
  47471. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47472. /**
  47473. * Clones the material.
  47474. * @param name The cloned name.
  47475. * @returns The cloned material.
  47476. */
  47477. clone(name: string): BackgroundMaterial;
  47478. /**
  47479. * Serializes the current material to its JSON representation.
  47480. * @returns The JSON representation.
  47481. */
  47482. serialize(): any;
  47483. /**
  47484. * Gets the class name of the material
  47485. * @returns "BackgroundMaterial"
  47486. */
  47487. getClassName(): string;
  47488. /**
  47489. * Parse a JSON input to create back a background material.
  47490. * @param source The JSON data to parse
  47491. * @param scene The scene to create the parsed material in
  47492. * @param rootUrl The root url of the assets the material depends upon
  47493. * @returns the instantiated BackgroundMaterial.
  47494. */
  47495. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47496. }
  47497. }
  47498. declare module "babylonjs/Helpers/environmentHelper" {
  47499. import { Observable } from "babylonjs/Misc/observable";
  47500. import { Nullable } from "babylonjs/types";
  47501. import { Scene } from "babylonjs/scene";
  47502. import { Vector3 } from "babylonjs/Maths/math.vector";
  47503. import { Color3 } from "babylonjs/Maths/math.color";
  47504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47505. import { Mesh } from "babylonjs/Meshes/mesh";
  47506. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47507. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47508. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47509. import "babylonjs/Meshes/Builders/planeBuilder";
  47510. import "babylonjs/Meshes/Builders/boxBuilder";
  47511. /**
  47512. * Represents the different options available during the creation of
  47513. * a Environment helper.
  47514. *
  47515. * This can control the default ground, skybox and image processing setup of your scene.
  47516. */
  47517. export interface IEnvironmentHelperOptions {
  47518. /**
  47519. * Specifies wether or not to create a ground.
  47520. * True by default.
  47521. */
  47522. createGround: boolean;
  47523. /**
  47524. * Specifies the ground size.
  47525. * 15 by default.
  47526. */
  47527. groundSize: number;
  47528. /**
  47529. * The texture used on the ground for the main color.
  47530. * Comes from the BabylonJS CDN by default.
  47531. *
  47532. * Remarks: Can be either a texture or a url.
  47533. */
  47534. groundTexture: string | BaseTexture;
  47535. /**
  47536. * The color mixed in the ground texture by default.
  47537. * BabylonJS clearColor by default.
  47538. */
  47539. groundColor: Color3;
  47540. /**
  47541. * Specifies the ground opacity.
  47542. * 1 by default.
  47543. */
  47544. groundOpacity: number;
  47545. /**
  47546. * Enables the ground to receive shadows.
  47547. * True by default.
  47548. */
  47549. enableGroundShadow: boolean;
  47550. /**
  47551. * Helps preventing the shadow to be fully black on the ground.
  47552. * 0.5 by default.
  47553. */
  47554. groundShadowLevel: number;
  47555. /**
  47556. * Creates a mirror texture attach to the ground.
  47557. * false by default.
  47558. */
  47559. enableGroundMirror: boolean;
  47560. /**
  47561. * Specifies the ground mirror size ratio.
  47562. * 0.3 by default as the default kernel is 64.
  47563. */
  47564. groundMirrorSizeRatio: number;
  47565. /**
  47566. * Specifies the ground mirror blur kernel size.
  47567. * 64 by default.
  47568. */
  47569. groundMirrorBlurKernel: number;
  47570. /**
  47571. * Specifies the ground mirror visibility amount.
  47572. * 1 by default
  47573. */
  47574. groundMirrorAmount: number;
  47575. /**
  47576. * Specifies the ground mirror reflectance weight.
  47577. * This uses the standard weight of the background material to setup the fresnel effect
  47578. * of the mirror.
  47579. * 1 by default.
  47580. */
  47581. groundMirrorFresnelWeight: number;
  47582. /**
  47583. * Specifies the ground mirror Falloff distance.
  47584. * This can helps reducing the size of the reflection.
  47585. * 0 by Default.
  47586. */
  47587. groundMirrorFallOffDistance: number;
  47588. /**
  47589. * Specifies the ground mirror texture type.
  47590. * Unsigned Int by Default.
  47591. */
  47592. groundMirrorTextureType: number;
  47593. /**
  47594. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47595. * the shown objects.
  47596. */
  47597. groundYBias: number;
  47598. /**
  47599. * Specifies wether or not to create a skybox.
  47600. * True by default.
  47601. */
  47602. createSkybox: boolean;
  47603. /**
  47604. * Specifies the skybox size.
  47605. * 20 by default.
  47606. */
  47607. skyboxSize: number;
  47608. /**
  47609. * The texture used on the skybox for the main color.
  47610. * Comes from the BabylonJS CDN by default.
  47611. *
  47612. * Remarks: Can be either a texture or a url.
  47613. */
  47614. skyboxTexture: string | BaseTexture;
  47615. /**
  47616. * The color mixed in the skybox texture by default.
  47617. * BabylonJS clearColor by default.
  47618. */
  47619. skyboxColor: Color3;
  47620. /**
  47621. * The background rotation around the Y axis of the scene.
  47622. * This helps aligning the key lights of your scene with the background.
  47623. * 0 by default.
  47624. */
  47625. backgroundYRotation: number;
  47626. /**
  47627. * Compute automatically the size of the elements to best fit with the scene.
  47628. */
  47629. sizeAuto: boolean;
  47630. /**
  47631. * Default position of the rootMesh if autoSize is not true.
  47632. */
  47633. rootPosition: Vector3;
  47634. /**
  47635. * Sets up the image processing in the scene.
  47636. * true by default.
  47637. */
  47638. setupImageProcessing: boolean;
  47639. /**
  47640. * The texture used as your environment texture in the scene.
  47641. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47642. *
  47643. * Remarks: Can be either a texture or a url.
  47644. */
  47645. environmentTexture: string | BaseTexture;
  47646. /**
  47647. * The value of the exposure to apply to the scene.
  47648. * 0.6 by default if setupImageProcessing is true.
  47649. */
  47650. cameraExposure: number;
  47651. /**
  47652. * The value of the contrast to apply to the scene.
  47653. * 1.6 by default if setupImageProcessing is true.
  47654. */
  47655. cameraContrast: number;
  47656. /**
  47657. * Specifies wether or not tonemapping should be enabled in the scene.
  47658. * true by default if setupImageProcessing is true.
  47659. */
  47660. toneMappingEnabled: boolean;
  47661. }
  47662. /**
  47663. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47664. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47665. * It also helps with the default setup of your imageProcessing configuration.
  47666. */
  47667. export class EnvironmentHelper {
  47668. /**
  47669. * Default ground texture URL.
  47670. */
  47671. private static _groundTextureCDNUrl;
  47672. /**
  47673. * Default skybox texture URL.
  47674. */
  47675. private static _skyboxTextureCDNUrl;
  47676. /**
  47677. * Default environment texture URL.
  47678. */
  47679. private static _environmentTextureCDNUrl;
  47680. /**
  47681. * Creates the default options for the helper.
  47682. */
  47683. private static _getDefaultOptions;
  47684. private _rootMesh;
  47685. /**
  47686. * Gets the root mesh created by the helper.
  47687. */
  47688. readonly rootMesh: Mesh;
  47689. private _skybox;
  47690. /**
  47691. * Gets the skybox created by the helper.
  47692. */
  47693. readonly skybox: Nullable<Mesh>;
  47694. private _skyboxTexture;
  47695. /**
  47696. * Gets the skybox texture created by the helper.
  47697. */
  47698. readonly skyboxTexture: Nullable<BaseTexture>;
  47699. private _skyboxMaterial;
  47700. /**
  47701. * Gets the skybox material created by the helper.
  47702. */
  47703. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47704. private _ground;
  47705. /**
  47706. * Gets the ground mesh created by the helper.
  47707. */
  47708. readonly ground: Nullable<Mesh>;
  47709. private _groundTexture;
  47710. /**
  47711. * Gets the ground texture created by the helper.
  47712. */
  47713. readonly groundTexture: Nullable<BaseTexture>;
  47714. private _groundMirror;
  47715. /**
  47716. * Gets the ground mirror created by the helper.
  47717. */
  47718. readonly groundMirror: Nullable<MirrorTexture>;
  47719. /**
  47720. * Gets the ground mirror render list to helps pushing the meshes
  47721. * you wish in the ground reflection.
  47722. */
  47723. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47724. private _groundMaterial;
  47725. /**
  47726. * Gets the ground material created by the helper.
  47727. */
  47728. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47729. /**
  47730. * Stores the creation options.
  47731. */
  47732. private readonly _scene;
  47733. private _options;
  47734. /**
  47735. * This observable will be notified with any error during the creation of the environment,
  47736. * mainly texture creation errors.
  47737. */
  47738. onErrorObservable: Observable<{
  47739. message?: string;
  47740. exception?: any;
  47741. }>;
  47742. /**
  47743. * constructor
  47744. * @param options Defines the options we want to customize the helper
  47745. * @param scene The scene to add the material to
  47746. */
  47747. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47748. /**
  47749. * Updates the background according to the new options
  47750. * @param options
  47751. */
  47752. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47753. /**
  47754. * Sets the primary color of all the available elements.
  47755. * @param color the main color to affect to the ground and the background
  47756. */
  47757. setMainColor(color: Color3): void;
  47758. /**
  47759. * Setup the image processing according to the specified options.
  47760. */
  47761. private _setupImageProcessing;
  47762. /**
  47763. * Setup the environment texture according to the specified options.
  47764. */
  47765. private _setupEnvironmentTexture;
  47766. /**
  47767. * Setup the background according to the specified options.
  47768. */
  47769. private _setupBackground;
  47770. /**
  47771. * Get the scene sizes according to the setup.
  47772. */
  47773. private _getSceneSize;
  47774. /**
  47775. * Setup the ground according to the specified options.
  47776. */
  47777. private _setupGround;
  47778. /**
  47779. * Setup the ground material according to the specified options.
  47780. */
  47781. private _setupGroundMaterial;
  47782. /**
  47783. * Setup the ground diffuse texture according to the specified options.
  47784. */
  47785. private _setupGroundDiffuseTexture;
  47786. /**
  47787. * Setup the ground mirror texture according to the specified options.
  47788. */
  47789. private _setupGroundMirrorTexture;
  47790. /**
  47791. * Setup the ground to receive the mirror texture.
  47792. */
  47793. private _setupMirrorInGroundMaterial;
  47794. /**
  47795. * Setup the skybox according to the specified options.
  47796. */
  47797. private _setupSkybox;
  47798. /**
  47799. * Setup the skybox material according to the specified options.
  47800. */
  47801. private _setupSkyboxMaterial;
  47802. /**
  47803. * Setup the skybox reflection texture according to the specified options.
  47804. */
  47805. private _setupSkyboxReflectionTexture;
  47806. private _errorHandler;
  47807. /**
  47808. * Dispose all the elements created by the Helper.
  47809. */
  47810. dispose(): void;
  47811. }
  47812. }
  47813. declare module "babylonjs/Helpers/photoDome" {
  47814. import { Observable } from "babylonjs/Misc/observable";
  47815. import { Nullable } from "babylonjs/types";
  47816. import { Scene } from "babylonjs/scene";
  47817. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47818. import { Mesh } from "babylonjs/Meshes/mesh";
  47819. import { Texture } from "babylonjs/Materials/Textures/texture";
  47820. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47821. import "babylonjs/Meshes/Builders/sphereBuilder";
  47822. /**
  47823. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47824. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47825. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47826. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47827. */
  47828. export class PhotoDome extends TransformNode {
  47829. /**
  47830. * Define the image as a Monoscopic panoramic 360 image.
  47831. */
  47832. static readonly MODE_MONOSCOPIC: number;
  47833. /**
  47834. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47835. */
  47836. static readonly MODE_TOPBOTTOM: number;
  47837. /**
  47838. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47839. */
  47840. static readonly MODE_SIDEBYSIDE: number;
  47841. private _useDirectMapping;
  47842. /**
  47843. * The texture being displayed on the sphere
  47844. */
  47845. protected _photoTexture: Texture;
  47846. /**
  47847. * Gets or sets the texture being displayed on the sphere
  47848. */
  47849. photoTexture: Texture;
  47850. /**
  47851. * Observable raised when an error occured while loading the 360 image
  47852. */
  47853. onLoadErrorObservable: Observable<string>;
  47854. /**
  47855. * The skybox material
  47856. */
  47857. protected _material: BackgroundMaterial;
  47858. /**
  47859. * The surface used for the skybox
  47860. */
  47861. protected _mesh: Mesh;
  47862. /**
  47863. * Gets the mesh used for the skybox.
  47864. */
  47865. readonly mesh: Mesh;
  47866. /**
  47867. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47868. * Also see the options.resolution property.
  47869. */
  47870. fovMultiplier: number;
  47871. private _imageMode;
  47872. /**
  47873. * Gets or set the current video mode for the video. It can be:
  47874. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47875. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47876. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47877. */
  47878. imageMode: number;
  47879. /**
  47880. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47881. * @param name Element's name, child elements will append suffixes for their own names.
  47882. * @param urlsOfPhoto defines the url of the photo to display
  47883. * @param options defines an object containing optional or exposed sub element properties
  47884. * @param onError defines a callback called when an error occured while loading the texture
  47885. */
  47886. constructor(name: string, urlOfPhoto: string, options: {
  47887. resolution?: number;
  47888. size?: number;
  47889. useDirectMapping?: boolean;
  47890. faceForward?: boolean;
  47891. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47892. private _onBeforeCameraRenderObserver;
  47893. private _changeImageMode;
  47894. /**
  47895. * Releases resources associated with this node.
  47896. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47897. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47898. */
  47899. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47900. }
  47901. }
  47902. declare module "babylonjs/Misc/rgbdTextureTools" {
  47903. import "babylonjs/Shaders/rgbdDecode.fragment";
  47904. import { Texture } from "babylonjs/Materials/Textures/texture";
  47905. /**
  47906. * Class used to host RGBD texture specific utilities
  47907. */
  47908. export class RGBDTextureTools {
  47909. /**
  47910. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47911. * @param texture the texture to expand.
  47912. */
  47913. static ExpandRGBDTexture(texture: Texture): void;
  47914. }
  47915. }
  47916. declare module "babylonjs/Misc/brdfTextureTools" {
  47917. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47918. import { Scene } from "babylonjs/scene";
  47919. /**
  47920. * Class used to host texture specific utilities
  47921. */
  47922. export class BRDFTextureTools {
  47923. /**
  47924. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47925. * @param scene defines the hosting scene
  47926. * @returns the environment BRDF texture
  47927. */
  47928. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47929. private static _environmentBRDFBase64Texture;
  47930. }
  47931. }
  47932. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47933. import { Nullable } from "babylonjs/types";
  47934. import { Color3 } from "babylonjs/Maths/math.color";
  47935. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47936. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47937. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47938. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47939. import { Engine } from "babylonjs/Engines/engine";
  47940. import { Scene } from "babylonjs/scene";
  47941. /**
  47942. * @hidden
  47943. */
  47944. export interface IMaterialClearCoatDefines {
  47945. CLEARCOAT: boolean;
  47946. CLEARCOAT_DEFAULTIOR: boolean;
  47947. CLEARCOAT_TEXTURE: boolean;
  47948. CLEARCOAT_TEXTUREDIRECTUV: number;
  47949. CLEARCOAT_BUMP: boolean;
  47950. CLEARCOAT_BUMPDIRECTUV: number;
  47951. CLEARCOAT_TINT: boolean;
  47952. CLEARCOAT_TINT_TEXTURE: boolean;
  47953. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47954. /** @hidden */
  47955. _areTexturesDirty: boolean;
  47956. }
  47957. /**
  47958. * Define the code related to the clear coat parameters of the pbr material.
  47959. */
  47960. export class PBRClearCoatConfiguration {
  47961. /**
  47962. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47963. * The default fits with a polyurethane material.
  47964. */
  47965. private static readonly _DefaultIndexOfRefraction;
  47966. private _isEnabled;
  47967. /**
  47968. * Defines if the clear coat is enabled in the material.
  47969. */
  47970. isEnabled: boolean;
  47971. /**
  47972. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47973. */
  47974. intensity: number;
  47975. /**
  47976. * Defines the clear coat layer roughness.
  47977. */
  47978. roughness: number;
  47979. private _indexOfRefraction;
  47980. /**
  47981. * Defines the index of refraction of the clear coat.
  47982. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47983. * The default fits with a polyurethane material.
  47984. * Changing the default value is more performance intensive.
  47985. */
  47986. indexOfRefraction: number;
  47987. private _texture;
  47988. /**
  47989. * Stores the clear coat values in a texture.
  47990. */
  47991. texture: Nullable<BaseTexture>;
  47992. private _bumpTexture;
  47993. /**
  47994. * Define the clear coat specific bump texture.
  47995. */
  47996. bumpTexture: Nullable<BaseTexture>;
  47997. private _isTintEnabled;
  47998. /**
  47999. * Defines if the clear coat tint is enabled in the material.
  48000. */
  48001. isTintEnabled: boolean;
  48002. /**
  48003. * Defines the clear coat tint of the material.
  48004. * This is only use if tint is enabled
  48005. */
  48006. tintColor: Color3;
  48007. /**
  48008. * Defines the distance at which the tint color should be found in the
  48009. * clear coat media.
  48010. * This is only use if tint is enabled
  48011. */
  48012. tintColorAtDistance: number;
  48013. /**
  48014. * Defines the clear coat layer thickness.
  48015. * This is only use if tint is enabled
  48016. */
  48017. tintThickness: number;
  48018. private _tintTexture;
  48019. /**
  48020. * Stores the clear tint values in a texture.
  48021. * rgb is tint
  48022. * a is a thickness factor
  48023. */
  48024. tintTexture: Nullable<BaseTexture>;
  48025. /** @hidden */
  48026. private _internalMarkAllSubMeshesAsTexturesDirty;
  48027. /** @hidden */
  48028. _markAllSubMeshesAsTexturesDirty(): void;
  48029. /**
  48030. * Instantiate a new istance of clear coat configuration.
  48031. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48032. */
  48033. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48034. /**
  48035. * Gets wehter the submesh is ready to be used or not.
  48036. * @param defines the list of "defines" to update.
  48037. * @param scene defines the scene the material belongs to.
  48038. * @param engine defines the engine the material belongs to.
  48039. * @param disableBumpMap defines wether the material disables bump or not.
  48040. * @returns - boolean indicating that the submesh is ready or not.
  48041. */
  48042. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48043. /**
  48044. * Checks to see if a texture is used in the material.
  48045. * @param defines the list of "defines" to update.
  48046. * @param scene defines the scene to the material belongs to.
  48047. */
  48048. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48049. /**
  48050. * Binds the material data.
  48051. * @param uniformBuffer defines the Uniform buffer to fill in.
  48052. * @param scene defines the scene the material belongs to.
  48053. * @param engine defines the engine the material belongs to.
  48054. * @param disableBumpMap defines wether the material disables bump or not.
  48055. * @param isFrozen defines wether the material is frozen or not.
  48056. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48057. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48058. */
  48059. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48060. /**
  48061. * Checks to see if a texture is used in the material.
  48062. * @param texture - Base texture to use.
  48063. * @returns - Boolean specifying if a texture is used in the material.
  48064. */
  48065. hasTexture(texture: BaseTexture): boolean;
  48066. /**
  48067. * Returns an array of the actively used textures.
  48068. * @param activeTextures Array of BaseTextures
  48069. */
  48070. getActiveTextures(activeTextures: BaseTexture[]): void;
  48071. /**
  48072. * Returns the animatable textures.
  48073. * @param animatables Array of animatable textures.
  48074. */
  48075. getAnimatables(animatables: IAnimatable[]): void;
  48076. /**
  48077. * Disposes the resources of the material.
  48078. * @param forceDisposeTextures - Forces the disposal of all textures.
  48079. */
  48080. dispose(forceDisposeTextures?: boolean): void;
  48081. /**
  48082. * Get the current class name of the texture useful for serialization or dynamic coding.
  48083. * @returns "PBRClearCoatConfiguration"
  48084. */
  48085. getClassName(): string;
  48086. /**
  48087. * Add fallbacks to the effect fallbacks list.
  48088. * @param defines defines the Base texture to use.
  48089. * @param fallbacks defines the current fallback list.
  48090. * @param currentRank defines the current fallback rank.
  48091. * @returns the new fallback rank.
  48092. */
  48093. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48094. /**
  48095. * Add the required uniforms to the current list.
  48096. * @param uniforms defines the current uniform list.
  48097. */
  48098. static AddUniforms(uniforms: string[]): void;
  48099. /**
  48100. * Add the required samplers to the current list.
  48101. * @param samplers defines the current sampler list.
  48102. */
  48103. static AddSamplers(samplers: string[]): void;
  48104. /**
  48105. * Add the required uniforms to the current buffer.
  48106. * @param uniformBuffer defines the current uniform buffer.
  48107. */
  48108. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48109. /**
  48110. * Makes a duplicate of the current configuration into another one.
  48111. * @param clearCoatConfiguration define the config where to copy the info
  48112. */
  48113. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48114. /**
  48115. * Serializes this clear coat configuration.
  48116. * @returns - An object with the serialized config.
  48117. */
  48118. serialize(): any;
  48119. /**
  48120. * Parses a anisotropy Configuration from a serialized object.
  48121. * @param source - Serialized object.
  48122. * @param scene Defines the scene we are parsing for
  48123. * @param rootUrl Defines the rootUrl to load from
  48124. */
  48125. parse(source: any, scene: Scene, rootUrl: string): void;
  48126. }
  48127. }
  48128. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48129. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48130. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48132. import { Vector2 } from "babylonjs/Maths/math.vector";
  48133. import { Scene } from "babylonjs/scene";
  48134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48135. import { Nullable } from "babylonjs/types";
  48136. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48137. /**
  48138. * @hidden
  48139. */
  48140. export interface IMaterialAnisotropicDefines {
  48141. ANISOTROPIC: boolean;
  48142. ANISOTROPIC_TEXTURE: boolean;
  48143. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48144. MAINUV1: boolean;
  48145. _areTexturesDirty: boolean;
  48146. _needUVs: boolean;
  48147. }
  48148. /**
  48149. * Define the code related to the anisotropic parameters of the pbr material.
  48150. */
  48151. export class PBRAnisotropicConfiguration {
  48152. private _isEnabled;
  48153. /**
  48154. * Defines if the anisotropy is enabled in the material.
  48155. */
  48156. isEnabled: boolean;
  48157. /**
  48158. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48159. */
  48160. intensity: number;
  48161. /**
  48162. * Defines if the effect is along the tangents, bitangents or in between.
  48163. * By default, the effect is "strectching" the highlights along the tangents.
  48164. */
  48165. direction: Vector2;
  48166. private _texture;
  48167. /**
  48168. * Stores the anisotropy values in a texture.
  48169. * rg is direction (like normal from -1 to 1)
  48170. * b is a intensity
  48171. */
  48172. texture: Nullable<BaseTexture>;
  48173. /** @hidden */
  48174. private _internalMarkAllSubMeshesAsTexturesDirty;
  48175. /** @hidden */
  48176. _markAllSubMeshesAsTexturesDirty(): void;
  48177. /**
  48178. * Instantiate a new istance of anisotropy configuration.
  48179. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48180. */
  48181. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48182. /**
  48183. * Specifies that the submesh is ready to be used.
  48184. * @param defines the list of "defines" to update.
  48185. * @param scene defines the scene the material belongs to.
  48186. * @returns - boolean indicating that the submesh is ready or not.
  48187. */
  48188. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48189. /**
  48190. * Checks to see if a texture is used in the material.
  48191. * @param defines the list of "defines" to update.
  48192. * @param mesh the mesh we are preparing the defines for.
  48193. * @param scene defines the scene the material belongs to.
  48194. */
  48195. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48196. /**
  48197. * Binds the material data.
  48198. * @param uniformBuffer defines the Uniform buffer to fill in.
  48199. * @param scene defines the scene the material belongs to.
  48200. * @param isFrozen defines wether the material is frozen or not.
  48201. */
  48202. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48203. /**
  48204. * Checks to see if a texture is used in the material.
  48205. * @param texture - Base texture to use.
  48206. * @returns - Boolean specifying if a texture is used in the material.
  48207. */
  48208. hasTexture(texture: BaseTexture): boolean;
  48209. /**
  48210. * Returns an array of the actively used textures.
  48211. * @param activeTextures Array of BaseTextures
  48212. */
  48213. getActiveTextures(activeTextures: BaseTexture[]): void;
  48214. /**
  48215. * Returns the animatable textures.
  48216. * @param animatables Array of animatable textures.
  48217. */
  48218. getAnimatables(animatables: IAnimatable[]): void;
  48219. /**
  48220. * Disposes the resources of the material.
  48221. * @param forceDisposeTextures - Forces the disposal of all textures.
  48222. */
  48223. dispose(forceDisposeTextures?: boolean): void;
  48224. /**
  48225. * Get the current class name of the texture useful for serialization or dynamic coding.
  48226. * @returns "PBRAnisotropicConfiguration"
  48227. */
  48228. getClassName(): string;
  48229. /**
  48230. * Add fallbacks to the effect fallbacks list.
  48231. * @param defines defines the Base texture to use.
  48232. * @param fallbacks defines the current fallback list.
  48233. * @param currentRank defines the current fallback rank.
  48234. * @returns the new fallback rank.
  48235. */
  48236. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48237. /**
  48238. * Add the required uniforms to the current list.
  48239. * @param uniforms defines the current uniform list.
  48240. */
  48241. static AddUniforms(uniforms: string[]): void;
  48242. /**
  48243. * Add the required uniforms to the current buffer.
  48244. * @param uniformBuffer defines the current uniform buffer.
  48245. */
  48246. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48247. /**
  48248. * Add the required samplers to the current list.
  48249. * @param samplers defines the current sampler list.
  48250. */
  48251. static AddSamplers(samplers: string[]): void;
  48252. /**
  48253. * Makes a duplicate of the current configuration into another one.
  48254. * @param anisotropicConfiguration define the config where to copy the info
  48255. */
  48256. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48257. /**
  48258. * Serializes this anisotropy configuration.
  48259. * @returns - An object with the serialized config.
  48260. */
  48261. serialize(): any;
  48262. /**
  48263. * Parses a anisotropy Configuration from a serialized object.
  48264. * @param source - Serialized object.
  48265. * @param scene Defines the scene we are parsing for
  48266. * @param rootUrl Defines the rootUrl to load from
  48267. */
  48268. parse(source: any, scene: Scene, rootUrl: string): void;
  48269. }
  48270. }
  48271. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48272. import { Scene } from "babylonjs/scene";
  48273. /**
  48274. * @hidden
  48275. */
  48276. export interface IMaterialBRDFDefines {
  48277. BRDF_V_HEIGHT_CORRELATED: boolean;
  48278. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48279. SPHERICAL_HARMONICS: boolean;
  48280. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48281. /** @hidden */
  48282. _areMiscDirty: boolean;
  48283. }
  48284. /**
  48285. * Define the code related to the BRDF parameters of the pbr material.
  48286. */
  48287. export class PBRBRDFConfiguration {
  48288. /**
  48289. * Default value used for the energy conservation.
  48290. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48291. */
  48292. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48293. /**
  48294. * Default value used for the Smith Visibility Height Correlated mode.
  48295. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48296. */
  48297. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48298. /**
  48299. * Default value used for the IBL diffuse part.
  48300. * This can help switching back to the polynomials mode globally which is a tiny bit
  48301. * less GPU intensive at the drawback of a lower quality.
  48302. */
  48303. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48304. /**
  48305. * Default value used for activating energy conservation for the specular workflow.
  48306. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48307. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48308. */
  48309. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48310. private _useEnergyConservation;
  48311. /**
  48312. * Defines if the material uses energy conservation.
  48313. */
  48314. useEnergyConservation: boolean;
  48315. private _useSmithVisibilityHeightCorrelated;
  48316. /**
  48317. * LEGACY Mode set to false
  48318. * Defines if the material uses height smith correlated visibility term.
  48319. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48320. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48321. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48322. * Not relying on height correlated will also disable energy conservation.
  48323. */
  48324. useSmithVisibilityHeightCorrelated: boolean;
  48325. private _useSphericalHarmonics;
  48326. /**
  48327. * LEGACY Mode set to false
  48328. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48329. * diffuse part of the IBL.
  48330. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48331. * to the ground truth.
  48332. */
  48333. useSphericalHarmonics: boolean;
  48334. private _useSpecularGlossinessInputEnergyConservation;
  48335. /**
  48336. * Defines if the material uses energy conservation, when the specular workflow is active.
  48337. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48338. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48339. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48340. */
  48341. useSpecularGlossinessInputEnergyConservation: boolean;
  48342. /** @hidden */
  48343. private _internalMarkAllSubMeshesAsMiscDirty;
  48344. /** @hidden */
  48345. _markAllSubMeshesAsMiscDirty(): void;
  48346. /**
  48347. * Instantiate a new istance of clear coat configuration.
  48348. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48349. */
  48350. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48351. /**
  48352. * Checks to see if a texture is used in the material.
  48353. * @param defines the list of "defines" to update.
  48354. */
  48355. prepareDefines(defines: IMaterialBRDFDefines): void;
  48356. /**
  48357. * Get the current class name of the texture useful for serialization or dynamic coding.
  48358. * @returns "PBRClearCoatConfiguration"
  48359. */
  48360. getClassName(): string;
  48361. /**
  48362. * Makes a duplicate of the current configuration into another one.
  48363. * @param brdfConfiguration define the config where to copy the info
  48364. */
  48365. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48366. /**
  48367. * Serializes this BRDF configuration.
  48368. * @returns - An object with the serialized config.
  48369. */
  48370. serialize(): any;
  48371. /**
  48372. * Parses a anisotropy Configuration from a serialized object.
  48373. * @param source - Serialized object.
  48374. * @param scene Defines the scene we are parsing for
  48375. * @param rootUrl Defines the rootUrl to load from
  48376. */
  48377. parse(source: any, scene: Scene, rootUrl: string): void;
  48378. }
  48379. }
  48380. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48381. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48382. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48383. import { Color3 } from "babylonjs/Maths/math.color";
  48384. import { Scene } from "babylonjs/scene";
  48385. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48386. import { Nullable } from "babylonjs/types";
  48387. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48388. /**
  48389. * @hidden
  48390. */
  48391. export interface IMaterialSheenDefines {
  48392. SHEEN: boolean;
  48393. SHEEN_TEXTURE: boolean;
  48394. SHEEN_TEXTUREDIRECTUV: number;
  48395. SHEEN_LINKWITHALBEDO: boolean;
  48396. /** @hidden */
  48397. _areTexturesDirty: boolean;
  48398. }
  48399. /**
  48400. * Define the code related to the Sheen parameters of the pbr material.
  48401. */
  48402. export class PBRSheenConfiguration {
  48403. private _isEnabled;
  48404. /**
  48405. * Defines if the material uses sheen.
  48406. */
  48407. isEnabled: boolean;
  48408. private _linkSheenWithAlbedo;
  48409. /**
  48410. * Defines if the sheen is linked to the sheen color.
  48411. */
  48412. linkSheenWithAlbedo: boolean;
  48413. /**
  48414. * Defines the sheen intensity.
  48415. */
  48416. intensity: number;
  48417. /**
  48418. * Defines the sheen color.
  48419. */
  48420. color: Color3;
  48421. private _texture;
  48422. /**
  48423. * Stores the sheen tint values in a texture.
  48424. * rgb is tint
  48425. * a is a intensity
  48426. */
  48427. texture: Nullable<BaseTexture>;
  48428. /** @hidden */
  48429. private _internalMarkAllSubMeshesAsTexturesDirty;
  48430. /** @hidden */
  48431. _markAllSubMeshesAsTexturesDirty(): void;
  48432. /**
  48433. * Instantiate a new istance of clear coat configuration.
  48434. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48435. */
  48436. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48437. /**
  48438. * Specifies that the submesh is ready to be used.
  48439. * @param defines the list of "defines" to update.
  48440. * @param scene defines the scene the material belongs to.
  48441. * @returns - boolean indicating that the submesh is ready or not.
  48442. */
  48443. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48444. /**
  48445. * Checks to see if a texture is used in the material.
  48446. * @param defines the list of "defines" to update.
  48447. * @param scene defines the scene the material belongs to.
  48448. */
  48449. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48450. /**
  48451. * Binds the material data.
  48452. * @param uniformBuffer defines the Uniform buffer to fill in.
  48453. * @param scene defines the scene the material belongs to.
  48454. * @param isFrozen defines wether the material is frozen or not.
  48455. */
  48456. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48457. /**
  48458. * Checks to see if a texture is used in the material.
  48459. * @param texture - Base texture to use.
  48460. * @returns - Boolean specifying if a texture is used in the material.
  48461. */
  48462. hasTexture(texture: BaseTexture): boolean;
  48463. /**
  48464. * Returns an array of the actively used textures.
  48465. * @param activeTextures Array of BaseTextures
  48466. */
  48467. getActiveTextures(activeTextures: BaseTexture[]): void;
  48468. /**
  48469. * Returns the animatable textures.
  48470. * @param animatables Array of animatable textures.
  48471. */
  48472. getAnimatables(animatables: IAnimatable[]): void;
  48473. /**
  48474. * Disposes the resources of the material.
  48475. * @param forceDisposeTextures - Forces the disposal of all textures.
  48476. */
  48477. dispose(forceDisposeTextures?: boolean): void;
  48478. /**
  48479. * Get the current class name of the texture useful for serialization or dynamic coding.
  48480. * @returns "PBRSheenConfiguration"
  48481. */
  48482. getClassName(): string;
  48483. /**
  48484. * Add fallbacks to the effect fallbacks list.
  48485. * @param defines defines the Base texture to use.
  48486. * @param fallbacks defines the current fallback list.
  48487. * @param currentRank defines the current fallback rank.
  48488. * @returns the new fallback rank.
  48489. */
  48490. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48491. /**
  48492. * Add the required uniforms to the current list.
  48493. * @param uniforms defines the current uniform list.
  48494. */
  48495. static AddUniforms(uniforms: string[]): void;
  48496. /**
  48497. * Add the required uniforms to the current buffer.
  48498. * @param uniformBuffer defines the current uniform buffer.
  48499. */
  48500. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48501. /**
  48502. * Add the required samplers to the current list.
  48503. * @param samplers defines the current sampler list.
  48504. */
  48505. static AddSamplers(samplers: string[]): void;
  48506. /**
  48507. * Makes a duplicate of the current configuration into another one.
  48508. * @param sheenConfiguration define the config where to copy the info
  48509. */
  48510. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48511. /**
  48512. * Serializes this BRDF configuration.
  48513. * @returns - An object with the serialized config.
  48514. */
  48515. serialize(): any;
  48516. /**
  48517. * Parses a anisotropy Configuration from a serialized object.
  48518. * @param source - Serialized object.
  48519. * @param scene Defines the scene we are parsing for
  48520. * @param rootUrl Defines the rootUrl to load from
  48521. */
  48522. parse(source: any, scene: Scene, rootUrl: string): void;
  48523. }
  48524. }
  48525. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48526. import { Nullable } from "babylonjs/types";
  48527. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48528. import { Color3 } from "babylonjs/Maths/math.color";
  48529. import { SmartArray } from "babylonjs/Misc/smartArray";
  48530. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48531. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48532. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  48533. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48534. import { Engine } from "babylonjs/Engines/engine";
  48535. import { Scene } from "babylonjs/scene";
  48536. /**
  48537. * @hidden
  48538. */
  48539. export interface IMaterialSubSurfaceDefines {
  48540. SUBSURFACE: boolean;
  48541. SS_REFRACTION: boolean;
  48542. SS_TRANSLUCENCY: boolean;
  48543. SS_SCATERRING: boolean;
  48544. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48545. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48546. SS_REFRACTIONMAP_3D: boolean;
  48547. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48548. SS_LODINREFRACTIONALPHA: boolean;
  48549. SS_GAMMAREFRACTION: boolean;
  48550. SS_RGBDREFRACTION: boolean;
  48551. SS_LINEARSPECULARREFRACTION: boolean;
  48552. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48553. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48554. /** @hidden */
  48555. _areTexturesDirty: boolean;
  48556. }
  48557. /**
  48558. * Define the code related to the sub surface parameters of the pbr material.
  48559. */
  48560. export class PBRSubSurfaceConfiguration {
  48561. private _isRefractionEnabled;
  48562. /**
  48563. * Defines if the refraction is enabled in the material.
  48564. */
  48565. isRefractionEnabled: boolean;
  48566. private _isTranslucencyEnabled;
  48567. /**
  48568. * Defines if the translucency is enabled in the material.
  48569. */
  48570. isTranslucencyEnabled: boolean;
  48571. private _isScatteringEnabled;
  48572. /**
  48573. * Defines the refraction intensity of the material.
  48574. * The refraction when enabled replaces the Diffuse part of the material.
  48575. * The intensity helps transitionning between diffuse and refraction.
  48576. */
  48577. refractionIntensity: number;
  48578. /**
  48579. * Defines the translucency intensity of the material.
  48580. * When translucency has been enabled, this defines how much of the "translucency"
  48581. * is addded to the diffuse part of the material.
  48582. */
  48583. translucencyIntensity: number;
  48584. /**
  48585. * Defines the scattering intensity of the material.
  48586. * When scattering has been enabled, this defines how much of the "scattered light"
  48587. * is addded to the diffuse part of the material.
  48588. */
  48589. scatteringIntensity: number;
  48590. private _thicknessTexture;
  48591. /**
  48592. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48593. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48594. * 0 would mean minimumThickness
  48595. * 1 would mean maximumThickness
  48596. * The other channels might be use as a mask to vary the different effects intensity.
  48597. */
  48598. thicknessTexture: Nullable<BaseTexture>;
  48599. private _refractionTexture;
  48600. /**
  48601. * Defines the texture to use for refraction.
  48602. */
  48603. refractionTexture: Nullable<BaseTexture>;
  48604. private _indexOfRefraction;
  48605. /**
  48606. * Defines the index of refraction used in the material.
  48607. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48608. */
  48609. indexOfRefraction: number;
  48610. private _invertRefractionY;
  48611. /**
  48612. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48613. */
  48614. invertRefractionY: boolean;
  48615. private _linkRefractionWithTransparency;
  48616. /**
  48617. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48618. * Materials half opaque for instance using refraction could benefit from this control.
  48619. */
  48620. linkRefractionWithTransparency: boolean;
  48621. /**
  48622. * Defines the minimum thickness stored in the thickness map.
  48623. * If no thickness map is defined, this value will be used to simulate thickness.
  48624. */
  48625. minimumThickness: number;
  48626. /**
  48627. * Defines the maximum thickness stored in the thickness map.
  48628. */
  48629. maximumThickness: number;
  48630. /**
  48631. * Defines the volume tint of the material.
  48632. * This is used for both translucency and scattering.
  48633. */
  48634. tintColor: Color3;
  48635. /**
  48636. * Defines the distance at which the tint color should be found in the media.
  48637. * This is used for refraction only.
  48638. */
  48639. tintColorAtDistance: number;
  48640. /**
  48641. * Defines how far each channel transmit through the media.
  48642. * It is defined as a color to simplify it selection.
  48643. */
  48644. diffusionDistance: Color3;
  48645. private _useMaskFromThicknessTexture;
  48646. /**
  48647. * Stores the intensity of the different subsurface effects in the thickness texture.
  48648. * * the green channel is the translucency intensity.
  48649. * * the blue channel is the scattering intensity.
  48650. * * the alpha channel is the refraction intensity.
  48651. */
  48652. useMaskFromThicknessTexture: boolean;
  48653. /** @hidden */
  48654. private _internalMarkAllSubMeshesAsTexturesDirty;
  48655. /** @hidden */
  48656. _markAllSubMeshesAsTexturesDirty(): void;
  48657. /**
  48658. * Instantiate a new istance of sub surface configuration.
  48659. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48660. */
  48661. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48662. /**
  48663. * Gets wehter the submesh is ready to be used or not.
  48664. * @param defines the list of "defines" to update.
  48665. * @param scene defines the scene the material belongs to.
  48666. * @returns - boolean indicating that the submesh is ready or not.
  48667. */
  48668. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48669. /**
  48670. * Checks to see if a texture is used in the material.
  48671. * @param defines the list of "defines" to update.
  48672. * @param scene defines the scene to the material belongs to.
  48673. */
  48674. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48675. /**
  48676. * Binds the material data.
  48677. * @param uniformBuffer defines the Uniform buffer to fill in.
  48678. * @param scene defines the scene the material belongs to.
  48679. * @param engine defines the engine the material belongs to.
  48680. * @param isFrozen defines wether the material is frozen or not.
  48681. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48682. */
  48683. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48684. /**
  48685. * Unbinds the material from the mesh.
  48686. * @param activeEffect defines the effect that should be unbound from.
  48687. * @returns true if unbound, otherwise false
  48688. */
  48689. unbind(activeEffect: Effect): boolean;
  48690. /**
  48691. * Returns the texture used for refraction or null if none is used.
  48692. * @param scene defines the scene the material belongs to.
  48693. * @returns - Refraction texture if present. If no refraction texture and refraction
  48694. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48695. */
  48696. private _getRefractionTexture;
  48697. /**
  48698. * Returns true if alpha blending should be disabled.
  48699. */
  48700. readonly disableAlphaBlending: boolean;
  48701. /**
  48702. * Fills the list of render target textures.
  48703. * @param renderTargets the list of render targets to update
  48704. */
  48705. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48706. /**
  48707. * Checks to see if a texture is used in the material.
  48708. * @param texture - Base texture to use.
  48709. * @returns - Boolean specifying if a texture is used in the material.
  48710. */
  48711. hasTexture(texture: BaseTexture): boolean;
  48712. /**
  48713. * Gets a boolean indicating that current material needs to register RTT
  48714. * @returns true if this uses a render target otherwise false.
  48715. */
  48716. hasRenderTargetTextures(): boolean;
  48717. /**
  48718. * Returns an array of the actively used textures.
  48719. * @param activeTextures Array of BaseTextures
  48720. */
  48721. getActiveTextures(activeTextures: BaseTexture[]): void;
  48722. /**
  48723. * Returns the animatable textures.
  48724. * @param animatables Array of animatable textures.
  48725. */
  48726. getAnimatables(animatables: IAnimatable[]): void;
  48727. /**
  48728. * Disposes the resources of the material.
  48729. * @param forceDisposeTextures - Forces the disposal of all textures.
  48730. */
  48731. dispose(forceDisposeTextures?: boolean): void;
  48732. /**
  48733. * Get the current class name of the texture useful for serialization or dynamic coding.
  48734. * @returns "PBRSubSurfaceConfiguration"
  48735. */
  48736. getClassName(): string;
  48737. /**
  48738. * Add fallbacks to the effect fallbacks list.
  48739. * @param defines defines the Base texture to use.
  48740. * @param fallbacks defines the current fallback list.
  48741. * @param currentRank defines the current fallback rank.
  48742. * @returns the new fallback rank.
  48743. */
  48744. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48745. /**
  48746. * Add the required uniforms to the current list.
  48747. * @param uniforms defines the current uniform list.
  48748. */
  48749. static AddUniforms(uniforms: string[]): void;
  48750. /**
  48751. * Add the required samplers to the current list.
  48752. * @param samplers defines the current sampler list.
  48753. */
  48754. static AddSamplers(samplers: string[]): void;
  48755. /**
  48756. * Add the required uniforms to the current buffer.
  48757. * @param uniformBuffer defines the current uniform buffer.
  48758. */
  48759. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48760. /**
  48761. * Makes a duplicate of the current configuration into another one.
  48762. * @param configuration define the config where to copy the info
  48763. */
  48764. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48765. /**
  48766. * Serializes this Sub Surface configuration.
  48767. * @returns - An object with the serialized config.
  48768. */
  48769. serialize(): any;
  48770. /**
  48771. * Parses a anisotropy Configuration from a serialized object.
  48772. * @param source - Serialized object.
  48773. * @param scene Defines the scene we are parsing for
  48774. * @param rootUrl Defines the rootUrl to load from
  48775. */
  48776. parse(source: any, scene: Scene, rootUrl: string): void;
  48777. }
  48778. }
  48779. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48780. /** @hidden */
  48781. export var pbrFragmentDeclaration: {
  48782. name: string;
  48783. shader: string;
  48784. };
  48785. }
  48786. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48787. /** @hidden */
  48788. export var pbrUboDeclaration: {
  48789. name: string;
  48790. shader: string;
  48791. };
  48792. }
  48793. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48794. /** @hidden */
  48795. export var pbrFragmentExtraDeclaration: {
  48796. name: string;
  48797. shader: string;
  48798. };
  48799. }
  48800. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48801. /** @hidden */
  48802. export var pbrFragmentSamplersDeclaration: {
  48803. name: string;
  48804. shader: string;
  48805. };
  48806. }
  48807. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48808. /** @hidden */
  48809. export var pbrHelperFunctions: {
  48810. name: string;
  48811. shader: string;
  48812. };
  48813. }
  48814. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48815. /** @hidden */
  48816. export var harmonicsFunctions: {
  48817. name: string;
  48818. shader: string;
  48819. };
  48820. }
  48821. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48822. /** @hidden */
  48823. export var pbrDirectLightingSetupFunctions: {
  48824. name: string;
  48825. shader: string;
  48826. };
  48827. }
  48828. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48829. /** @hidden */
  48830. export var pbrDirectLightingFalloffFunctions: {
  48831. name: string;
  48832. shader: string;
  48833. };
  48834. }
  48835. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48836. /** @hidden */
  48837. export var pbrBRDFFunctions: {
  48838. name: string;
  48839. shader: string;
  48840. };
  48841. }
  48842. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48843. /** @hidden */
  48844. export var pbrDirectLightingFunctions: {
  48845. name: string;
  48846. shader: string;
  48847. };
  48848. }
  48849. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48850. /** @hidden */
  48851. export var pbrIBLFunctions: {
  48852. name: string;
  48853. shader: string;
  48854. };
  48855. }
  48856. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48857. /** @hidden */
  48858. export var pbrDebug: {
  48859. name: string;
  48860. shader: string;
  48861. };
  48862. }
  48863. declare module "babylonjs/Shaders/pbr.fragment" {
  48864. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48865. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48866. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48867. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48868. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48869. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48870. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48871. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48872. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48873. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48874. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48875. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48876. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48877. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48878. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48879. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48880. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48881. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48882. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48883. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48884. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48885. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48886. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48887. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48888. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48889. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48890. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48891. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48892. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48893. /** @hidden */
  48894. export var pbrPixelShader: {
  48895. name: string;
  48896. shader: string;
  48897. };
  48898. }
  48899. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48900. /** @hidden */
  48901. export var pbrVertexDeclaration: {
  48902. name: string;
  48903. shader: string;
  48904. };
  48905. }
  48906. declare module "babylonjs/Shaders/pbr.vertex" {
  48907. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48908. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48909. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48910. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48911. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48912. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48913. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48914. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48915. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48916. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48917. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48918. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48919. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48920. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48921. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48922. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48923. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48924. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48925. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48926. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48927. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48928. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48929. /** @hidden */
  48930. export var pbrVertexShader: {
  48931. name: string;
  48932. shader: string;
  48933. };
  48934. }
  48935. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48936. import { Nullable } from "babylonjs/types";
  48937. import { Scene } from "babylonjs/scene";
  48938. import { Matrix } from "babylonjs/Maths/math.vector";
  48939. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48941. import { Mesh } from "babylonjs/Meshes/mesh";
  48942. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48943. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48944. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48945. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48946. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48947. import { Color3 } from "babylonjs/Maths/math.color";
  48948. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48949. import { Material } from "babylonjs/Materials/material";
  48950. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48951. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48952. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48953. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48954. import "babylonjs/Shaders/pbr.fragment";
  48955. import "babylonjs/Shaders/pbr.vertex";
  48956. /**
  48957. * Manages the defines for the PBR Material.
  48958. * @hidden
  48959. */
  48960. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48961. PBR: boolean;
  48962. MAINUV1: boolean;
  48963. MAINUV2: boolean;
  48964. UV1: boolean;
  48965. UV2: boolean;
  48966. ALBEDO: boolean;
  48967. ALBEDODIRECTUV: number;
  48968. VERTEXCOLOR: boolean;
  48969. AMBIENT: boolean;
  48970. AMBIENTDIRECTUV: number;
  48971. AMBIENTINGRAYSCALE: boolean;
  48972. OPACITY: boolean;
  48973. VERTEXALPHA: boolean;
  48974. OPACITYDIRECTUV: number;
  48975. OPACITYRGB: boolean;
  48976. ALPHATEST: boolean;
  48977. DEPTHPREPASS: boolean;
  48978. ALPHABLEND: boolean;
  48979. ALPHAFROMALBEDO: boolean;
  48980. ALPHATESTVALUE: string;
  48981. SPECULAROVERALPHA: boolean;
  48982. RADIANCEOVERALPHA: boolean;
  48983. ALPHAFRESNEL: boolean;
  48984. LINEARALPHAFRESNEL: boolean;
  48985. PREMULTIPLYALPHA: boolean;
  48986. EMISSIVE: boolean;
  48987. EMISSIVEDIRECTUV: number;
  48988. REFLECTIVITY: boolean;
  48989. REFLECTIVITYDIRECTUV: number;
  48990. SPECULARTERM: boolean;
  48991. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48992. MICROSURFACEAUTOMATIC: boolean;
  48993. LODBASEDMICROSFURACE: boolean;
  48994. MICROSURFACEMAP: boolean;
  48995. MICROSURFACEMAPDIRECTUV: number;
  48996. METALLICWORKFLOW: boolean;
  48997. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48998. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48999. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49000. AOSTOREINMETALMAPRED: boolean;
  49001. ENVIRONMENTBRDF: boolean;
  49002. ENVIRONMENTBRDF_RGBD: boolean;
  49003. NORMAL: boolean;
  49004. TANGENT: boolean;
  49005. BUMP: boolean;
  49006. BUMPDIRECTUV: number;
  49007. OBJECTSPACE_NORMALMAP: boolean;
  49008. PARALLAX: boolean;
  49009. PARALLAXOCCLUSION: boolean;
  49010. NORMALXYSCALE: boolean;
  49011. LIGHTMAP: boolean;
  49012. LIGHTMAPDIRECTUV: number;
  49013. USELIGHTMAPASSHADOWMAP: boolean;
  49014. GAMMALIGHTMAP: boolean;
  49015. RGBDLIGHTMAP: boolean;
  49016. REFLECTION: boolean;
  49017. REFLECTIONMAP_3D: boolean;
  49018. REFLECTIONMAP_SPHERICAL: boolean;
  49019. REFLECTIONMAP_PLANAR: boolean;
  49020. REFLECTIONMAP_CUBIC: boolean;
  49021. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49022. REFLECTIONMAP_PROJECTION: boolean;
  49023. REFLECTIONMAP_SKYBOX: boolean;
  49024. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49025. REFLECTIONMAP_EXPLICIT: boolean;
  49026. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49027. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49028. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49029. INVERTCUBICMAP: boolean;
  49030. USESPHERICALFROMREFLECTIONMAP: boolean;
  49031. USEIRRADIANCEMAP: boolean;
  49032. SPHERICAL_HARMONICS: boolean;
  49033. USESPHERICALINVERTEX: boolean;
  49034. REFLECTIONMAP_OPPOSITEZ: boolean;
  49035. LODINREFLECTIONALPHA: boolean;
  49036. GAMMAREFLECTION: boolean;
  49037. RGBDREFLECTION: boolean;
  49038. LINEARSPECULARREFLECTION: boolean;
  49039. RADIANCEOCCLUSION: boolean;
  49040. HORIZONOCCLUSION: boolean;
  49041. INSTANCES: boolean;
  49042. NUM_BONE_INFLUENCERS: number;
  49043. BonesPerMesh: number;
  49044. BONETEXTURE: boolean;
  49045. NONUNIFORMSCALING: boolean;
  49046. MORPHTARGETS: boolean;
  49047. MORPHTARGETS_NORMAL: boolean;
  49048. MORPHTARGETS_TANGENT: boolean;
  49049. MORPHTARGETS_UV: boolean;
  49050. NUM_MORPH_INFLUENCERS: number;
  49051. IMAGEPROCESSING: boolean;
  49052. VIGNETTE: boolean;
  49053. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49054. VIGNETTEBLENDMODEOPAQUE: boolean;
  49055. TONEMAPPING: boolean;
  49056. TONEMAPPING_ACES: boolean;
  49057. CONTRAST: boolean;
  49058. COLORCURVES: boolean;
  49059. COLORGRADING: boolean;
  49060. COLORGRADING3D: boolean;
  49061. SAMPLER3DGREENDEPTH: boolean;
  49062. SAMPLER3DBGRMAP: boolean;
  49063. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49064. EXPOSURE: boolean;
  49065. MULTIVIEW: boolean;
  49066. USEPHYSICALLIGHTFALLOFF: boolean;
  49067. USEGLTFLIGHTFALLOFF: boolean;
  49068. TWOSIDEDLIGHTING: boolean;
  49069. SHADOWFLOAT: boolean;
  49070. CLIPPLANE: boolean;
  49071. CLIPPLANE2: boolean;
  49072. CLIPPLANE3: boolean;
  49073. CLIPPLANE4: boolean;
  49074. POINTSIZE: boolean;
  49075. FOG: boolean;
  49076. LOGARITHMICDEPTH: boolean;
  49077. FORCENORMALFORWARD: boolean;
  49078. SPECULARAA: boolean;
  49079. CLEARCOAT: boolean;
  49080. CLEARCOAT_DEFAULTIOR: boolean;
  49081. CLEARCOAT_TEXTURE: boolean;
  49082. CLEARCOAT_TEXTUREDIRECTUV: number;
  49083. CLEARCOAT_BUMP: boolean;
  49084. CLEARCOAT_BUMPDIRECTUV: number;
  49085. CLEARCOAT_TINT: boolean;
  49086. CLEARCOAT_TINT_TEXTURE: boolean;
  49087. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49088. ANISOTROPIC: boolean;
  49089. ANISOTROPIC_TEXTURE: boolean;
  49090. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49091. BRDF_V_HEIGHT_CORRELATED: boolean;
  49092. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49093. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49094. SHEEN: boolean;
  49095. SHEEN_TEXTURE: boolean;
  49096. SHEEN_TEXTUREDIRECTUV: number;
  49097. SHEEN_LINKWITHALBEDO: boolean;
  49098. SUBSURFACE: boolean;
  49099. SS_REFRACTION: boolean;
  49100. SS_TRANSLUCENCY: boolean;
  49101. SS_SCATERRING: boolean;
  49102. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49103. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49104. SS_REFRACTIONMAP_3D: boolean;
  49105. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49106. SS_LODINREFRACTIONALPHA: boolean;
  49107. SS_GAMMAREFRACTION: boolean;
  49108. SS_RGBDREFRACTION: boolean;
  49109. SS_LINEARSPECULARREFRACTION: boolean;
  49110. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49111. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49112. UNLIT: boolean;
  49113. DEBUGMODE: number;
  49114. /**
  49115. * Initializes the PBR Material defines.
  49116. */
  49117. constructor();
  49118. /**
  49119. * Resets the PBR Material defines.
  49120. */
  49121. reset(): void;
  49122. }
  49123. /**
  49124. * The Physically based material base class of BJS.
  49125. *
  49126. * This offers the main features of a standard PBR material.
  49127. * For more information, please refer to the documentation :
  49128. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49129. */
  49130. export abstract class PBRBaseMaterial extends PushMaterial {
  49131. /**
  49132. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49133. */
  49134. static readonly PBRMATERIAL_OPAQUE: number;
  49135. /**
  49136. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49137. */
  49138. static readonly PBRMATERIAL_ALPHATEST: number;
  49139. /**
  49140. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49141. */
  49142. static readonly PBRMATERIAL_ALPHABLEND: number;
  49143. /**
  49144. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49145. * They are also discarded below the alpha cutoff threshold to improve performances.
  49146. */
  49147. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49148. /**
  49149. * Defines the default value of how much AO map is occluding the analytical lights
  49150. * (point spot...).
  49151. */
  49152. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49153. /**
  49154. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49155. */
  49156. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49157. /**
  49158. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49159. * to enhance interoperability with other engines.
  49160. */
  49161. static readonly LIGHTFALLOFF_GLTF: number;
  49162. /**
  49163. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49164. * to enhance interoperability with other materials.
  49165. */
  49166. static readonly LIGHTFALLOFF_STANDARD: number;
  49167. /**
  49168. * Intensity of the direct lights e.g. the four lights available in your scene.
  49169. * This impacts both the direct diffuse and specular highlights.
  49170. */
  49171. protected _directIntensity: number;
  49172. /**
  49173. * Intensity of the emissive part of the material.
  49174. * This helps controlling the emissive effect without modifying the emissive color.
  49175. */
  49176. protected _emissiveIntensity: number;
  49177. /**
  49178. * Intensity of the environment e.g. how much the environment will light the object
  49179. * either through harmonics for rough material or through the refelction for shiny ones.
  49180. */
  49181. protected _environmentIntensity: number;
  49182. /**
  49183. * This is a special control allowing the reduction of the specular highlights coming from the
  49184. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49185. */
  49186. protected _specularIntensity: number;
  49187. /**
  49188. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49189. */
  49190. private _lightingInfos;
  49191. /**
  49192. * Debug Control allowing disabling the bump map on this material.
  49193. */
  49194. protected _disableBumpMap: boolean;
  49195. /**
  49196. * AKA Diffuse Texture in standard nomenclature.
  49197. */
  49198. protected _albedoTexture: Nullable<BaseTexture>;
  49199. /**
  49200. * AKA Occlusion Texture in other nomenclature.
  49201. */
  49202. protected _ambientTexture: Nullable<BaseTexture>;
  49203. /**
  49204. * AKA Occlusion Texture Intensity in other nomenclature.
  49205. */
  49206. protected _ambientTextureStrength: number;
  49207. /**
  49208. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49209. * 1 means it completely occludes it
  49210. * 0 mean it has no impact
  49211. */
  49212. protected _ambientTextureImpactOnAnalyticalLights: number;
  49213. /**
  49214. * Stores the alpha values in a texture.
  49215. */
  49216. protected _opacityTexture: Nullable<BaseTexture>;
  49217. /**
  49218. * Stores the reflection values in a texture.
  49219. */
  49220. protected _reflectionTexture: Nullable<BaseTexture>;
  49221. /**
  49222. * Stores the emissive values in a texture.
  49223. */
  49224. protected _emissiveTexture: Nullable<BaseTexture>;
  49225. /**
  49226. * AKA Specular texture in other nomenclature.
  49227. */
  49228. protected _reflectivityTexture: Nullable<BaseTexture>;
  49229. /**
  49230. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49231. */
  49232. protected _metallicTexture: Nullable<BaseTexture>;
  49233. /**
  49234. * Specifies the metallic scalar of the metallic/roughness workflow.
  49235. * Can also be used to scale the metalness values of the metallic texture.
  49236. */
  49237. protected _metallic: Nullable<number>;
  49238. /**
  49239. * Specifies the roughness scalar of the metallic/roughness workflow.
  49240. * Can also be used to scale the roughness values of the metallic texture.
  49241. */
  49242. protected _roughness: Nullable<number>;
  49243. /**
  49244. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49245. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49246. */
  49247. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49248. /**
  49249. * Stores surface normal data used to displace a mesh in a texture.
  49250. */
  49251. protected _bumpTexture: Nullable<BaseTexture>;
  49252. /**
  49253. * Stores the pre-calculated light information of a mesh in a texture.
  49254. */
  49255. protected _lightmapTexture: Nullable<BaseTexture>;
  49256. /**
  49257. * The color of a material in ambient lighting.
  49258. */
  49259. protected _ambientColor: Color3;
  49260. /**
  49261. * AKA Diffuse Color in other nomenclature.
  49262. */
  49263. protected _albedoColor: Color3;
  49264. /**
  49265. * AKA Specular Color in other nomenclature.
  49266. */
  49267. protected _reflectivityColor: Color3;
  49268. /**
  49269. * The color applied when light is reflected from a material.
  49270. */
  49271. protected _reflectionColor: Color3;
  49272. /**
  49273. * The color applied when light is emitted from a material.
  49274. */
  49275. protected _emissiveColor: Color3;
  49276. /**
  49277. * AKA Glossiness in other nomenclature.
  49278. */
  49279. protected _microSurface: number;
  49280. /**
  49281. * Specifies that the material will use the light map as a show map.
  49282. */
  49283. protected _useLightmapAsShadowmap: boolean;
  49284. /**
  49285. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49286. * makes the reflect vector face the model (under horizon).
  49287. */
  49288. protected _useHorizonOcclusion: boolean;
  49289. /**
  49290. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49291. * too much the area relying on ambient texture to define their ambient occlusion.
  49292. */
  49293. protected _useRadianceOcclusion: boolean;
  49294. /**
  49295. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49296. */
  49297. protected _useAlphaFromAlbedoTexture: boolean;
  49298. /**
  49299. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49300. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49301. */
  49302. protected _useSpecularOverAlpha: boolean;
  49303. /**
  49304. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49305. */
  49306. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49307. /**
  49308. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49309. */
  49310. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49311. /**
  49312. * Specifies if the metallic texture contains the roughness information in its green channel.
  49313. */
  49314. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49315. /**
  49316. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49317. */
  49318. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49319. /**
  49320. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49321. */
  49322. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49323. /**
  49324. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49325. */
  49326. protected _useAmbientInGrayScale: boolean;
  49327. /**
  49328. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49329. * The material will try to infer what glossiness each pixel should be.
  49330. */
  49331. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49332. /**
  49333. * Defines the falloff type used in this material.
  49334. * It by default is Physical.
  49335. */
  49336. protected _lightFalloff: number;
  49337. /**
  49338. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49339. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49340. */
  49341. protected _useRadianceOverAlpha: boolean;
  49342. /**
  49343. * Allows using an object space normal map (instead of tangent space).
  49344. */
  49345. protected _useObjectSpaceNormalMap: boolean;
  49346. /**
  49347. * Allows using the bump map in parallax mode.
  49348. */
  49349. protected _useParallax: boolean;
  49350. /**
  49351. * Allows using the bump map in parallax occlusion mode.
  49352. */
  49353. protected _useParallaxOcclusion: boolean;
  49354. /**
  49355. * Controls the scale bias of the parallax mode.
  49356. */
  49357. protected _parallaxScaleBias: number;
  49358. /**
  49359. * If sets to true, disables all the lights affecting the material.
  49360. */
  49361. protected _disableLighting: boolean;
  49362. /**
  49363. * Number of Simultaneous lights allowed on the material.
  49364. */
  49365. protected _maxSimultaneousLights: number;
  49366. /**
  49367. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49368. */
  49369. protected _invertNormalMapX: boolean;
  49370. /**
  49371. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49372. */
  49373. protected _invertNormalMapY: boolean;
  49374. /**
  49375. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49376. */
  49377. protected _twoSidedLighting: boolean;
  49378. /**
  49379. * Defines the alpha limits in alpha test mode.
  49380. */
  49381. protected _alphaCutOff: number;
  49382. /**
  49383. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49384. */
  49385. protected _forceAlphaTest: boolean;
  49386. /**
  49387. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49388. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49389. */
  49390. protected _useAlphaFresnel: boolean;
  49391. /**
  49392. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49393. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49394. */
  49395. protected _useLinearAlphaFresnel: boolean;
  49396. /**
  49397. * The transparency mode of the material.
  49398. */
  49399. protected _transparencyMode: Nullable<number>;
  49400. /**
  49401. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49402. * from cos thetav and roughness:
  49403. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49404. */
  49405. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49406. /**
  49407. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49408. */
  49409. protected _forceIrradianceInFragment: boolean;
  49410. /**
  49411. * Force normal to face away from face.
  49412. */
  49413. protected _forceNormalForward: boolean;
  49414. /**
  49415. * Enables specular anti aliasing in the PBR shader.
  49416. * It will both interacts on the Geometry for analytical and IBL lighting.
  49417. * It also prefilter the roughness map based on the bump values.
  49418. */
  49419. protected _enableSpecularAntiAliasing: boolean;
  49420. /**
  49421. * Default configuration related to image processing available in the PBR Material.
  49422. */
  49423. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49424. /**
  49425. * Keep track of the image processing observer to allow dispose and replace.
  49426. */
  49427. private _imageProcessingObserver;
  49428. /**
  49429. * Attaches a new image processing configuration to the PBR Material.
  49430. * @param configuration
  49431. */
  49432. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49433. /**
  49434. * Stores the available render targets.
  49435. */
  49436. private _renderTargets;
  49437. /**
  49438. * Sets the global ambient color for the material used in lighting calculations.
  49439. */
  49440. private _globalAmbientColor;
  49441. /**
  49442. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49443. */
  49444. private _useLogarithmicDepth;
  49445. /**
  49446. * If set to true, no lighting calculations will be applied.
  49447. */
  49448. private _unlit;
  49449. private _debugMode;
  49450. /**
  49451. * @hidden
  49452. * This is reserved for the inspector.
  49453. * Defines the material debug mode.
  49454. * It helps seeing only some components of the material while troubleshooting.
  49455. */
  49456. debugMode: number;
  49457. /**
  49458. * @hidden
  49459. * This is reserved for the inspector.
  49460. * Specify from where on screen the debug mode should start.
  49461. * The value goes from -1 (full screen) to 1 (not visible)
  49462. * It helps with side by side comparison against the final render
  49463. * This defaults to -1
  49464. */
  49465. private debugLimit;
  49466. /**
  49467. * @hidden
  49468. * This is reserved for the inspector.
  49469. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49470. * You can use the factor to better multiply the final value.
  49471. */
  49472. private debugFactor;
  49473. /**
  49474. * Defines the clear coat layer parameters for the material.
  49475. */
  49476. readonly clearCoat: PBRClearCoatConfiguration;
  49477. /**
  49478. * Defines the anisotropic parameters for the material.
  49479. */
  49480. readonly anisotropy: PBRAnisotropicConfiguration;
  49481. /**
  49482. * Defines the BRDF parameters for the material.
  49483. */
  49484. readonly brdf: PBRBRDFConfiguration;
  49485. /**
  49486. * Defines the Sheen parameters for the material.
  49487. */
  49488. readonly sheen: PBRSheenConfiguration;
  49489. /**
  49490. * Defines the SubSurface parameters for the material.
  49491. */
  49492. readonly subSurface: PBRSubSurfaceConfiguration;
  49493. /**
  49494. * Custom callback helping to override the default shader used in the material.
  49495. */
  49496. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49497. protected _rebuildInParallel: boolean;
  49498. /**
  49499. * Instantiates a new PBRMaterial instance.
  49500. *
  49501. * @param name The material name
  49502. * @param scene The scene the material will be use in.
  49503. */
  49504. constructor(name: string, scene: Scene);
  49505. /**
  49506. * Gets a boolean indicating that current material needs to register RTT
  49507. */
  49508. readonly hasRenderTargetTextures: boolean;
  49509. /**
  49510. * Gets the name of the material class.
  49511. */
  49512. getClassName(): string;
  49513. /**
  49514. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49515. */
  49516. /**
  49517. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49518. */
  49519. useLogarithmicDepth: boolean;
  49520. /**
  49521. * Gets the current transparency mode.
  49522. */
  49523. /**
  49524. * Sets the transparency mode of the material.
  49525. *
  49526. * | Value | Type | Description |
  49527. * | ----- | ----------------------------------- | ----------- |
  49528. * | 0 | OPAQUE | |
  49529. * | 1 | ALPHATEST | |
  49530. * | 2 | ALPHABLEND | |
  49531. * | 3 | ALPHATESTANDBLEND | |
  49532. *
  49533. */
  49534. transparencyMode: Nullable<number>;
  49535. /**
  49536. * Returns true if alpha blending should be disabled.
  49537. */
  49538. private readonly _disableAlphaBlending;
  49539. /**
  49540. * Specifies whether or not this material should be rendered in alpha blend mode.
  49541. */
  49542. needAlphaBlending(): boolean;
  49543. /**
  49544. * Specifies if the mesh will require alpha blending.
  49545. * @param mesh - BJS mesh.
  49546. */
  49547. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49548. /**
  49549. * Specifies whether or not this material should be rendered in alpha test mode.
  49550. */
  49551. needAlphaTesting(): boolean;
  49552. /**
  49553. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49554. */
  49555. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49556. /**
  49557. * Gets the texture used for the alpha test.
  49558. */
  49559. getAlphaTestTexture(): Nullable<BaseTexture>;
  49560. /**
  49561. * Specifies that the submesh is ready to be used.
  49562. * @param mesh - BJS mesh.
  49563. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49564. * @param useInstances - Specifies that instances should be used.
  49565. * @returns - boolean indicating that the submesh is ready or not.
  49566. */
  49567. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49568. /**
  49569. * Specifies if the material uses metallic roughness workflow.
  49570. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49571. */
  49572. isMetallicWorkflow(): boolean;
  49573. private _prepareEffect;
  49574. private _prepareDefines;
  49575. /**
  49576. * Force shader compilation
  49577. */
  49578. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49579. clipPlane: boolean;
  49580. }>): void;
  49581. /**
  49582. * Initializes the uniform buffer layout for the shader.
  49583. */
  49584. buildUniformLayout(): void;
  49585. /**
  49586. * Unbinds the material from the mesh
  49587. */
  49588. unbind(): void;
  49589. /**
  49590. * Binds the submesh data.
  49591. * @param world - The world matrix.
  49592. * @param mesh - The BJS mesh.
  49593. * @param subMesh - A submesh of the BJS mesh.
  49594. */
  49595. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49596. /**
  49597. * Returns the animatable textures.
  49598. * @returns - Array of animatable textures.
  49599. */
  49600. getAnimatables(): IAnimatable[];
  49601. /**
  49602. * Returns the texture used for reflections.
  49603. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49604. */
  49605. private _getReflectionTexture;
  49606. /**
  49607. * Returns an array of the actively used textures.
  49608. * @returns - Array of BaseTextures
  49609. */
  49610. getActiveTextures(): BaseTexture[];
  49611. /**
  49612. * Checks to see if a texture is used in the material.
  49613. * @param texture - Base texture to use.
  49614. * @returns - Boolean specifying if a texture is used in the material.
  49615. */
  49616. hasTexture(texture: BaseTexture): boolean;
  49617. /**
  49618. * Disposes the resources of the material.
  49619. * @param forceDisposeEffect - Forces the disposal of effects.
  49620. * @param forceDisposeTextures - Forces the disposal of all textures.
  49621. */
  49622. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49623. }
  49624. }
  49625. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49626. import { Nullable } from "babylonjs/types";
  49627. import { Scene } from "babylonjs/scene";
  49628. import { Color3 } from "babylonjs/Maths/math.color";
  49629. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49630. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49631. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49632. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49633. /**
  49634. * The Physically based material of BJS.
  49635. *
  49636. * This offers the main features of a standard PBR material.
  49637. * For more information, please refer to the documentation :
  49638. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49639. */
  49640. export class PBRMaterial extends PBRBaseMaterial {
  49641. /**
  49642. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49643. */
  49644. static readonly PBRMATERIAL_OPAQUE: number;
  49645. /**
  49646. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49647. */
  49648. static readonly PBRMATERIAL_ALPHATEST: number;
  49649. /**
  49650. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49651. */
  49652. static readonly PBRMATERIAL_ALPHABLEND: number;
  49653. /**
  49654. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49655. * They are also discarded below the alpha cutoff threshold to improve performances.
  49656. */
  49657. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49658. /**
  49659. * Defines the default value of how much AO map is occluding the analytical lights
  49660. * (point spot...).
  49661. */
  49662. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49663. /**
  49664. * Intensity of the direct lights e.g. the four lights available in your scene.
  49665. * This impacts both the direct diffuse and specular highlights.
  49666. */
  49667. directIntensity: number;
  49668. /**
  49669. * Intensity of the emissive part of the material.
  49670. * This helps controlling the emissive effect without modifying the emissive color.
  49671. */
  49672. emissiveIntensity: number;
  49673. /**
  49674. * Intensity of the environment e.g. how much the environment will light the object
  49675. * either through harmonics for rough material or through the refelction for shiny ones.
  49676. */
  49677. environmentIntensity: number;
  49678. /**
  49679. * This is a special control allowing the reduction of the specular highlights coming from the
  49680. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49681. */
  49682. specularIntensity: number;
  49683. /**
  49684. * Debug Control allowing disabling the bump map on this material.
  49685. */
  49686. disableBumpMap: boolean;
  49687. /**
  49688. * AKA Diffuse Texture in standard nomenclature.
  49689. */
  49690. albedoTexture: BaseTexture;
  49691. /**
  49692. * AKA Occlusion Texture in other nomenclature.
  49693. */
  49694. ambientTexture: BaseTexture;
  49695. /**
  49696. * AKA Occlusion Texture Intensity in other nomenclature.
  49697. */
  49698. ambientTextureStrength: number;
  49699. /**
  49700. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49701. * 1 means it completely occludes it
  49702. * 0 mean it has no impact
  49703. */
  49704. ambientTextureImpactOnAnalyticalLights: number;
  49705. /**
  49706. * Stores the alpha values in a texture.
  49707. */
  49708. opacityTexture: BaseTexture;
  49709. /**
  49710. * Stores the reflection values in a texture.
  49711. */
  49712. reflectionTexture: Nullable<BaseTexture>;
  49713. /**
  49714. * Stores the emissive values in a texture.
  49715. */
  49716. emissiveTexture: BaseTexture;
  49717. /**
  49718. * AKA Specular texture in other nomenclature.
  49719. */
  49720. reflectivityTexture: BaseTexture;
  49721. /**
  49722. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49723. */
  49724. metallicTexture: BaseTexture;
  49725. /**
  49726. * Specifies the metallic scalar of the metallic/roughness workflow.
  49727. * Can also be used to scale the metalness values of the metallic texture.
  49728. */
  49729. metallic: Nullable<number>;
  49730. /**
  49731. * Specifies the roughness scalar of the metallic/roughness workflow.
  49732. * Can also be used to scale the roughness values of the metallic texture.
  49733. */
  49734. roughness: Nullable<number>;
  49735. /**
  49736. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49737. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49738. */
  49739. microSurfaceTexture: BaseTexture;
  49740. /**
  49741. * Stores surface normal data used to displace a mesh in a texture.
  49742. */
  49743. bumpTexture: BaseTexture;
  49744. /**
  49745. * Stores the pre-calculated light information of a mesh in a texture.
  49746. */
  49747. lightmapTexture: BaseTexture;
  49748. /**
  49749. * Stores the refracted light information in a texture.
  49750. */
  49751. refractionTexture: Nullable<BaseTexture>;
  49752. /**
  49753. * The color of a material in ambient lighting.
  49754. */
  49755. ambientColor: Color3;
  49756. /**
  49757. * AKA Diffuse Color in other nomenclature.
  49758. */
  49759. albedoColor: Color3;
  49760. /**
  49761. * AKA Specular Color in other nomenclature.
  49762. */
  49763. reflectivityColor: Color3;
  49764. /**
  49765. * The color reflected from the material.
  49766. */
  49767. reflectionColor: Color3;
  49768. /**
  49769. * The color emitted from the material.
  49770. */
  49771. emissiveColor: Color3;
  49772. /**
  49773. * AKA Glossiness in other nomenclature.
  49774. */
  49775. microSurface: number;
  49776. /**
  49777. * source material index of refraction (IOR)' / 'destination material IOR.
  49778. */
  49779. indexOfRefraction: number;
  49780. /**
  49781. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49782. */
  49783. invertRefractionY: boolean;
  49784. /**
  49785. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49786. * Materials half opaque for instance using refraction could benefit from this control.
  49787. */
  49788. linkRefractionWithTransparency: boolean;
  49789. /**
  49790. * If true, the light map contains occlusion information instead of lighting info.
  49791. */
  49792. useLightmapAsShadowmap: boolean;
  49793. /**
  49794. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49795. */
  49796. useAlphaFromAlbedoTexture: boolean;
  49797. /**
  49798. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49799. */
  49800. forceAlphaTest: boolean;
  49801. /**
  49802. * Defines the alpha limits in alpha test mode.
  49803. */
  49804. alphaCutOff: number;
  49805. /**
  49806. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49807. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49808. */
  49809. useSpecularOverAlpha: boolean;
  49810. /**
  49811. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49812. */
  49813. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49814. /**
  49815. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49816. */
  49817. useRoughnessFromMetallicTextureAlpha: boolean;
  49818. /**
  49819. * Specifies if the metallic texture contains the roughness information in its green channel.
  49820. */
  49821. useRoughnessFromMetallicTextureGreen: boolean;
  49822. /**
  49823. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49824. */
  49825. useMetallnessFromMetallicTextureBlue: boolean;
  49826. /**
  49827. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49828. */
  49829. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49830. /**
  49831. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49832. */
  49833. useAmbientInGrayScale: boolean;
  49834. /**
  49835. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49836. * The material will try to infer what glossiness each pixel should be.
  49837. */
  49838. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49839. /**
  49840. * BJS is using an harcoded light falloff based on a manually sets up range.
  49841. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49842. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49843. */
  49844. /**
  49845. * BJS is using an harcoded light falloff based on a manually sets up range.
  49846. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49847. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49848. */
  49849. usePhysicalLightFalloff: boolean;
  49850. /**
  49851. * In order to support the falloff compatibility with gltf, a special mode has been added
  49852. * to reproduce the gltf light falloff.
  49853. */
  49854. /**
  49855. * In order to support the falloff compatibility with gltf, a special mode has been added
  49856. * to reproduce the gltf light falloff.
  49857. */
  49858. useGLTFLightFalloff: boolean;
  49859. /**
  49860. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49861. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49862. */
  49863. useRadianceOverAlpha: boolean;
  49864. /**
  49865. * Allows using an object space normal map (instead of tangent space).
  49866. */
  49867. useObjectSpaceNormalMap: boolean;
  49868. /**
  49869. * Allows using the bump map in parallax mode.
  49870. */
  49871. useParallax: boolean;
  49872. /**
  49873. * Allows using the bump map in parallax occlusion mode.
  49874. */
  49875. useParallaxOcclusion: boolean;
  49876. /**
  49877. * Controls the scale bias of the parallax mode.
  49878. */
  49879. parallaxScaleBias: number;
  49880. /**
  49881. * If sets to true, disables all the lights affecting the material.
  49882. */
  49883. disableLighting: boolean;
  49884. /**
  49885. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49886. */
  49887. forceIrradianceInFragment: boolean;
  49888. /**
  49889. * Number of Simultaneous lights allowed on the material.
  49890. */
  49891. maxSimultaneousLights: number;
  49892. /**
  49893. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49894. */
  49895. invertNormalMapX: boolean;
  49896. /**
  49897. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49898. */
  49899. invertNormalMapY: boolean;
  49900. /**
  49901. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49902. */
  49903. twoSidedLighting: boolean;
  49904. /**
  49905. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49906. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49907. */
  49908. useAlphaFresnel: boolean;
  49909. /**
  49910. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49911. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49912. */
  49913. useLinearAlphaFresnel: boolean;
  49914. /**
  49915. * Let user defines the brdf lookup texture used for IBL.
  49916. * A default 8bit version is embedded but you could point at :
  49917. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49918. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49919. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49920. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49921. */
  49922. environmentBRDFTexture: Nullable<BaseTexture>;
  49923. /**
  49924. * Force normal to face away from face.
  49925. */
  49926. forceNormalForward: boolean;
  49927. /**
  49928. * Enables specular anti aliasing in the PBR shader.
  49929. * It will both interacts on the Geometry for analytical and IBL lighting.
  49930. * It also prefilter the roughness map based on the bump values.
  49931. */
  49932. enableSpecularAntiAliasing: boolean;
  49933. /**
  49934. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49935. * makes the reflect vector face the model (under horizon).
  49936. */
  49937. useHorizonOcclusion: boolean;
  49938. /**
  49939. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49940. * too much the area relying on ambient texture to define their ambient occlusion.
  49941. */
  49942. useRadianceOcclusion: boolean;
  49943. /**
  49944. * If set to true, no lighting calculations will be applied.
  49945. */
  49946. unlit: boolean;
  49947. /**
  49948. * Gets the image processing configuration used either in this material.
  49949. */
  49950. /**
  49951. * Sets the Default image processing configuration used either in the this material.
  49952. *
  49953. * If sets to null, the scene one is in use.
  49954. */
  49955. imageProcessingConfiguration: ImageProcessingConfiguration;
  49956. /**
  49957. * Gets wether the color curves effect is enabled.
  49958. */
  49959. /**
  49960. * Sets wether the color curves effect is enabled.
  49961. */
  49962. cameraColorCurvesEnabled: boolean;
  49963. /**
  49964. * Gets wether the color grading effect is enabled.
  49965. */
  49966. /**
  49967. * Gets wether the color grading effect is enabled.
  49968. */
  49969. cameraColorGradingEnabled: boolean;
  49970. /**
  49971. * Gets wether tonemapping is enabled or not.
  49972. */
  49973. /**
  49974. * Sets wether tonemapping is enabled or not
  49975. */
  49976. cameraToneMappingEnabled: boolean;
  49977. /**
  49978. * The camera exposure used on this material.
  49979. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49980. * This corresponds to a photographic exposure.
  49981. */
  49982. /**
  49983. * The camera exposure used on this material.
  49984. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49985. * This corresponds to a photographic exposure.
  49986. */
  49987. cameraExposure: number;
  49988. /**
  49989. * Gets The camera contrast used on this material.
  49990. */
  49991. /**
  49992. * Sets The camera contrast used on this material.
  49993. */
  49994. cameraContrast: number;
  49995. /**
  49996. * Gets the Color Grading 2D Lookup Texture.
  49997. */
  49998. /**
  49999. * Sets the Color Grading 2D Lookup Texture.
  50000. */
  50001. cameraColorGradingTexture: Nullable<BaseTexture>;
  50002. /**
  50003. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50004. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50005. * 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;
  50006. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50007. */
  50008. /**
  50009. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50010. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50011. * 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;
  50012. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50013. */
  50014. cameraColorCurves: Nullable<ColorCurves>;
  50015. /**
  50016. * Instantiates a new PBRMaterial instance.
  50017. *
  50018. * @param name The material name
  50019. * @param scene The scene the material will be use in.
  50020. */
  50021. constructor(name: string, scene: Scene);
  50022. /**
  50023. * Returns the name of this material class.
  50024. */
  50025. getClassName(): string;
  50026. /**
  50027. * Makes a duplicate of the current material.
  50028. * @param name - name to use for the new material.
  50029. */
  50030. clone(name: string): PBRMaterial;
  50031. /**
  50032. * Serializes this PBR Material.
  50033. * @returns - An object with the serialized material.
  50034. */
  50035. serialize(): any;
  50036. /**
  50037. * Parses a PBR Material from a serialized object.
  50038. * @param source - Serialized object.
  50039. * @param scene - BJS scene instance.
  50040. * @param rootUrl - url for the scene object
  50041. * @returns - PBRMaterial
  50042. */
  50043. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50044. }
  50045. }
  50046. declare module "babylonjs/Misc/dds" {
  50047. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50048. import { Engine } from "babylonjs/Engines/engine";
  50049. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50050. import { Nullable } from "babylonjs/types";
  50051. import { Scene } from "babylonjs/scene";
  50052. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50053. /**
  50054. * Direct draw surface info
  50055. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50056. */
  50057. export interface DDSInfo {
  50058. /**
  50059. * Width of the texture
  50060. */
  50061. width: number;
  50062. /**
  50063. * Width of the texture
  50064. */
  50065. height: number;
  50066. /**
  50067. * Number of Mipmaps for the texture
  50068. * @see https://en.wikipedia.org/wiki/Mipmap
  50069. */
  50070. mipmapCount: number;
  50071. /**
  50072. * If the textures format is a known fourCC format
  50073. * @see https://www.fourcc.org/
  50074. */
  50075. isFourCC: boolean;
  50076. /**
  50077. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50078. */
  50079. isRGB: boolean;
  50080. /**
  50081. * If the texture is a lumincance format
  50082. */
  50083. isLuminance: boolean;
  50084. /**
  50085. * If this is a cube texture
  50086. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50087. */
  50088. isCube: boolean;
  50089. /**
  50090. * If the texture is a compressed format eg. FOURCC_DXT1
  50091. */
  50092. isCompressed: boolean;
  50093. /**
  50094. * The dxgiFormat of the texture
  50095. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50096. */
  50097. dxgiFormat: number;
  50098. /**
  50099. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50100. */
  50101. textureType: number;
  50102. /**
  50103. * Sphericle polynomial created for the dds texture
  50104. */
  50105. sphericalPolynomial?: SphericalPolynomial;
  50106. }
  50107. /**
  50108. * Class used to provide DDS decompression tools
  50109. */
  50110. export class DDSTools {
  50111. /**
  50112. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50113. */
  50114. static StoreLODInAlphaChannel: boolean;
  50115. /**
  50116. * Gets DDS information from an array buffer
  50117. * @param arrayBuffer defines the array buffer to read data from
  50118. * @returns the DDS information
  50119. */
  50120. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50121. private static _FloatView;
  50122. private static _Int32View;
  50123. private static _ToHalfFloat;
  50124. private static _FromHalfFloat;
  50125. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50126. private static _GetHalfFloatRGBAArrayBuffer;
  50127. private static _GetFloatRGBAArrayBuffer;
  50128. private static _GetFloatAsUIntRGBAArrayBuffer;
  50129. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50130. private static _GetRGBAArrayBuffer;
  50131. private static _ExtractLongWordOrder;
  50132. private static _GetRGBArrayBuffer;
  50133. private static _GetLuminanceArrayBuffer;
  50134. /**
  50135. * Uploads DDS Levels to a Babylon Texture
  50136. * @hidden
  50137. */
  50138. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50139. }
  50140. module "babylonjs/Engines/engine" {
  50141. interface Engine {
  50142. /**
  50143. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50144. * @param rootUrl defines the url where the file to load is located
  50145. * @param scene defines the current scene
  50146. * @param lodScale defines scale to apply to the mip map selection
  50147. * @param lodOffset defines offset to apply to the mip map selection
  50148. * @param onLoad defines an optional callback raised when the texture is loaded
  50149. * @param onError defines an optional callback raised if there is an issue to load the texture
  50150. * @param format defines the format of the data
  50151. * @param forcedExtension defines the extension to use to pick the right loader
  50152. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50153. * @returns the cube texture as an InternalTexture
  50154. */
  50155. 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;
  50156. }
  50157. }
  50158. }
  50159. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50160. import { Nullable } from "babylonjs/types";
  50161. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50162. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50163. /**
  50164. * Implementation of the DDS Texture Loader.
  50165. * @hidden
  50166. */
  50167. export class _DDSTextureLoader implements IInternalTextureLoader {
  50168. /**
  50169. * Defines wether the loader supports cascade loading the different faces.
  50170. */
  50171. readonly supportCascades: boolean;
  50172. /**
  50173. * This returns if the loader support the current file information.
  50174. * @param extension defines the file extension of the file being loaded
  50175. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50176. * @param fallback defines the fallback internal texture if any
  50177. * @param isBase64 defines whether the texture is encoded as a base64
  50178. * @param isBuffer defines whether the texture data are stored as a buffer
  50179. * @returns true if the loader can load the specified file
  50180. */
  50181. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50182. /**
  50183. * Transform the url before loading if required.
  50184. * @param rootUrl the url of the texture
  50185. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50186. * @returns the transformed texture
  50187. */
  50188. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50189. /**
  50190. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50191. * @param rootUrl the url of the texture
  50192. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50193. * @returns the fallback texture
  50194. */
  50195. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50196. /**
  50197. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50198. * @param data contains the texture data
  50199. * @param texture defines the BabylonJS internal texture
  50200. * @param createPolynomials will be true if polynomials have been requested
  50201. * @param onLoad defines the callback to trigger once the texture is ready
  50202. * @param onError defines the callback to trigger in case of error
  50203. */
  50204. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50205. /**
  50206. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50207. * @param data contains the texture data
  50208. * @param texture defines the BabylonJS internal texture
  50209. * @param callback defines the method to call once ready to upload
  50210. */
  50211. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50212. }
  50213. }
  50214. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50215. import { Nullable } from "babylonjs/types";
  50216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50217. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50218. /**
  50219. * Implementation of the ENV Texture Loader.
  50220. * @hidden
  50221. */
  50222. export class _ENVTextureLoader implements IInternalTextureLoader {
  50223. /**
  50224. * Defines wether the loader supports cascade loading the different faces.
  50225. */
  50226. readonly supportCascades: boolean;
  50227. /**
  50228. * This returns if the loader support the current file information.
  50229. * @param extension defines the file extension of the file being loaded
  50230. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50231. * @param fallback defines the fallback internal texture if any
  50232. * @param isBase64 defines whether the texture is encoded as a base64
  50233. * @param isBuffer defines whether the texture data are stored as a buffer
  50234. * @returns true if the loader can load the specified file
  50235. */
  50236. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50237. /**
  50238. * Transform the url before loading if required.
  50239. * @param rootUrl the url of the texture
  50240. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50241. * @returns the transformed texture
  50242. */
  50243. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50244. /**
  50245. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50246. * @param rootUrl the url of the texture
  50247. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50248. * @returns the fallback texture
  50249. */
  50250. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50251. /**
  50252. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50253. * @param data contains the texture data
  50254. * @param texture defines the BabylonJS internal texture
  50255. * @param createPolynomials will be true if polynomials have been requested
  50256. * @param onLoad defines the callback to trigger once the texture is ready
  50257. * @param onError defines the callback to trigger in case of error
  50258. */
  50259. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50260. /**
  50261. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50262. * @param data contains the texture data
  50263. * @param texture defines the BabylonJS internal texture
  50264. * @param callback defines the method to call once ready to upload
  50265. */
  50266. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50267. }
  50268. }
  50269. declare module "babylonjs/Misc/khronosTextureContainer" {
  50270. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50271. /**
  50272. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50273. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50274. */
  50275. export class KhronosTextureContainer {
  50276. /** contents of the KTX container file */
  50277. arrayBuffer: any;
  50278. private static HEADER_LEN;
  50279. private static COMPRESSED_2D;
  50280. private static COMPRESSED_3D;
  50281. private static TEX_2D;
  50282. private static TEX_3D;
  50283. /**
  50284. * Gets the openGL type
  50285. */
  50286. glType: number;
  50287. /**
  50288. * Gets the openGL type size
  50289. */
  50290. glTypeSize: number;
  50291. /**
  50292. * Gets the openGL format
  50293. */
  50294. glFormat: number;
  50295. /**
  50296. * Gets the openGL internal format
  50297. */
  50298. glInternalFormat: number;
  50299. /**
  50300. * Gets the base internal format
  50301. */
  50302. glBaseInternalFormat: number;
  50303. /**
  50304. * Gets image width in pixel
  50305. */
  50306. pixelWidth: number;
  50307. /**
  50308. * Gets image height in pixel
  50309. */
  50310. pixelHeight: number;
  50311. /**
  50312. * Gets image depth in pixels
  50313. */
  50314. pixelDepth: number;
  50315. /**
  50316. * Gets the number of array elements
  50317. */
  50318. numberOfArrayElements: number;
  50319. /**
  50320. * Gets the number of faces
  50321. */
  50322. numberOfFaces: number;
  50323. /**
  50324. * Gets the number of mipmap levels
  50325. */
  50326. numberOfMipmapLevels: number;
  50327. /**
  50328. * Gets the bytes of key value data
  50329. */
  50330. bytesOfKeyValueData: number;
  50331. /**
  50332. * Gets the load type
  50333. */
  50334. loadType: number;
  50335. /**
  50336. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50337. */
  50338. isInvalid: boolean;
  50339. /**
  50340. * Creates a new KhronosTextureContainer
  50341. * @param arrayBuffer contents of the KTX container file
  50342. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50343. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50344. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50345. */
  50346. constructor(
  50347. /** contents of the KTX container file */
  50348. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50349. /**
  50350. * Uploads KTX content to a Babylon Texture.
  50351. * It is assumed that the texture has already been created & is currently bound
  50352. * @hidden
  50353. */
  50354. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50355. private _upload2DCompressedLevels;
  50356. }
  50357. }
  50358. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50359. import { Nullable } from "babylonjs/types";
  50360. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50361. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50362. /**
  50363. * Implementation of the KTX Texture Loader.
  50364. * @hidden
  50365. */
  50366. export class _KTXTextureLoader implements IInternalTextureLoader {
  50367. /**
  50368. * Defines wether the loader supports cascade loading the different faces.
  50369. */
  50370. readonly supportCascades: boolean;
  50371. /**
  50372. * This returns if the loader support the current file information.
  50373. * @param extension defines the file extension of the file being loaded
  50374. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50375. * @param fallback defines the fallback internal texture if any
  50376. * @param isBase64 defines whether the texture is encoded as a base64
  50377. * @param isBuffer defines whether the texture data are stored as a buffer
  50378. * @returns true if the loader can load the specified file
  50379. */
  50380. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50381. /**
  50382. * Transform the url before loading if required.
  50383. * @param rootUrl the url of the texture
  50384. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50385. * @returns the transformed texture
  50386. */
  50387. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50388. /**
  50389. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50390. * @param rootUrl the url of the texture
  50391. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50392. * @returns the fallback texture
  50393. */
  50394. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50395. /**
  50396. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50397. * @param data contains the texture data
  50398. * @param texture defines the BabylonJS internal texture
  50399. * @param createPolynomials will be true if polynomials have been requested
  50400. * @param onLoad defines the callback to trigger once the texture is ready
  50401. * @param onError defines the callback to trigger in case of error
  50402. */
  50403. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50404. /**
  50405. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50406. * @param data contains the texture data
  50407. * @param texture defines the BabylonJS internal texture
  50408. * @param callback defines the method to call once ready to upload
  50409. */
  50410. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50411. }
  50412. }
  50413. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50414. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50415. import { Scene } from "babylonjs/scene";
  50416. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50417. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50418. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50419. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50420. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50421. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50423. /**
  50424. * Options for the default xr helper
  50425. */
  50426. export class WebXRDefaultExperienceOptions {
  50427. /**
  50428. * Floor meshes that should be used for teleporting
  50429. */
  50430. floorMeshes: Array<AbstractMesh>;
  50431. }
  50432. /**
  50433. * Default experience which provides a similar setup to the previous webVRExperience
  50434. */
  50435. export class WebXRDefaultExperience {
  50436. /**
  50437. * Base experience
  50438. */
  50439. baseExperience: WebXRExperienceHelper;
  50440. /**
  50441. * Input experience extension
  50442. */
  50443. input: WebXRInput;
  50444. /**
  50445. * Loads the controller models
  50446. */
  50447. controllerModelLoader: WebXRControllerModelLoader;
  50448. /**
  50449. * Enables laser pointer and selection
  50450. */
  50451. pointerSelection: WebXRControllerPointerSelection;
  50452. /**
  50453. * Enables teleportation
  50454. */
  50455. teleportation: WebXRControllerTeleportation;
  50456. /**
  50457. * Enables ui for enetering/exiting xr
  50458. */
  50459. enterExitUI: WebXREnterExitUI;
  50460. /**
  50461. * Default output canvas xr should render to
  50462. */
  50463. outputCanvas: WebXRManagedOutputCanvas;
  50464. /**
  50465. * Creates the default xr experience
  50466. * @param scene scene
  50467. * @param options options for basic configuration
  50468. * @returns resulting WebXRDefaultExperience
  50469. */
  50470. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50471. private constructor();
  50472. /**
  50473. * DIsposes of the experience helper
  50474. */
  50475. dispose(): void;
  50476. }
  50477. }
  50478. declare module "babylonjs/Helpers/sceneHelpers" {
  50479. import { Nullable } from "babylonjs/types";
  50480. import { Mesh } from "babylonjs/Meshes/mesh";
  50481. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50482. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50483. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50484. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50485. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50486. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50487. import "babylonjs/Meshes/Builders/boxBuilder";
  50488. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50489. /** @hidden */
  50490. export var _forceSceneHelpersToBundle: boolean;
  50491. module "babylonjs/scene" {
  50492. interface Scene {
  50493. /**
  50494. * Creates a default light for the scene.
  50495. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50496. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50497. */
  50498. createDefaultLight(replace?: boolean): void;
  50499. /**
  50500. * Creates a default camera for the scene.
  50501. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50502. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50503. * @param replace has default false, when true replaces the active camera in the scene
  50504. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50505. */
  50506. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50507. /**
  50508. * Creates a default camera and a default light.
  50509. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50510. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50511. * @param replace has the default false, when true replaces the active camera/light in the scene
  50512. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50513. */
  50514. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50515. /**
  50516. * Creates a new sky box
  50517. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50518. * @param environmentTexture defines the texture to use as environment texture
  50519. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50520. * @param scale defines the overall scale of the skybox
  50521. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50522. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50523. * @returns a new mesh holding the sky box
  50524. */
  50525. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50526. /**
  50527. * Creates a new environment
  50528. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50529. * @param options defines the options you can use to configure the environment
  50530. * @returns the new EnvironmentHelper
  50531. */
  50532. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50533. /**
  50534. * Creates a new VREXperienceHelper
  50535. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50536. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50537. * @returns a new VREXperienceHelper
  50538. */
  50539. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50540. /**
  50541. * Creates a new WebXRDefaultExperience
  50542. * @see http://doc.babylonjs.com/how_to/webxr
  50543. * @param options experience options
  50544. * @returns a promise for a new WebXRDefaultExperience
  50545. */
  50546. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50547. }
  50548. }
  50549. }
  50550. declare module "babylonjs/Helpers/videoDome" {
  50551. import { Scene } from "babylonjs/scene";
  50552. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50553. import { Mesh } from "babylonjs/Meshes/mesh";
  50554. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50555. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50556. import "babylonjs/Meshes/Builders/sphereBuilder";
  50557. /**
  50558. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50559. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50560. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50561. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50562. */
  50563. export class VideoDome extends TransformNode {
  50564. /**
  50565. * Define the video source as a Monoscopic panoramic 360 video.
  50566. */
  50567. static readonly MODE_MONOSCOPIC: number;
  50568. /**
  50569. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50570. */
  50571. static readonly MODE_TOPBOTTOM: number;
  50572. /**
  50573. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50574. */
  50575. static readonly MODE_SIDEBYSIDE: number;
  50576. private _halfDome;
  50577. private _useDirectMapping;
  50578. /**
  50579. * The video texture being displayed on the sphere
  50580. */
  50581. protected _videoTexture: VideoTexture;
  50582. /**
  50583. * Gets the video texture being displayed on the sphere
  50584. */
  50585. readonly videoTexture: VideoTexture;
  50586. /**
  50587. * The skybox material
  50588. */
  50589. protected _material: BackgroundMaterial;
  50590. /**
  50591. * The surface used for the skybox
  50592. */
  50593. protected _mesh: Mesh;
  50594. /**
  50595. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50596. */
  50597. private _halfDomeMask;
  50598. /**
  50599. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50600. * Also see the options.resolution property.
  50601. */
  50602. fovMultiplier: number;
  50603. private _videoMode;
  50604. /**
  50605. * Gets or set the current video mode for the video. It can be:
  50606. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50607. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50608. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50609. */
  50610. videoMode: number;
  50611. /**
  50612. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50613. *
  50614. */
  50615. /**
  50616. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50617. */
  50618. halfDome: boolean;
  50619. /**
  50620. * Oberserver used in Stereoscopic VR Mode.
  50621. */
  50622. private _onBeforeCameraRenderObserver;
  50623. /**
  50624. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50625. * @param name Element's name, child elements will append suffixes for their own names.
  50626. * @param urlsOrVideo defines the url(s) or the video element to use
  50627. * @param options An object containing optional or exposed sub element properties
  50628. */
  50629. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50630. resolution?: number;
  50631. clickToPlay?: boolean;
  50632. autoPlay?: boolean;
  50633. loop?: boolean;
  50634. size?: number;
  50635. poster?: string;
  50636. faceForward?: boolean;
  50637. useDirectMapping?: boolean;
  50638. halfDomeMode?: boolean;
  50639. }, scene: Scene);
  50640. private _changeVideoMode;
  50641. /**
  50642. * Releases resources associated with this node.
  50643. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50644. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50645. */
  50646. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50647. }
  50648. }
  50649. declare module "babylonjs/Helpers/index" {
  50650. export * from "babylonjs/Helpers/environmentHelper";
  50651. export * from "babylonjs/Helpers/photoDome";
  50652. export * from "babylonjs/Helpers/sceneHelpers";
  50653. export * from "babylonjs/Helpers/videoDome";
  50654. }
  50655. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50656. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50657. import { IDisposable } from "babylonjs/scene";
  50658. import { Engine } from "babylonjs/Engines/engine";
  50659. /**
  50660. * This class can be used to get instrumentation data from a Babylon engine
  50661. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50662. */
  50663. export class EngineInstrumentation implements IDisposable {
  50664. /**
  50665. * Define the instrumented engine.
  50666. */
  50667. engine: Engine;
  50668. private _captureGPUFrameTime;
  50669. private _gpuFrameTimeToken;
  50670. private _gpuFrameTime;
  50671. private _captureShaderCompilationTime;
  50672. private _shaderCompilationTime;
  50673. private _onBeginFrameObserver;
  50674. private _onEndFrameObserver;
  50675. private _onBeforeShaderCompilationObserver;
  50676. private _onAfterShaderCompilationObserver;
  50677. /**
  50678. * Gets the perf counter used for GPU frame time
  50679. */
  50680. readonly gpuFrameTimeCounter: PerfCounter;
  50681. /**
  50682. * Gets the GPU frame time capture status
  50683. */
  50684. /**
  50685. * Enable or disable the GPU frame time capture
  50686. */
  50687. captureGPUFrameTime: boolean;
  50688. /**
  50689. * Gets the perf counter used for shader compilation time
  50690. */
  50691. readonly shaderCompilationTimeCounter: PerfCounter;
  50692. /**
  50693. * Gets the shader compilation time capture status
  50694. */
  50695. /**
  50696. * Enable or disable the shader compilation time capture
  50697. */
  50698. captureShaderCompilationTime: boolean;
  50699. /**
  50700. * Instantiates a new engine instrumentation.
  50701. * This class can be used to get instrumentation data from a Babylon engine
  50702. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50703. * @param engine Defines the engine to instrument
  50704. */
  50705. constructor(
  50706. /**
  50707. * Define the instrumented engine.
  50708. */
  50709. engine: Engine);
  50710. /**
  50711. * Dispose and release associated resources.
  50712. */
  50713. dispose(): void;
  50714. }
  50715. }
  50716. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50717. import { Scene, IDisposable } from "babylonjs/scene";
  50718. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50719. /**
  50720. * This class can be used to get instrumentation data from a Babylon engine
  50721. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50722. */
  50723. export class SceneInstrumentation implements IDisposable {
  50724. /**
  50725. * Defines the scene to instrument
  50726. */
  50727. scene: Scene;
  50728. private _captureActiveMeshesEvaluationTime;
  50729. private _activeMeshesEvaluationTime;
  50730. private _captureRenderTargetsRenderTime;
  50731. private _renderTargetsRenderTime;
  50732. private _captureFrameTime;
  50733. private _frameTime;
  50734. private _captureRenderTime;
  50735. private _renderTime;
  50736. private _captureInterFrameTime;
  50737. private _interFrameTime;
  50738. private _captureParticlesRenderTime;
  50739. private _particlesRenderTime;
  50740. private _captureSpritesRenderTime;
  50741. private _spritesRenderTime;
  50742. private _capturePhysicsTime;
  50743. private _physicsTime;
  50744. private _captureAnimationsTime;
  50745. private _animationsTime;
  50746. private _captureCameraRenderTime;
  50747. private _cameraRenderTime;
  50748. private _onBeforeActiveMeshesEvaluationObserver;
  50749. private _onAfterActiveMeshesEvaluationObserver;
  50750. private _onBeforeRenderTargetsRenderObserver;
  50751. private _onAfterRenderTargetsRenderObserver;
  50752. private _onAfterRenderObserver;
  50753. private _onBeforeDrawPhaseObserver;
  50754. private _onAfterDrawPhaseObserver;
  50755. private _onBeforeAnimationsObserver;
  50756. private _onBeforeParticlesRenderingObserver;
  50757. private _onAfterParticlesRenderingObserver;
  50758. private _onBeforeSpritesRenderingObserver;
  50759. private _onAfterSpritesRenderingObserver;
  50760. private _onBeforePhysicsObserver;
  50761. private _onAfterPhysicsObserver;
  50762. private _onAfterAnimationsObserver;
  50763. private _onBeforeCameraRenderObserver;
  50764. private _onAfterCameraRenderObserver;
  50765. /**
  50766. * Gets the perf counter used for active meshes evaluation time
  50767. */
  50768. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50769. /**
  50770. * Gets the active meshes evaluation time capture status
  50771. */
  50772. /**
  50773. * Enable or disable the active meshes evaluation time capture
  50774. */
  50775. captureActiveMeshesEvaluationTime: boolean;
  50776. /**
  50777. * Gets the perf counter used for render targets render time
  50778. */
  50779. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50780. /**
  50781. * Gets the render targets render time capture status
  50782. */
  50783. /**
  50784. * Enable or disable the render targets render time capture
  50785. */
  50786. captureRenderTargetsRenderTime: boolean;
  50787. /**
  50788. * Gets the perf counter used for particles render time
  50789. */
  50790. readonly particlesRenderTimeCounter: PerfCounter;
  50791. /**
  50792. * Gets the particles render time capture status
  50793. */
  50794. /**
  50795. * Enable or disable the particles render time capture
  50796. */
  50797. captureParticlesRenderTime: boolean;
  50798. /**
  50799. * Gets the perf counter used for sprites render time
  50800. */
  50801. readonly spritesRenderTimeCounter: PerfCounter;
  50802. /**
  50803. * Gets the sprites render time capture status
  50804. */
  50805. /**
  50806. * Enable or disable the sprites render time capture
  50807. */
  50808. captureSpritesRenderTime: boolean;
  50809. /**
  50810. * Gets the perf counter used for physics time
  50811. */
  50812. readonly physicsTimeCounter: PerfCounter;
  50813. /**
  50814. * Gets the physics time capture status
  50815. */
  50816. /**
  50817. * Enable or disable the physics time capture
  50818. */
  50819. capturePhysicsTime: boolean;
  50820. /**
  50821. * Gets the perf counter used for animations time
  50822. */
  50823. readonly animationsTimeCounter: PerfCounter;
  50824. /**
  50825. * Gets the animations time capture status
  50826. */
  50827. /**
  50828. * Enable or disable the animations time capture
  50829. */
  50830. captureAnimationsTime: boolean;
  50831. /**
  50832. * Gets the perf counter used for frame time capture
  50833. */
  50834. readonly frameTimeCounter: PerfCounter;
  50835. /**
  50836. * Gets the frame time capture status
  50837. */
  50838. /**
  50839. * Enable or disable the frame time capture
  50840. */
  50841. captureFrameTime: boolean;
  50842. /**
  50843. * Gets the perf counter used for inter-frames time capture
  50844. */
  50845. readonly interFrameTimeCounter: PerfCounter;
  50846. /**
  50847. * Gets the inter-frames time capture status
  50848. */
  50849. /**
  50850. * Enable or disable the inter-frames time capture
  50851. */
  50852. captureInterFrameTime: boolean;
  50853. /**
  50854. * Gets the perf counter used for render time capture
  50855. */
  50856. readonly renderTimeCounter: PerfCounter;
  50857. /**
  50858. * Gets the render time capture status
  50859. */
  50860. /**
  50861. * Enable or disable the render time capture
  50862. */
  50863. captureRenderTime: boolean;
  50864. /**
  50865. * Gets the perf counter used for camera render time capture
  50866. */
  50867. readonly cameraRenderTimeCounter: PerfCounter;
  50868. /**
  50869. * Gets the camera render time capture status
  50870. */
  50871. /**
  50872. * Enable or disable the camera render time capture
  50873. */
  50874. captureCameraRenderTime: boolean;
  50875. /**
  50876. * Gets the perf counter used for draw calls
  50877. */
  50878. readonly drawCallsCounter: PerfCounter;
  50879. /**
  50880. * Instantiates a new scene instrumentation.
  50881. * This class can be used to get instrumentation data from a Babylon engine
  50882. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50883. * @param scene Defines the scene to instrument
  50884. */
  50885. constructor(
  50886. /**
  50887. * Defines the scene to instrument
  50888. */
  50889. scene: Scene);
  50890. /**
  50891. * Dispose and release associated resources.
  50892. */
  50893. dispose(): void;
  50894. }
  50895. }
  50896. declare module "babylonjs/Instrumentation/index" {
  50897. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50898. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50899. export * from "babylonjs/Instrumentation/timeToken";
  50900. }
  50901. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50902. /** @hidden */
  50903. export var glowMapGenerationPixelShader: {
  50904. name: string;
  50905. shader: string;
  50906. };
  50907. }
  50908. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50909. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50910. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50911. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50912. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50913. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50914. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50915. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50916. /** @hidden */
  50917. export var glowMapGenerationVertexShader: {
  50918. name: string;
  50919. shader: string;
  50920. };
  50921. }
  50922. declare module "babylonjs/Layers/effectLayer" {
  50923. import { Observable } from "babylonjs/Misc/observable";
  50924. import { Nullable } from "babylonjs/types";
  50925. import { Camera } from "babylonjs/Cameras/camera";
  50926. import { Scene } from "babylonjs/scene";
  50927. import { ISize } from "babylonjs/Maths/math.size";
  50928. import { Color4 } from "babylonjs/Maths/math.color";
  50929. import { Engine } from "babylonjs/Engines/engine";
  50930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50932. import { Mesh } from "babylonjs/Meshes/mesh";
  50933. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50934. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50935. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50936. import { Effect } from "babylonjs/Materials/effect";
  50937. import { Material } from "babylonjs/Materials/material";
  50938. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50939. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50940. /**
  50941. * Effect layer options. This helps customizing the behaviour
  50942. * of the effect layer.
  50943. */
  50944. export interface IEffectLayerOptions {
  50945. /**
  50946. * Multiplication factor apply to the canvas size to compute the render target size
  50947. * used to generated the objects (the smaller the faster).
  50948. */
  50949. mainTextureRatio: number;
  50950. /**
  50951. * Enforces a fixed size texture to ensure effect stability across devices.
  50952. */
  50953. mainTextureFixedSize?: number;
  50954. /**
  50955. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50956. */
  50957. alphaBlendingMode: number;
  50958. /**
  50959. * The camera attached to the layer.
  50960. */
  50961. camera: Nullable<Camera>;
  50962. /**
  50963. * The rendering group to draw the layer in.
  50964. */
  50965. renderingGroupId: number;
  50966. }
  50967. /**
  50968. * The effect layer Helps adding post process effect blended with the main pass.
  50969. *
  50970. * This can be for instance use to generate glow or higlight effects on the scene.
  50971. *
  50972. * The effect layer class can not be used directly and is intented to inherited from to be
  50973. * customized per effects.
  50974. */
  50975. export abstract class EffectLayer {
  50976. private _vertexBuffers;
  50977. private _indexBuffer;
  50978. private _cachedDefines;
  50979. private _effectLayerMapGenerationEffect;
  50980. private _effectLayerOptions;
  50981. private _mergeEffect;
  50982. protected _scene: Scene;
  50983. protected _engine: Engine;
  50984. protected _maxSize: number;
  50985. protected _mainTextureDesiredSize: ISize;
  50986. protected _mainTexture: RenderTargetTexture;
  50987. protected _shouldRender: boolean;
  50988. protected _postProcesses: PostProcess[];
  50989. protected _textures: BaseTexture[];
  50990. protected _emissiveTextureAndColor: {
  50991. texture: Nullable<BaseTexture>;
  50992. color: Color4;
  50993. };
  50994. /**
  50995. * The name of the layer
  50996. */
  50997. name: string;
  50998. /**
  50999. * The clear color of the texture used to generate the glow map.
  51000. */
  51001. neutralColor: Color4;
  51002. /**
  51003. * Specifies wether the highlight layer is enabled or not.
  51004. */
  51005. isEnabled: boolean;
  51006. /**
  51007. * Gets the camera attached to the layer.
  51008. */
  51009. readonly camera: Nullable<Camera>;
  51010. /**
  51011. * Gets the rendering group id the layer should render in.
  51012. */
  51013. renderingGroupId: number;
  51014. /**
  51015. * An event triggered when the effect layer has been disposed.
  51016. */
  51017. onDisposeObservable: Observable<EffectLayer>;
  51018. /**
  51019. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51020. */
  51021. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51022. /**
  51023. * An event triggered when the generated texture is being merged in the scene.
  51024. */
  51025. onBeforeComposeObservable: Observable<EffectLayer>;
  51026. /**
  51027. * An event triggered when the generated texture has been merged in the scene.
  51028. */
  51029. onAfterComposeObservable: Observable<EffectLayer>;
  51030. /**
  51031. * An event triggered when the efffect layer changes its size.
  51032. */
  51033. onSizeChangedObservable: Observable<EffectLayer>;
  51034. /** @hidden */
  51035. static _SceneComponentInitialization: (scene: Scene) => void;
  51036. /**
  51037. * Instantiates a new effect Layer and references it in the scene.
  51038. * @param name The name of the layer
  51039. * @param scene The scene to use the layer in
  51040. */
  51041. constructor(
  51042. /** The Friendly of the effect in the scene */
  51043. name: string, scene: Scene);
  51044. /**
  51045. * Get the effect name of the layer.
  51046. * @return The effect name
  51047. */
  51048. abstract getEffectName(): string;
  51049. /**
  51050. * Checks for the readiness of the element composing the layer.
  51051. * @param subMesh the mesh to check for
  51052. * @param useInstances specify wether or not to use instances to render the mesh
  51053. * @return true if ready otherwise, false
  51054. */
  51055. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51056. /**
  51057. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51058. * @returns true if the effect requires stencil during the main canvas render pass.
  51059. */
  51060. abstract needStencil(): boolean;
  51061. /**
  51062. * Create the merge effect. This is the shader use to blit the information back
  51063. * to the main canvas at the end of the scene rendering.
  51064. * @returns The effect containing the shader used to merge the effect on the main canvas
  51065. */
  51066. protected abstract _createMergeEffect(): Effect;
  51067. /**
  51068. * Creates the render target textures and post processes used in the effect layer.
  51069. */
  51070. protected abstract _createTextureAndPostProcesses(): void;
  51071. /**
  51072. * Implementation specific of rendering the generating effect on the main canvas.
  51073. * @param effect The effect used to render through
  51074. */
  51075. protected abstract _internalRender(effect: Effect): void;
  51076. /**
  51077. * Sets the required values for both the emissive texture and and the main color.
  51078. */
  51079. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51080. /**
  51081. * Free any resources and references associated to a mesh.
  51082. * Internal use
  51083. * @param mesh The mesh to free.
  51084. */
  51085. abstract _disposeMesh(mesh: Mesh): void;
  51086. /**
  51087. * Serializes this layer (Glow or Highlight for example)
  51088. * @returns a serialized layer object
  51089. */
  51090. abstract serialize?(): any;
  51091. /**
  51092. * Initializes the effect layer with the required options.
  51093. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51094. */
  51095. protected _init(options: Partial<IEffectLayerOptions>): void;
  51096. /**
  51097. * Generates the index buffer of the full screen quad blending to the main canvas.
  51098. */
  51099. private _generateIndexBuffer;
  51100. /**
  51101. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51102. */
  51103. private _generateVertexBuffer;
  51104. /**
  51105. * Sets the main texture desired size which is the closest power of two
  51106. * of the engine canvas size.
  51107. */
  51108. private _setMainTextureSize;
  51109. /**
  51110. * Creates the main texture for the effect layer.
  51111. */
  51112. protected _createMainTexture(): void;
  51113. /**
  51114. * Adds specific effects defines.
  51115. * @param defines The defines to add specifics to.
  51116. */
  51117. protected _addCustomEffectDefines(defines: string[]): void;
  51118. /**
  51119. * Checks for the readiness of the element composing the layer.
  51120. * @param subMesh the mesh to check for
  51121. * @param useInstances specify wether or not to use instances to render the mesh
  51122. * @param emissiveTexture the associated emissive texture used to generate the glow
  51123. * @return true if ready otherwise, false
  51124. */
  51125. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51126. /**
  51127. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51128. */
  51129. render(): void;
  51130. /**
  51131. * Determine if a given mesh will be used in the current effect.
  51132. * @param mesh mesh to test
  51133. * @returns true if the mesh will be used
  51134. */
  51135. hasMesh(mesh: AbstractMesh): boolean;
  51136. /**
  51137. * Returns true if the layer contains information to display, otherwise false.
  51138. * @returns true if the glow layer should be rendered
  51139. */
  51140. shouldRender(): boolean;
  51141. /**
  51142. * Returns true if the mesh should render, otherwise false.
  51143. * @param mesh The mesh to render
  51144. * @returns true if it should render otherwise false
  51145. */
  51146. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51147. /**
  51148. * Returns true if the mesh can be rendered, otherwise false.
  51149. * @param mesh The mesh to render
  51150. * @param material The material used on the mesh
  51151. * @returns true if it can be rendered otherwise false
  51152. */
  51153. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51154. /**
  51155. * Returns true if the mesh should render, otherwise false.
  51156. * @param mesh The mesh to render
  51157. * @returns true if it should render otherwise false
  51158. */
  51159. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51160. /**
  51161. * Renders the submesh passed in parameter to the generation map.
  51162. */
  51163. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51164. /**
  51165. * Rebuild the required buffers.
  51166. * @hidden Internal use only.
  51167. */
  51168. _rebuild(): void;
  51169. /**
  51170. * Dispose only the render target textures and post process.
  51171. */
  51172. private _disposeTextureAndPostProcesses;
  51173. /**
  51174. * Dispose the highlight layer and free resources.
  51175. */
  51176. dispose(): void;
  51177. /**
  51178. * Gets the class name of the effect layer
  51179. * @returns the string with the class name of the effect layer
  51180. */
  51181. getClassName(): string;
  51182. /**
  51183. * Creates an effect layer from parsed effect layer data
  51184. * @param parsedEffectLayer defines effect layer data
  51185. * @param scene defines the current scene
  51186. * @param rootUrl defines the root URL containing the effect layer information
  51187. * @returns a parsed effect Layer
  51188. */
  51189. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51190. }
  51191. }
  51192. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51193. import { Scene } from "babylonjs/scene";
  51194. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51195. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51196. import { AbstractScene } from "babylonjs/abstractScene";
  51197. module "babylonjs/abstractScene" {
  51198. interface AbstractScene {
  51199. /**
  51200. * The list of effect layers (highlights/glow) added to the scene
  51201. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51202. * @see http://doc.babylonjs.com/how_to/glow_layer
  51203. */
  51204. effectLayers: Array<EffectLayer>;
  51205. /**
  51206. * Removes the given effect layer from this scene.
  51207. * @param toRemove defines the effect layer to remove
  51208. * @returns the index of the removed effect layer
  51209. */
  51210. removeEffectLayer(toRemove: EffectLayer): number;
  51211. /**
  51212. * Adds the given effect layer to this scene
  51213. * @param newEffectLayer defines the effect layer to add
  51214. */
  51215. addEffectLayer(newEffectLayer: EffectLayer): void;
  51216. }
  51217. }
  51218. /**
  51219. * Defines the layer scene component responsible to manage any effect layers
  51220. * in a given scene.
  51221. */
  51222. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51223. /**
  51224. * The component name helpfull to identify the component in the list of scene components.
  51225. */
  51226. readonly name: string;
  51227. /**
  51228. * The scene the component belongs to.
  51229. */
  51230. scene: Scene;
  51231. private _engine;
  51232. private _renderEffects;
  51233. private _needStencil;
  51234. private _previousStencilState;
  51235. /**
  51236. * Creates a new instance of the component for the given scene
  51237. * @param scene Defines the scene to register the component in
  51238. */
  51239. constructor(scene: Scene);
  51240. /**
  51241. * Registers the component in a given scene
  51242. */
  51243. register(): void;
  51244. /**
  51245. * Rebuilds the elements related to this component in case of
  51246. * context lost for instance.
  51247. */
  51248. rebuild(): void;
  51249. /**
  51250. * Serializes the component data to the specified json object
  51251. * @param serializationObject The object to serialize to
  51252. */
  51253. serialize(serializationObject: any): void;
  51254. /**
  51255. * Adds all the elements from the container to the scene
  51256. * @param container the container holding the elements
  51257. */
  51258. addFromContainer(container: AbstractScene): void;
  51259. /**
  51260. * Removes all the elements in the container from the scene
  51261. * @param container contains the elements to remove
  51262. * @param dispose if the removed element should be disposed (default: false)
  51263. */
  51264. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51265. /**
  51266. * Disposes the component and the associated ressources.
  51267. */
  51268. dispose(): void;
  51269. private _isReadyForMesh;
  51270. private _renderMainTexture;
  51271. private _setStencil;
  51272. private _setStencilBack;
  51273. private _draw;
  51274. private _drawCamera;
  51275. private _drawRenderingGroup;
  51276. }
  51277. }
  51278. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51279. /** @hidden */
  51280. export var glowMapMergePixelShader: {
  51281. name: string;
  51282. shader: string;
  51283. };
  51284. }
  51285. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51286. /** @hidden */
  51287. export var glowMapMergeVertexShader: {
  51288. name: string;
  51289. shader: string;
  51290. };
  51291. }
  51292. declare module "babylonjs/Layers/glowLayer" {
  51293. import { Nullable } from "babylonjs/types";
  51294. import { Camera } from "babylonjs/Cameras/camera";
  51295. import { Scene } from "babylonjs/scene";
  51296. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51298. import { Mesh } from "babylonjs/Meshes/mesh";
  51299. import { Texture } from "babylonjs/Materials/Textures/texture";
  51300. import { Effect } from "babylonjs/Materials/effect";
  51301. import { Material } from "babylonjs/Materials/material";
  51302. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51303. import { Color4 } from "babylonjs/Maths/math.color";
  51304. import "babylonjs/Shaders/glowMapMerge.fragment";
  51305. import "babylonjs/Shaders/glowMapMerge.vertex";
  51306. import "babylonjs/Layers/effectLayerSceneComponent";
  51307. module "babylonjs/abstractScene" {
  51308. interface AbstractScene {
  51309. /**
  51310. * Return a the first highlight layer of the scene with a given name.
  51311. * @param name The name of the highlight layer to look for.
  51312. * @return The highlight layer if found otherwise null.
  51313. */
  51314. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51315. }
  51316. }
  51317. /**
  51318. * Glow layer options. This helps customizing the behaviour
  51319. * of the glow layer.
  51320. */
  51321. export interface IGlowLayerOptions {
  51322. /**
  51323. * Multiplication factor apply to the canvas size to compute the render target size
  51324. * used to generated the glowing objects (the smaller the faster).
  51325. */
  51326. mainTextureRatio: number;
  51327. /**
  51328. * Enforces a fixed size texture to ensure resize independant blur.
  51329. */
  51330. mainTextureFixedSize?: number;
  51331. /**
  51332. * How big is the kernel of the blur texture.
  51333. */
  51334. blurKernelSize: number;
  51335. /**
  51336. * The camera attached to the layer.
  51337. */
  51338. camera: Nullable<Camera>;
  51339. /**
  51340. * Enable MSAA by chosing the number of samples.
  51341. */
  51342. mainTextureSamples?: number;
  51343. /**
  51344. * The rendering group to draw the layer in.
  51345. */
  51346. renderingGroupId: number;
  51347. }
  51348. /**
  51349. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51350. *
  51351. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51352. * glowy meshes to your scene.
  51353. *
  51354. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51355. */
  51356. export class GlowLayer extends EffectLayer {
  51357. /**
  51358. * Effect Name of the layer.
  51359. */
  51360. static readonly EffectName: string;
  51361. /**
  51362. * The default blur kernel size used for the glow.
  51363. */
  51364. static DefaultBlurKernelSize: number;
  51365. /**
  51366. * The default texture size ratio used for the glow.
  51367. */
  51368. static DefaultTextureRatio: number;
  51369. /**
  51370. * Sets the kernel size of the blur.
  51371. */
  51372. /**
  51373. * Gets the kernel size of the blur.
  51374. */
  51375. blurKernelSize: number;
  51376. /**
  51377. * Sets the glow intensity.
  51378. */
  51379. /**
  51380. * Gets the glow intensity.
  51381. */
  51382. intensity: number;
  51383. private _options;
  51384. private _intensity;
  51385. private _horizontalBlurPostprocess1;
  51386. private _verticalBlurPostprocess1;
  51387. private _horizontalBlurPostprocess2;
  51388. private _verticalBlurPostprocess2;
  51389. private _blurTexture1;
  51390. private _blurTexture2;
  51391. private _postProcesses1;
  51392. private _postProcesses2;
  51393. private _includedOnlyMeshes;
  51394. private _excludedMeshes;
  51395. /**
  51396. * Callback used to let the user override the color selection on a per mesh basis
  51397. */
  51398. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51399. /**
  51400. * Callback used to let the user override the texture selection on a per mesh basis
  51401. */
  51402. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51403. /**
  51404. * Instantiates a new glow Layer and references it to the scene.
  51405. * @param name The name of the layer
  51406. * @param scene The scene to use the layer in
  51407. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51408. */
  51409. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51410. /**
  51411. * Get the effect name of the layer.
  51412. * @return The effect name
  51413. */
  51414. getEffectName(): string;
  51415. /**
  51416. * Create the merge effect. This is the shader use to blit the information back
  51417. * to the main canvas at the end of the scene rendering.
  51418. */
  51419. protected _createMergeEffect(): Effect;
  51420. /**
  51421. * Creates the render target textures and post processes used in the glow layer.
  51422. */
  51423. protected _createTextureAndPostProcesses(): void;
  51424. /**
  51425. * Checks for the readiness of the element composing the layer.
  51426. * @param subMesh the mesh to check for
  51427. * @param useInstances specify wether or not to use instances to render the mesh
  51428. * @param emissiveTexture the associated emissive texture used to generate the glow
  51429. * @return true if ready otherwise, false
  51430. */
  51431. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51432. /**
  51433. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51434. */
  51435. needStencil(): boolean;
  51436. /**
  51437. * Returns true if the mesh can be rendered, otherwise false.
  51438. * @param mesh The mesh to render
  51439. * @param material The material used on the mesh
  51440. * @returns true if it can be rendered otherwise false
  51441. */
  51442. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51443. /**
  51444. * Implementation specific of rendering the generating effect on the main canvas.
  51445. * @param effect The effect used to render through
  51446. */
  51447. protected _internalRender(effect: Effect): void;
  51448. /**
  51449. * Sets the required values for both the emissive texture and and the main color.
  51450. */
  51451. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51452. /**
  51453. * Returns true if the mesh should render, otherwise false.
  51454. * @param mesh The mesh to render
  51455. * @returns true if it should render otherwise false
  51456. */
  51457. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51458. /**
  51459. * Adds specific effects defines.
  51460. * @param defines The defines to add specifics to.
  51461. */
  51462. protected _addCustomEffectDefines(defines: string[]): void;
  51463. /**
  51464. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51465. * @param mesh The mesh to exclude from the glow layer
  51466. */
  51467. addExcludedMesh(mesh: Mesh): void;
  51468. /**
  51469. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51470. * @param mesh The mesh to remove
  51471. */
  51472. removeExcludedMesh(mesh: Mesh): void;
  51473. /**
  51474. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51475. * @param mesh The mesh to include in the glow layer
  51476. */
  51477. addIncludedOnlyMesh(mesh: Mesh): void;
  51478. /**
  51479. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51480. * @param mesh The mesh to remove
  51481. */
  51482. removeIncludedOnlyMesh(mesh: Mesh): void;
  51483. /**
  51484. * Determine if a given mesh will be used in the glow layer
  51485. * @param mesh The mesh to test
  51486. * @returns true if the mesh will be highlighted by the current glow layer
  51487. */
  51488. hasMesh(mesh: AbstractMesh): boolean;
  51489. /**
  51490. * Free any resources and references associated to a mesh.
  51491. * Internal use
  51492. * @param mesh The mesh to free.
  51493. * @hidden
  51494. */
  51495. _disposeMesh(mesh: Mesh): void;
  51496. /**
  51497. * Gets the class name of the effect layer
  51498. * @returns the string with the class name of the effect layer
  51499. */
  51500. getClassName(): string;
  51501. /**
  51502. * Serializes this glow layer
  51503. * @returns a serialized glow layer object
  51504. */
  51505. serialize(): any;
  51506. /**
  51507. * Creates a Glow Layer from parsed glow layer data
  51508. * @param parsedGlowLayer defines glow layer data
  51509. * @param scene defines the current scene
  51510. * @param rootUrl defines the root URL containing the glow layer information
  51511. * @returns a parsed Glow Layer
  51512. */
  51513. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51514. }
  51515. }
  51516. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51517. /** @hidden */
  51518. export var glowBlurPostProcessPixelShader: {
  51519. name: string;
  51520. shader: string;
  51521. };
  51522. }
  51523. declare module "babylonjs/Layers/highlightLayer" {
  51524. import { Observable } from "babylonjs/Misc/observable";
  51525. import { Nullable } from "babylonjs/types";
  51526. import { Camera } from "babylonjs/Cameras/camera";
  51527. import { Scene } from "babylonjs/scene";
  51528. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51530. import { Mesh } from "babylonjs/Meshes/mesh";
  51531. import { Effect } from "babylonjs/Materials/effect";
  51532. import { Material } from "babylonjs/Materials/material";
  51533. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51534. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51535. import "babylonjs/Shaders/glowMapMerge.fragment";
  51536. import "babylonjs/Shaders/glowMapMerge.vertex";
  51537. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51538. module "babylonjs/abstractScene" {
  51539. interface AbstractScene {
  51540. /**
  51541. * Return a the first highlight layer of the scene with a given name.
  51542. * @param name The name of the highlight layer to look for.
  51543. * @return The highlight layer if found otherwise null.
  51544. */
  51545. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51546. }
  51547. }
  51548. /**
  51549. * Highlight layer options. This helps customizing the behaviour
  51550. * of the highlight layer.
  51551. */
  51552. export interface IHighlightLayerOptions {
  51553. /**
  51554. * Multiplication factor apply to the canvas size to compute the render target size
  51555. * used to generated the glowing objects (the smaller the faster).
  51556. */
  51557. mainTextureRatio: number;
  51558. /**
  51559. * Enforces a fixed size texture to ensure resize independant blur.
  51560. */
  51561. mainTextureFixedSize?: number;
  51562. /**
  51563. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51564. * of the picture to blur (the smaller the faster).
  51565. */
  51566. blurTextureSizeRatio: number;
  51567. /**
  51568. * How big in texel of the blur texture is the vertical blur.
  51569. */
  51570. blurVerticalSize: number;
  51571. /**
  51572. * How big in texel of the blur texture is the horizontal blur.
  51573. */
  51574. blurHorizontalSize: number;
  51575. /**
  51576. * Alpha blending mode used to apply the blur. Default is combine.
  51577. */
  51578. alphaBlendingMode: number;
  51579. /**
  51580. * The camera attached to the layer.
  51581. */
  51582. camera: Nullable<Camera>;
  51583. /**
  51584. * Should we display highlight as a solid stroke?
  51585. */
  51586. isStroke?: boolean;
  51587. /**
  51588. * The rendering group to draw the layer in.
  51589. */
  51590. renderingGroupId: number;
  51591. }
  51592. /**
  51593. * The highlight layer Helps adding a glow effect around a mesh.
  51594. *
  51595. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51596. * glowy meshes to your scene.
  51597. *
  51598. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51599. */
  51600. export class HighlightLayer extends EffectLayer {
  51601. name: string;
  51602. /**
  51603. * Effect Name of the highlight layer.
  51604. */
  51605. static readonly EffectName: string;
  51606. /**
  51607. * The neutral color used during the preparation of the glow effect.
  51608. * This is black by default as the blend operation is a blend operation.
  51609. */
  51610. static NeutralColor: Color4;
  51611. /**
  51612. * Stencil value used for glowing meshes.
  51613. */
  51614. static GlowingMeshStencilReference: number;
  51615. /**
  51616. * Stencil value used for the other meshes in the scene.
  51617. */
  51618. static NormalMeshStencilReference: number;
  51619. /**
  51620. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51621. */
  51622. innerGlow: boolean;
  51623. /**
  51624. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51625. */
  51626. outerGlow: boolean;
  51627. /**
  51628. * Specifies the horizontal size of the blur.
  51629. */
  51630. /**
  51631. * Gets the horizontal size of the blur.
  51632. */
  51633. blurHorizontalSize: number;
  51634. /**
  51635. * Specifies the vertical size of the blur.
  51636. */
  51637. /**
  51638. * Gets the vertical size of the blur.
  51639. */
  51640. blurVerticalSize: number;
  51641. /**
  51642. * An event triggered when the highlight layer is being blurred.
  51643. */
  51644. onBeforeBlurObservable: Observable<HighlightLayer>;
  51645. /**
  51646. * An event triggered when the highlight layer has been blurred.
  51647. */
  51648. onAfterBlurObservable: Observable<HighlightLayer>;
  51649. private _instanceGlowingMeshStencilReference;
  51650. private _options;
  51651. private _downSamplePostprocess;
  51652. private _horizontalBlurPostprocess;
  51653. private _verticalBlurPostprocess;
  51654. private _blurTexture;
  51655. private _meshes;
  51656. private _excludedMeshes;
  51657. /**
  51658. * Instantiates a new highlight Layer and references it to the scene..
  51659. * @param name The name of the layer
  51660. * @param scene The scene to use the layer in
  51661. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51662. */
  51663. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51664. /**
  51665. * Get the effect name of the layer.
  51666. * @return The effect name
  51667. */
  51668. getEffectName(): string;
  51669. /**
  51670. * Create the merge effect. This is the shader use to blit the information back
  51671. * to the main canvas at the end of the scene rendering.
  51672. */
  51673. protected _createMergeEffect(): Effect;
  51674. /**
  51675. * Creates the render target textures and post processes used in the highlight layer.
  51676. */
  51677. protected _createTextureAndPostProcesses(): void;
  51678. /**
  51679. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51680. */
  51681. needStencil(): boolean;
  51682. /**
  51683. * Checks for the readiness of the element composing the layer.
  51684. * @param subMesh the mesh to check for
  51685. * @param useInstances specify wether or not to use instances to render the mesh
  51686. * @param emissiveTexture the associated emissive texture used to generate the glow
  51687. * @return true if ready otherwise, false
  51688. */
  51689. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51690. /**
  51691. * Implementation specific of rendering the generating effect on the main canvas.
  51692. * @param effect The effect used to render through
  51693. */
  51694. protected _internalRender(effect: Effect): void;
  51695. /**
  51696. * Returns true if the layer contains information to display, otherwise false.
  51697. */
  51698. shouldRender(): boolean;
  51699. /**
  51700. * Returns true if the mesh should render, otherwise false.
  51701. * @param mesh The mesh to render
  51702. * @returns true if it should render otherwise false
  51703. */
  51704. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51705. /**
  51706. * Sets the required values for both the emissive texture and and the main color.
  51707. */
  51708. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51709. /**
  51710. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51711. * @param mesh The mesh to exclude from the highlight layer
  51712. */
  51713. addExcludedMesh(mesh: Mesh): void;
  51714. /**
  51715. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51716. * @param mesh The mesh to highlight
  51717. */
  51718. removeExcludedMesh(mesh: Mesh): void;
  51719. /**
  51720. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51721. * @param mesh mesh to test
  51722. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51723. */
  51724. hasMesh(mesh: AbstractMesh): boolean;
  51725. /**
  51726. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51727. * @param mesh The mesh to highlight
  51728. * @param color The color of the highlight
  51729. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51730. */
  51731. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51732. /**
  51733. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51734. * @param mesh The mesh to highlight
  51735. */
  51736. removeMesh(mesh: Mesh): void;
  51737. /**
  51738. * Force the stencil to the normal expected value for none glowing parts
  51739. */
  51740. private _defaultStencilReference;
  51741. /**
  51742. * Free any resources and references associated to a mesh.
  51743. * Internal use
  51744. * @param mesh The mesh to free.
  51745. * @hidden
  51746. */
  51747. _disposeMesh(mesh: Mesh): void;
  51748. /**
  51749. * Dispose the highlight layer and free resources.
  51750. */
  51751. dispose(): void;
  51752. /**
  51753. * Gets the class name of the effect layer
  51754. * @returns the string with the class name of the effect layer
  51755. */
  51756. getClassName(): string;
  51757. /**
  51758. * Serializes this Highlight layer
  51759. * @returns a serialized Highlight layer object
  51760. */
  51761. serialize(): any;
  51762. /**
  51763. * Creates a Highlight layer from parsed Highlight layer data
  51764. * @param parsedHightlightLayer defines the Highlight layer data
  51765. * @param scene defines the current scene
  51766. * @param rootUrl defines the root URL containing the Highlight layer information
  51767. * @returns a parsed Highlight layer
  51768. */
  51769. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51770. }
  51771. }
  51772. declare module "babylonjs/Layers/layerSceneComponent" {
  51773. import { Scene } from "babylonjs/scene";
  51774. import { ISceneComponent } from "babylonjs/sceneComponent";
  51775. import { Layer } from "babylonjs/Layers/layer";
  51776. import { AbstractScene } from "babylonjs/abstractScene";
  51777. module "babylonjs/abstractScene" {
  51778. interface AbstractScene {
  51779. /**
  51780. * The list of layers (background and foreground) of the scene
  51781. */
  51782. layers: Array<Layer>;
  51783. }
  51784. }
  51785. /**
  51786. * Defines the layer scene component responsible to manage any layers
  51787. * in a given scene.
  51788. */
  51789. export class LayerSceneComponent implements ISceneComponent {
  51790. /**
  51791. * The component name helpfull to identify the component in the list of scene components.
  51792. */
  51793. readonly name: string;
  51794. /**
  51795. * The scene the component belongs to.
  51796. */
  51797. scene: Scene;
  51798. private _engine;
  51799. /**
  51800. * Creates a new instance of the component for the given scene
  51801. * @param scene Defines the scene to register the component in
  51802. */
  51803. constructor(scene: Scene);
  51804. /**
  51805. * Registers the component in a given scene
  51806. */
  51807. register(): void;
  51808. /**
  51809. * Rebuilds the elements related to this component in case of
  51810. * context lost for instance.
  51811. */
  51812. rebuild(): void;
  51813. /**
  51814. * Disposes the component and the associated ressources.
  51815. */
  51816. dispose(): void;
  51817. private _draw;
  51818. private _drawCameraPredicate;
  51819. private _drawCameraBackground;
  51820. private _drawCameraForeground;
  51821. private _drawRenderTargetPredicate;
  51822. private _drawRenderTargetBackground;
  51823. private _drawRenderTargetForeground;
  51824. /**
  51825. * Adds all the elements from the container to the scene
  51826. * @param container the container holding the elements
  51827. */
  51828. addFromContainer(container: AbstractScene): void;
  51829. /**
  51830. * Removes all the elements in the container from the scene
  51831. * @param container contains the elements to remove
  51832. * @param dispose if the removed element should be disposed (default: false)
  51833. */
  51834. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51835. }
  51836. }
  51837. declare module "babylonjs/Shaders/layer.fragment" {
  51838. /** @hidden */
  51839. export var layerPixelShader: {
  51840. name: string;
  51841. shader: string;
  51842. };
  51843. }
  51844. declare module "babylonjs/Shaders/layer.vertex" {
  51845. /** @hidden */
  51846. export var layerVertexShader: {
  51847. name: string;
  51848. shader: string;
  51849. };
  51850. }
  51851. declare module "babylonjs/Layers/layer" {
  51852. import { Observable } from "babylonjs/Misc/observable";
  51853. import { Nullable } from "babylonjs/types";
  51854. import { Scene } from "babylonjs/scene";
  51855. import { Vector2 } from "babylonjs/Maths/math.vector";
  51856. import { Color4 } from "babylonjs/Maths/math.color";
  51857. import { Texture } from "babylonjs/Materials/Textures/texture";
  51858. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51859. import "babylonjs/Shaders/layer.fragment";
  51860. import "babylonjs/Shaders/layer.vertex";
  51861. /**
  51862. * This represents a full screen 2d layer.
  51863. * This can be useful to display a picture in the background of your scene for instance.
  51864. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51865. */
  51866. export class Layer {
  51867. /**
  51868. * Define the name of the layer.
  51869. */
  51870. name: string;
  51871. /**
  51872. * Define the texture the layer should display.
  51873. */
  51874. texture: Nullable<Texture>;
  51875. /**
  51876. * Is the layer in background or foreground.
  51877. */
  51878. isBackground: boolean;
  51879. /**
  51880. * Define the color of the layer (instead of texture).
  51881. */
  51882. color: Color4;
  51883. /**
  51884. * Define the scale of the layer in order to zoom in out of the texture.
  51885. */
  51886. scale: Vector2;
  51887. /**
  51888. * Define an offset for the layer in order to shift the texture.
  51889. */
  51890. offset: Vector2;
  51891. /**
  51892. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51893. */
  51894. alphaBlendingMode: number;
  51895. /**
  51896. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51897. * Alpha test will not mix with the background color in case of transparency.
  51898. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51899. */
  51900. alphaTest: boolean;
  51901. /**
  51902. * Define a mask to restrict the layer to only some of the scene cameras.
  51903. */
  51904. layerMask: number;
  51905. /**
  51906. * Define the list of render target the layer is visible into.
  51907. */
  51908. renderTargetTextures: RenderTargetTexture[];
  51909. /**
  51910. * Define if the layer is only used in renderTarget or if it also
  51911. * renders in the main frame buffer of the canvas.
  51912. */
  51913. renderOnlyInRenderTargetTextures: boolean;
  51914. private _scene;
  51915. private _vertexBuffers;
  51916. private _indexBuffer;
  51917. private _effect;
  51918. private _alphaTestEffect;
  51919. /**
  51920. * An event triggered when the layer is disposed.
  51921. */
  51922. onDisposeObservable: Observable<Layer>;
  51923. private _onDisposeObserver;
  51924. /**
  51925. * Back compatibility with callback before the onDisposeObservable existed.
  51926. * The set callback will be triggered when the layer has been disposed.
  51927. */
  51928. onDispose: () => void;
  51929. /**
  51930. * An event triggered before rendering the scene
  51931. */
  51932. onBeforeRenderObservable: Observable<Layer>;
  51933. private _onBeforeRenderObserver;
  51934. /**
  51935. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51936. * The set callback will be triggered just before rendering the layer.
  51937. */
  51938. onBeforeRender: () => void;
  51939. /**
  51940. * An event triggered after rendering the scene
  51941. */
  51942. onAfterRenderObservable: Observable<Layer>;
  51943. private _onAfterRenderObserver;
  51944. /**
  51945. * Back compatibility with callback before the onAfterRenderObservable existed.
  51946. * The set callback will be triggered just after rendering the layer.
  51947. */
  51948. onAfterRender: () => void;
  51949. /**
  51950. * Instantiates a new layer.
  51951. * This represents a full screen 2d layer.
  51952. * This can be useful to display a picture in the background of your scene for instance.
  51953. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51954. * @param name Define the name of the layer in the scene
  51955. * @param imgUrl Define the url of the texture to display in the layer
  51956. * @param scene Define the scene the layer belongs to
  51957. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51958. * @param color Defines a color for the layer
  51959. */
  51960. constructor(
  51961. /**
  51962. * Define the name of the layer.
  51963. */
  51964. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51965. private _createIndexBuffer;
  51966. /** @hidden */
  51967. _rebuild(): void;
  51968. /**
  51969. * Renders the layer in the scene.
  51970. */
  51971. render(): void;
  51972. /**
  51973. * Disposes and releases the associated ressources.
  51974. */
  51975. dispose(): void;
  51976. }
  51977. }
  51978. declare module "babylonjs/Layers/index" {
  51979. export * from "babylonjs/Layers/effectLayer";
  51980. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51981. export * from "babylonjs/Layers/glowLayer";
  51982. export * from "babylonjs/Layers/highlightLayer";
  51983. export * from "babylonjs/Layers/layer";
  51984. export * from "babylonjs/Layers/layerSceneComponent";
  51985. }
  51986. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51987. /** @hidden */
  51988. export var lensFlarePixelShader: {
  51989. name: string;
  51990. shader: string;
  51991. };
  51992. }
  51993. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51994. /** @hidden */
  51995. export var lensFlareVertexShader: {
  51996. name: string;
  51997. shader: string;
  51998. };
  51999. }
  52000. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52001. import { Scene } from "babylonjs/scene";
  52002. import { Vector3 } from "babylonjs/Maths/math.vector";
  52003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52004. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52005. import "babylonjs/Shaders/lensFlare.fragment";
  52006. import "babylonjs/Shaders/lensFlare.vertex";
  52007. import { Viewport } from "babylonjs/Maths/math.viewport";
  52008. /**
  52009. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52010. * It is usually composed of several `lensFlare`.
  52011. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52012. */
  52013. export class LensFlareSystem {
  52014. /**
  52015. * Define the name of the lens flare system
  52016. */
  52017. name: string;
  52018. /**
  52019. * List of lens flares used in this system.
  52020. */
  52021. lensFlares: LensFlare[];
  52022. /**
  52023. * Define a limit from the border the lens flare can be visible.
  52024. */
  52025. borderLimit: number;
  52026. /**
  52027. * Define a viewport border we do not want to see the lens flare in.
  52028. */
  52029. viewportBorder: number;
  52030. /**
  52031. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52032. */
  52033. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52034. /**
  52035. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52036. */
  52037. layerMask: number;
  52038. /**
  52039. * Define the id of the lens flare system in the scene.
  52040. * (equal to name by default)
  52041. */
  52042. id: string;
  52043. private _scene;
  52044. private _emitter;
  52045. private _vertexBuffers;
  52046. private _indexBuffer;
  52047. private _effect;
  52048. private _positionX;
  52049. private _positionY;
  52050. private _isEnabled;
  52051. /** @hidden */
  52052. static _SceneComponentInitialization: (scene: Scene) => void;
  52053. /**
  52054. * Instantiates a lens flare system.
  52055. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52056. * It is usually composed of several `lensFlare`.
  52057. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52058. * @param name Define the name of the lens flare system in the scene
  52059. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52060. * @param scene Define the scene the lens flare system belongs to
  52061. */
  52062. constructor(
  52063. /**
  52064. * Define the name of the lens flare system
  52065. */
  52066. name: string, emitter: any, scene: Scene);
  52067. /**
  52068. * Define if the lens flare system is enabled.
  52069. */
  52070. isEnabled: boolean;
  52071. /**
  52072. * Get the scene the effects belongs to.
  52073. * @returns the scene holding the lens flare system
  52074. */
  52075. getScene(): Scene;
  52076. /**
  52077. * Get the emitter of the lens flare system.
  52078. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52079. * @returns the emitter of the lens flare system
  52080. */
  52081. getEmitter(): any;
  52082. /**
  52083. * Set the emitter of the lens flare system.
  52084. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52085. * @param newEmitter Define the new emitter of the system
  52086. */
  52087. setEmitter(newEmitter: any): void;
  52088. /**
  52089. * Get the lens flare system emitter position.
  52090. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52091. * @returns the position
  52092. */
  52093. getEmitterPosition(): Vector3;
  52094. /**
  52095. * @hidden
  52096. */
  52097. computeEffectivePosition(globalViewport: Viewport): boolean;
  52098. /** @hidden */
  52099. _isVisible(): boolean;
  52100. /**
  52101. * @hidden
  52102. */
  52103. render(): boolean;
  52104. /**
  52105. * Dispose and release the lens flare with its associated resources.
  52106. */
  52107. dispose(): void;
  52108. /**
  52109. * Parse a lens flare system from a JSON repressentation
  52110. * @param parsedLensFlareSystem Define the JSON to parse
  52111. * @param scene Define the scene the parsed system should be instantiated in
  52112. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52113. * @returns the parsed system
  52114. */
  52115. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52116. /**
  52117. * Serialize the current Lens Flare System into a JSON representation.
  52118. * @returns the serialized JSON
  52119. */
  52120. serialize(): any;
  52121. }
  52122. }
  52123. declare module "babylonjs/LensFlares/lensFlare" {
  52124. import { Nullable } from "babylonjs/types";
  52125. import { Color3 } from "babylonjs/Maths/math.color";
  52126. import { Texture } from "babylonjs/Materials/Textures/texture";
  52127. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52128. /**
  52129. * This represents one of the lens effect in a `lensFlareSystem`.
  52130. * It controls one of the indiviual texture used in the effect.
  52131. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52132. */
  52133. export class LensFlare {
  52134. /**
  52135. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52136. */
  52137. size: number;
  52138. /**
  52139. * 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.
  52140. */
  52141. position: number;
  52142. /**
  52143. * Define the lens color.
  52144. */
  52145. color: Color3;
  52146. /**
  52147. * Define the lens texture.
  52148. */
  52149. texture: Nullable<Texture>;
  52150. /**
  52151. * Define the alpha mode to render this particular lens.
  52152. */
  52153. alphaMode: number;
  52154. private _system;
  52155. /**
  52156. * Creates a new Lens Flare.
  52157. * This represents one of the lens effect in a `lensFlareSystem`.
  52158. * It controls one of the indiviual texture used in the effect.
  52159. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52160. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52161. * @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.
  52162. * @param color Define the lens color
  52163. * @param imgUrl Define the lens texture url
  52164. * @param system Define the `lensFlareSystem` this flare is part of
  52165. * @returns The newly created Lens Flare
  52166. */
  52167. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52168. /**
  52169. * Instantiates a new Lens Flare.
  52170. * This represents one of the lens effect in a `lensFlareSystem`.
  52171. * It controls one of the indiviual texture used in the effect.
  52172. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52173. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52174. * @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.
  52175. * @param color Define the lens color
  52176. * @param imgUrl Define the lens texture url
  52177. * @param system Define the `lensFlareSystem` this flare is part of
  52178. */
  52179. constructor(
  52180. /**
  52181. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52182. */
  52183. size: number,
  52184. /**
  52185. * 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.
  52186. */
  52187. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52188. /**
  52189. * Dispose and release the lens flare with its associated resources.
  52190. */
  52191. dispose(): void;
  52192. }
  52193. }
  52194. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52195. import { Nullable } from "babylonjs/types";
  52196. import { Scene } from "babylonjs/scene";
  52197. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52198. import { AbstractScene } from "babylonjs/abstractScene";
  52199. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52200. module "babylonjs/abstractScene" {
  52201. interface AbstractScene {
  52202. /**
  52203. * The list of lens flare system added to the scene
  52204. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52205. */
  52206. lensFlareSystems: Array<LensFlareSystem>;
  52207. /**
  52208. * Removes the given lens flare system from this scene.
  52209. * @param toRemove The lens flare system to remove
  52210. * @returns The index of the removed lens flare system
  52211. */
  52212. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52213. /**
  52214. * Adds the given lens flare system to this scene
  52215. * @param newLensFlareSystem The lens flare system to add
  52216. */
  52217. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52218. /**
  52219. * Gets a lens flare system using its name
  52220. * @param name defines the name to look for
  52221. * @returns the lens flare system or null if not found
  52222. */
  52223. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52224. /**
  52225. * Gets a lens flare system using its id
  52226. * @param id defines the id to look for
  52227. * @returns the lens flare system or null if not found
  52228. */
  52229. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52230. }
  52231. }
  52232. /**
  52233. * Defines the lens flare scene component responsible to manage any lens flares
  52234. * in a given scene.
  52235. */
  52236. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52237. /**
  52238. * The component name helpfull to identify the component in the list of scene components.
  52239. */
  52240. readonly name: string;
  52241. /**
  52242. * The scene the component belongs to.
  52243. */
  52244. scene: Scene;
  52245. /**
  52246. * Creates a new instance of the component for the given scene
  52247. * @param scene Defines the scene to register the component in
  52248. */
  52249. constructor(scene: Scene);
  52250. /**
  52251. * Registers the component in a given scene
  52252. */
  52253. register(): void;
  52254. /**
  52255. * Rebuilds the elements related to this component in case of
  52256. * context lost for instance.
  52257. */
  52258. rebuild(): void;
  52259. /**
  52260. * Adds all the elements from the container to the scene
  52261. * @param container the container holding the elements
  52262. */
  52263. addFromContainer(container: AbstractScene): void;
  52264. /**
  52265. * Removes all the elements in the container from the scene
  52266. * @param container contains the elements to remove
  52267. * @param dispose if the removed element should be disposed (default: false)
  52268. */
  52269. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52270. /**
  52271. * Serializes the component data to the specified json object
  52272. * @param serializationObject The object to serialize to
  52273. */
  52274. serialize(serializationObject: any): void;
  52275. /**
  52276. * Disposes the component and the associated ressources.
  52277. */
  52278. dispose(): void;
  52279. private _draw;
  52280. }
  52281. }
  52282. declare module "babylonjs/LensFlares/index" {
  52283. export * from "babylonjs/LensFlares/lensFlare";
  52284. export * from "babylonjs/LensFlares/lensFlareSystem";
  52285. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52286. }
  52287. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52288. import { Scene } from "babylonjs/scene";
  52289. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52290. import { AbstractScene } from "babylonjs/abstractScene";
  52291. /**
  52292. * Defines the shadow generator component responsible to manage any shadow generators
  52293. * in a given scene.
  52294. */
  52295. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52296. /**
  52297. * The component name helpfull to identify the component in the list of scene components.
  52298. */
  52299. readonly name: string;
  52300. /**
  52301. * The scene the component belongs to.
  52302. */
  52303. scene: Scene;
  52304. /**
  52305. * Creates a new instance of the component for the given scene
  52306. * @param scene Defines the scene to register the component in
  52307. */
  52308. constructor(scene: Scene);
  52309. /**
  52310. * Registers the component in a given scene
  52311. */
  52312. register(): void;
  52313. /**
  52314. * Rebuilds the elements related to this component in case of
  52315. * context lost for instance.
  52316. */
  52317. rebuild(): void;
  52318. /**
  52319. * Serializes the component data to the specified json object
  52320. * @param serializationObject The object to serialize to
  52321. */
  52322. serialize(serializationObject: any): void;
  52323. /**
  52324. * Adds all the elements from the container to the scene
  52325. * @param container the container holding the elements
  52326. */
  52327. addFromContainer(container: AbstractScene): void;
  52328. /**
  52329. * Removes all the elements in the container from the scene
  52330. * @param container contains the elements to remove
  52331. * @param dispose if the removed element should be disposed (default: false)
  52332. */
  52333. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52334. /**
  52335. * Rebuilds the elements related to this component in case of
  52336. * context lost for instance.
  52337. */
  52338. dispose(): void;
  52339. private _gatherRenderTargets;
  52340. }
  52341. }
  52342. declare module "babylonjs/Lights/Shadows/index" {
  52343. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52344. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52345. }
  52346. declare module "babylonjs/Lights/pointLight" {
  52347. import { Scene } from "babylonjs/scene";
  52348. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52350. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52351. import { Effect } from "babylonjs/Materials/effect";
  52352. /**
  52353. * A point light is a light defined by an unique point in world space.
  52354. * The light is emitted in every direction from this point.
  52355. * A good example of a point light is a standard light bulb.
  52356. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52357. */
  52358. export class PointLight extends ShadowLight {
  52359. private _shadowAngle;
  52360. /**
  52361. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52362. * This specifies what angle the shadow will use to be created.
  52363. *
  52364. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52365. */
  52366. /**
  52367. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52368. * This specifies what angle the shadow will use to be created.
  52369. *
  52370. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52371. */
  52372. shadowAngle: number;
  52373. /**
  52374. * Gets the direction if it has been set.
  52375. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52376. */
  52377. /**
  52378. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52379. */
  52380. direction: Vector3;
  52381. /**
  52382. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52383. * A PointLight emits the light in every direction.
  52384. * It can cast shadows.
  52385. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52386. * ```javascript
  52387. * var pointLight = new PointLight("pl", camera.position, scene);
  52388. * ```
  52389. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52390. * @param name The light friendly name
  52391. * @param position The position of the point light in the scene
  52392. * @param scene The scene the lights belongs to
  52393. */
  52394. constructor(name: string, position: Vector3, scene: Scene);
  52395. /**
  52396. * Returns the string "PointLight"
  52397. * @returns the class name
  52398. */
  52399. getClassName(): string;
  52400. /**
  52401. * Returns the integer 0.
  52402. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52403. */
  52404. getTypeID(): number;
  52405. /**
  52406. * Specifies wether or not the shadowmap should be a cube texture.
  52407. * @returns true if the shadowmap needs to be a cube texture.
  52408. */
  52409. needCube(): boolean;
  52410. /**
  52411. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52412. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52413. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52414. */
  52415. getShadowDirection(faceIndex?: number): Vector3;
  52416. /**
  52417. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52418. * - fov = PI / 2
  52419. * - aspect ratio : 1.0
  52420. * - z-near and far equal to the active camera minZ and maxZ.
  52421. * Returns the PointLight.
  52422. */
  52423. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52424. protected _buildUniformLayout(): void;
  52425. /**
  52426. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52427. * @param effect The effect to update
  52428. * @param lightIndex The index of the light in the effect to update
  52429. * @returns The point light
  52430. */
  52431. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52432. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52433. /**
  52434. * Prepares the list of defines specific to the light type.
  52435. * @param defines the list of defines
  52436. * @param lightIndex defines the index of the light for the effect
  52437. */
  52438. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52439. }
  52440. }
  52441. declare module "babylonjs/Lights/index" {
  52442. export * from "babylonjs/Lights/light";
  52443. export * from "babylonjs/Lights/shadowLight";
  52444. export * from "babylonjs/Lights/Shadows/index";
  52445. export * from "babylonjs/Lights/directionalLight";
  52446. export * from "babylonjs/Lights/hemisphericLight";
  52447. export * from "babylonjs/Lights/pointLight";
  52448. export * from "babylonjs/Lights/spotLight";
  52449. }
  52450. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52451. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52452. /**
  52453. * Header information of HDR texture files.
  52454. */
  52455. export interface HDRInfo {
  52456. /**
  52457. * The height of the texture in pixels.
  52458. */
  52459. height: number;
  52460. /**
  52461. * The width of the texture in pixels.
  52462. */
  52463. width: number;
  52464. /**
  52465. * The index of the beginning of the data in the binary file.
  52466. */
  52467. dataPosition: number;
  52468. }
  52469. /**
  52470. * This groups tools to convert HDR texture to native colors array.
  52471. */
  52472. export class HDRTools {
  52473. private static Ldexp;
  52474. private static Rgbe2float;
  52475. private static readStringLine;
  52476. /**
  52477. * Reads header information from an RGBE texture stored in a native array.
  52478. * More information on this format are available here:
  52479. * https://en.wikipedia.org/wiki/RGBE_image_format
  52480. *
  52481. * @param uint8array The binary file stored in native array.
  52482. * @return The header information.
  52483. */
  52484. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52485. /**
  52486. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52487. * This RGBE texture needs to store the information as a panorama.
  52488. *
  52489. * More information on this format are available here:
  52490. * https://en.wikipedia.org/wiki/RGBE_image_format
  52491. *
  52492. * @param buffer The binary file stored in an array buffer.
  52493. * @param size The expected size of the extracted cubemap.
  52494. * @return The Cube Map information.
  52495. */
  52496. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52497. /**
  52498. * Returns the pixels data extracted from an RGBE texture.
  52499. * This pixels will be stored left to right up to down in the R G B order in one array.
  52500. *
  52501. * More information on this format are available here:
  52502. * https://en.wikipedia.org/wiki/RGBE_image_format
  52503. *
  52504. * @param uint8array The binary file stored in an array buffer.
  52505. * @param hdrInfo The header information of the file.
  52506. * @return The pixels data in RGB right to left up to down order.
  52507. */
  52508. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52509. private static RGBE_ReadPixels_RLE;
  52510. }
  52511. }
  52512. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52513. import { Nullable } from "babylonjs/types";
  52514. import { Scene } from "babylonjs/scene";
  52515. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52516. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52517. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52518. /**
  52519. * This represents a texture coming from an HDR input.
  52520. *
  52521. * The only supported format is currently panorama picture stored in RGBE format.
  52522. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52523. */
  52524. export class HDRCubeTexture extends BaseTexture {
  52525. private static _facesMapping;
  52526. private _generateHarmonics;
  52527. private _noMipmap;
  52528. private _textureMatrix;
  52529. private _size;
  52530. private _onLoad;
  52531. private _onError;
  52532. /**
  52533. * The texture URL.
  52534. */
  52535. url: string;
  52536. /**
  52537. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52538. */
  52539. coordinatesMode: number;
  52540. protected _isBlocking: boolean;
  52541. /**
  52542. * Sets wether or not the texture is blocking during loading.
  52543. */
  52544. /**
  52545. * Gets wether or not the texture is blocking during loading.
  52546. */
  52547. isBlocking: boolean;
  52548. protected _rotationY: number;
  52549. /**
  52550. * Sets texture matrix rotation angle around Y axis in radians.
  52551. */
  52552. /**
  52553. * Gets texture matrix rotation angle around Y axis radians.
  52554. */
  52555. rotationY: number;
  52556. /**
  52557. * Gets or sets the center of the bounding box associated with the cube texture
  52558. * It must define where the camera used to render the texture was set
  52559. */
  52560. boundingBoxPosition: Vector3;
  52561. private _boundingBoxSize;
  52562. /**
  52563. * Gets or sets the size of the bounding box associated with the cube texture
  52564. * When defined, the cubemap will switch to local mode
  52565. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52566. * @example https://www.babylonjs-playground.com/#RNASML
  52567. */
  52568. boundingBoxSize: Vector3;
  52569. /**
  52570. * Instantiates an HDRTexture from the following parameters.
  52571. *
  52572. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52573. * @param scene The scene the texture will be used in
  52574. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52575. * @param noMipmap Forces to not generate the mipmap if true
  52576. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52577. * @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)
  52578. * @param reserved Reserved flag for internal use.
  52579. */
  52580. 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>);
  52581. /**
  52582. * Get the current class name of the texture useful for serialization or dynamic coding.
  52583. * @returns "HDRCubeTexture"
  52584. */
  52585. getClassName(): string;
  52586. /**
  52587. * Occurs when the file is raw .hdr file.
  52588. */
  52589. private loadTexture;
  52590. clone(): HDRCubeTexture;
  52591. delayLoad(): void;
  52592. /**
  52593. * Get the texture reflection matrix used to rotate/transform the reflection.
  52594. * @returns the reflection matrix
  52595. */
  52596. getReflectionTextureMatrix(): Matrix;
  52597. /**
  52598. * Set the texture reflection matrix used to rotate/transform the reflection.
  52599. * @param value Define the reflection matrix to set
  52600. */
  52601. setReflectionTextureMatrix(value: Matrix): void;
  52602. /**
  52603. * Parses a JSON representation of an HDR Texture in order to create the texture
  52604. * @param parsedTexture Define the JSON representation
  52605. * @param scene Define the scene the texture should be created in
  52606. * @param rootUrl Define the root url in case we need to load relative dependencies
  52607. * @returns the newly created texture after parsing
  52608. */
  52609. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52610. serialize(): any;
  52611. }
  52612. }
  52613. declare module "babylonjs/Physics/physicsEngine" {
  52614. import { Nullable } from "babylonjs/types";
  52615. import { Vector3 } from "babylonjs/Maths/math.vector";
  52616. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52617. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52618. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52619. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52620. /**
  52621. * Class used to control physics engine
  52622. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52623. */
  52624. export class PhysicsEngine implements IPhysicsEngine {
  52625. private _physicsPlugin;
  52626. /**
  52627. * Global value used to control the smallest number supported by the simulation
  52628. */
  52629. static Epsilon: number;
  52630. private _impostors;
  52631. private _joints;
  52632. /**
  52633. * Gets the gravity vector used by the simulation
  52634. */
  52635. gravity: Vector3;
  52636. /**
  52637. * Factory used to create the default physics plugin.
  52638. * @returns The default physics plugin
  52639. */
  52640. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52641. /**
  52642. * Creates a new Physics Engine
  52643. * @param gravity defines the gravity vector used by the simulation
  52644. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52645. */
  52646. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52647. /**
  52648. * Sets the gravity vector used by the simulation
  52649. * @param gravity defines the gravity vector to use
  52650. */
  52651. setGravity(gravity: Vector3): void;
  52652. /**
  52653. * Set the time step of the physics engine.
  52654. * Default is 1/60.
  52655. * To slow it down, enter 1/600 for example.
  52656. * To speed it up, 1/30
  52657. * @param newTimeStep defines the new timestep to apply to this world.
  52658. */
  52659. setTimeStep(newTimeStep?: number): void;
  52660. /**
  52661. * Get the time step of the physics engine.
  52662. * @returns the current time step
  52663. */
  52664. getTimeStep(): number;
  52665. /**
  52666. * Release all resources
  52667. */
  52668. dispose(): void;
  52669. /**
  52670. * Gets the name of the current physics plugin
  52671. * @returns the name of the plugin
  52672. */
  52673. getPhysicsPluginName(): string;
  52674. /**
  52675. * Adding a new impostor for the impostor tracking.
  52676. * This will be done by the impostor itself.
  52677. * @param impostor the impostor to add
  52678. */
  52679. addImpostor(impostor: PhysicsImpostor): void;
  52680. /**
  52681. * Remove an impostor from the engine.
  52682. * This impostor and its mesh will not longer be updated by the physics engine.
  52683. * @param impostor the impostor to remove
  52684. */
  52685. removeImpostor(impostor: PhysicsImpostor): void;
  52686. /**
  52687. * Add a joint to the physics engine
  52688. * @param mainImpostor defines the main impostor to which the joint is added.
  52689. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52690. * @param joint defines the joint that will connect both impostors.
  52691. */
  52692. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52693. /**
  52694. * Removes a joint from the simulation
  52695. * @param mainImpostor defines the impostor used with the joint
  52696. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52697. * @param joint defines the joint to remove
  52698. */
  52699. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52700. /**
  52701. * Called by the scene. No need to call it.
  52702. * @param delta defines the timespam between frames
  52703. */
  52704. _step(delta: number): void;
  52705. /**
  52706. * Gets the current plugin used to run the simulation
  52707. * @returns current plugin
  52708. */
  52709. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52710. /**
  52711. * Gets the list of physic impostors
  52712. * @returns an array of PhysicsImpostor
  52713. */
  52714. getImpostors(): Array<PhysicsImpostor>;
  52715. /**
  52716. * Gets the impostor for a physics enabled object
  52717. * @param object defines the object impersonated by the impostor
  52718. * @returns the PhysicsImpostor or null if not found
  52719. */
  52720. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52721. /**
  52722. * Gets the impostor for a physics body object
  52723. * @param body defines physics body used by the impostor
  52724. * @returns the PhysicsImpostor or null if not found
  52725. */
  52726. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52727. /**
  52728. * Does a raycast in the physics world
  52729. * @param from when should the ray start?
  52730. * @param to when should the ray end?
  52731. * @returns PhysicsRaycastResult
  52732. */
  52733. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52734. }
  52735. }
  52736. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52737. import { Nullable } from "babylonjs/types";
  52738. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52740. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52741. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52742. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52743. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52744. /** @hidden */
  52745. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52746. private _useDeltaForWorldStep;
  52747. world: any;
  52748. name: string;
  52749. private _physicsMaterials;
  52750. private _fixedTimeStep;
  52751. private _cannonRaycastResult;
  52752. private _raycastResult;
  52753. private _physicsBodysToRemoveAfterStep;
  52754. BJSCANNON: any;
  52755. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52756. setGravity(gravity: Vector3): void;
  52757. setTimeStep(timeStep: number): void;
  52758. getTimeStep(): number;
  52759. executeStep(delta: number): void;
  52760. private _removeMarkedPhysicsBodiesFromWorld;
  52761. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52762. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52763. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52764. private _processChildMeshes;
  52765. removePhysicsBody(impostor: PhysicsImpostor): void;
  52766. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52767. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52768. private _addMaterial;
  52769. private _checkWithEpsilon;
  52770. private _createShape;
  52771. private _createHeightmap;
  52772. private _minus90X;
  52773. private _plus90X;
  52774. private _tmpPosition;
  52775. private _tmpDeltaPosition;
  52776. private _tmpUnityRotation;
  52777. private _updatePhysicsBodyTransformation;
  52778. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52779. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52780. isSupported(): boolean;
  52781. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52782. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52783. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52784. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52785. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52786. getBodyMass(impostor: PhysicsImpostor): number;
  52787. getBodyFriction(impostor: PhysicsImpostor): number;
  52788. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52789. getBodyRestitution(impostor: PhysicsImpostor): number;
  52790. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52791. sleepBody(impostor: PhysicsImpostor): void;
  52792. wakeUpBody(impostor: PhysicsImpostor): void;
  52793. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52794. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52795. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52796. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52797. getRadius(impostor: PhysicsImpostor): number;
  52798. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52799. dispose(): void;
  52800. private _extendNamespace;
  52801. /**
  52802. * Does a raycast in the physics world
  52803. * @param from when should the ray start?
  52804. * @param to when should the ray end?
  52805. * @returns PhysicsRaycastResult
  52806. */
  52807. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52808. }
  52809. }
  52810. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52811. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52812. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52813. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52815. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52816. import { Nullable } from "babylonjs/types";
  52817. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52818. /** @hidden */
  52819. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52820. world: any;
  52821. name: string;
  52822. BJSOIMO: any;
  52823. private _raycastResult;
  52824. constructor(iterations?: number, oimoInjection?: any);
  52825. setGravity(gravity: Vector3): void;
  52826. setTimeStep(timeStep: number): void;
  52827. getTimeStep(): number;
  52828. private _tmpImpostorsArray;
  52829. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52830. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52831. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52832. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52833. private _tmpPositionVector;
  52834. removePhysicsBody(impostor: PhysicsImpostor): void;
  52835. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52836. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52837. isSupported(): boolean;
  52838. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52839. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52840. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52841. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52842. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52843. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52844. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52845. getBodyMass(impostor: PhysicsImpostor): number;
  52846. getBodyFriction(impostor: PhysicsImpostor): number;
  52847. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52848. getBodyRestitution(impostor: PhysicsImpostor): number;
  52849. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52850. sleepBody(impostor: PhysicsImpostor): void;
  52851. wakeUpBody(impostor: PhysicsImpostor): void;
  52852. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52853. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52854. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52855. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52856. getRadius(impostor: PhysicsImpostor): number;
  52857. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52858. dispose(): void;
  52859. /**
  52860. * Does a raycast in the physics world
  52861. * @param from when should the ray start?
  52862. * @param to when should the ray end?
  52863. * @returns PhysicsRaycastResult
  52864. */
  52865. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52866. }
  52867. }
  52868. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52869. import { Nullable } from "babylonjs/types";
  52870. import { Scene } from "babylonjs/scene";
  52871. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52872. import { Color4 } from "babylonjs/Maths/math.color";
  52873. import { Mesh } from "babylonjs/Meshes/mesh";
  52874. /**
  52875. * Class containing static functions to help procedurally build meshes
  52876. */
  52877. export class RibbonBuilder {
  52878. /**
  52879. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52880. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52881. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52882. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52883. * * 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
  52884. * * 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
  52885. * * 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
  52886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52888. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52889. * * 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
  52890. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52891. * * 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
  52892. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52894. * @param name defines the name of the mesh
  52895. * @param options defines the options used to create the mesh
  52896. * @param scene defines the hosting scene
  52897. * @returns the ribbon mesh
  52898. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52899. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52900. */
  52901. static CreateRibbon(name: string, options: {
  52902. pathArray: Vector3[][];
  52903. closeArray?: boolean;
  52904. closePath?: boolean;
  52905. offset?: number;
  52906. updatable?: boolean;
  52907. sideOrientation?: number;
  52908. frontUVs?: Vector4;
  52909. backUVs?: Vector4;
  52910. instance?: Mesh;
  52911. invertUV?: boolean;
  52912. uvs?: Vector2[];
  52913. colors?: Color4[];
  52914. }, scene?: Nullable<Scene>): Mesh;
  52915. }
  52916. }
  52917. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52918. import { Nullable } from "babylonjs/types";
  52919. import { Scene } from "babylonjs/scene";
  52920. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52921. import { Mesh } from "babylonjs/Meshes/mesh";
  52922. /**
  52923. * Class containing static functions to help procedurally build meshes
  52924. */
  52925. export class ShapeBuilder {
  52926. /**
  52927. * 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.
  52928. * * 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.
  52929. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52930. * * 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.
  52931. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52932. * * 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
  52933. * * 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
  52934. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52937. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52939. * @param name defines the name of the mesh
  52940. * @param options defines the options used to create the mesh
  52941. * @param scene defines the hosting scene
  52942. * @returns the extruded shape mesh
  52943. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52945. */
  52946. static ExtrudeShape(name: string, options: {
  52947. shape: Vector3[];
  52948. path: Vector3[];
  52949. scale?: number;
  52950. rotation?: number;
  52951. cap?: number;
  52952. updatable?: boolean;
  52953. sideOrientation?: number;
  52954. frontUVs?: Vector4;
  52955. backUVs?: Vector4;
  52956. instance?: Mesh;
  52957. invertUV?: boolean;
  52958. }, scene?: Nullable<Scene>): Mesh;
  52959. /**
  52960. * Creates an custom extruded shape mesh.
  52961. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52962. * * 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.
  52963. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52964. * * 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
  52965. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52966. * * 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
  52967. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52968. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52969. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52970. * * 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
  52971. * * 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
  52972. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52975. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52977. * @param name defines the name of the mesh
  52978. * @param options defines the options used to create the mesh
  52979. * @param scene defines the hosting scene
  52980. * @returns the custom extruded shape mesh
  52981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52982. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52983. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52984. */
  52985. static ExtrudeShapeCustom(name: string, options: {
  52986. shape: Vector3[];
  52987. path: Vector3[];
  52988. scaleFunction?: any;
  52989. rotationFunction?: any;
  52990. ribbonCloseArray?: boolean;
  52991. ribbonClosePath?: boolean;
  52992. cap?: number;
  52993. updatable?: boolean;
  52994. sideOrientation?: number;
  52995. frontUVs?: Vector4;
  52996. backUVs?: Vector4;
  52997. instance?: Mesh;
  52998. invertUV?: boolean;
  52999. }, scene?: Nullable<Scene>): Mesh;
  53000. private static _ExtrudeShapeGeneric;
  53001. }
  53002. }
  53003. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53004. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53005. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53006. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53007. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53008. import { Nullable } from "babylonjs/types";
  53009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53010. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53011. /**
  53012. * AmmoJS Physics plugin
  53013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53014. * @see https://github.com/kripken/ammo.js/
  53015. */
  53016. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53017. private _useDeltaForWorldStep;
  53018. /**
  53019. * Reference to the Ammo library
  53020. */
  53021. bjsAMMO: any;
  53022. /**
  53023. * Created ammoJS world which physics bodies are added to
  53024. */
  53025. world: any;
  53026. /**
  53027. * Name of the plugin
  53028. */
  53029. name: string;
  53030. private _timeStep;
  53031. private _fixedTimeStep;
  53032. private _maxSteps;
  53033. private _tmpQuaternion;
  53034. private _tmpAmmoTransform;
  53035. private _tmpAmmoQuaternion;
  53036. private _tmpAmmoConcreteContactResultCallback;
  53037. private _collisionConfiguration;
  53038. private _dispatcher;
  53039. private _overlappingPairCache;
  53040. private _solver;
  53041. private _softBodySolver;
  53042. private _tmpAmmoVectorA;
  53043. private _tmpAmmoVectorB;
  53044. private _tmpAmmoVectorC;
  53045. private _tmpAmmoVectorD;
  53046. private _tmpContactCallbackResult;
  53047. private _tmpAmmoVectorRCA;
  53048. private _tmpAmmoVectorRCB;
  53049. private _raycastResult;
  53050. private static readonly DISABLE_COLLISION_FLAG;
  53051. private static readonly KINEMATIC_FLAG;
  53052. private static readonly DISABLE_DEACTIVATION_FLAG;
  53053. /**
  53054. * Initializes the ammoJS plugin
  53055. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53056. * @param ammoInjection can be used to inject your own ammo reference
  53057. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53058. */
  53059. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53060. /**
  53061. * Sets the gravity of the physics world (m/(s^2))
  53062. * @param gravity Gravity to set
  53063. */
  53064. setGravity(gravity: Vector3): void;
  53065. /**
  53066. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53067. * @param timeStep timestep to use in seconds
  53068. */
  53069. setTimeStep(timeStep: number): void;
  53070. /**
  53071. * 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)
  53072. * @param fixedTimeStep fixedTimeStep to use in seconds
  53073. */
  53074. setFixedTimeStep(fixedTimeStep: number): void;
  53075. /**
  53076. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53077. * @param maxSteps the maximum number of steps by the physics engine per frame
  53078. */
  53079. setMaxSteps(maxSteps: number): void;
  53080. /**
  53081. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53082. * @returns the current timestep in seconds
  53083. */
  53084. getTimeStep(): number;
  53085. private _isImpostorInContact;
  53086. private _isImpostorPairInContact;
  53087. private _stepSimulation;
  53088. /**
  53089. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53090. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53091. * After the step the babylon meshes are set to the position of the physics imposters
  53092. * @param delta amount of time to step forward
  53093. * @param impostors array of imposters to update before/after the step
  53094. */
  53095. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53096. /**
  53097. * Update babylon mesh to match physics world object
  53098. * @param impostor imposter to match
  53099. */
  53100. private _afterSoftStep;
  53101. /**
  53102. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53103. * @param impostor imposter to match
  53104. */
  53105. private _ropeStep;
  53106. /**
  53107. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53108. * @param impostor imposter to match
  53109. */
  53110. private _softbodyOrClothStep;
  53111. private _tmpVector;
  53112. private _tmpMatrix;
  53113. /**
  53114. * Applies an impulse on the imposter
  53115. * @param impostor imposter to apply impulse to
  53116. * @param force amount of force to be applied to the imposter
  53117. * @param contactPoint the location to apply the impulse on the imposter
  53118. */
  53119. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53120. /**
  53121. * Applies a force on the imposter
  53122. * @param impostor imposter to apply force
  53123. * @param force amount of force to be applied to the imposter
  53124. * @param contactPoint the location to apply the force on the imposter
  53125. */
  53126. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53127. /**
  53128. * Creates a physics body using the plugin
  53129. * @param impostor the imposter to create the physics body on
  53130. */
  53131. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53132. /**
  53133. * Removes the physics body from the imposter and disposes of the body's memory
  53134. * @param impostor imposter to remove the physics body from
  53135. */
  53136. removePhysicsBody(impostor: PhysicsImpostor): void;
  53137. /**
  53138. * Generates a joint
  53139. * @param impostorJoint the imposter joint to create the joint with
  53140. */
  53141. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53142. /**
  53143. * Removes a joint
  53144. * @param impostorJoint the imposter joint to remove the joint from
  53145. */
  53146. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53147. private _addMeshVerts;
  53148. /**
  53149. * Initialise the soft body vertices to match its object's (mesh) vertices
  53150. * Softbody vertices (nodes) are in world space and to match this
  53151. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53152. * @param impostor to create the softbody for
  53153. */
  53154. private _softVertexData;
  53155. /**
  53156. * Create an impostor's soft body
  53157. * @param impostor to create the softbody for
  53158. */
  53159. private _createSoftbody;
  53160. /**
  53161. * Create cloth for an impostor
  53162. * @param impostor to create the softbody for
  53163. */
  53164. private _createCloth;
  53165. /**
  53166. * Create rope for an impostor
  53167. * @param impostor to create the softbody for
  53168. */
  53169. private _createRope;
  53170. private _addHullVerts;
  53171. private _createShape;
  53172. /**
  53173. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53174. * @param impostor imposter containing the physics body and babylon object
  53175. */
  53176. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53177. /**
  53178. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53179. * @param impostor imposter containing the physics body and babylon object
  53180. * @param newPosition new position
  53181. * @param newRotation new rotation
  53182. */
  53183. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53184. /**
  53185. * If this plugin is supported
  53186. * @returns true if its supported
  53187. */
  53188. isSupported(): boolean;
  53189. /**
  53190. * Sets the linear velocity of the physics body
  53191. * @param impostor imposter to set the velocity on
  53192. * @param velocity velocity to set
  53193. */
  53194. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53195. /**
  53196. * Sets the angular velocity of the physics body
  53197. * @param impostor imposter to set the velocity on
  53198. * @param velocity velocity to set
  53199. */
  53200. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53201. /**
  53202. * gets the linear velocity
  53203. * @param impostor imposter to get linear velocity from
  53204. * @returns linear velocity
  53205. */
  53206. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53207. /**
  53208. * gets the angular velocity
  53209. * @param impostor imposter to get angular velocity from
  53210. * @returns angular velocity
  53211. */
  53212. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53213. /**
  53214. * Sets the mass of physics body
  53215. * @param impostor imposter to set the mass on
  53216. * @param mass mass to set
  53217. */
  53218. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53219. /**
  53220. * Gets the mass of the physics body
  53221. * @param impostor imposter to get the mass from
  53222. * @returns mass
  53223. */
  53224. getBodyMass(impostor: PhysicsImpostor): number;
  53225. /**
  53226. * Gets friction of the impostor
  53227. * @param impostor impostor to get friction from
  53228. * @returns friction value
  53229. */
  53230. getBodyFriction(impostor: PhysicsImpostor): number;
  53231. /**
  53232. * Sets friction of the impostor
  53233. * @param impostor impostor to set friction on
  53234. * @param friction friction value
  53235. */
  53236. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53237. /**
  53238. * Gets restitution of the impostor
  53239. * @param impostor impostor to get restitution from
  53240. * @returns restitution value
  53241. */
  53242. getBodyRestitution(impostor: PhysicsImpostor): number;
  53243. /**
  53244. * Sets resitution of the impostor
  53245. * @param impostor impostor to set resitution on
  53246. * @param restitution resitution value
  53247. */
  53248. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53249. /**
  53250. * Gets pressure inside the impostor
  53251. * @param impostor impostor to get pressure from
  53252. * @returns pressure value
  53253. */
  53254. getBodyPressure(impostor: PhysicsImpostor): number;
  53255. /**
  53256. * Sets pressure inside a soft body impostor
  53257. * Cloth and rope must remain 0 pressure
  53258. * @param impostor impostor to set pressure on
  53259. * @param pressure pressure value
  53260. */
  53261. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53262. /**
  53263. * Gets stiffness of the impostor
  53264. * @param impostor impostor to get stiffness from
  53265. * @returns pressure value
  53266. */
  53267. getBodyStiffness(impostor: PhysicsImpostor): number;
  53268. /**
  53269. * Sets stiffness of the impostor
  53270. * @param impostor impostor to set stiffness on
  53271. * @param stiffness stiffness value from 0 to 1
  53272. */
  53273. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53274. /**
  53275. * Gets velocityIterations of the impostor
  53276. * @param impostor impostor to get velocity iterations from
  53277. * @returns velocityIterations value
  53278. */
  53279. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53280. /**
  53281. * Sets velocityIterations of the impostor
  53282. * @param impostor impostor to set velocity iterations on
  53283. * @param velocityIterations velocityIterations value
  53284. */
  53285. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53286. /**
  53287. * Gets positionIterations of the impostor
  53288. * @param impostor impostor to get position iterations from
  53289. * @returns positionIterations value
  53290. */
  53291. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53292. /**
  53293. * Sets positionIterations of the impostor
  53294. * @param impostor impostor to set position on
  53295. * @param positionIterations positionIterations value
  53296. */
  53297. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53298. /**
  53299. * Append an anchor to a cloth object
  53300. * @param impostor is the cloth impostor to add anchor to
  53301. * @param otherImpostor is the rigid impostor to anchor to
  53302. * @param width ratio across width from 0 to 1
  53303. * @param height ratio up height from 0 to 1
  53304. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53305. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53306. */
  53307. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53308. /**
  53309. * Append an hook to a rope object
  53310. * @param impostor is the rope impostor to add hook to
  53311. * @param otherImpostor is the rigid impostor to hook to
  53312. * @param length ratio along the rope from 0 to 1
  53313. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53314. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53315. */
  53316. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53317. /**
  53318. * Sleeps the physics body and stops it from being active
  53319. * @param impostor impostor to sleep
  53320. */
  53321. sleepBody(impostor: PhysicsImpostor): void;
  53322. /**
  53323. * Activates the physics body
  53324. * @param impostor impostor to activate
  53325. */
  53326. wakeUpBody(impostor: PhysicsImpostor): void;
  53327. /**
  53328. * Updates the distance parameters of the joint
  53329. * @param joint joint to update
  53330. * @param maxDistance maximum distance of the joint
  53331. * @param minDistance minimum distance of the joint
  53332. */
  53333. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53334. /**
  53335. * Sets a motor on the joint
  53336. * @param joint joint to set motor on
  53337. * @param speed speed of the motor
  53338. * @param maxForce maximum force of the motor
  53339. * @param motorIndex index of the motor
  53340. */
  53341. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53342. /**
  53343. * Sets the motors limit
  53344. * @param joint joint to set limit on
  53345. * @param upperLimit upper limit
  53346. * @param lowerLimit lower limit
  53347. */
  53348. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53349. /**
  53350. * Syncs the position and rotation of a mesh with the impostor
  53351. * @param mesh mesh to sync
  53352. * @param impostor impostor to update the mesh with
  53353. */
  53354. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53355. /**
  53356. * Gets the radius of the impostor
  53357. * @param impostor impostor to get radius from
  53358. * @returns the radius
  53359. */
  53360. getRadius(impostor: PhysicsImpostor): number;
  53361. /**
  53362. * Gets the box size of the impostor
  53363. * @param impostor impostor to get box size from
  53364. * @param result the resulting box size
  53365. */
  53366. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53367. /**
  53368. * Disposes of the impostor
  53369. */
  53370. dispose(): void;
  53371. /**
  53372. * Does a raycast in the physics world
  53373. * @param from when should the ray start?
  53374. * @param to when should the ray end?
  53375. * @returns PhysicsRaycastResult
  53376. */
  53377. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53378. }
  53379. }
  53380. declare module "babylonjs/Probes/reflectionProbe" {
  53381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53382. import { Vector3 } from "babylonjs/Maths/math.vector";
  53383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53384. import { Nullable } from "babylonjs/types";
  53385. import { Scene } from "babylonjs/scene";
  53386. module "babylonjs/abstractScene" {
  53387. interface AbstractScene {
  53388. /**
  53389. * The list of reflection probes added to the scene
  53390. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53391. */
  53392. reflectionProbes: Array<ReflectionProbe>;
  53393. /**
  53394. * Removes the given reflection probe from this scene.
  53395. * @param toRemove The reflection probe to remove
  53396. * @returns The index of the removed reflection probe
  53397. */
  53398. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53399. /**
  53400. * Adds the given reflection probe to this scene.
  53401. * @param newReflectionProbe The reflection probe to add
  53402. */
  53403. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53404. }
  53405. }
  53406. /**
  53407. * Class used to generate realtime reflection / refraction cube textures
  53408. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53409. */
  53410. export class ReflectionProbe {
  53411. /** defines the name of the probe */
  53412. name: string;
  53413. private _scene;
  53414. private _renderTargetTexture;
  53415. private _projectionMatrix;
  53416. private _viewMatrix;
  53417. private _target;
  53418. private _add;
  53419. private _attachedMesh;
  53420. private _invertYAxis;
  53421. /** Gets or sets probe position (center of the cube map) */
  53422. position: Vector3;
  53423. /**
  53424. * Creates a new reflection probe
  53425. * @param name defines the name of the probe
  53426. * @param size defines the texture resolution (for each face)
  53427. * @param scene defines the hosting scene
  53428. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53429. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53430. */
  53431. constructor(
  53432. /** defines the name of the probe */
  53433. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53434. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53435. samples: number;
  53436. /** Gets or sets the refresh rate to use (on every frame by default) */
  53437. refreshRate: number;
  53438. /**
  53439. * Gets the hosting scene
  53440. * @returns a Scene
  53441. */
  53442. getScene(): Scene;
  53443. /** Gets the internal CubeTexture used to render to */
  53444. readonly cubeTexture: RenderTargetTexture;
  53445. /** Gets the list of meshes to render */
  53446. readonly renderList: Nullable<AbstractMesh[]>;
  53447. /**
  53448. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53449. * @param mesh defines the mesh to attach to
  53450. */
  53451. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53452. /**
  53453. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53454. * @param renderingGroupId The rendering group id corresponding to its index
  53455. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53456. */
  53457. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53458. /**
  53459. * Clean all associated resources
  53460. */
  53461. dispose(): void;
  53462. /**
  53463. * Converts the reflection probe information to a readable string for debug purpose.
  53464. * @param fullDetails Supports for multiple levels of logging within scene loading
  53465. * @returns the human readable reflection probe info
  53466. */
  53467. toString(fullDetails?: boolean): string;
  53468. /**
  53469. * Get the class name of the relfection probe.
  53470. * @returns "ReflectionProbe"
  53471. */
  53472. getClassName(): string;
  53473. /**
  53474. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53475. * @returns The JSON representation of the texture
  53476. */
  53477. serialize(): any;
  53478. /**
  53479. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53480. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53481. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53482. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53483. * @returns The parsed reflection probe if successful
  53484. */
  53485. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53486. }
  53487. }
  53488. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53489. /** @hidden */
  53490. export var _BabylonLoaderRegistered: boolean;
  53491. }
  53492. declare module "babylonjs/Loading/Plugins/index" {
  53493. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53494. }
  53495. declare module "babylonjs/Loading/index" {
  53496. export * from "babylonjs/Loading/loadingScreen";
  53497. export * from "babylonjs/Loading/Plugins/index";
  53498. export * from "babylonjs/Loading/sceneLoader";
  53499. export * from "babylonjs/Loading/sceneLoaderFlags";
  53500. }
  53501. declare module "babylonjs/Materials/Background/index" {
  53502. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53503. }
  53504. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53505. import { Scene } from "babylonjs/scene";
  53506. import { Color3 } from "babylonjs/Maths/math.color";
  53507. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53508. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53509. /**
  53510. * The Physically based simple base material of BJS.
  53511. *
  53512. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53513. * It is used as the base class for both the specGloss and metalRough conventions.
  53514. */
  53515. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53516. /**
  53517. * Number of Simultaneous lights allowed on the material.
  53518. */
  53519. maxSimultaneousLights: number;
  53520. /**
  53521. * If sets to true, disables all the lights affecting the material.
  53522. */
  53523. disableLighting: boolean;
  53524. /**
  53525. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53526. */
  53527. environmentTexture: BaseTexture;
  53528. /**
  53529. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53530. */
  53531. invertNormalMapX: boolean;
  53532. /**
  53533. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53534. */
  53535. invertNormalMapY: boolean;
  53536. /**
  53537. * Normal map used in the model.
  53538. */
  53539. normalTexture: BaseTexture;
  53540. /**
  53541. * Emissivie color used to self-illuminate the model.
  53542. */
  53543. emissiveColor: Color3;
  53544. /**
  53545. * Emissivie texture used to self-illuminate the model.
  53546. */
  53547. emissiveTexture: BaseTexture;
  53548. /**
  53549. * Occlusion Channel Strenght.
  53550. */
  53551. occlusionStrength: number;
  53552. /**
  53553. * Occlusion Texture of the material (adding extra occlusion effects).
  53554. */
  53555. occlusionTexture: BaseTexture;
  53556. /**
  53557. * Defines the alpha limits in alpha test mode.
  53558. */
  53559. alphaCutOff: number;
  53560. /**
  53561. * Gets the current double sided mode.
  53562. */
  53563. /**
  53564. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53565. */
  53566. doubleSided: boolean;
  53567. /**
  53568. * Stores the pre-calculated light information of a mesh in a texture.
  53569. */
  53570. lightmapTexture: BaseTexture;
  53571. /**
  53572. * If true, the light map contains occlusion information instead of lighting info.
  53573. */
  53574. useLightmapAsShadowmap: boolean;
  53575. /**
  53576. * Instantiates a new PBRMaterial instance.
  53577. *
  53578. * @param name The material name
  53579. * @param scene The scene the material will be use in.
  53580. */
  53581. constructor(name: string, scene: Scene);
  53582. getClassName(): string;
  53583. }
  53584. }
  53585. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53586. import { Scene } from "babylonjs/scene";
  53587. import { Color3 } from "babylonjs/Maths/math.color";
  53588. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53589. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53590. /**
  53591. * The PBR material of BJS following the metal roughness convention.
  53592. *
  53593. * This fits to the PBR convention in the GLTF definition:
  53594. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53595. */
  53596. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53597. /**
  53598. * The base color has two different interpretations depending on the value of metalness.
  53599. * When the material is a metal, the base color is the specific measured reflectance value
  53600. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53601. * of the material.
  53602. */
  53603. baseColor: Color3;
  53604. /**
  53605. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53606. * well as opacity information in the alpha channel.
  53607. */
  53608. baseTexture: BaseTexture;
  53609. /**
  53610. * Specifies the metallic scalar value of the material.
  53611. * Can also be used to scale the metalness values of the metallic texture.
  53612. */
  53613. metallic: number;
  53614. /**
  53615. * Specifies the roughness scalar value of the material.
  53616. * Can also be used to scale the roughness values of the metallic texture.
  53617. */
  53618. roughness: number;
  53619. /**
  53620. * Texture containing both the metallic value in the B channel and the
  53621. * roughness value in the G channel to keep better precision.
  53622. */
  53623. metallicRoughnessTexture: BaseTexture;
  53624. /**
  53625. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53626. *
  53627. * @param name The material name
  53628. * @param scene The scene the material will be use in.
  53629. */
  53630. constructor(name: string, scene: Scene);
  53631. /**
  53632. * Return the currrent class name of the material.
  53633. */
  53634. getClassName(): string;
  53635. /**
  53636. * Makes a duplicate of the current material.
  53637. * @param name - name to use for the new material.
  53638. */
  53639. clone(name: string): PBRMetallicRoughnessMaterial;
  53640. /**
  53641. * Serialize the material to a parsable JSON object.
  53642. */
  53643. serialize(): any;
  53644. /**
  53645. * Parses a JSON object correponding to the serialize function.
  53646. */
  53647. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53648. }
  53649. }
  53650. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53651. import { Scene } from "babylonjs/scene";
  53652. import { Color3 } from "babylonjs/Maths/math.color";
  53653. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53654. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53655. /**
  53656. * The PBR material of BJS following the specular glossiness convention.
  53657. *
  53658. * This fits to the PBR convention in the GLTF definition:
  53659. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53660. */
  53661. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53662. /**
  53663. * Specifies the diffuse color of the material.
  53664. */
  53665. diffuseColor: Color3;
  53666. /**
  53667. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53668. * channel.
  53669. */
  53670. diffuseTexture: BaseTexture;
  53671. /**
  53672. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53673. */
  53674. specularColor: Color3;
  53675. /**
  53676. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53677. */
  53678. glossiness: number;
  53679. /**
  53680. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53681. */
  53682. specularGlossinessTexture: BaseTexture;
  53683. /**
  53684. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53685. *
  53686. * @param name The material name
  53687. * @param scene The scene the material will be use in.
  53688. */
  53689. constructor(name: string, scene: Scene);
  53690. /**
  53691. * Return the currrent class name of the material.
  53692. */
  53693. getClassName(): string;
  53694. /**
  53695. * Makes a duplicate of the current material.
  53696. * @param name - name to use for the new material.
  53697. */
  53698. clone(name: string): PBRSpecularGlossinessMaterial;
  53699. /**
  53700. * Serialize the material to a parsable JSON object.
  53701. */
  53702. serialize(): any;
  53703. /**
  53704. * Parses a JSON object correponding to the serialize function.
  53705. */
  53706. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53707. }
  53708. }
  53709. declare module "babylonjs/Materials/PBR/index" {
  53710. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53711. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53712. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53713. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53714. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53715. }
  53716. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53717. import { Nullable } from "babylonjs/types";
  53718. import { Scene } from "babylonjs/scene";
  53719. import { Matrix } from "babylonjs/Maths/math.vector";
  53720. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53721. /**
  53722. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53723. * It can help converting any input color in a desired output one. This can then be used to create effects
  53724. * from sepia, black and white to sixties or futuristic rendering...
  53725. *
  53726. * The only supported format is currently 3dl.
  53727. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53728. */
  53729. export class ColorGradingTexture extends BaseTexture {
  53730. /**
  53731. * The current texture matrix. (will always be identity in color grading texture)
  53732. */
  53733. private _textureMatrix;
  53734. /**
  53735. * The texture URL.
  53736. */
  53737. url: string;
  53738. /**
  53739. * Empty line regex stored for GC.
  53740. */
  53741. private static _noneEmptyLineRegex;
  53742. private _engine;
  53743. /**
  53744. * Instantiates a ColorGradingTexture from the following parameters.
  53745. *
  53746. * @param url The location of the color gradind data (currently only supporting 3dl)
  53747. * @param scene The scene the texture will be used in
  53748. */
  53749. constructor(url: string, scene: Scene);
  53750. /**
  53751. * Returns the texture matrix used in most of the material.
  53752. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53753. */
  53754. getTextureMatrix(): Matrix;
  53755. /**
  53756. * Occurs when the file being loaded is a .3dl LUT file.
  53757. */
  53758. private load3dlTexture;
  53759. /**
  53760. * Starts the loading process of the texture.
  53761. */
  53762. private loadTexture;
  53763. /**
  53764. * Clones the color gradind texture.
  53765. */
  53766. clone(): ColorGradingTexture;
  53767. /**
  53768. * Called during delayed load for textures.
  53769. */
  53770. delayLoad(): void;
  53771. /**
  53772. * Parses a color grading texture serialized by Babylon.
  53773. * @param parsedTexture The texture information being parsedTexture
  53774. * @param scene The scene to load the texture in
  53775. * @param rootUrl The root url of the data assets to load
  53776. * @return A color gradind texture
  53777. */
  53778. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53779. /**
  53780. * Serializes the LUT texture to json format.
  53781. */
  53782. serialize(): any;
  53783. }
  53784. }
  53785. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53786. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53787. import { Scene } from "babylonjs/scene";
  53788. import { Nullable } from "babylonjs/types";
  53789. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53790. /**
  53791. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53792. */
  53793. export class EquiRectangularCubeTexture extends BaseTexture {
  53794. /** The six faces of the cube. */
  53795. private static _FacesMapping;
  53796. private _noMipmap;
  53797. private _onLoad;
  53798. private _onError;
  53799. /** The size of the cubemap. */
  53800. private _size;
  53801. /** The buffer of the image. */
  53802. private _buffer;
  53803. /** The width of the input image. */
  53804. private _width;
  53805. /** The height of the input image. */
  53806. private _height;
  53807. /** The URL to the image. */
  53808. url: string;
  53809. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53810. coordinatesMode: number;
  53811. /**
  53812. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53813. * @param url The location of the image
  53814. * @param scene The scene the texture will be used in
  53815. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53816. * @param noMipmap Forces to not generate the mipmap if true
  53817. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53818. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53819. * @param onLoad — defines a callback called when texture is loaded
  53820. * @param onError — defines a callback called if there is an error
  53821. */
  53822. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53823. /**
  53824. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53825. */
  53826. private loadImage;
  53827. /**
  53828. * Convert the image buffer into a cubemap and create a CubeTexture.
  53829. */
  53830. private loadTexture;
  53831. /**
  53832. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53833. * @param buffer The ArrayBuffer that should be converted.
  53834. * @returns The buffer as Float32Array.
  53835. */
  53836. private getFloat32ArrayFromArrayBuffer;
  53837. /**
  53838. * Get the current class name of the texture useful for serialization or dynamic coding.
  53839. * @returns "EquiRectangularCubeTexture"
  53840. */
  53841. getClassName(): string;
  53842. /**
  53843. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53844. * @returns A clone of the current EquiRectangularCubeTexture.
  53845. */
  53846. clone(): EquiRectangularCubeTexture;
  53847. }
  53848. }
  53849. declare module "babylonjs/Misc/tga" {
  53850. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53851. /**
  53852. * Based on jsTGALoader - Javascript loader for TGA file
  53853. * By Vincent Thibault
  53854. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53855. */
  53856. export class TGATools {
  53857. private static _TYPE_INDEXED;
  53858. private static _TYPE_RGB;
  53859. private static _TYPE_GREY;
  53860. private static _TYPE_RLE_INDEXED;
  53861. private static _TYPE_RLE_RGB;
  53862. private static _TYPE_RLE_GREY;
  53863. private static _ORIGIN_MASK;
  53864. private static _ORIGIN_SHIFT;
  53865. private static _ORIGIN_BL;
  53866. private static _ORIGIN_BR;
  53867. private static _ORIGIN_UL;
  53868. private static _ORIGIN_UR;
  53869. /**
  53870. * Gets the header of a TGA file
  53871. * @param data defines the TGA data
  53872. * @returns the header
  53873. */
  53874. static GetTGAHeader(data: Uint8Array): any;
  53875. /**
  53876. * Uploads TGA content to a Babylon Texture
  53877. * @hidden
  53878. */
  53879. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53880. /** @hidden */
  53881. 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;
  53882. /** @hidden */
  53883. 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;
  53884. /** @hidden */
  53885. 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;
  53886. /** @hidden */
  53887. 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;
  53888. /** @hidden */
  53889. 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;
  53890. /** @hidden */
  53891. 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;
  53892. }
  53893. }
  53894. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53895. import { Nullable } from "babylonjs/types";
  53896. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53897. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53898. /**
  53899. * Implementation of the TGA Texture Loader.
  53900. * @hidden
  53901. */
  53902. export class _TGATextureLoader implements IInternalTextureLoader {
  53903. /**
  53904. * Defines wether the loader supports cascade loading the different faces.
  53905. */
  53906. readonly supportCascades: boolean;
  53907. /**
  53908. * This returns if the loader support the current file information.
  53909. * @param extension defines the file extension of the file being loaded
  53910. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53911. * @param fallback defines the fallback internal texture if any
  53912. * @param isBase64 defines whether the texture is encoded as a base64
  53913. * @param isBuffer defines whether the texture data are stored as a buffer
  53914. * @returns true if the loader can load the specified file
  53915. */
  53916. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53917. /**
  53918. * Transform the url before loading if required.
  53919. * @param rootUrl the url of the texture
  53920. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53921. * @returns the transformed texture
  53922. */
  53923. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53924. /**
  53925. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53926. * @param rootUrl the url of the texture
  53927. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53928. * @returns the fallback texture
  53929. */
  53930. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53931. /**
  53932. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53933. * @param data contains the texture data
  53934. * @param texture defines the BabylonJS internal texture
  53935. * @param createPolynomials will be true if polynomials have been requested
  53936. * @param onLoad defines the callback to trigger once the texture is ready
  53937. * @param onError defines the callback to trigger in case of error
  53938. */
  53939. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53940. /**
  53941. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53942. * @param data contains the texture data
  53943. * @param texture defines the BabylonJS internal texture
  53944. * @param callback defines the method to call once ready to upload
  53945. */
  53946. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53947. }
  53948. }
  53949. declare module "babylonjs/Misc/basis" {
  53950. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53951. /**
  53952. * Info about the .basis files
  53953. */
  53954. class BasisFileInfo {
  53955. /**
  53956. * If the file has alpha
  53957. */
  53958. hasAlpha: boolean;
  53959. /**
  53960. * Info about each image of the basis file
  53961. */
  53962. images: Array<{
  53963. levels: Array<{
  53964. width: number;
  53965. height: number;
  53966. transcodedPixels: ArrayBufferView;
  53967. }>;
  53968. }>;
  53969. }
  53970. /**
  53971. * Result of transcoding a basis file
  53972. */
  53973. class TranscodeResult {
  53974. /**
  53975. * Info about the .basis file
  53976. */
  53977. fileInfo: BasisFileInfo;
  53978. /**
  53979. * Format to use when loading the file
  53980. */
  53981. format: number;
  53982. }
  53983. /**
  53984. * Configuration options for the Basis transcoder
  53985. */
  53986. export class BasisTranscodeConfiguration {
  53987. /**
  53988. * Supported compression formats used to determine the supported output format of the transcoder
  53989. */
  53990. supportedCompressionFormats?: {
  53991. /**
  53992. * etc1 compression format
  53993. */
  53994. etc1?: boolean;
  53995. /**
  53996. * s3tc compression format
  53997. */
  53998. s3tc?: boolean;
  53999. /**
  54000. * pvrtc compression format
  54001. */
  54002. pvrtc?: boolean;
  54003. /**
  54004. * etc2 compression format
  54005. */
  54006. etc2?: boolean;
  54007. };
  54008. /**
  54009. * If mipmap levels should be loaded for transcoded images (Default: true)
  54010. */
  54011. loadMipmapLevels?: boolean;
  54012. /**
  54013. * Index of a single image to load (Default: all images)
  54014. */
  54015. loadSingleImage?: number;
  54016. }
  54017. /**
  54018. * Used to load .Basis files
  54019. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54020. */
  54021. export class BasisTools {
  54022. private static _IgnoreSupportedFormats;
  54023. /**
  54024. * URL to use when loading the basis transcoder
  54025. */
  54026. static JSModuleURL: string;
  54027. /**
  54028. * URL to use when loading the wasm module for the transcoder
  54029. */
  54030. static WasmModuleURL: string;
  54031. /**
  54032. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54033. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54034. * @returns internal format corresponding to the Basis format
  54035. */
  54036. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54037. private static _WorkerPromise;
  54038. private static _Worker;
  54039. private static _actionId;
  54040. private static _CreateWorkerAsync;
  54041. /**
  54042. * Transcodes a loaded image file to compressed pixel data
  54043. * @param imageData image data to transcode
  54044. * @param config configuration options for the transcoding
  54045. * @returns a promise resulting in the transcoded image
  54046. */
  54047. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54048. /**
  54049. * Loads a texture from the transcode result
  54050. * @param texture texture load to
  54051. * @param transcodeResult the result of transcoding the basis file to load from
  54052. */
  54053. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54054. }
  54055. }
  54056. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54057. import { Nullable } from "babylonjs/types";
  54058. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54059. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54060. /**
  54061. * Loader for .basis file format
  54062. */
  54063. export class _BasisTextureLoader implements IInternalTextureLoader {
  54064. /**
  54065. * Defines whether the loader supports cascade loading the different faces.
  54066. */
  54067. readonly supportCascades: boolean;
  54068. /**
  54069. * This returns if the loader support the current file information.
  54070. * @param extension defines the file extension of the file being loaded
  54071. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54072. * @param fallback defines the fallback internal texture if any
  54073. * @param isBase64 defines whether the texture is encoded as a base64
  54074. * @param isBuffer defines whether the texture data are stored as a buffer
  54075. * @returns true if the loader can load the specified file
  54076. */
  54077. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54078. /**
  54079. * Transform the url before loading if required.
  54080. * @param rootUrl the url of the texture
  54081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54082. * @returns the transformed texture
  54083. */
  54084. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54085. /**
  54086. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54087. * @param rootUrl the url of the texture
  54088. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54089. * @returns the fallback texture
  54090. */
  54091. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54092. /**
  54093. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54094. * @param data contains the texture data
  54095. * @param texture defines the BabylonJS internal texture
  54096. * @param createPolynomials will be true if polynomials have been requested
  54097. * @param onLoad defines the callback to trigger once the texture is ready
  54098. * @param onError defines the callback to trigger in case of error
  54099. */
  54100. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54101. /**
  54102. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54103. * @param data contains the texture data
  54104. * @param texture defines the BabylonJS internal texture
  54105. * @param callback defines the method to call once ready to upload
  54106. */
  54107. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54108. }
  54109. }
  54110. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54111. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54112. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54113. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54114. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54115. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54116. }
  54117. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54118. import { Scene } from "babylonjs/scene";
  54119. import { Texture } from "babylonjs/Materials/Textures/texture";
  54120. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54121. /**
  54122. * 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.
  54123. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54124. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54125. */
  54126. export class CustomProceduralTexture extends ProceduralTexture {
  54127. private _animate;
  54128. private _time;
  54129. private _config;
  54130. private _texturePath;
  54131. /**
  54132. * Instantiates a new Custom Procedural Texture.
  54133. * 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.
  54134. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54135. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54136. * @param name Define the name of the texture
  54137. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54138. * @param size Define the size of the texture to create
  54139. * @param scene Define the scene the texture belongs to
  54140. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54141. * @param generateMipMaps Define if the texture should creates mip maps or not
  54142. */
  54143. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54144. private _loadJson;
  54145. /**
  54146. * Is the texture ready to be used ? (rendered at least once)
  54147. * @returns true if ready, otherwise, false.
  54148. */
  54149. isReady(): boolean;
  54150. /**
  54151. * Render the texture to its associated render target.
  54152. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54153. */
  54154. render(useCameraPostProcess?: boolean): void;
  54155. /**
  54156. * Update the list of dependant textures samplers in the shader.
  54157. */
  54158. updateTextures(): void;
  54159. /**
  54160. * Update the uniform values of the procedural texture in the shader.
  54161. */
  54162. updateShaderUniforms(): void;
  54163. /**
  54164. * Define if the texture animates or not.
  54165. */
  54166. animate: boolean;
  54167. }
  54168. }
  54169. declare module "babylonjs/Shaders/noise.fragment" {
  54170. /** @hidden */
  54171. export var noisePixelShader: {
  54172. name: string;
  54173. shader: string;
  54174. };
  54175. }
  54176. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54177. import { Nullable } from "babylonjs/types";
  54178. import { Scene } from "babylonjs/scene";
  54179. import { Texture } from "babylonjs/Materials/Textures/texture";
  54180. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54181. import "babylonjs/Shaders/noise.fragment";
  54182. /**
  54183. * Class used to generate noise procedural textures
  54184. */
  54185. export class NoiseProceduralTexture extends ProceduralTexture {
  54186. private _time;
  54187. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54188. brightness: number;
  54189. /** Defines the number of octaves to process */
  54190. octaves: number;
  54191. /** Defines the level of persistence (0.8 by default) */
  54192. persistence: number;
  54193. /** Gets or sets animation speed factor (default is 1) */
  54194. animationSpeedFactor: number;
  54195. /**
  54196. * Creates a new NoiseProceduralTexture
  54197. * @param name defines the name fo the texture
  54198. * @param size defines the size of the texture (default is 256)
  54199. * @param scene defines the hosting scene
  54200. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54201. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54202. */
  54203. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54204. private _updateShaderUniforms;
  54205. protected _getDefines(): string;
  54206. /** Generate the current state of the procedural texture */
  54207. render(useCameraPostProcess?: boolean): void;
  54208. /**
  54209. * Serializes this noise procedural texture
  54210. * @returns a serialized noise procedural texture object
  54211. */
  54212. serialize(): any;
  54213. /**
  54214. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54215. * @param parsedTexture defines parsed texture data
  54216. * @param scene defines the current scene
  54217. * @param rootUrl defines the root URL containing noise procedural texture information
  54218. * @returns a parsed NoiseProceduralTexture
  54219. */
  54220. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54221. }
  54222. }
  54223. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54224. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54225. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54226. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54227. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54228. }
  54229. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54230. import { Nullable } from "babylonjs/types";
  54231. import { Scene } from "babylonjs/scene";
  54232. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54233. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54234. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54235. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54236. /**
  54237. * Raw cube texture where the raw buffers are passed in
  54238. */
  54239. export class RawCubeTexture extends CubeTexture {
  54240. /**
  54241. * Creates a cube texture where the raw buffers are passed in.
  54242. * @param scene defines the scene the texture is attached to
  54243. * @param data defines the array of data to use to create each face
  54244. * @param size defines the size of the textures
  54245. * @param format defines the format of the data
  54246. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54247. * @param generateMipMaps defines if the engine should generate the mip levels
  54248. * @param invertY defines if data must be stored with Y axis inverted
  54249. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54250. * @param compression defines the compression used (null by default)
  54251. */
  54252. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54253. /**
  54254. * Updates the raw cube texture.
  54255. * @param data defines the data to store
  54256. * @param format defines the data format
  54257. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54258. * @param invertY defines if data must be stored with Y axis inverted
  54259. * @param compression defines the compression used (null by default)
  54260. * @param level defines which level of the texture to update
  54261. */
  54262. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54263. /**
  54264. * Updates a raw cube texture with RGBD encoded data.
  54265. * @param data defines the array of data [mipmap][face] to use to create each face
  54266. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54267. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54268. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54269. * @returns a promsie that resolves when the operation is complete
  54270. */
  54271. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54272. /**
  54273. * Clones the raw cube texture.
  54274. * @return a new cube texture
  54275. */
  54276. clone(): CubeTexture;
  54277. /** @hidden */
  54278. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54279. }
  54280. }
  54281. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54282. import { Scene } from "babylonjs/scene";
  54283. import { Texture } from "babylonjs/Materials/Textures/texture";
  54284. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54285. /**
  54286. * Class used to store 3D textures containing user data
  54287. */
  54288. export class RawTexture3D extends Texture {
  54289. /** Gets or sets the texture format to use */
  54290. format: number;
  54291. private _engine;
  54292. /**
  54293. * Create a new RawTexture3D
  54294. * @param data defines the data of the texture
  54295. * @param width defines the width of the texture
  54296. * @param height defines the height of the texture
  54297. * @param depth defines the depth of the texture
  54298. * @param format defines the texture format to use
  54299. * @param scene defines the hosting scene
  54300. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54301. * @param invertY defines if texture must be stored with Y axis inverted
  54302. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54303. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54304. */
  54305. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54306. /** Gets or sets the texture format to use */
  54307. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54308. /**
  54309. * Update the texture with new data
  54310. * @param data defines the data to store in the texture
  54311. */
  54312. update(data: ArrayBufferView): void;
  54313. }
  54314. }
  54315. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54316. import { Scene } from "babylonjs/scene";
  54317. import { Plane } from "babylonjs/Maths/math.plane";
  54318. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54319. /**
  54320. * Creates a refraction texture used by refraction channel of the standard material.
  54321. * It is like a mirror but to see through a material.
  54322. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54323. */
  54324. export class RefractionTexture extends RenderTargetTexture {
  54325. /**
  54326. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54327. * 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.
  54328. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54329. */
  54330. refractionPlane: Plane;
  54331. /**
  54332. * Define how deep under the surface we should see.
  54333. */
  54334. depth: number;
  54335. /**
  54336. * Creates a refraction texture used by refraction channel of the standard material.
  54337. * It is like a mirror but to see through a material.
  54338. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54339. * @param name Define the texture name
  54340. * @param size Define the size of the underlying texture
  54341. * @param scene Define the scene the refraction belongs to
  54342. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54343. */
  54344. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54345. /**
  54346. * Clone the refraction texture.
  54347. * @returns the cloned texture
  54348. */
  54349. clone(): RefractionTexture;
  54350. /**
  54351. * Serialize the texture to a JSON representation you could use in Parse later on
  54352. * @returns the serialized JSON representation
  54353. */
  54354. serialize(): any;
  54355. }
  54356. }
  54357. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54358. import { Nullable } from "babylonjs/types";
  54359. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54360. import { Matrix } from "babylonjs/Maths/math.vector";
  54361. import { Engine } from "babylonjs/Engines/engine";
  54362. import { Scene } from "babylonjs/scene";
  54363. /**
  54364. * Defines the options related to the creation of an HtmlElementTexture
  54365. */
  54366. export interface IHtmlElementTextureOptions {
  54367. /**
  54368. * Defines wether mip maps should be created or not.
  54369. */
  54370. generateMipMaps?: boolean;
  54371. /**
  54372. * Defines the sampling mode of the texture.
  54373. */
  54374. samplingMode?: number;
  54375. /**
  54376. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54377. */
  54378. engine: Nullable<Engine>;
  54379. /**
  54380. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54381. */
  54382. scene: Nullable<Scene>;
  54383. }
  54384. /**
  54385. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54386. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54387. * is automatically managed.
  54388. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54389. * in your application.
  54390. *
  54391. * As the update is not automatic, you need to call them manually.
  54392. */
  54393. export class HtmlElementTexture extends BaseTexture {
  54394. /**
  54395. * The texture URL.
  54396. */
  54397. element: HTMLVideoElement | HTMLCanvasElement;
  54398. private static readonly DefaultOptions;
  54399. private _textureMatrix;
  54400. private _engine;
  54401. private _isVideo;
  54402. private _generateMipMaps;
  54403. private _samplingMode;
  54404. /**
  54405. * Instantiates a HtmlElementTexture from the following parameters.
  54406. *
  54407. * @param name Defines the name of the texture
  54408. * @param element Defines the video or canvas the texture is filled with
  54409. * @param options Defines the other none mandatory texture creation options
  54410. */
  54411. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54412. private _createInternalTexture;
  54413. /**
  54414. * Returns the texture matrix used in most of the material.
  54415. */
  54416. getTextureMatrix(): Matrix;
  54417. /**
  54418. * Updates the content of the texture.
  54419. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54420. */
  54421. update(invertY?: Nullable<boolean>): void;
  54422. }
  54423. }
  54424. declare module "babylonjs/Materials/Textures/index" {
  54425. export * from "babylonjs/Materials/Textures/baseTexture";
  54426. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54427. export * from "babylonjs/Materials/Textures/cubeTexture";
  54428. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54429. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54430. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54431. export * from "babylonjs/Materials/Textures/internalTexture";
  54432. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54433. export * from "babylonjs/Materials/Textures/Loaders/index";
  54434. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54435. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54436. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54437. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54438. export * from "babylonjs/Materials/Textures/rawTexture";
  54439. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54440. export * from "babylonjs/Materials/Textures/refractionTexture";
  54441. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54442. export * from "babylonjs/Materials/Textures/texture";
  54443. export * from "babylonjs/Materials/Textures/videoTexture";
  54444. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54445. }
  54446. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54447. /**
  54448. * Enum used to define the target of a block
  54449. */
  54450. export enum NodeMaterialBlockTargets {
  54451. /** Vertex shader */
  54452. Vertex = 1,
  54453. /** Fragment shader */
  54454. Fragment = 2,
  54455. /** Neutral */
  54456. Neutral = 4,
  54457. /** Vertex and Fragment */
  54458. VertexAndFragment = 3
  54459. }
  54460. }
  54461. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  54462. /**
  54463. * Defines the kind of connection point for node based material
  54464. */
  54465. export enum NodeMaterialBlockConnectionPointTypes {
  54466. /** Float */
  54467. Float = 1,
  54468. /** Int */
  54469. Int = 2,
  54470. /** Vector2 */
  54471. Vector2 = 4,
  54472. /** Vector3 */
  54473. Vector3 = 8,
  54474. /** Vector4 */
  54475. Vector4 = 16,
  54476. /** Color3 */
  54477. Color3 = 32,
  54478. /** Color4 */
  54479. Color4 = 64,
  54480. /** Matrix */
  54481. Matrix = 128,
  54482. /** Detect type based on connection */
  54483. AutoDetect = 1024,
  54484. /** Output type that will be defined by input type */
  54485. BasedOnInput = 2048
  54486. }
  54487. }
  54488. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  54489. /**
  54490. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54491. */
  54492. export enum NodeMaterialBlockConnectionPointMode {
  54493. /** Value is an uniform */
  54494. Uniform = 0,
  54495. /** Value is a mesh attribute */
  54496. Attribute = 1,
  54497. /** Value is a varying between vertex and fragment shaders */
  54498. Varying = 2,
  54499. /** Mode is undefined */
  54500. Undefined = 3
  54501. }
  54502. }
  54503. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  54504. /**
  54505. * Enum used to define system values e.g. values automatically provided by the system
  54506. */
  54507. export enum NodeMaterialSystemValues {
  54508. /** World */
  54509. World = 1,
  54510. /** View */
  54511. View = 2,
  54512. /** Projection */
  54513. Projection = 3,
  54514. /** ViewProjection */
  54515. ViewProjection = 4,
  54516. /** WorldView */
  54517. WorldView = 5,
  54518. /** WorldViewProjection */
  54519. WorldViewProjection = 6,
  54520. /** CameraPosition */
  54521. CameraPosition = 7,
  54522. /** Fog Color */
  54523. FogColor = 8
  54524. }
  54525. }
  54526. declare module "babylonjs/Materials/Node/Enums/index" {
  54527. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  54528. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  54529. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  54530. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  54531. }
  54532. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54533. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54534. /**
  54535. * Root class for all node material optimizers
  54536. */
  54537. export class NodeMaterialOptimizer {
  54538. /**
  54539. * Function used to optimize a NodeMaterial graph
  54540. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54541. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54542. */
  54543. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54544. }
  54545. }
  54546. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54547. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54548. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54549. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54550. import { Scene } from "babylonjs/scene";
  54551. /**
  54552. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54553. */
  54554. export class TransformBlock extends NodeMaterialBlock {
  54555. /**
  54556. * Defines the value to use to complement W value to transform it to a Vector4
  54557. */
  54558. complementW: number;
  54559. /**
  54560. * Defines the value to use to complement z value to transform it to a Vector4
  54561. */
  54562. complementZ: number;
  54563. /**
  54564. * Creates a new TransformBlock
  54565. * @param name defines the block name
  54566. */
  54567. constructor(name: string);
  54568. /**
  54569. * Gets the current class name
  54570. * @returns the class name
  54571. */
  54572. getClassName(): string;
  54573. /**
  54574. * Gets the vector input
  54575. */
  54576. readonly vector: NodeMaterialConnectionPoint;
  54577. /**
  54578. * Gets the output component
  54579. */
  54580. readonly output: NodeMaterialConnectionPoint;
  54581. /**
  54582. * Gets the matrix transform input
  54583. */
  54584. readonly transform: NodeMaterialConnectionPoint;
  54585. protected _buildBlock(state: NodeMaterialBuildState): this;
  54586. serialize(): any;
  54587. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54588. protected _dumpPropertiesCode(): string;
  54589. }
  54590. }
  54591. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54592. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54593. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54594. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54595. /**
  54596. * Block used to output the vertex position
  54597. */
  54598. export class VertexOutputBlock extends NodeMaterialBlock {
  54599. /**
  54600. * Creates a new VertexOutputBlock
  54601. * @param name defines the block name
  54602. */
  54603. constructor(name: string);
  54604. /**
  54605. * Gets the current class name
  54606. * @returns the class name
  54607. */
  54608. getClassName(): string;
  54609. /**
  54610. * Gets the vector input component
  54611. */
  54612. readonly vector: NodeMaterialConnectionPoint;
  54613. protected _buildBlock(state: NodeMaterialBuildState): this;
  54614. }
  54615. }
  54616. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54617. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54618. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54619. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54620. /**
  54621. * Block used to output the final color
  54622. */
  54623. export class FragmentOutputBlock extends NodeMaterialBlock {
  54624. /**
  54625. * Create a new FragmentOutputBlock
  54626. * @param name defines the block name
  54627. */
  54628. constructor(name: string);
  54629. /**
  54630. * Gets the current class name
  54631. * @returns the class name
  54632. */
  54633. getClassName(): string;
  54634. /**
  54635. * Gets the rgba input component
  54636. */
  54637. readonly rgba: NodeMaterialConnectionPoint;
  54638. /**
  54639. * Gets the rgb input component
  54640. */
  54641. readonly rgb: NodeMaterialConnectionPoint;
  54642. /**
  54643. * Gets the a input component
  54644. */
  54645. readonly a: NodeMaterialConnectionPoint;
  54646. protected _buildBlock(state: NodeMaterialBuildState): this;
  54647. }
  54648. }
  54649. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54651. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54653. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54655. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54656. import { Effect } from "babylonjs/Materials/effect";
  54657. import { Mesh } from "babylonjs/Meshes/mesh";
  54658. import { Nullable } from "babylonjs/types";
  54659. import { Scene } from "babylonjs/scene";
  54660. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54661. /**
  54662. * Block used to read a reflection texture from a sampler
  54663. */
  54664. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54665. private _define3DName;
  54666. private _defineCubicName;
  54667. private _defineExplicitName;
  54668. private _defineProjectionName;
  54669. private _defineLocalCubicName;
  54670. private _defineSphericalName;
  54671. private _definePlanarName;
  54672. private _defineEquirectangularName;
  54673. private _defineMirroredEquirectangularFixedName;
  54674. private _defineEquirectangularFixedName;
  54675. private _defineSkyboxName;
  54676. private _cubeSamplerName;
  54677. private _2DSamplerName;
  54678. private _positionUVWName;
  54679. private _directionWName;
  54680. private _reflectionCoordsName;
  54681. private _reflection2DCoordsName;
  54682. private _reflectionColorName;
  54683. private _reflectionMatrixName;
  54684. /**
  54685. * Gets or sets the texture associated with the node
  54686. */
  54687. texture: Nullable<BaseTexture>;
  54688. /**
  54689. * Create a new TextureBlock
  54690. * @param name defines the block name
  54691. */
  54692. constructor(name: string);
  54693. /**
  54694. * Gets the current class name
  54695. * @returns the class name
  54696. */
  54697. getClassName(): string;
  54698. /**
  54699. * Gets the world position input component
  54700. */
  54701. readonly position: NodeMaterialConnectionPoint;
  54702. /**
  54703. * Gets the world position input component
  54704. */
  54705. readonly worldPosition: NodeMaterialConnectionPoint;
  54706. /**
  54707. * Gets the world normal input component
  54708. */
  54709. readonly worldNormal: NodeMaterialConnectionPoint;
  54710. /**
  54711. * Gets the world input component
  54712. */
  54713. readonly world: NodeMaterialConnectionPoint;
  54714. /**
  54715. * Gets the camera (or eye) position component
  54716. */
  54717. readonly cameraPosition: NodeMaterialConnectionPoint;
  54718. /**
  54719. * Gets the view input component
  54720. */
  54721. readonly view: NodeMaterialConnectionPoint;
  54722. /**
  54723. * Gets the rgb output component
  54724. */
  54725. readonly rgb: NodeMaterialConnectionPoint;
  54726. /**
  54727. * Gets the r output component
  54728. */
  54729. readonly r: NodeMaterialConnectionPoint;
  54730. /**
  54731. * Gets the g output component
  54732. */
  54733. readonly g: NodeMaterialConnectionPoint;
  54734. /**
  54735. * Gets the b output component
  54736. */
  54737. readonly b: NodeMaterialConnectionPoint;
  54738. autoConfigure(material: NodeMaterial): void;
  54739. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54740. isReady(): boolean;
  54741. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54742. private _injectVertexCode;
  54743. private _writeOutput;
  54744. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54745. serialize(): any;
  54746. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54747. }
  54748. }
  54749. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54750. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54751. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54752. import { Scene } from "babylonjs/scene";
  54753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54754. import { Matrix } from "babylonjs/Maths/math.vector";
  54755. import { Mesh } from "babylonjs/Meshes/mesh";
  54756. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54757. import { Observable } from "babylonjs/Misc/observable";
  54758. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54759. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54760. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54761. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54762. import { Nullable } from "babylonjs/types";
  54763. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54764. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54765. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54766. /**
  54767. * Interface used to configure the node material editor
  54768. */
  54769. export interface INodeMaterialEditorOptions {
  54770. /** Define the URl to load node editor script */
  54771. editorURL?: string;
  54772. }
  54773. /** @hidden */
  54774. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54775. /** BONES */
  54776. NUM_BONE_INFLUENCERS: number;
  54777. BonesPerMesh: number;
  54778. BONETEXTURE: boolean;
  54779. /** MORPH TARGETS */
  54780. MORPHTARGETS: boolean;
  54781. MORPHTARGETS_NORMAL: boolean;
  54782. MORPHTARGETS_TANGENT: boolean;
  54783. MORPHTARGETS_UV: boolean;
  54784. NUM_MORPH_INFLUENCERS: number;
  54785. /** IMAGE PROCESSING */
  54786. IMAGEPROCESSING: boolean;
  54787. VIGNETTE: boolean;
  54788. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54789. VIGNETTEBLENDMODEOPAQUE: boolean;
  54790. TONEMAPPING: boolean;
  54791. TONEMAPPING_ACES: boolean;
  54792. CONTRAST: boolean;
  54793. EXPOSURE: boolean;
  54794. COLORCURVES: boolean;
  54795. COLORGRADING: boolean;
  54796. COLORGRADING3D: boolean;
  54797. SAMPLER3DGREENDEPTH: boolean;
  54798. SAMPLER3DBGRMAP: boolean;
  54799. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54800. /** MISC. */
  54801. BUMPDIRECTUV: number;
  54802. constructor();
  54803. setValue(name: string, value: boolean): void;
  54804. }
  54805. /**
  54806. * Class used to configure NodeMaterial
  54807. */
  54808. export interface INodeMaterialOptions {
  54809. /**
  54810. * Defines if blocks should emit comments
  54811. */
  54812. emitComments: boolean;
  54813. }
  54814. /**
  54815. * Class used to create a node based material built by assembling shader blocks
  54816. */
  54817. export class NodeMaterial extends PushMaterial {
  54818. private static _BuildIdGenerator;
  54819. private _options;
  54820. private _vertexCompilationState;
  54821. private _fragmentCompilationState;
  54822. private _sharedData;
  54823. private _buildId;
  54824. private _buildWasSuccessful;
  54825. private _cachedWorldViewMatrix;
  54826. private _cachedWorldViewProjectionMatrix;
  54827. private _optimizers;
  54828. private _animationFrame;
  54829. /** Define the URl to load node editor script */
  54830. static EditorURL: string;
  54831. private BJSNODEMATERIALEDITOR;
  54832. /** Get the inspector from bundle or global */
  54833. private _getGlobalNodeMaterialEditor;
  54834. /**
  54835. * 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)
  54836. */
  54837. ignoreAlpha: boolean;
  54838. /**
  54839. * Defines the maximum number of lights that can be used in the material
  54840. */
  54841. maxSimultaneousLights: number;
  54842. /**
  54843. * Observable raised when the material is built
  54844. */
  54845. onBuildObservable: Observable<NodeMaterial>;
  54846. /**
  54847. * Gets or sets the root nodes of the material vertex shader
  54848. */
  54849. _vertexOutputNodes: NodeMaterialBlock[];
  54850. /**
  54851. * Gets or sets the root nodes of the material fragment (pixel) shader
  54852. */
  54853. _fragmentOutputNodes: NodeMaterialBlock[];
  54854. /** Gets or sets options to control the node material overall behavior */
  54855. options: INodeMaterialOptions;
  54856. /**
  54857. * Default configuration related to image processing available in the standard Material.
  54858. */
  54859. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54860. /**
  54861. * Gets the image processing configuration used either in this material.
  54862. */
  54863. /**
  54864. * Sets the Default image processing configuration used either in the this material.
  54865. *
  54866. * If sets to null, the scene one is in use.
  54867. */
  54868. imageProcessingConfiguration: ImageProcessingConfiguration;
  54869. /**
  54870. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54871. */
  54872. attachedBlocks: NodeMaterialBlock[];
  54873. /**
  54874. * Create a new node based material
  54875. * @param name defines the material name
  54876. * @param scene defines the hosting scene
  54877. * @param options defines creation option
  54878. */
  54879. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54880. /**
  54881. * Gets the current class name of the material e.g. "NodeMaterial"
  54882. * @returns the class name
  54883. */
  54884. getClassName(): string;
  54885. /**
  54886. * Keep track of the image processing observer to allow dispose and replace.
  54887. */
  54888. private _imageProcessingObserver;
  54889. /**
  54890. * Attaches a new image processing configuration to the Standard Material.
  54891. * @param configuration
  54892. */
  54893. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54894. /**
  54895. * Get a block by its name
  54896. * @param name defines the name of the block to retrieve
  54897. * @returns the required block or null if not found
  54898. */
  54899. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54900. /**
  54901. * Get a block by its name
  54902. * @param predicate defines the predicate used to find the good candidate
  54903. * @returns the required block or null if not found
  54904. */
  54905. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54906. /**
  54907. * Get an input block by its name
  54908. * @param predicate defines the predicate used to find the good candidate
  54909. * @returns the required input block or null if not found
  54910. */
  54911. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54912. /**
  54913. * Gets the list of input blocks attached to this material
  54914. * @returns an array of InputBlocks
  54915. */
  54916. getInputBlocks(): InputBlock[];
  54917. /**
  54918. * Adds a new optimizer to the list of optimizers
  54919. * @param optimizer defines the optimizers to add
  54920. * @returns the current material
  54921. */
  54922. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54923. /**
  54924. * Remove an optimizer from the list of optimizers
  54925. * @param optimizer defines the optimizers to remove
  54926. * @returns the current material
  54927. */
  54928. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54929. /**
  54930. * Add a new block to the list of output nodes
  54931. * @param node defines the node to add
  54932. * @returns the current material
  54933. */
  54934. addOutputNode(node: NodeMaterialBlock): this;
  54935. /**
  54936. * Remove a block from the list of root nodes
  54937. * @param node defines the node to remove
  54938. * @returns the current material
  54939. */
  54940. removeOutputNode(node: NodeMaterialBlock): this;
  54941. private _addVertexOutputNode;
  54942. private _removeVertexOutputNode;
  54943. private _addFragmentOutputNode;
  54944. private _removeFragmentOutputNode;
  54945. /**
  54946. * Specifies if the material will require alpha blending
  54947. * @returns a boolean specifying if alpha blending is needed
  54948. */
  54949. needAlphaBlending(): boolean;
  54950. /**
  54951. * Specifies if this material should be rendered in alpha test mode
  54952. * @returns a boolean specifying if an alpha test is needed.
  54953. */
  54954. needAlphaTesting(): boolean;
  54955. private _initializeBlock;
  54956. private _resetDualBlocks;
  54957. /**
  54958. * Build the material and generates the inner effect
  54959. * @param verbose defines if the build should log activity
  54960. */
  54961. build(verbose?: boolean): void;
  54962. /**
  54963. * Runs an otpimization phase to try to improve the shader code
  54964. */
  54965. optimize(): void;
  54966. private _prepareDefinesForAttributes;
  54967. /**
  54968. * Get if the submesh is ready to be used and all its information available.
  54969. * Child classes can use it to update shaders
  54970. * @param mesh defines the mesh to check
  54971. * @param subMesh defines which submesh to check
  54972. * @param useInstances specifies that instances should be used
  54973. * @returns a boolean indicating that the submesh is ready or not
  54974. */
  54975. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54976. /**
  54977. * Get a string representing the shaders built by the current node graph
  54978. */
  54979. readonly compiledShaders: string;
  54980. /**
  54981. * Binds the world matrix to the material
  54982. * @param world defines the world transformation matrix
  54983. */
  54984. bindOnlyWorldMatrix(world: Matrix): void;
  54985. /**
  54986. * Binds the submesh to this material by preparing the effect and shader to draw
  54987. * @param world defines the world transformation matrix
  54988. * @param mesh defines the mesh containing the submesh
  54989. * @param subMesh defines the submesh to bind the material to
  54990. */
  54991. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54992. /**
  54993. * Gets the active textures from the material
  54994. * @returns an array of textures
  54995. */
  54996. getActiveTextures(): BaseTexture[];
  54997. /**
  54998. * Gets the list of texture blocks
  54999. * @returns an array of texture blocks
  55000. */
  55001. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55002. /**
  55003. * Specifies if the material uses a texture
  55004. * @param texture defines the texture to check against the material
  55005. * @returns a boolean specifying if the material uses the texture
  55006. */
  55007. hasTexture(texture: BaseTexture): boolean;
  55008. /**
  55009. * Disposes the material
  55010. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55011. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55012. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55013. */
  55014. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55015. /** Creates the node editor window. */
  55016. private _createNodeEditor;
  55017. /**
  55018. * Launch the node material editor
  55019. * @param config Define the configuration of the editor
  55020. * @return a promise fulfilled when the node editor is visible
  55021. */
  55022. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55023. /**
  55024. * Clear the current material
  55025. */
  55026. clear(): void;
  55027. /**
  55028. * Clear the current material and set it to a default state
  55029. */
  55030. setToDefault(): void;
  55031. /**
  55032. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55033. * @param url defines the url to load from
  55034. * @returns a promise that will fullfil when the material is fully loaded
  55035. */
  55036. loadAsync(url: string): Promise<unknown>;
  55037. private _gatherBlocks;
  55038. /**
  55039. * Generate a string containing the code declaration required to create an equivalent of this material
  55040. * @returns a string
  55041. */
  55042. generateCode(): string;
  55043. /**
  55044. * Serializes this material in a JSON representation
  55045. * @returns the serialized material object
  55046. */
  55047. serialize(): any;
  55048. private _restoreConnections;
  55049. /**
  55050. * Clear the current graph and load a new one from a serialization object
  55051. * @param source defines the JSON representation of the material
  55052. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55053. */
  55054. loadFromSerialization(source: any, rootUrl?: string): void;
  55055. /**
  55056. * Creates a node material from parsed material data
  55057. * @param source defines the JSON representation of the material
  55058. * @param scene defines the hosting scene
  55059. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55060. * @returns a new node material
  55061. */
  55062. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55063. /**
  55064. * Creates a new node material set to default basic configuration
  55065. * @param name defines the name of the material
  55066. * @param scene defines the hosting scene
  55067. * @returns a new NodeMaterial
  55068. */
  55069. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55070. }
  55071. }
  55072. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55073. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55074. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55075. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55078. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55079. import { Effect } from "babylonjs/Materials/effect";
  55080. import { Mesh } from "babylonjs/Meshes/mesh";
  55081. import { Nullable } from "babylonjs/types";
  55082. import { Texture } from "babylonjs/Materials/Textures/texture";
  55083. import { Scene } from "babylonjs/scene";
  55084. /**
  55085. * Block used to read a texture from a sampler
  55086. */
  55087. export class TextureBlock extends NodeMaterialBlock {
  55088. private _defineName;
  55089. private _samplerName;
  55090. private _transformedUVName;
  55091. private _textureTransformName;
  55092. private _textureInfoName;
  55093. private _mainUVName;
  55094. private _mainUVDefineName;
  55095. /**
  55096. * Gets or sets the texture associated with the node
  55097. */
  55098. texture: Nullable<Texture>;
  55099. /**
  55100. * Create a new TextureBlock
  55101. * @param name defines the block name
  55102. */
  55103. constructor(name: string);
  55104. /**
  55105. * Gets the current class name
  55106. * @returns the class name
  55107. */
  55108. getClassName(): string;
  55109. /**
  55110. * Gets the uv input component
  55111. */
  55112. readonly uv: NodeMaterialConnectionPoint;
  55113. /**
  55114. * Gets the rgba output component
  55115. */
  55116. readonly rgba: NodeMaterialConnectionPoint;
  55117. /**
  55118. * Gets the rgb output component
  55119. */
  55120. readonly rgb: NodeMaterialConnectionPoint;
  55121. /**
  55122. * Gets the r output component
  55123. */
  55124. readonly r: NodeMaterialConnectionPoint;
  55125. /**
  55126. * Gets the g output component
  55127. */
  55128. readonly g: NodeMaterialConnectionPoint;
  55129. /**
  55130. * Gets the b output component
  55131. */
  55132. readonly b: NodeMaterialConnectionPoint;
  55133. /**
  55134. * Gets the a output component
  55135. */
  55136. readonly a: NodeMaterialConnectionPoint;
  55137. readonly target: NodeMaterialBlockTargets;
  55138. autoConfigure(material: NodeMaterial): void;
  55139. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55140. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55141. isReady(): boolean;
  55142. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55143. private readonly _isMixed;
  55144. private _injectVertexCode;
  55145. private _writeOutput;
  55146. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55147. protected _dumpPropertiesCode(): string;
  55148. serialize(): any;
  55149. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55150. }
  55151. }
  55152. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55153. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55154. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55155. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55156. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55157. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55158. import { Scene } from "babylonjs/scene";
  55159. /**
  55160. * Class used to store shared data between 2 NodeMaterialBuildState
  55161. */
  55162. export class NodeMaterialBuildStateSharedData {
  55163. /**
  55164. * Gets the list of emitted varyings
  55165. */
  55166. temps: string[];
  55167. /**
  55168. * Gets the list of emitted varyings
  55169. */
  55170. varyings: string[];
  55171. /**
  55172. * Gets the varying declaration string
  55173. */
  55174. varyingDeclaration: string;
  55175. /**
  55176. * Input blocks
  55177. */
  55178. inputBlocks: InputBlock[];
  55179. /**
  55180. * Input blocks
  55181. */
  55182. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55183. /**
  55184. * Bindable blocks (Blocks that need to set data to the effect)
  55185. */
  55186. bindableBlocks: NodeMaterialBlock[];
  55187. /**
  55188. * List of blocks that can provide a compilation fallback
  55189. */
  55190. blocksWithFallbacks: NodeMaterialBlock[];
  55191. /**
  55192. * List of blocks that can provide a define update
  55193. */
  55194. blocksWithDefines: NodeMaterialBlock[];
  55195. /**
  55196. * List of blocks that can provide a repeatable content
  55197. */
  55198. repeatableContentBlocks: NodeMaterialBlock[];
  55199. /**
  55200. * List of blocks that can provide a dynamic list of uniforms
  55201. */
  55202. dynamicUniformBlocks: NodeMaterialBlock[];
  55203. /**
  55204. * List of blocks that can block the isReady function for the material
  55205. */
  55206. blockingBlocks: NodeMaterialBlock[];
  55207. /**
  55208. * Gets the list of animated inputs
  55209. */
  55210. animatedInputs: InputBlock[];
  55211. /**
  55212. * Build Id used to avoid multiple recompilations
  55213. */
  55214. buildId: number;
  55215. /** List of emitted variables */
  55216. variableNames: {
  55217. [key: string]: number;
  55218. };
  55219. /** List of emitted defines */
  55220. defineNames: {
  55221. [key: string]: number;
  55222. };
  55223. /** Should emit comments? */
  55224. emitComments: boolean;
  55225. /** Emit build activity */
  55226. verbose: boolean;
  55227. /** Gets or sets the hosting scene */
  55228. scene: Scene;
  55229. /**
  55230. * Gets the compilation hints emitted at compilation time
  55231. */
  55232. hints: {
  55233. needWorldViewMatrix: boolean;
  55234. needWorldViewProjectionMatrix: boolean;
  55235. needAlphaBlending: boolean;
  55236. needAlphaTesting: boolean;
  55237. };
  55238. /**
  55239. * List of compilation checks
  55240. */
  55241. checks: {
  55242. emitVertex: boolean;
  55243. emitFragment: boolean;
  55244. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55245. };
  55246. /** Creates a new shared data */
  55247. constructor();
  55248. /**
  55249. * Emits console errors and exceptions if there is a failing check
  55250. */
  55251. emitErrors(): void;
  55252. }
  55253. }
  55254. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55255. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55256. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55257. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55258. /**
  55259. * Class used to store node based material build state
  55260. */
  55261. export class NodeMaterialBuildState {
  55262. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55263. supportUniformBuffers: boolean;
  55264. /**
  55265. * Gets the list of emitted attributes
  55266. */
  55267. attributes: string[];
  55268. /**
  55269. * Gets the list of emitted uniforms
  55270. */
  55271. uniforms: string[];
  55272. /**
  55273. * Gets the list of emitted constants
  55274. */
  55275. constants: string[];
  55276. /**
  55277. * Gets the list of emitted uniform buffers
  55278. */
  55279. uniformBuffers: string[];
  55280. /**
  55281. * Gets the list of emitted samplers
  55282. */
  55283. samplers: string[];
  55284. /**
  55285. * Gets the list of emitted functions
  55286. */
  55287. functions: {
  55288. [key: string]: string;
  55289. };
  55290. /**
  55291. * Gets the list of emitted extensions
  55292. */
  55293. extensions: {
  55294. [key: string]: string;
  55295. };
  55296. /**
  55297. * Gets the target of the compilation state
  55298. */
  55299. target: NodeMaterialBlockTargets;
  55300. /**
  55301. * Gets the list of emitted counters
  55302. */
  55303. counters: {
  55304. [key: string]: number;
  55305. };
  55306. /**
  55307. * Shared data between multiple NodeMaterialBuildState instances
  55308. */
  55309. sharedData: NodeMaterialBuildStateSharedData;
  55310. /** @hidden */
  55311. _vertexState: NodeMaterialBuildState;
  55312. /** @hidden */
  55313. _attributeDeclaration: string;
  55314. /** @hidden */
  55315. _uniformDeclaration: string;
  55316. /** @hidden */
  55317. _constantDeclaration: string;
  55318. /** @hidden */
  55319. _samplerDeclaration: string;
  55320. /** @hidden */
  55321. _varyingTransfer: string;
  55322. private _repeatableContentAnchorIndex;
  55323. /** @hidden */
  55324. _builtCompilationString: string;
  55325. /**
  55326. * Gets the emitted compilation strings
  55327. */
  55328. compilationString: string;
  55329. /**
  55330. * Finalize the compilation strings
  55331. * @param state defines the current compilation state
  55332. */
  55333. finalize(state: NodeMaterialBuildState): void;
  55334. /** @hidden */
  55335. readonly _repeatableContentAnchor: string;
  55336. /** @hidden */
  55337. _getFreeVariableName(prefix: string): string;
  55338. /** @hidden */
  55339. _getFreeDefineName(prefix: string): string;
  55340. /** @hidden */
  55341. _excludeVariableName(name: string): void;
  55342. /** @hidden */
  55343. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55344. /** @hidden */
  55345. _emitExtension(name: string, extension: string): void;
  55346. /** @hidden */
  55347. _emitFunction(name: string, code: string, comments: string): void;
  55348. /** @hidden */
  55349. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55350. replaceStrings?: {
  55351. search: RegExp;
  55352. replace: string;
  55353. }[];
  55354. repeatKey?: string;
  55355. }): string;
  55356. /** @hidden */
  55357. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55358. repeatKey?: string;
  55359. removeAttributes?: boolean;
  55360. removeUniforms?: boolean;
  55361. removeVaryings?: boolean;
  55362. removeIfDef?: boolean;
  55363. replaceStrings?: {
  55364. search: RegExp;
  55365. replace: string;
  55366. }[];
  55367. }, storeKey?: string): void;
  55368. /** @hidden */
  55369. _registerTempVariable(name: string): boolean;
  55370. /** @hidden */
  55371. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55372. /** @hidden */
  55373. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55374. }
  55375. }
  55376. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55377. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55378. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55379. import { Nullable } from "babylonjs/types";
  55380. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55381. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55382. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55384. import { Mesh } from "babylonjs/Meshes/mesh";
  55385. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55386. import { Scene } from "babylonjs/scene";
  55387. /**
  55388. * Defines a block that can be used inside a node based material
  55389. */
  55390. export class NodeMaterialBlock {
  55391. private _buildId;
  55392. private _buildTarget;
  55393. private _target;
  55394. private _isFinalMerger;
  55395. private _isInput;
  55396. /** @hidden */
  55397. _codeVariableName: string;
  55398. /** @hidden */
  55399. _inputs: NodeMaterialConnectionPoint[];
  55400. /** @hidden */
  55401. _outputs: NodeMaterialConnectionPoint[];
  55402. /** @hidden */
  55403. _preparationId: number;
  55404. /**
  55405. * Gets or sets the name of the block
  55406. */
  55407. name: string;
  55408. /**
  55409. * Gets or sets the unique id of the node
  55410. */
  55411. uniqueId: number;
  55412. /**
  55413. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55414. */
  55415. readonly isFinalMerger: boolean;
  55416. /**
  55417. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55418. */
  55419. readonly isInput: boolean;
  55420. /**
  55421. * Gets or sets the build Id
  55422. */
  55423. buildId: number;
  55424. /**
  55425. * Gets or sets the target of the block
  55426. */
  55427. target: NodeMaterialBlockTargets;
  55428. /**
  55429. * Gets the list of input points
  55430. */
  55431. readonly inputs: NodeMaterialConnectionPoint[];
  55432. /** Gets the list of output points */
  55433. readonly outputs: NodeMaterialConnectionPoint[];
  55434. /**
  55435. * Find an input by its name
  55436. * @param name defines the name of the input to look for
  55437. * @returns the input or null if not found
  55438. */
  55439. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55440. /**
  55441. * Find an output by its name
  55442. * @param name defines the name of the outputto look for
  55443. * @returns the output or null if not found
  55444. */
  55445. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55446. /**
  55447. * Creates a new NodeMaterialBlock
  55448. * @param name defines the block name
  55449. * @param target defines the target of that block (Vertex by default)
  55450. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55451. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55452. */
  55453. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55454. /**
  55455. * Initialize the block and prepare the context for build
  55456. * @param state defines the state that will be used for the build
  55457. */
  55458. initialize(state: NodeMaterialBuildState): void;
  55459. /**
  55460. * Bind data to effect. Will only be called for blocks with isBindable === true
  55461. * @param effect defines the effect to bind data to
  55462. * @param nodeMaterial defines the hosting NodeMaterial
  55463. * @param mesh defines the mesh that will be rendered
  55464. */
  55465. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55466. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55467. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55468. protected _writeFloat(value: number): string;
  55469. /**
  55470. * Gets the current class name e.g. "NodeMaterialBlock"
  55471. * @returns the class name
  55472. */
  55473. getClassName(): string;
  55474. /**
  55475. * Register a new input. Must be called inside a block constructor
  55476. * @param name defines the connection point name
  55477. * @param type defines the connection point type
  55478. * @param isOptional defines a boolean indicating that this input can be omitted
  55479. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55480. * @returns the current block
  55481. */
  55482. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55483. /**
  55484. * Register a new output. Must be called inside a block constructor
  55485. * @param name defines the connection point name
  55486. * @param type defines the connection point type
  55487. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55488. * @returns the current block
  55489. */
  55490. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55491. /**
  55492. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55493. * @param forOutput defines an optional connection point to check compatibility with
  55494. * @returns the first available input or null
  55495. */
  55496. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55497. /**
  55498. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55499. * @param forBlock defines an optional block to check compatibility with
  55500. * @returns the first available input or null
  55501. */
  55502. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55503. /**
  55504. * Gets the sibling of the given output
  55505. * @param current defines the current output
  55506. * @returns the next output in the list or null
  55507. */
  55508. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55509. /**
  55510. * Connect current block with another block
  55511. * @param other defines the block to connect with
  55512. * @param options define the various options to help pick the right connections
  55513. * @returns the current block
  55514. */
  55515. connectTo(other: NodeMaterialBlock, options?: {
  55516. input?: string;
  55517. output?: string;
  55518. outputSwizzle?: string;
  55519. }): this | undefined;
  55520. protected _buildBlock(state: NodeMaterialBuildState): void;
  55521. /**
  55522. * Add uniforms, samplers and uniform buffers at compilation time
  55523. * @param state defines the state to update
  55524. * @param nodeMaterial defines the node material requesting the update
  55525. * @param defines defines the material defines to update
  55526. */
  55527. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55528. /**
  55529. * Add potential fallbacks if shader compilation fails
  55530. * @param mesh defines the mesh to be rendered
  55531. * @param fallbacks defines the current prioritized list of fallbacks
  55532. */
  55533. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55534. /**
  55535. * Initialize defines for shader compilation
  55536. * @param mesh defines the mesh to be rendered
  55537. * @param nodeMaterial defines the node material requesting the update
  55538. * @param defines defines the material defines to update
  55539. * @param useInstances specifies that instances should be used
  55540. */
  55541. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55542. /**
  55543. * Update defines for shader compilation
  55544. * @param mesh defines the mesh to be rendered
  55545. * @param nodeMaterial defines the node material requesting the update
  55546. * @param defines defines the material defines to update
  55547. * @param useInstances specifies that instances should be used
  55548. */
  55549. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55550. /**
  55551. * Lets the block try to connect some inputs automatically
  55552. * @param material defines the hosting NodeMaterial
  55553. */
  55554. autoConfigure(material: NodeMaterial): void;
  55555. /**
  55556. * Function called when a block is declared as repeatable content generator
  55557. * @param vertexShaderState defines the current compilation state for the vertex shader
  55558. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55559. * @param mesh defines the mesh to be rendered
  55560. * @param defines defines the material defines to update
  55561. */
  55562. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55563. /**
  55564. * Checks if the block is ready
  55565. * @param mesh defines the mesh to be rendered
  55566. * @param nodeMaterial defines the node material requesting the update
  55567. * @param defines defines the material defines to update
  55568. * @param useInstances specifies that instances should be used
  55569. * @returns true if the block is ready
  55570. */
  55571. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55572. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55573. private _processBuild;
  55574. /**
  55575. * Compile the current node and generate the shader code
  55576. * @param state defines the current compilation state (uniforms, samplers, current string)
  55577. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55578. * @returns true if already built
  55579. */
  55580. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55581. protected _inputRename(name: string): string;
  55582. protected _outputRename(name: string): string;
  55583. protected _dumpPropertiesCode(): string;
  55584. /** @hidden */
  55585. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55586. /**
  55587. * Clone the current block to a new identical block
  55588. * @param scene defines the hosting scene
  55589. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55590. * @returns a copy of the current block
  55591. */
  55592. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55593. /**
  55594. * Serializes this block in a JSON representation
  55595. * @returns the serialized block object
  55596. */
  55597. serialize(): any;
  55598. /** @hidden */
  55599. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55600. }
  55601. }
  55602. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55603. /**
  55604. * Enum defining the type of animations supported by InputBlock
  55605. */
  55606. export enum AnimatedInputBlockTypes {
  55607. /** No animation */
  55608. None = 0,
  55609. /** Time based animation. Will only work for floats */
  55610. Time = 1
  55611. }
  55612. }
  55613. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55614. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55615. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55616. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55617. import { Nullable } from "babylonjs/types";
  55618. import { Effect } from "babylonjs/Materials/effect";
  55619. import { Matrix } from "babylonjs/Maths/math.vector";
  55620. import { Scene } from "babylonjs/scene";
  55621. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55622. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55623. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55624. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55625. /**
  55626. * Block used to expose an input value
  55627. */
  55628. export class InputBlock extends NodeMaterialBlock {
  55629. private _mode;
  55630. private _associatedVariableName;
  55631. private _storedValue;
  55632. private _valueCallback;
  55633. private _type;
  55634. private _animationType;
  55635. /** Gets or set a value used to limit the range of float values */
  55636. min: number;
  55637. /** Gets or set a value used to limit the range of float values */
  55638. max: number;
  55639. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  55640. matrixMode: number;
  55641. /** @hidden */
  55642. _systemValue: Nullable<NodeMaterialSystemValues>;
  55643. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55644. visibleInInspector: boolean;
  55645. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  55646. isConstant: boolean;
  55647. /**
  55648. * Gets or sets the connection point type (default is float)
  55649. */
  55650. readonly type: NodeMaterialBlockConnectionPointTypes;
  55651. /**
  55652. * Creates a new InputBlock
  55653. * @param name defines the block name
  55654. * @param target defines the target of that block (Vertex by default)
  55655. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55656. */
  55657. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55658. /**
  55659. * Gets the output component
  55660. */
  55661. readonly output: NodeMaterialConnectionPoint;
  55662. /**
  55663. * Set the source of this connection point to a vertex attribute
  55664. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55665. * @returns the current connection point
  55666. */
  55667. setAsAttribute(attributeName?: string): InputBlock;
  55668. /**
  55669. * Set the source of this connection point to a system value
  55670. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55671. * @returns the current connection point
  55672. */
  55673. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55674. /**
  55675. * Gets or sets the value of that point.
  55676. * Please note that this value will be ignored if valueCallback is defined
  55677. */
  55678. value: any;
  55679. /**
  55680. * Gets or sets a callback used to get the value of that point.
  55681. * Please note that setting this value will force the connection point to ignore the value property
  55682. */
  55683. valueCallback: () => any;
  55684. /**
  55685. * Gets or sets the associated variable name in the shader
  55686. */
  55687. associatedVariableName: string;
  55688. /** Gets or sets the type of animation applied to the input */
  55689. animationType: AnimatedInputBlockTypes;
  55690. /**
  55691. * Gets a boolean indicating that this connection point not defined yet
  55692. */
  55693. readonly isUndefined: boolean;
  55694. /**
  55695. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55696. * In this case the connection point name must be the name of the uniform to use.
  55697. * Can only be set on inputs
  55698. */
  55699. isUniform: boolean;
  55700. /**
  55701. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55702. * In this case the connection point name must be the name of the attribute to use
  55703. * Can only be set on inputs
  55704. */
  55705. isAttribute: boolean;
  55706. /**
  55707. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55708. * Can only be set on exit points
  55709. */
  55710. isVarying: boolean;
  55711. /**
  55712. * Gets a boolean indicating that the current connection point is a system value
  55713. */
  55714. readonly isSystemValue: boolean;
  55715. /**
  55716. * Gets or sets the current well known value or null if not defined as a system value
  55717. */
  55718. systemValue: Nullable<NodeMaterialSystemValues>;
  55719. /**
  55720. * Gets the current class name
  55721. * @returns the class name
  55722. */
  55723. getClassName(): string;
  55724. /**
  55725. * Animate the input if animationType !== None
  55726. * @param scene defines the rendering scene
  55727. */
  55728. animate(scene: Scene): void;
  55729. private _emitDefine;
  55730. initialize(state: NodeMaterialBuildState): void;
  55731. /**
  55732. * Set the input block to its default value (based on its type)
  55733. */
  55734. setDefaultValue(): void;
  55735. private _emitConstant;
  55736. private _emit;
  55737. /** @hidden */
  55738. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55739. /** @hidden */
  55740. _transmit(effect: Effect, scene: Scene): void;
  55741. protected _buildBlock(state: NodeMaterialBuildState): void;
  55742. protected _dumpPropertiesCode(): string;
  55743. serialize(): any;
  55744. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55745. }
  55746. }
  55747. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55748. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55749. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55750. import { Nullable } from "babylonjs/types";
  55751. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55752. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55753. /**
  55754. * Defines a connection point for a block
  55755. */
  55756. export class NodeMaterialConnectionPoint {
  55757. /** @hidden */
  55758. _ownerBlock: NodeMaterialBlock;
  55759. /** @hidden */
  55760. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55761. private _endpoints;
  55762. private _associatedVariableName;
  55763. /** @hidden */
  55764. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55765. /** @hidden */
  55766. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55767. private _type;
  55768. /** @hidden */
  55769. _enforceAssociatedVariableName: boolean;
  55770. /**
  55771. * Gets or sets the additional types supported by this connection point
  55772. */
  55773. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55774. /**
  55775. * Gets or sets the additional types excluded by this connection point
  55776. */
  55777. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55778. /**
  55779. * Gets or sets the associated variable name in the shader
  55780. */
  55781. associatedVariableName: string;
  55782. /**
  55783. * Gets or sets the connection point type (default is float)
  55784. */
  55785. type: NodeMaterialBlockConnectionPointTypes;
  55786. /**
  55787. * Gets or sets the connection point name
  55788. */
  55789. name: string;
  55790. /**
  55791. * Gets or sets a boolean indicating that this connection point can be omitted
  55792. */
  55793. isOptional: boolean;
  55794. /**
  55795. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55796. */
  55797. define: string;
  55798. /** Gets or sets the target of that connection point */
  55799. target: NodeMaterialBlockTargets;
  55800. /**
  55801. * Gets a boolean indicating that the current point is connected
  55802. */
  55803. readonly isConnected: boolean;
  55804. /**
  55805. * Gets a boolean indicating that the current point is connected to an input block
  55806. */
  55807. readonly isConnectedToInputBlock: boolean;
  55808. /**
  55809. * Gets a the connected input block (if any)
  55810. */
  55811. readonly connectInputBlock: Nullable<InputBlock>;
  55812. /** Get the other side of the connection (if any) */
  55813. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55814. /** Get the block that owns this connection point */
  55815. readonly ownerBlock: NodeMaterialBlock;
  55816. /** Get the block connected on the other side of this connection (if any) */
  55817. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55818. /** Get the block connected on the endpoints of this connection (if any) */
  55819. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55820. /** Gets the list of connected endpoints */
  55821. readonly endpoints: NodeMaterialConnectionPoint[];
  55822. /** Gets a boolean indicating if that output point is connected to at least one input */
  55823. readonly hasEndpoints: boolean;
  55824. /**
  55825. * Creates a new connection point
  55826. * @param name defines the connection point name
  55827. * @param ownerBlock defines the block hosting this connection point
  55828. */
  55829. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55830. /**
  55831. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55832. * @returns the class name
  55833. */
  55834. getClassName(): string;
  55835. /**
  55836. * Gets an boolean indicating if the current point can be connected to another point
  55837. * @param connectionPoint defines the other connection point
  55838. * @returns true if the connection is possible
  55839. */
  55840. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55841. /**
  55842. * Connect this point to another connection point
  55843. * @param connectionPoint defines the other connection point
  55844. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55845. * @returns the current connection point
  55846. */
  55847. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55848. /**
  55849. * Disconnect this point from one of his endpoint
  55850. * @param endpoint defines the other connection point
  55851. * @returns the current connection point
  55852. */
  55853. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55854. /**
  55855. * Serializes this point in a JSON representation
  55856. * @returns the serialized point object
  55857. */
  55858. serialize(): any;
  55859. }
  55860. }
  55861. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55862. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55863. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55865. import { Mesh } from "babylonjs/Meshes/mesh";
  55866. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55867. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55868. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55869. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55870. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55871. /**
  55872. * Block used to add support for vertex skinning (bones)
  55873. */
  55874. export class BonesBlock extends NodeMaterialBlock {
  55875. /**
  55876. * Creates a new BonesBlock
  55877. * @param name defines the block name
  55878. */
  55879. constructor(name: string);
  55880. /**
  55881. * Initialize the block and prepare the context for build
  55882. * @param state defines the state that will be used for the build
  55883. */
  55884. initialize(state: NodeMaterialBuildState): void;
  55885. /**
  55886. * Gets the current class name
  55887. * @returns the class name
  55888. */
  55889. getClassName(): string;
  55890. /**
  55891. * Gets the matrix indices input component
  55892. */
  55893. readonly matricesIndices: NodeMaterialConnectionPoint;
  55894. /**
  55895. * Gets the matrix weights input component
  55896. */
  55897. readonly matricesWeights: NodeMaterialConnectionPoint;
  55898. /**
  55899. * Gets the extra matrix indices input component
  55900. */
  55901. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55902. /**
  55903. * Gets the extra matrix weights input component
  55904. */
  55905. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55906. /**
  55907. * Gets the world input component
  55908. */
  55909. readonly world: NodeMaterialConnectionPoint;
  55910. /**
  55911. * Gets the output component
  55912. */
  55913. readonly output: NodeMaterialConnectionPoint;
  55914. autoConfigure(material: NodeMaterial): void;
  55915. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55916. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55917. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55918. protected _buildBlock(state: NodeMaterialBuildState): this;
  55919. }
  55920. }
  55921. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55924. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55926. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55927. /**
  55928. * Block used to add support for instances
  55929. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55930. */
  55931. export class InstancesBlock extends NodeMaterialBlock {
  55932. /**
  55933. * Creates a new InstancesBlock
  55934. * @param name defines the block name
  55935. */
  55936. constructor(name: string);
  55937. /**
  55938. * Gets the current class name
  55939. * @returns the class name
  55940. */
  55941. getClassName(): string;
  55942. /**
  55943. * Gets the first world row input component
  55944. */
  55945. readonly world0: NodeMaterialConnectionPoint;
  55946. /**
  55947. * Gets the second world row input component
  55948. */
  55949. readonly world1: NodeMaterialConnectionPoint;
  55950. /**
  55951. * Gets the third world row input component
  55952. */
  55953. readonly world2: NodeMaterialConnectionPoint;
  55954. /**
  55955. * Gets the forth world row input component
  55956. */
  55957. readonly world3: NodeMaterialConnectionPoint;
  55958. /**
  55959. * Gets the world input component
  55960. */
  55961. readonly world: NodeMaterialConnectionPoint;
  55962. /**
  55963. * Gets the output component
  55964. */
  55965. readonly output: NodeMaterialConnectionPoint;
  55966. autoConfigure(material: NodeMaterial): void;
  55967. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55968. protected _buildBlock(state: NodeMaterialBuildState): this;
  55969. }
  55970. }
  55971. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55972. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55973. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55974. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55976. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55977. import { Effect } from "babylonjs/Materials/effect";
  55978. import { Mesh } from "babylonjs/Meshes/mesh";
  55979. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55980. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55981. /**
  55982. * Block used to add morph targets support to vertex shader
  55983. */
  55984. export class MorphTargetsBlock extends NodeMaterialBlock {
  55985. private _repeatableContentAnchor;
  55986. private _repeatebleContentGenerated;
  55987. /**
  55988. * Create a new MorphTargetsBlock
  55989. * @param name defines the block name
  55990. */
  55991. constructor(name: string);
  55992. /**
  55993. * Gets the current class name
  55994. * @returns the class name
  55995. */
  55996. getClassName(): string;
  55997. /**
  55998. * Gets the position input component
  55999. */
  56000. readonly position: NodeMaterialConnectionPoint;
  56001. /**
  56002. * Gets the normal input component
  56003. */
  56004. readonly normal: NodeMaterialConnectionPoint;
  56005. /**
  56006. * Gets the tangent input component
  56007. */
  56008. readonly tangent: NodeMaterialConnectionPoint;
  56009. /**
  56010. * Gets the tangent input component
  56011. */
  56012. readonly uv: NodeMaterialConnectionPoint;
  56013. /**
  56014. * Gets the position output component
  56015. */
  56016. readonly positionOutput: NodeMaterialConnectionPoint;
  56017. /**
  56018. * Gets the normal output component
  56019. */
  56020. readonly normalOutput: NodeMaterialConnectionPoint;
  56021. /**
  56022. * Gets the tangent output component
  56023. */
  56024. readonly tangentOutput: NodeMaterialConnectionPoint;
  56025. /**
  56026. * Gets the tangent output component
  56027. */
  56028. readonly uvOutput: NodeMaterialConnectionPoint;
  56029. initialize(state: NodeMaterialBuildState): void;
  56030. autoConfigure(material: NodeMaterial): void;
  56031. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56032. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56033. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56034. protected _buildBlock(state: NodeMaterialBuildState): this;
  56035. }
  56036. }
  56037. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56038. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56039. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56040. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56041. import { Nullable } from "babylonjs/types";
  56042. import { Scene } from "babylonjs/scene";
  56043. import { Effect } from "babylonjs/Materials/effect";
  56044. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56045. import { Mesh } from "babylonjs/Meshes/mesh";
  56046. import { Light } from "babylonjs/Lights/light";
  56047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56048. /**
  56049. * Block used to get data information from a light
  56050. */
  56051. export class LightInformationBlock extends NodeMaterialBlock {
  56052. private _lightDataUniformName;
  56053. private _lightColorUniformName;
  56054. private _lightTypeDefineName;
  56055. /**
  56056. * Gets or sets the light associated with this block
  56057. */
  56058. light: Nullable<Light>;
  56059. /**
  56060. * Creates a new LightInformationBlock
  56061. * @param name defines the block name
  56062. */
  56063. constructor(name: string);
  56064. /**
  56065. * Gets the current class name
  56066. * @returns the class name
  56067. */
  56068. getClassName(): string;
  56069. /**
  56070. * Gets the world position input component
  56071. */
  56072. readonly worldPosition: NodeMaterialConnectionPoint;
  56073. /**
  56074. * Gets the direction output component
  56075. */
  56076. readonly direction: NodeMaterialConnectionPoint;
  56077. /**
  56078. * Gets the direction output component
  56079. */
  56080. readonly color: NodeMaterialConnectionPoint;
  56081. /**
  56082. * Gets the direction output component
  56083. */
  56084. readonly intensity: NodeMaterialConnectionPoint;
  56085. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56086. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56087. protected _buildBlock(state: NodeMaterialBuildState): this;
  56088. serialize(): any;
  56089. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56090. }
  56091. }
  56092. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56093. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56094. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56095. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56096. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56097. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56098. }
  56099. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56100. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56101. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56102. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56104. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56105. import { Effect } from "babylonjs/Materials/effect";
  56106. import { Mesh } from "babylonjs/Meshes/mesh";
  56107. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56108. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56109. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56110. /**
  56111. * Block used to add image processing support to fragment shader
  56112. */
  56113. export class ImageProcessingBlock extends NodeMaterialBlock {
  56114. /**
  56115. * Create a new ImageProcessingBlock
  56116. * @param name defines the block name
  56117. */
  56118. constructor(name: string);
  56119. /**
  56120. * Gets the current class name
  56121. * @returns the class name
  56122. */
  56123. getClassName(): string;
  56124. /**
  56125. * Gets the color input component
  56126. */
  56127. readonly color: NodeMaterialConnectionPoint;
  56128. /**
  56129. * Gets the output component
  56130. */
  56131. readonly output: NodeMaterialConnectionPoint;
  56132. /**
  56133. * Initialize the block and prepare the context for build
  56134. * @param state defines the state that will be used for the build
  56135. */
  56136. initialize(state: NodeMaterialBuildState): void;
  56137. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56138. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56139. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56140. protected _buildBlock(state: NodeMaterialBuildState): this;
  56141. }
  56142. }
  56143. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56147. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56149. import { Effect } from "babylonjs/Materials/effect";
  56150. import { Mesh } from "babylonjs/Meshes/mesh";
  56151. import { Scene } from "babylonjs/scene";
  56152. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56153. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56154. /**
  56155. * Block used to pertub normals based on a normal map
  56156. */
  56157. export class PerturbNormalBlock extends NodeMaterialBlock {
  56158. private _tangentSpaceParameterName;
  56159. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56160. invertX: boolean;
  56161. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56162. invertY: boolean;
  56163. /**
  56164. * Create a new PerturbNormalBlock
  56165. * @param name defines the block name
  56166. */
  56167. constructor(name: string);
  56168. /**
  56169. * Gets the current class name
  56170. * @returns the class name
  56171. */
  56172. getClassName(): string;
  56173. /**
  56174. * Gets the world position input component
  56175. */
  56176. readonly worldPosition: NodeMaterialConnectionPoint;
  56177. /**
  56178. * Gets the world normal input component
  56179. */
  56180. readonly worldNormal: NodeMaterialConnectionPoint;
  56181. /**
  56182. * Gets the uv input component
  56183. */
  56184. readonly uv: NodeMaterialConnectionPoint;
  56185. /**
  56186. * Gets the normal map color input component
  56187. */
  56188. readonly normalMapColor: NodeMaterialConnectionPoint;
  56189. /**
  56190. * Gets the strength input component
  56191. */
  56192. readonly strength: NodeMaterialConnectionPoint;
  56193. /**
  56194. * Gets the output component
  56195. */
  56196. readonly output: NodeMaterialConnectionPoint;
  56197. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56198. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56199. autoConfigure(material: NodeMaterial): void;
  56200. protected _buildBlock(state: NodeMaterialBuildState): this;
  56201. protected _dumpPropertiesCode(): string;
  56202. serialize(): any;
  56203. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56204. }
  56205. }
  56206. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56207. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56208. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56209. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56210. /**
  56211. * Block used to discard a pixel if a value is smaller than a cutoff
  56212. */
  56213. export class DiscardBlock extends NodeMaterialBlock {
  56214. /**
  56215. * Create a new DiscardBlock
  56216. * @param name defines the block name
  56217. */
  56218. constructor(name: string);
  56219. /**
  56220. * Gets the current class name
  56221. * @returns the class name
  56222. */
  56223. getClassName(): string;
  56224. /**
  56225. * Gets the color input component
  56226. */
  56227. readonly value: NodeMaterialConnectionPoint;
  56228. /**
  56229. * Gets the cutoff input component
  56230. */
  56231. readonly cutoff: NodeMaterialConnectionPoint;
  56232. protected _buildBlock(state: NodeMaterialBuildState): this;
  56233. }
  56234. }
  56235. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56236. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56237. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56238. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56239. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56240. }
  56241. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56242. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56243. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56244. import { Mesh } from "babylonjs/Meshes/mesh";
  56245. import { Effect } from "babylonjs/Materials/effect";
  56246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56248. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56249. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56250. /**
  56251. * Block used to add support for scene fog
  56252. */
  56253. export class FogBlock extends NodeMaterialBlock {
  56254. private _fogDistanceName;
  56255. private _fogParameters;
  56256. /**
  56257. * Create a new FogBlock
  56258. * @param name defines the block name
  56259. */
  56260. constructor(name: string);
  56261. /**
  56262. * Gets the current class name
  56263. * @returns the class name
  56264. */
  56265. getClassName(): string;
  56266. /**
  56267. * Gets the world position input component
  56268. */
  56269. readonly worldPosition: NodeMaterialConnectionPoint;
  56270. /**
  56271. * Gets the view input component
  56272. */
  56273. readonly view: NodeMaterialConnectionPoint;
  56274. /**
  56275. * Gets the color input component
  56276. */
  56277. readonly input: NodeMaterialConnectionPoint;
  56278. /**
  56279. * Gets the fog color input component
  56280. */
  56281. readonly fogColor: NodeMaterialConnectionPoint;
  56282. /**
  56283. * Gets the output component
  56284. */
  56285. readonly output: NodeMaterialConnectionPoint;
  56286. autoConfigure(material: NodeMaterial): void;
  56287. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56288. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56289. protected _buildBlock(state: NodeMaterialBuildState): this;
  56290. }
  56291. }
  56292. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56294. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56297. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56298. import { Effect } from "babylonjs/Materials/effect";
  56299. import { Mesh } from "babylonjs/Meshes/mesh";
  56300. import { Light } from "babylonjs/Lights/light";
  56301. import { Nullable } from "babylonjs/types";
  56302. import { Scene } from "babylonjs/scene";
  56303. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56304. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56305. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56306. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56307. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56308. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56309. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56310. /**
  56311. * Block used to add light in the fragment shader
  56312. */
  56313. export class LightBlock extends NodeMaterialBlock {
  56314. private _lightId;
  56315. /**
  56316. * Gets or sets the light associated with this block
  56317. */
  56318. light: Nullable<Light>;
  56319. /**
  56320. * Create a new LightBlock
  56321. * @param name defines the block name
  56322. */
  56323. constructor(name: string);
  56324. /**
  56325. * Gets the current class name
  56326. * @returns the class name
  56327. */
  56328. getClassName(): string;
  56329. /**
  56330. * Gets the world position input component
  56331. */
  56332. readonly worldPosition: NodeMaterialConnectionPoint;
  56333. /**
  56334. * Gets the world normal input component
  56335. */
  56336. readonly worldNormal: NodeMaterialConnectionPoint;
  56337. /**
  56338. * Gets the camera (or eye) position component
  56339. */
  56340. readonly cameraPosition: NodeMaterialConnectionPoint;
  56341. /**
  56342. * Gets the diffuse output component
  56343. */
  56344. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56345. /**
  56346. * Gets the specular output component
  56347. */
  56348. readonly specularOutput: NodeMaterialConnectionPoint;
  56349. autoConfigure(material: NodeMaterial): void;
  56350. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56351. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56352. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56353. private _injectVertexCode;
  56354. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56355. serialize(): any;
  56356. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56357. }
  56358. }
  56359. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56360. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56361. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56362. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56363. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56364. }
  56365. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56366. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56367. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56368. }
  56369. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56370. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56371. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56372. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56373. /**
  56374. * Block used to multiply 2 values
  56375. */
  56376. export class MultiplyBlock extends NodeMaterialBlock {
  56377. /**
  56378. * Creates a new MultiplyBlock
  56379. * @param name defines the block name
  56380. */
  56381. constructor(name: string);
  56382. /**
  56383. * Gets the current class name
  56384. * @returns the class name
  56385. */
  56386. getClassName(): string;
  56387. /**
  56388. * Gets the left operand input component
  56389. */
  56390. readonly left: NodeMaterialConnectionPoint;
  56391. /**
  56392. * Gets the right operand input component
  56393. */
  56394. readonly right: NodeMaterialConnectionPoint;
  56395. /**
  56396. * Gets the output component
  56397. */
  56398. readonly output: NodeMaterialConnectionPoint;
  56399. protected _buildBlock(state: NodeMaterialBuildState): this;
  56400. }
  56401. }
  56402. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56403. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56404. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56405. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56406. /**
  56407. * Block used to add 2 vectors
  56408. */
  56409. export class AddBlock extends NodeMaterialBlock {
  56410. /**
  56411. * Creates a new AddBlock
  56412. * @param name defines the block name
  56413. */
  56414. constructor(name: string);
  56415. /**
  56416. * Gets the current class name
  56417. * @returns the class name
  56418. */
  56419. getClassName(): string;
  56420. /**
  56421. * Gets the left operand input component
  56422. */
  56423. readonly left: NodeMaterialConnectionPoint;
  56424. /**
  56425. * Gets the right operand input component
  56426. */
  56427. readonly right: NodeMaterialConnectionPoint;
  56428. /**
  56429. * Gets the output component
  56430. */
  56431. readonly output: NodeMaterialConnectionPoint;
  56432. protected _buildBlock(state: NodeMaterialBuildState): this;
  56433. }
  56434. }
  56435. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56436. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56437. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56438. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56439. /**
  56440. * Block used to scale a vector by a float
  56441. */
  56442. export class ScaleBlock extends NodeMaterialBlock {
  56443. /**
  56444. * Creates a new ScaleBlock
  56445. * @param name defines the block name
  56446. */
  56447. constructor(name: string);
  56448. /**
  56449. * Gets the current class name
  56450. * @returns the class name
  56451. */
  56452. getClassName(): string;
  56453. /**
  56454. * Gets the input component
  56455. */
  56456. readonly input: NodeMaterialConnectionPoint;
  56457. /**
  56458. * Gets the factor input component
  56459. */
  56460. readonly factor: NodeMaterialConnectionPoint;
  56461. /**
  56462. * Gets the output component
  56463. */
  56464. readonly output: NodeMaterialConnectionPoint;
  56465. protected _buildBlock(state: NodeMaterialBuildState): this;
  56466. }
  56467. }
  56468. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56471. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56472. import { Scene } from "babylonjs/scene";
  56473. /**
  56474. * Block used to clamp a float
  56475. */
  56476. export class ClampBlock extends NodeMaterialBlock {
  56477. /** Gets or sets the minimum range */
  56478. minimum: number;
  56479. /** Gets or sets the maximum range */
  56480. maximum: number;
  56481. /**
  56482. * Creates a new ClampBlock
  56483. * @param name defines the block name
  56484. */
  56485. constructor(name: string);
  56486. /**
  56487. * Gets the current class name
  56488. * @returns the class name
  56489. */
  56490. getClassName(): string;
  56491. /**
  56492. * Gets the value input component
  56493. */
  56494. readonly value: NodeMaterialConnectionPoint;
  56495. /**
  56496. * Gets the output component
  56497. */
  56498. readonly output: NodeMaterialConnectionPoint;
  56499. protected _buildBlock(state: NodeMaterialBuildState): this;
  56500. protected _dumpPropertiesCode(): string;
  56501. serialize(): any;
  56502. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56503. }
  56504. }
  56505. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56506. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56507. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56508. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56509. /**
  56510. * Block used to apply a cross product between 2 vectors
  56511. */
  56512. export class CrossBlock extends NodeMaterialBlock {
  56513. /**
  56514. * Creates a new CrossBlock
  56515. * @param name defines the block name
  56516. */
  56517. constructor(name: string);
  56518. /**
  56519. * Gets the current class name
  56520. * @returns the class name
  56521. */
  56522. getClassName(): string;
  56523. /**
  56524. * Gets the left operand input component
  56525. */
  56526. readonly left: NodeMaterialConnectionPoint;
  56527. /**
  56528. * Gets the right operand input component
  56529. */
  56530. readonly right: NodeMaterialConnectionPoint;
  56531. /**
  56532. * Gets the output component
  56533. */
  56534. readonly output: NodeMaterialConnectionPoint;
  56535. protected _buildBlock(state: NodeMaterialBuildState): this;
  56536. }
  56537. }
  56538. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  56539. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56540. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56541. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56542. /**
  56543. * Block used to apply a dot product between 2 vectors
  56544. */
  56545. export class DotBlock extends NodeMaterialBlock {
  56546. /**
  56547. * Creates a new DotBlock
  56548. * @param name defines the block name
  56549. */
  56550. constructor(name: string);
  56551. /**
  56552. * Gets the current class name
  56553. * @returns the class name
  56554. */
  56555. getClassName(): string;
  56556. /**
  56557. * Gets the left operand input component
  56558. */
  56559. readonly left: NodeMaterialConnectionPoint;
  56560. /**
  56561. * Gets the right operand input component
  56562. */
  56563. readonly right: NodeMaterialConnectionPoint;
  56564. /**
  56565. * Gets the output component
  56566. */
  56567. readonly output: NodeMaterialConnectionPoint;
  56568. protected _buildBlock(state: NodeMaterialBuildState): this;
  56569. }
  56570. }
  56571. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56575. import { Vector2 } from "babylonjs/Maths/math.vector";
  56576. import { Scene } from "babylonjs/scene";
  56577. /**
  56578. * Block used to remap a float from a range to a new one
  56579. */
  56580. export class RemapBlock extends NodeMaterialBlock {
  56581. /**
  56582. * Gets or sets the source range
  56583. */
  56584. sourceRange: Vector2;
  56585. /**
  56586. * Gets or sets the target range
  56587. */
  56588. targetRange: Vector2;
  56589. /**
  56590. * Creates a new RemapBlock
  56591. * @param name defines the block name
  56592. */
  56593. constructor(name: string);
  56594. /**
  56595. * Gets the current class name
  56596. * @returns the class name
  56597. */
  56598. getClassName(): string;
  56599. /**
  56600. * Gets the input component
  56601. */
  56602. readonly input: NodeMaterialConnectionPoint;
  56603. /**
  56604. * Gets the source min input component
  56605. */
  56606. readonly sourceMin: NodeMaterialConnectionPoint;
  56607. /**
  56608. * Gets the source max input component
  56609. */
  56610. readonly sourceMax: NodeMaterialConnectionPoint;
  56611. /**
  56612. * Gets the target min input component
  56613. */
  56614. readonly targetMin: NodeMaterialConnectionPoint;
  56615. /**
  56616. * Gets the target max input component
  56617. */
  56618. readonly targetMax: NodeMaterialConnectionPoint;
  56619. /**
  56620. * Gets the output component
  56621. */
  56622. readonly output: NodeMaterialConnectionPoint;
  56623. protected _buildBlock(state: NodeMaterialBuildState): this;
  56624. protected _dumpPropertiesCode(): string;
  56625. serialize(): any;
  56626. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56627. }
  56628. }
  56629. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56630. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56631. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56632. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56633. /**
  56634. * Block used to normalize a vector
  56635. */
  56636. export class NormalizeBlock extends NodeMaterialBlock {
  56637. /**
  56638. * Creates a new NormalizeBlock
  56639. * @param name defines the block name
  56640. */
  56641. constructor(name: string);
  56642. /**
  56643. * Gets the current class name
  56644. * @returns the class name
  56645. */
  56646. getClassName(): string;
  56647. /**
  56648. * Gets the input component
  56649. */
  56650. readonly input: NodeMaterialConnectionPoint;
  56651. /**
  56652. * Gets the output component
  56653. */
  56654. readonly output: NodeMaterialConnectionPoint;
  56655. protected _buildBlock(state: NodeMaterialBuildState): this;
  56656. }
  56657. }
  56658. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56660. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56661. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56662. import { Scene } from "babylonjs/scene";
  56663. /**
  56664. * Operations supported by the Trigonometry block
  56665. */
  56666. export enum TrigonometryBlockOperations {
  56667. /** Cos */
  56668. Cos = 0,
  56669. /** Sin */
  56670. Sin = 1,
  56671. /** Abs */
  56672. Abs = 2,
  56673. /** Exp */
  56674. Exp = 3,
  56675. /** Exp2 */
  56676. Exp2 = 4,
  56677. /** Round */
  56678. Round = 5,
  56679. /** Floor */
  56680. Floor = 6,
  56681. /** Ceiling */
  56682. Ceiling = 7,
  56683. /** Square root */
  56684. Sqrt = 8
  56685. }
  56686. /**
  56687. * Block used to apply trigonometry operation to floats
  56688. */
  56689. export class TrigonometryBlock extends NodeMaterialBlock {
  56690. /**
  56691. * Gets or sets the operation applied by the block
  56692. */
  56693. operation: TrigonometryBlockOperations;
  56694. /**
  56695. * Creates a new TrigonometryBlock
  56696. * @param name defines the block name
  56697. */
  56698. constructor(name: string);
  56699. /**
  56700. * Gets the current class name
  56701. * @returns the class name
  56702. */
  56703. getClassName(): string;
  56704. /**
  56705. * Gets the input component
  56706. */
  56707. readonly input: NodeMaterialConnectionPoint;
  56708. /**
  56709. * Gets the output component
  56710. */
  56711. readonly output: NodeMaterialConnectionPoint;
  56712. protected _buildBlock(state: NodeMaterialBuildState): this;
  56713. serialize(): any;
  56714. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56715. }
  56716. }
  56717. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56718. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56719. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56720. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56721. /**
  56722. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56723. */
  56724. export class ColorMergerBlock extends NodeMaterialBlock {
  56725. /**
  56726. * Create a new ColorMergerBlock
  56727. * @param name defines the block name
  56728. */
  56729. constructor(name: string);
  56730. /**
  56731. * Gets the current class name
  56732. * @returns the class name
  56733. */
  56734. getClassName(): string;
  56735. /**
  56736. * Gets the r component (input)
  56737. */
  56738. readonly r: NodeMaterialConnectionPoint;
  56739. /**
  56740. * Gets the g component (input)
  56741. */
  56742. readonly g: NodeMaterialConnectionPoint;
  56743. /**
  56744. * Gets the b component (input)
  56745. */
  56746. readonly b: NodeMaterialConnectionPoint;
  56747. /**
  56748. * Gets the a component (input)
  56749. */
  56750. readonly a: NodeMaterialConnectionPoint;
  56751. /**
  56752. * Gets the rgba component (output)
  56753. */
  56754. readonly rgba: NodeMaterialConnectionPoint;
  56755. /**
  56756. * Gets the rgb component (output)
  56757. */
  56758. readonly rgb: NodeMaterialConnectionPoint;
  56759. protected _buildBlock(state: NodeMaterialBuildState): this;
  56760. }
  56761. }
  56762. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56763. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56764. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56765. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56766. /**
  56767. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56768. */
  56769. export class VectorMergerBlock extends NodeMaterialBlock {
  56770. /**
  56771. * Create a new VectorMergerBlock
  56772. * @param name defines the block name
  56773. */
  56774. constructor(name: string);
  56775. /**
  56776. * Gets the current class name
  56777. * @returns the class name
  56778. */
  56779. getClassName(): string;
  56780. /**
  56781. * Gets the x component (input)
  56782. */
  56783. readonly x: NodeMaterialConnectionPoint;
  56784. /**
  56785. * Gets the y component (input)
  56786. */
  56787. readonly y: NodeMaterialConnectionPoint;
  56788. /**
  56789. * Gets the z component (input)
  56790. */
  56791. readonly z: NodeMaterialConnectionPoint;
  56792. /**
  56793. * Gets the w component (input)
  56794. */
  56795. readonly w: NodeMaterialConnectionPoint;
  56796. /**
  56797. * Gets the xyzw component (output)
  56798. */
  56799. readonly xyzw: NodeMaterialConnectionPoint;
  56800. /**
  56801. * Gets the xyz component (output)
  56802. */
  56803. readonly xyz: NodeMaterialConnectionPoint;
  56804. /**
  56805. * Gets the xy component (output)
  56806. */
  56807. readonly xy: NodeMaterialConnectionPoint;
  56808. protected _buildBlock(state: NodeMaterialBuildState): this;
  56809. }
  56810. }
  56811. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56812. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56813. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56814. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56815. /**
  56816. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56817. */
  56818. export class ColorSplitterBlock extends NodeMaterialBlock {
  56819. /**
  56820. * Create a new ColorSplitterBlock
  56821. * @param name defines the block name
  56822. */
  56823. constructor(name: string);
  56824. /**
  56825. * Gets the current class name
  56826. * @returns the class name
  56827. */
  56828. getClassName(): string;
  56829. /**
  56830. * Gets the rgba component (input)
  56831. */
  56832. readonly rgba: NodeMaterialConnectionPoint;
  56833. /**
  56834. * Gets the rgb component (input)
  56835. */
  56836. readonly rgbIn: NodeMaterialConnectionPoint;
  56837. /**
  56838. * Gets the rgb component (output)
  56839. */
  56840. readonly rgbOut: NodeMaterialConnectionPoint;
  56841. /**
  56842. * Gets the r component (output)
  56843. */
  56844. readonly r: NodeMaterialConnectionPoint;
  56845. /**
  56846. * Gets the g component (output)
  56847. */
  56848. readonly g: NodeMaterialConnectionPoint;
  56849. /**
  56850. * Gets the b component (output)
  56851. */
  56852. readonly b: NodeMaterialConnectionPoint;
  56853. /**
  56854. * Gets the a component (output)
  56855. */
  56856. readonly a: NodeMaterialConnectionPoint;
  56857. protected _inputRename(name: string): string;
  56858. protected _outputRename(name: string): string;
  56859. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56860. }
  56861. }
  56862. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56863. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56864. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56865. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56866. /**
  56867. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56868. */
  56869. export class VectorSplitterBlock extends NodeMaterialBlock {
  56870. /**
  56871. * Create a new VectorSplitterBlock
  56872. * @param name defines the block name
  56873. */
  56874. constructor(name: string);
  56875. /**
  56876. * Gets the current class name
  56877. * @returns the class name
  56878. */
  56879. getClassName(): string;
  56880. /**
  56881. * Gets the xyzw component (input)
  56882. */
  56883. readonly xyzw: NodeMaterialConnectionPoint;
  56884. /**
  56885. * Gets the xyz component (input)
  56886. */
  56887. readonly xyzIn: NodeMaterialConnectionPoint;
  56888. /**
  56889. * Gets the xy component (input)
  56890. */
  56891. readonly xyIn: NodeMaterialConnectionPoint;
  56892. /**
  56893. * Gets the xyz component (output)
  56894. */
  56895. readonly xyzOut: NodeMaterialConnectionPoint;
  56896. /**
  56897. * Gets the xy component (output)
  56898. */
  56899. readonly xyOut: NodeMaterialConnectionPoint;
  56900. /**
  56901. * Gets the x component (output)
  56902. */
  56903. readonly x: NodeMaterialConnectionPoint;
  56904. /**
  56905. * Gets the y component (output)
  56906. */
  56907. readonly y: NodeMaterialConnectionPoint;
  56908. /**
  56909. * Gets the z component (output)
  56910. */
  56911. readonly z: NodeMaterialConnectionPoint;
  56912. /**
  56913. * Gets the w component (output)
  56914. */
  56915. readonly w: NodeMaterialConnectionPoint;
  56916. protected _inputRename(name: string): string;
  56917. protected _outputRename(name: string): string;
  56918. protected _buildBlock(state: NodeMaterialBuildState): this;
  56919. }
  56920. }
  56921. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56924. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56925. /**
  56926. * Block used to lerp 2 values
  56927. */
  56928. export class LerpBlock extends NodeMaterialBlock {
  56929. /**
  56930. * Creates a new LerpBlock
  56931. * @param name defines the block name
  56932. */
  56933. constructor(name: string);
  56934. /**
  56935. * Gets the current class name
  56936. * @returns the class name
  56937. */
  56938. getClassName(): string;
  56939. /**
  56940. * Gets the left operand input component
  56941. */
  56942. readonly left: NodeMaterialConnectionPoint;
  56943. /**
  56944. * Gets the right operand input component
  56945. */
  56946. readonly right: NodeMaterialConnectionPoint;
  56947. /**
  56948. * Gets the gradient operand input component
  56949. */
  56950. readonly gradient: NodeMaterialConnectionPoint;
  56951. /**
  56952. * Gets the output component
  56953. */
  56954. readonly output: NodeMaterialConnectionPoint;
  56955. protected _buildBlock(state: NodeMaterialBuildState): this;
  56956. }
  56957. }
  56958. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56959. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56960. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56961. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56962. /**
  56963. * Block used to divide 2 vectors
  56964. */
  56965. export class DivideBlock extends NodeMaterialBlock {
  56966. /**
  56967. * Creates a new DivideBlock
  56968. * @param name defines the block name
  56969. */
  56970. constructor(name: string);
  56971. /**
  56972. * Gets the current class name
  56973. * @returns the class name
  56974. */
  56975. getClassName(): string;
  56976. /**
  56977. * Gets the left operand input component
  56978. */
  56979. readonly left: NodeMaterialConnectionPoint;
  56980. /**
  56981. * Gets the right operand input component
  56982. */
  56983. readonly right: NodeMaterialConnectionPoint;
  56984. /**
  56985. * Gets the output component
  56986. */
  56987. readonly output: NodeMaterialConnectionPoint;
  56988. protected _buildBlock(state: NodeMaterialBuildState): this;
  56989. }
  56990. }
  56991. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56992. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56993. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56994. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56995. /**
  56996. * Block used to subtract 2 vectors
  56997. */
  56998. export class SubtractBlock extends NodeMaterialBlock {
  56999. /**
  57000. * Creates a new SubtractBlock
  57001. * @param name defines the block name
  57002. */
  57003. constructor(name: string);
  57004. /**
  57005. * Gets the current class name
  57006. * @returns the class name
  57007. */
  57008. getClassName(): string;
  57009. /**
  57010. * Gets the left operand input component
  57011. */
  57012. readonly left: NodeMaterialConnectionPoint;
  57013. /**
  57014. * Gets the right operand input component
  57015. */
  57016. readonly right: NodeMaterialConnectionPoint;
  57017. /**
  57018. * Gets the output component
  57019. */
  57020. readonly output: NodeMaterialConnectionPoint;
  57021. protected _buildBlock(state: NodeMaterialBuildState): this;
  57022. }
  57023. }
  57024. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57025. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57026. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57027. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57028. /**
  57029. * Block used to step a value
  57030. */
  57031. export class StepBlock extends NodeMaterialBlock {
  57032. /**
  57033. * Creates a new AddBlock
  57034. * @param name defines the block name
  57035. */
  57036. constructor(name: string);
  57037. /**
  57038. * Gets the current class name
  57039. * @returns the class name
  57040. */
  57041. getClassName(): string;
  57042. /**
  57043. * Gets the value operand input component
  57044. */
  57045. readonly value: NodeMaterialConnectionPoint;
  57046. /**
  57047. * Gets the edge operand input component
  57048. */
  57049. readonly edge: NodeMaterialConnectionPoint;
  57050. /**
  57051. * Gets the output component
  57052. */
  57053. readonly output: NodeMaterialConnectionPoint;
  57054. protected _buildBlock(state: NodeMaterialBuildState): this;
  57055. }
  57056. }
  57057. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57058. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57059. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57060. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57061. /**
  57062. * Block used to get the opposite (1 - x) of a value
  57063. */
  57064. export class OneMinusBlock extends NodeMaterialBlock {
  57065. /**
  57066. * Creates a new OneMinusBlock
  57067. * @param name defines the block name
  57068. */
  57069. constructor(name: string);
  57070. /**
  57071. * Gets the current class name
  57072. * @returns the class name
  57073. */
  57074. getClassName(): string;
  57075. /**
  57076. * Gets the input component
  57077. */
  57078. readonly input: NodeMaterialConnectionPoint;
  57079. /**
  57080. * Gets the output component
  57081. */
  57082. readonly output: NodeMaterialConnectionPoint;
  57083. protected _buildBlock(state: NodeMaterialBuildState): this;
  57084. }
  57085. }
  57086. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57089. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57090. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57091. /**
  57092. * Block used to get the view direction
  57093. */
  57094. export class ViewDirectionBlock extends NodeMaterialBlock {
  57095. /**
  57096. * Creates a new ViewDirectionBlock
  57097. * @param name defines the block name
  57098. */
  57099. constructor(name: string);
  57100. /**
  57101. * Gets the current class name
  57102. * @returns the class name
  57103. */
  57104. getClassName(): string;
  57105. /**
  57106. * Gets the world position component
  57107. */
  57108. readonly worldPosition: NodeMaterialConnectionPoint;
  57109. /**
  57110. * Gets the camera position component
  57111. */
  57112. readonly cameraPosition: NodeMaterialConnectionPoint;
  57113. /**
  57114. * Gets the output component
  57115. */
  57116. readonly output: NodeMaterialConnectionPoint;
  57117. autoConfigure(material: NodeMaterial): void;
  57118. protected _buildBlock(state: NodeMaterialBuildState): this;
  57119. }
  57120. }
  57121. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57122. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57124. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57125. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57126. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57127. /**
  57128. * Block used to compute fresnel value
  57129. */
  57130. export class FresnelBlock extends NodeMaterialBlock {
  57131. /**
  57132. * Create a new FresnelBlock
  57133. * @param name defines the block name
  57134. */
  57135. constructor(name: string);
  57136. /**
  57137. * Gets the current class name
  57138. * @returns the class name
  57139. */
  57140. getClassName(): string;
  57141. /**
  57142. * Gets the world normal input component
  57143. */
  57144. readonly worldNormal: NodeMaterialConnectionPoint;
  57145. /**
  57146. * Gets the view direction input component
  57147. */
  57148. readonly viewDirection: NodeMaterialConnectionPoint;
  57149. /**
  57150. * Gets the bias input component
  57151. */
  57152. readonly bias: NodeMaterialConnectionPoint;
  57153. /**
  57154. * Gets the camera (or eye) position component
  57155. */
  57156. readonly power: NodeMaterialConnectionPoint;
  57157. /**
  57158. * Gets the fresnel output component
  57159. */
  57160. readonly fresnel: NodeMaterialConnectionPoint;
  57161. autoConfigure(material: NodeMaterial): void;
  57162. protected _buildBlock(state: NodeMaterialBuildState): this;
  57163. }
  57164. }
  57165. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57166. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57167. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57168. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57169. /**
  57170. * Block used to get the max of 2 values
  57171. */
  57172. export class MaxBlock extends NodeMaterialBlock {
  57173. /**
  57174. * Creates a new MaxBlock
  57175. * @param name defines the block name
  57176. */
  57177. constructor(name: string);
  57178. /**
  57179. * Gets the current class name
  57180. * @returns the class name
  57181. */
  57182. getClassName(): string;
  57183. /**
  57184. * Gets the left operand input component
  57185. */
  57186. readonly left: NodeMaterialConnectionPoint;
  57187. /**
  57188. * Gets the right operand input component
  57189. */
  57190. readonly right: NodeMaterialConnectionPoint;
  57191. /**
  57192. * Gets the output component
  57193. */
  57194. readonly output: NodeMaterialConnectionPoint;
  57195. protected _buildBlock(state: NodeMaterialBuildState): this;
  57196. }
  57197. }
  57198. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57199. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57200. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57201. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57202. /**
  57203. * Block used to get the min of 2 values
  57204. */
  57205. export class MinBlock extends NodeMaterialBlock {
  57206. /**
  57207. * Creates a new MinBlock
  57208. * @param name defines the block name
  57209. */
  57210. constructor(name: string);
  57211. /**
  57212. * Gets the current class name
  57213. * @returns the class name
  57214. */
  57215. getClassName(): string;
  57216. /**
  57217. * Gets the left operand input component
  57218. */
  57219. readonly left: NodeMaterialConnectionPoint;
  57220. /**
  57221. * Gets the right operand input component
  57222. */
  57223. readonly right: NodeMaterialConnectionPoint;
  57224. /**
  57225. * Gets the output component
  57226. */
  57227. readonly output: NodeMaterialConnectionPoint;
  57228. protected _buildBlock(state: NodeMaterialBuildState): this;
  57229. }
  57230. }
  57231. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57232. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57233. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57234. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57235. /**
  57236. * Block used to get the distance between 2 values
  57237. */
  57238. export class DistanceBlock extends NodeMaterialBlock {
  57239. /**
  57240. * Creates a new DistanceBlock
  57241. * @param name defines the block name
  57242. */
  57243. constructor(name: string);
  57244. /**
  57245. * Gets the current class name
  57246. * @returns the class name
  57247. */
  57248. getClassName(): string;
  57249. /**
  57250. * Gets the left operand input component
  57251. */
  57252. readonly left: NodeMaterialConnectionPoint;
  57253. /**
  57254. * Gets the right operand input component
  57255. */
  57256. readonly right: NodeMaterialConnectionPoint;
  57257. /**
  57258. * Gets the output component
  57259. */
  57260. readonly output: NodeMaterialConnectionPoint;
  57261. protected _buildBlock(state: NodeMaterialBuildState): this;
  57262. }
  57263. }
  57264. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57265. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57266. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57267. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57268. /**
  57269. * Block used to get the length of a vector
  57270. */
  57271. export class LengthBlock extends NodeMaterialBlock {
  57272. /**
  57273. * Creates a new LengthBlock
  57274. * @param name defines the block name
  57275. */
  57276. constructor(name: string);
  57277. /**
  57278. * Gets the current class name
  57279. * @returns the class name
  57280. */
  57281. getClassName(): string;
  57282. /**
  57283. * Gets the value input component
  57284. */
  57285. readonly value: NodeMaterialConnectionPoint;
  57286. /**
  57287. * Gets the output component
  57288. */
  57289. readonly output: NodeMaterialConnectionPoint;
  57290. protected _buildBlock(state: NodeMaterialBuildState): this;
  57291. }
  57292. }
  57293. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57294. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57295. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57296. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57297. /**
  57298. * Block used to get negative version of a value (i.e. x * -1)
  57299. */
  57300. export class NegateBlock extends NodeMaterialBlock {
  57301. /**
  57302. * Creates a new NegateBlock
  57303. * @param name defines the block name
  57304. */
  57305. constructor(name: string);
  57306. /**
  57307. * Gets the current class name
  57308. * @returns the class name
  57309. */
  57310. getClassName(): string;
  57311. /**
  57312. * Gets the value input component
  57313. */
  57314. readonly value: NodeMaterialConnectionPoint;
  57315. /**
  57316. * Gets the output component
  57317. */
  57318. readonly output: NodeMaterialConnectionPoint;
  57319. protected _buildBlock(state: NodeMaterialBuildState): this;
  57320. }
  57321. }
  57322. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57323. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57324. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57325. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57326. /**
  57327. * Block used to get the value of the first parameter raised to the power of the second
  57328. */
  57329. export class PowBlock extends NodeMaterialBlock {
  57330. /**
  57331. * Creates a new PowBlock
  57332. * @param name defines the block name
  57333. */
  57334. constructor(name: string);
  57335. /**
  57336. * Gets the current class name
  57337. * @returns the class name
  57338. */
  57339. getClassName(): string;
  57340. /**
  57341. * Gets the value operand input component
  57342. */
  57343. readonly value: NodeMaterialConnectionPoint;
  57344. /**
  57345. * Gets the power operand input component
  57346. */
  57347. readonly power: NodeMaterialConnectionPoint;
  57348. /**
  57349. * Gets the output component
  57350. */
  57351. readonly output: NodeMaterialConnectionPoint;
  57352. protected _buildBlock(state: NodeMaterialBuildState): this;
  57353. }
  57354. }
  57355. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57357. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57358. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57359. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57360. /**
  57361. * Block used to get a random number
  57362. */
  57363. export class RandomNumberBlock extends NodeMaterialBlock {
  57364. /**
  57365. * Creates a new RandomNumberBlock
  57366. * @param name defines the block name
  57367. */
  57368. constructor(name: string);
  57369. /**
  57370. * Gets the current class name
  57371. * @returns the class name
  57372. */
  57373. getClassName(): string;
  57374. /**
  57375. * Gets the seed input component
  57376. */
  57377. readonly seed: NodeMaterialConnectionPoint;
  57378. /**
  57379. * Gets the output component
  57380. */
  57381. readonly output: NodeMaterialConnectionPoint;
  57382. protected _buildBlock(state: NodeMaterialBuildState): this;
  57383. }
  57384. }
  57385. declare module "babylonjs/Materials/Node/Blocks/index" {
  57386. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  57387. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  57388. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  57389. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  57390. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  57391. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  57392. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  57393. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  57394. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  57395. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  57396. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  57397. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  57398. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57399. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57400. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57401. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57402. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57403. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57404. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57405. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57406. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57407. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57408. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  57409. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57410. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57411. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57412. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57413. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  57414. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  57415. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  57416. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  57417. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  57418. }
  57419. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57420. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57421. }
  57422. declare module "babylonjs/Materials/Node/index" {
  57423. export * from "babylonjs/Materials/Node/Enums/index";
  57424. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57425. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57426. export * from "babylonjs/Materials/Node/nodeMaterial";
  57427. export * from "babylonjs/Materials/Node/Blocks/index";
  57428. export * from "babylonjs/Materials/Node/Optimizers/index";
  57429. }
  57430. declare module "babylonjs/Materials/effectRenderer" {
  57431. import { Nullable } from "babylonjs/types";
  57432. import { Texture } from "babylonjs/Materials/Textures/texture";
  57433. import { Engine } from "babylonjs/Engines/engine";
  57434. import { Viewport } from "babylonjs/Maths/math.viewport";
  57435. import { Observable } from "babylonjs/Misc/observable";
  57436. import { Effect } from "babylonjs/Materials/effect";
  57437. import "babylonjs/Shaders/postprocess.vertex";
  57438. /**
  57439. * Effect Render Options
  57440. */
  57441. export interface IEffectRendererOptions {
  57442. /**
  57443. * Defines the vertices positions.
  57444. */
  57445. positions?: number[];
  57446. /**
  57447. * Defines the indices.
  57448. */
  57449. indices?: number[];
  57450. }
  57451. /**
  57452. * Helper class to render one or more effects
  57453. */
  57454. export class EffectRenderer {
  57455. private engine;
  57456. private static _DefaultOptions;
  57457. private _vertexBuffers;
  57458. private _indexBuffer;
  57459. private _ringBufferIndex;
  57460. private _ringScreenBuffer;
  57461. private _fullscreenViewport;
  57462. private _getNextFrameBuffer;
  57463. /**
  57464. * Creates an effect renderer
  57465. * @param engine the engine to use for rendering
  57466. * @param options defines the options of the effect renderer
  57467. */
  57468. constructor(engine: Engine, options?: IEffectRendererOptions);
  57469. /**
  57470. * Sets the current viewport in normalized coordinates 0-1
  57471. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57472. */
  57473. setViewport(viewport?: Viewport): void;
  57474. /**
  57475. * Binds the embedded attributes buffer to the effect.
  57476. * @param effect Defines the effect to bind the attributes for
  57477. */
  57478. bindBuffers(effect: Effect): void;
  57479. /**
  57480. * Sets the current effect wrapper to use during draw.
  57481. * The effect needs to be ready before calling this api.
  57482. * This also sets the default full screen position attribute.
  57483. * @param effectWrapper Defines the effect to draw with
  57484. */
  57485. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57486. /**
  57487. * Draws a full screen quad.
  57488. */
  57489. draw(): void;
  57490. /**
  57491. * renders one or more effects to a specified texture
  57492. * @param effectWrappers list of effects to renderer
  57493. * @param outputTexture texture to draw to, if null it will render to the screen
  57494. */
  57495. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57496. /**
  57497. * Disposes of the effect renderer
  57498. */
  57499. dispose(): void;
  57500. }
  57501. /**
  57502. * Options to create an EffectWrapper
  57503. */
  57504. interface EffectWrapperCreationOptions {
  57505. /**
  57506. * Engine to use to create the effect
  57507. */
  57508. engine: Engine;
  57509. /**
  57510. * Fragment shader for the effect
  57511. */
  57512. fragmentShader: string;
  57513. /**
  57514. * Vertex shader for the effect
  57515. */
  57516. vertexShader?: string;
  57517. /**
  57518. * Attributes to use in the shader
  57519. */
  57520. attributeNames?: Array<string>;
  57521. /**
  57522. * Uniforms to use in the shader
  57523. */
  57524. uniformNames?: Array<string>;
  57525. /**
  57526. * Texture sampler names to use in the shader
  57527. */
  57528. samplerNames?: Array<string>;
  57529. /**
  57530. * The friendly name of the effect displayed in Spector.
  57531. */
  57532. name?: string;
  57533. }
  57534. /**
  57535. * Wraps an effect to be used for rendering
  57536. */
  57537. export class EffectWrapper {
  57538. /**
  57539. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57540. */
  57541. onApplyObservable: Observable<{}>;
  57542. /**
  57543. * The underlying effect
  57544. */
  57545. effect: Effect;
  57546. /**
  57547. * Creates an effect to be renderer
  57548. * @param creationOptions options to create the effect
  57549. */
  57550. constructor(creationOptions: EffectWrapperCreationOptions);
  57551. /**
  57552. * Disposes of the effect wrapper
  57553. */
  57554. dispose(): void;
  57555. }
  57556. }
  57557. declare module "babylonjs/Materials/index" {
  57558. export * from "babylonjs/Materials/Background/index";
  57559. export * from "babylonjs/Materials/colorCurves";
  57560. export * from "babylonjs/Materials/effect";
  57561. export * from "babylonjs/Materials/fresnelParameters";
  57562. export * from "babylonjs/Materials/imageProcessingConfiguration";
  57563. export * from "babylonjs/Materials/material";
  57564. export * from "babylonjs/Materials/materialDefines";
  57565. export * from "babylonjs/Materials/materialHelper";
  57566. export * from "babylonjs/Materials/multiMaterial";
  57567. export * from "babylonjs/Materials/PBR/index";
  57568. export * from "babylonjs/Materials/pushMaterial";
  57569. export * from "babylonjs/Materials/shaderMaterial";
  57570. export * from "babylonjs/Materials/standardMaterial";
  57571. export * from "babylonjs/Materials/Textures/index";
  57572. export * from "babylonjs/Materials/uniformBuffer";
  57573. export * from "babylonjs/Materials/materialFlags";
  57574. export * from "babylonjs/Materials/Node/index";
  57575. export * from "babylonjs/Materials/effectRenderer";
  57576. }
  57577. declare module "babylonjs/Maths/index" {
  57578. export * from "babylonjs/Maths/math.scalar";
  57579. export * from "babylonjs/Maths/math";
  57580. export * from "babylonjs/Maths/sphericalPolynomial";
  57581. }
  57582. declare module "babylonjs/Misc/workerPool" {
  57583. import { IDisposable } from "babylonjs/scene";
  57584. /**
  57585. * Helper class to push actions to a pool of workers.
  57586. */
  57587. export class WorkerPool implements IDisposable {
  57588. private _workerInfos;
  57589. private _pendingActions;
  57590. /**
  57591. * Constructor
  57592. * @param workers Array of workers to use for actions
  57593. */
  57594. constructor(workers: Array<Worker>);
  57595. /**
  57596. * Terminates all workers and clears any pending actions.
  57597. */
  57598. dispose(): void;
  57599. /**
  57600. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57601. * pended until a worker has completed its action.
  57602. * @param action The action to perform. Call onComplete when the action is complete.
  57603. */
  57604. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57605. private _execute;
  57606. }
  57607. }
  57608. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  57609. import { IDisposable } from "babylonjs/scene";
  57610. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57611. /**
  57612. * Configuration for Draco compression
  57613. */
  57614. export interface IDracoCompressionConfiguration {
  57615. /**
  57616. * Configuration for the decoder.
  57617. */
  57618. decoder: {
  57619. /**
  57620. * The url to the WebAssembly module.
  57621. */
  57622. wasmUrl?: string;
  57623. /**
  57624. * The url to the WebAssembly binary.
  57625. */
  57626. wasmBinaryUrl?: string;
  57627. /**
  57628. * The url to the fallback JavaScript module.
  57629. */
  57630. fallbackUrl?: string;
  57631. };
  57632. }
  57633. /**
  57634. * Draco compression (https://google.github.io/draco/)
  57635. *
  57636. * This class wraps the Draco module.
  57637. *
  57638. * **Encoder**
  57639. *
  57640. * The encoder is not currently implemented.
  57641. *
  57642. * **Decoder**
  57643. *
  57644. * 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.
  57645. *
  57646. * To update the configuration, use the following code:
  57647. * ```javascript
  57648. * DracoCompression.Configuration = {
  57649. * decoder: {
  57650. * wasmUrl: "<url to the WebAssembly library>",
  57651. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57652. * fallbackUrl: "<url to the fallback JavaScript library>",
  57653. * }
  57654. * };
  57655. * ```
  57656. *
  57657. * 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.
  57658. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57659. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57660. *
  57661. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57662. * ```javascript
  57663. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57664. * ```
  57665. *
  57666. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57667. */
  57668. export class DracoCompression implements IDisposable {
  57669. private _workerPoolPromise?;
  57670. private _decoderModulePromise?;
  57671. /**
  57672. * The configuration. Defaults to the following urls:
  57673. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57674. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57675. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57676. */
  57677. static Configuration: IDracoCompressionConfiguration;
  57678. /**
  57679. * Returns true if the decoder configuration is available.
  57680. */
  57681. static readonly DecoderAvailable: boolean;
  57682. /**
  57683. * Default number of workers to create when creating the draco compression object.
  57684. */
  57685. static DefaultNumWorkers: number;
  57686. private static GetDefaultNumWorkers;
  57687. private static _Default;
  57688. /**
  57689. * Default instance for the draco compression object.
  57690. */
  57691. static readonly Default: DracoCompression;
  57692. /**
  57693. * Constructor
  57694. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57695. */
  57696. constructor(numWorkers?: number);
  57697. /**
  57698. * Stop all async operations and release resources.
  57699. */
  57700. dispose(): void;
  57701. /**
  57702. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57703. * @returns a promise that resolves when ready
  57704. */
  57705. whenReadyAsync(): Promise<void>;
  57706. /**
  57707. * Decode Draco compressed mesh data to vertex data.
  57708. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57709. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57710. * @returns A promise that resolves with the decoded vertex data
  57711. */
  57712. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57713. [kind: string]: number;
  57714. }): Promise<VertexData>;
  57715. }
  57716. }
  57717. declare module "babylonjs/Meshes/Compression/index" {
  57718. export * from "babylonjs/Meshes/Compression/dracoCompression";
  57719. }
  57720. declare module "babylonjs/Meshes/csg" {
  57721. import { Nullable } from "babylonjs/types";
  57722. import { Scene } from "babylonjs/scene";
  57723. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57724. import { Mesh } from "babylonjs/Meshes/mesh";
  57725. import { Material } from "babylonjs/Materials/material";
  57726. /**
  57727. * Class for building Constructive Solid Geometry
  57728. */
  57729. export class CSG {
  57730. private polygons;
  57731. /**
  57732. * The world matrix
  57733. */
  57734. matrix: Matrix;
  57735. /**
  57736. * Stores the position
  57737. */
  57738. position: Vector3;
  57739. /**
  57740. * Stores the rotation
  57741. */
  57742. rotation: Vector3;
  57743. /**
  57744. * Stores the rotation quaternion
  57745. */
  57746. rotationQuaternion: Nullable<Quaternion>;
  57747. /**
  57748. * Stores the scaling vector
  57749. */
  57750. scaling: Vector3;
  57751. /**
  57752. * Convert the Mesh to CSG
  57753. * @param mesh The Mesh to convert to CSG
  57754. * @returns A new CSG from the Mesh
  57755. */
  57756. static FromMesh(mesh: Mesh): CSG;
  57757. /**
  57758. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57759. * @param polygons Polygons used to construct a CSG solid
  57760. */
  57761. private static FromPolygons;
  57762. /**
  57763. * Clones, or makes a deep copy, of the CSG
  57764. * @returns A new CSG
  57765. */
  57766. clone(): CSG;
  57767. /**
  57768. * Unions this CSG with another CSG
  57769. * @param csg The CSG to union against this CSG
  57770. * @returns The unioned CSG
  57771. */
  57772. union(csg: CSG): CSG;
  57773. /**
  57774. * Unions this CSG with another CSG in place
  57775. * @param csg The CSG to union against this CSG
  57776. */
  57777. unionInPlace(csg: CSG): void;
  57778. /**
  57779. * Subtracts this CSG with another CSG
  57780. * @param csg The CSG to subtract against this CSG
  57781. * @returns A new CSG
  57782. */
  57783. subtract(csg: CSG): CSG;
  57784. /**
  57785. * Subtracts this CSG with another CSG in place
  57786. * @param csg The CSG to subtact against this CSG
  57787. */
  57788. subtractInPlace(csg: CSG): void;
  57789. /**
  57790. * Intersect this CSG with another CSG
  57791. * @param csg The CSG to intersect against this CSG
  57792. * @returns A new CSG
  57793. */
  57794. intersect(csg: CSG): CSG;
  57795. /**
  57796. * Intersects this CSG with another CSG in place
  57797. * @param csg The CSG to intersect against this CSG
  57798. */
  57799. intersectInPlace(csg: CSG): void;
  57800. /**
  57801. * Return a new CSG solid with solid and empty space switched. This solid is
  57802. * not modified.
  57803. * @returns A new CSG solid with solid and empty space switched
  57804. */
  57805. inverse(): CSG;
  57806. /**
  57807. * Inverses the CSG in place
  57808. */
  57809. inverseInPlace(): void;
  57810. /**
  57811. * This is used to keep meshes transformations so they can be restored
  57812. * when we build back a Babylon Mesh
  57813. * NB : All CSG operations are performed in world coordinates
  57814. * @param csg The CSG to copy the transform attributes from
  57815. * @returns This CSG
  57816. */
  57817. copyTransformAttributes(csg: CSG): CSG;
  57818. /**
  57819. * Build Raw mesh from CSG
  57820. * Coordinates here are in world space
  57821. * @param name The name of the mesh geometry
  57822. * @param scene The Scene
  57823. * @param keepSubMeshes Specifies if the submeshes should be kept
  57824. * @returns A new Mesh
  57825. */
  57826. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57827. /**
  57828. * Build Mesh from CSG taking material and transforms into account
  57829. * @param name The name of the Mesh
  57830. * @param material The material of the Mesh
  57831. * @param scene The Scene
  57832. * @param keepSubMeshes Specifies if submeshes should be kept
  57833. * @returns The new Mesh
  57834. */
  57835. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57836. }
  57837. }
  57838. declare module "babylonjs/Meshes/trailMesh" {
  57839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57840. import { Mesh } from "babylonjs/Meshes/mesh";
  57841. import { Scene } from "babylonjs/scene";
  57842. /**
  57843. * Class used to create a trail following a mesh
  57844. */
  57845. export class TrailMesh extends Mesh {
  57846. private _generator;
  57847. private _autoStart;
  57848. private _running;
  57849. private _diameter;
  57850. private _length;
  57851. private _sectionPolygonPointsCount;
  57852. private _sectionVectors;
  57853. private _sectionNormalVectors;
  57854. private _beforeRenderObserver;
  57855. /**
  57856. * @constructor
  57857. * @param name The value used by scene.getMeshByName() to do a lookup.
  57858. * @param generator The mesh to generate a trail.
  57859. * @param scene The scene to add this mesh to.
  57860. * @param diameter Diameter of trailing mesh. Default is 1.
  57861. * @param length Length of trailing mesh. Default is 60.
  57862. * @param autoStart Automatically start trailing mesh. Default true.
  57863. */
  57864. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57865. /**
  57866. * "TrailMesh"
  57867. * @returns "TrailMesh"
  57868. */
  57869. getClassName(): string;
  57870. private _createMesh;
  57871. /**
  57872. * Start trailing mesh.
  57873. */
  57874. start(): void;
  57875. /**
  57876. * Stop trailing mesh.
  57877. */
  57878. stop(): void;
  57879. /**
  57880. * Update trailing mesh geometry.
  57881. */
  57882. update(): void;
  57883. /**
  57884. * Returns a new TrailMesh object.
  57885. * @param name is a string, the name given to the new mesh
  57886. * @param newGenerator use new generator object for cloned trail mesh
  57887. * @returns a new mesh
  57888. */
  57889. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57890. /**
  57891. * Serializes this trail mesh
  57892. * @param serializationObject object to write serialization to
  57893. */
  57894. serialize(serializationObject: any): void;
  57895. /**
  57896. * Parses a serialized trail mesh
  57897. * @param parsedMesh the serialized mesh
  57898. * @param scene the scene to create the trail mesh in
  57899. * @returns the created trail mesh
  57900. */
  57901. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57902. }
  57903. }
  57904. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  57905. import { Nullable } from "babylonjs/types";
  57906. import { Scene } from "babylonjs/scene";
  57907. import { Vector4 } from "babylonjs/Maths/math.vector";
  57908. import { Color4 } from "babylonjs/Maths/math.color";
  57909. import { Mesh } from "babylonjs/Meshes/mesh";
  57910. /**
  57911. * Class containing static functions to help procedurally build meshes
  57912. */
  57913. export class TiledBoxBuilder {
  57914. /**
  57915. * Creates a box mesh
  57916. * 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)
  57917. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57919. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57921. * @param name defines the name of the mesh
  57922. * @param options defines the options used to create the mesh
  57923. * @param scene defines the hosting scene
  57924. * @returns the box mesh
  57925. */
  57926. static CreateTiledBox(name: string, options: {
  57927. pattern?: number;
  57928. width?: number;
  57929. height?: number;
  57930. depth?: number;
  57931. tileSize?: number;
  57932. tileWidth?: number;
  57933. tileHeight?: number;
  57934. alignHorizontal?: number;
  57935. alignVertical?: number;
  57936. faceUV?: Vector4[];
  57937. faceColors?: Color4[];
  57938. sideOrientation?: number;
  57939. updatable?: boolean;
  57940. }, scene?: Nullable<Scene>): Mesh;
  57941. }
  57942. }
  57943. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57944. import { Vector4 } from "babylonjs/Maths/math.vector";
  57945. import { Mesh } from "babylonjs/Meshes/mesh";
  57946. /**
  57947. * Class containing static functions to help procedurally build meshes
  57948. */
  57949. export class TorusKnotBuilder {
  57950. /**
  57951. * Creates a torus knot mesh
  57952. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57953. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57954. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57955. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57959. * @param name defines the name of the mesh
  57960. * @param options defines the options used to create the mesh
  57961. * @param scene defines the hosting scene
  57962. * @returns the torus knot mesh
  57963. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57964. */
  57965. static CreateTorusKnot(name: string, options: {
  57966. radius?: number;
  57967. tube?: number;
  57968. radialSegments?: number;
  57969. tubularSegments?: number;
  57970. p?: number;
  57971. q?: number;
  57972. updatable?: boolean;
  57973. sideOrientation?: number;
  57974. frontUVs?: Vector4;
  57975. backUVs?: Vector4;
  57976. }, scene: any): Mesh;
  57977. }
  57978. }
  57979. declare module "babylonjs/Meshes/polygonMesh" {
  57980. import { Scene } from "babylonjs/scene";
  57981. import { Vector2 } from "babylonjs/Maths/math.vector";
  57982. import { Mesh } from "babylonjs/Meshes/mesh";
  57983. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57984. import { Path2 } from "babylonjs/Maths/math.path";
  57985. /**
  57986. * Polygon
  57987. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57988. */
  57989. export class Polygon {
  57990. /**
  57991. * Creates a rectangle
  57992. * @param xmin bottom X coord
  57993. * @param ymin bottom Y coord
  57994. * @param xmax top X coord
  57995. * @param ymax top Y coord
  57996. * @returns points that make the resulting rectation
  57997. */
  57998. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57999. /**
  58000. * Creates a circle
  58001. * @param radius radius of circle
  58002. * @param cx scale in x
  58003. * @param cy scale in y
  58004. * @param numberOfSides number of sides that make up the circle
  58005. * @returns points that make the resulting circle
  58006. */
  58007. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58008. /**
  58009. * Creates a polygon from input string
  58010. * @param input Input polygon data
  58011. * @returns the parsed points
  58012. */
  58013. static Parse(input: string): Vector2[];
  58014. /**
  58015. * Starts building a polygon from x and y coordinates
  58016. * @param x x coordinate
  58017. * @param y y coordinate
  58018. * @returns the started path2
  58019. */
  58020. static StartingAt(x: number, y: number): Path2;
  58021. }
  58022. /**
  58023. * Builds a polygon
  58024. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58025. */
  58026. export class PolygonMeshBuilder {
  58027. private _points;
  58028. private _outlinepoints;
  58029. private _holes;
  58030. private _name;
  58031. private _scene;
  58032. private _epoints;
  58033. private _eholes;
  58034. private _addToepoint;
  58035. /**
  58036. * Babylon reference to the earcut plugin.
  58037. */
  58038. bjsEarcut: any;
  58039. /**
  58040. * Creates a PolygonMeshBuilder
  58041. * @param name name of the builder
  58042. * @param contours Path of the polygon
  58043. * @param scene scene to add to when creating the mesh
  58044. * @param earcutInjection can be used to inject your own earcut reference
  58045. */
  58046. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58047. /**
  58048. * Adds a whole within the polygon
  58049. * @param hole Array of points defining the hole
  58050. * @returns this
  58051. */
  58052. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58053. /**
  58054. * Creates the polygon
  58055. * @param updatable If the mesh should be updatable
  58056. * @param depth The depth of the mesh created
  58057. * @returns the created mesh
  58058. */
  58059. build(updatable?: boolean, depth?: number): Mesh;
  58060. /**
  58061. * Creates the polygon
  58062. * @param depth The depth of the mesh created
  58063. * @returns the created VertexData
  58064. */
  58065. buildVertexData(depth?: number): VertexData;
  58066. /**
  58067. * Adds a side to the polygon
  58068. * @param positions points that make the polygon
  58069. * @param normals normals of the polygon
  58070. * @param uvs uvs of the polygon
  58071. * @param indices indices of the polygon
  58072. * @param bounds bounds of the polygon
  58073. * @param points points of the polygon
  58074. * @param depth depth of the polygon
  58075. * @param flip flip of the polygon
  58076. */
  58077. private addSide;
  58078. }
  58079. }
  58080. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  58081. import { Scene } from "babylonjs/scene";
  58082. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58083. import { Color4 } from "babylonjs/Maths/math.color";
  58084. import { Mesh } from "babylonjs/Meshes/mesh";
  58085. import { Nullable } from "babylonjs/types";
  58086. /**
  58087. * Class containing static functions to help procedurally build meshes
  58088. */
  58089. export class PolygonBuilder {
  58090. /**
  58091. * Creates a polygon mesh
  58092. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58093. * * 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
  58094. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58097. * * Remember you can only change the shape positions, not their number when updating a polygon
  58098. * @param name defines the name of the mesh
  58099. * @param options defines the options used to create the mesh
  58100. * @param scene defines the hosting scene
  58101. * @param earcutInjection can be used to inject your own earcut reference
  58102. * @returns the polygon mesh
  58103. */
  58104. static CreatePolygon(name: string, options: {
  58105. shape: Vector3[];
  58106. holes?: Vector3[][];
  58107. depth?: number;
  58108. faceUV?: Vector4[];
  58109. faceColors?: Color4[];
  58110. updatable?: boolean;
  58111. sideOrientation?: number;
  58112. frontUVs?: Vector4;
  58113. backUVs?: Vector4;
  58114. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58115. /**
  58116. * Creates an extruded polygon mesh, with depth in the Y direction.
  58117. * * 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)
  58118. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58119. * @param name defines the name of the mesh
  58120. * @param options defines the options used to create the mesh
  58121. * @param scene defines the hosting scene
  58122. * @param earcutInjection can be used to inject your own earcut reference
  58123. * @returns the polygon mesh
  58124. */
  58125. static ExtrudePolygon(name: string, options: {
  58126. shape: Vector3[];
  58127. holes?: Vector3[][];
  58128. depth?: number;
  58129. faceUV?: Vector4[];
  58130. faceColors?: Color4[];
  58131. updatable?: boolean;
  58132. sideOrientation?: number;
  58133. frontUVs?: Vector4;
  58134. backUVs?: Vector4;
  58135. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58136. }
  58137. }
  58138. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58139. import { Scene } from "babylonjs/scene";
  58140. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58141. import { Mesh } from "babylonjs/Meshes/mesh";
  58142. import { Nullable } from "babylonjs/types";
  58143. /**
  58144. * Class containing static functions to help procedurally build meshes
  58145. */
  58146. export class LatheBuilder {
  58147. /**
  58148. * Creates lathe mesh.
  58149. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58150. * * 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
  58151. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58152. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58153. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58154. * * 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
  58155. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58156. * * 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
  58157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58159. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58161. * @param name defines the name of the mesh
  58162. * @param options defines the options used to create the mesh
  58163. * @param scene defines the hosting scene
  58164. * @returns the lathe mesh
  58165. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58166. */
  58167. static CreateLathe(name: string, options: {
  58168. shape: Vector3[];
  58169. radius?: number;
  58170. tessellation?: number;
  58171. clip?: number;
  58172. arc?: number;
  58173. closed?: boolean;
  58174. updatable?: boolean;
  58175. sideOrientation?: number;
  58176. frontUVs?: Vector4;
  58177. backUVs?: Vector4;
  58178. cap?: number;
  58179. invertUV?: boolean;
  58180. }, scene?: Nullable<Scene>): Mesh;
  58181. }
  58182. }
  58183. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58184. import { Nullable } from "babylonjs/types";
  58185. import { Scene } from "babylonjs/scene";
  58186. import { Vector4 } from "babylonjs/Maths/math.vector";
  58187. import { Mesh } from "babylonjs/Meshes/mesh";
  58188. /**
  58189. * Class containing static functions to help procedurally build meshes
  58190. */
  58191. export class TiledPlaneBuilder {
  58192. /**
  58193. * Creates a tiled plane mesh
  58194. * * The parameter `pattern` will, depending on value, do nothing or
  58195. * * * flip (reflect about central vertical) alternate tiles across and up
  58196. * * * flip every tile on alternate rows
  58197. * * * rotate (180 degs) alternate tiles across and up
  58198. * * * rotate every tile on alternate rows
  58199. * * * flip and rotate alternate tiles across and up
  58200. * * * flip and rotate every tile on alternate rows
  58201. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58202. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58204. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58205. * * 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)
  58206. * * 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)
  58207. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58208. * @param name defines the name of the mesh
  58209. * @param options defines the options used to create the mesh
  58210. * @param scene defines the hosting scene
  58211. * @returns the box mesh
  58212. */
  58213. static CreateTiledPlane(name: string, options: {
  58214. pattern?: number;
  58215. tileSize?: number;
  58216. tileWidth?: number;
  58217. tileHeight?: number;
  58218. size?: number;
  58219. width?: number;
  58220. height?: number;
  58221. alignHorizontal?: number;
  58222. alignVertical?: number;
  58223. sideOrientation?: number;
  58224. frontUVs?: Vector4;
  58225. backUVs?: Vector4;
  58226. updatable?: boolean;
  58227. }, scene?: Nullable<Scene>): Mesh;
  58228. }
  58229. }
  58230. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  58231. import { Nullable } from "babylonjs/types";
  58232. import { Scene } from "babylonjs/scene";
  58233. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58234. import { Mesh } from "babylonjs/Meshes/mesh";
  58235. /**
  58236. * Class containing static functions to help procedurally build meshes
  58237. */
  58238. export class TubeBuilder {
  58239. /**
  58240. * Creates a tube mesh.
  58241. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58242. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58243. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58244. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58245. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58246. * * 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)
  58247. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58248. * * 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
  58249. * * 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
  58250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58252. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58254. * @param name defines the name of the mesh
  58255. * @param options defines the options used to create the mesh
  58256. * @param scene defines the hosting scene
  58257. * @returns the tube mesh
  58258. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58259. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58260. */
  58261. static CreateTube(name: string, options: {
  58262. path: Vector3[];
  58263. radius?: number;
  58264. tessellation?: number;
  58265. radiusFunction?: {
  58266. (i: number, distance: number): number;
  58267. };
  58268. cap?: number;
  58269. arc?: number;
  58270. updatable?: boolean;
  58271. sideOrientation?: number;
  58272. frontUVs?: Vector4;
  58273. backUVs?: Vector4;
  58274. instance?: Mesh;
  58275. invertUV?: boolean;
  58276. }, scene?: Nullable<Scene>): Mesh;
  58277. }
  58278. }
  58279. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  58280. import { Scene } from "babylonjs/scene";
  58281. import { Vector4 } from "babylonjs/Maths/math.vector";
  58282. import { Mesh } from "babylonjs/Meshes/mesh";
  58283. import { Nullable } from "babylonjs/types";
  58284. /**
  58285. * Class containing static functions to help procedurally build meshes
  58286. */
  58287. export class IcoSphereBuilder {
  58288. /**
  58289. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58290. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58291. * * 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`)
  58292. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58293. * * 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
  58294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58297. * @param name defines the name of the mesh
  58298. * @param options defines the options used to create the mesh
  58299. * @param scene defines the hosting scene
  58300. * @returns the icosahedron mesh
  58301. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58302. */
  58303. static CreateIcoSphere(name: string, options: {
  58304. radius?: number;
  58305. radiusX?: number;
  58306. radiusY?: number;
  58307. radiusZ?: number;
  58308. flat?: boolean;
  58309. subdivisions?: number;
  58310. sideOrientation?: number;
  58311. frontUVs?: Vector4;
  58312. backUVs?: Vector4;
  58313. updatable?: boolean;
  58314. }, scene?: Nullable<Scene>): Mesh;
  58315. }
  58316. }
  58317. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  58318. import { Vector3 } from "babylonjs/Maths/math.vector";
  58319. import { Mesh } from "babylonjs/Meshes/mesh";
  58320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58321. /**
  58322. * Class containing static functions to help procedurally build meshes
  58323. */
  58324. export class DecalBuilder {
  58325. /**
  58326. * Creates a decal mesh.
  58327. * 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
  58328. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58329. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58330. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58331. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58332. * @param name defines the name of the mesh
  58333. * @param sourceMesh defines the mesh where the decal must be applied
  58334. * @param options defines the options used to create the mesh
  58335. * @param scene defines the hosting scene
  58336. * @returns the decal mesh
  58337. * @see https://doc.babylonjs.com/how_to/decals
  58338. */
  58339. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58340. position?: Vector3;
  58341. normal?: Vector3;
  58342. size?: Vector3;
  58343. angle?: number;
  58344. }): Mesh;
  58345. }
  58346. }
  58347. declare module "babylonjs/Meshes/meshBuilder" {
  58348. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  58349. import { Nullable } from "babylonjs/types";
  58350. import { Scene } from "babylonjs/scene";
  58351. import { Mesh } from "babylonjs/Meshes/mesh";
  58352. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58353. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  58354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58355. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58356. import { Plane } from "babylonjs/Maths/math.plane";
  58357. /**
  58358. * Class containing static functions to help procedurally build meshes
  58359. */
  58360. export class MeshBuilder {
  58361. /**
  58362. * Creates a box mesh
  58363. * * The parameter `size` sets the size (float) of each box side (default 1)
  58364. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58365. * * 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)
  58366. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58370. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58371. * @param name defines the name of the mesh
  58372. * @param options defines the options used to create the mesh
  58373. * @param scene defines the hosting scene
  58374. * @returns the box mesh
  58375. */
  58376. static CreateBox(name: string, options: {
  58377. size?: number;
  58378. width?: number;
  58379. height?: number;
  58380. depth?: number;
  58381. faceUV?: Vector4[];
  58382. faceColors?: Color4[];
  58383. sideOrientation?: number;
  58384. frontUVs?: Vector4;
  58385. backUVs?: Vector4;
  58386. updatable?: boolean;
  58387. }, scene?: Nullable<Scene>): Mesh;
  58388. /**
  58389. * Creates a tiled box mesh
  58390. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58392. * @param name defines the name of the mesh
  58393. * @param options defines the options used to create the mesh
  58394. * @param scene defines the hosting scene
  58395. * @returns the tiled box mesh
  58396. */
  58397. static CreateTiledBox(name: string, options: {
  58398. pattern?: number;
  58399. size?: number;
  58400. width?: number;
  58401. height?: number;
  58402. depth: number;
  58403. tileSize?: number;
  58404. tileWidth?: number;
  58405. tileHeight?: number;
  58406. faceUV?: Vector4[];
  58407. faceColors?: Color4[];
  58408. alignHorizontal?: number;
  58409. alignVertical?: number;
  58410. sideOrientation?: number;
  58411. updatable?: boolean;
  58412. }, scene?: Nullable<Scene>): Mesh;
  58413. /**
  58414. * Creates a sphere mesh
  58415. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58416. * * 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`)
  58417. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58418. * * 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
  58419. * * 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)
  58420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58423. * @param name defines the name of the mesh
  58424. * @param options defines the options used to create the mesh
  58425. * @param scene defines the hosting scene
  58426. * @returns the sphere mesh
  58427. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58428. */
  58429. static CreateSphere(name: string, options: {
  58430. segments?: number;
  58431. diameter?: number;
  58432. diameterX?: number;
  58433. diameterY?: number;
  58434. diameterZ?: number;
  58435. arc?: number;
  58436. slice?: number;
  58437. sideOrientation?: number;
  58438. frontUVs?: Vector4;
  58439. backUVs?: Vector4;
  58440. updatable?: boolean;
  58441. }, scene?: Nullable<Scene>): Mesh;
  58442. /**
  58443. * Creates a plane polygonal mesh. By default, this is a disc
  58444. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58445. * * 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
  58446. * * 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
  58447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58450. * @param name defines the name of the mesh
  58451. * @param options defines the options used to create the mesh
  58452. * @param scene defines the hosting scene
  58453. * @returns the plane polygonal mesh
  58454. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58455. */
  58456. static CreateDisc(name: string, options: {
  58457. radius?: number;
  58458. tessellation?: number;
  58459. arc?: number;
  58460. updatable?: boolean;
  58461. sideOrientation?: number;
  58462. frontUVs?: Vector4;
  58463. backUVs?: Vector4;
  58464. }, scene?: Nullable<Scene>): Mesh;
  58465. /**
  58466. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58467. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58468. * * 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`)
  58469. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58470. * * 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
  58471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58474. * @param name defines the name of the mesh
  58475. * @param options defines the options used to create the mesh
  58476. * @param scene defines the hosting scene
  58477. * @returns the icosahedron mesh
  58478. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58479. */
  58480. static CreateIcoSphere(name: string, options: {
  58481. radius?: number;
  58482. radiusX?: number;
  58483. radiusY?: number;
  58484. radiusZ?: number;
  58485. flat?: boolean;
  58486. subdivisions?: number;
  58487. sideOrientation?: number;
  58488. frontUVs?: Vector4;
  58489. backUVs?: Vector4;
  58490. updatable?: boolean;
  58491. }, scene?: Nullable<Scene>): Mesh;
  58492. /**
  58493. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58494. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58495. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58496. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58497. * * 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
  58498. * * 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
  58499. * * 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
  58500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58502. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58503. * * 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
  58504. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58505. * * 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
  58506. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58508. * @param name defines the name of the mesh
  58509. * @param options defines the options used to create the mesh
  58510. * @param scene defines the hosting scene
  58511. * @returns the ribbon mesh
  58512. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58513. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58514. */
  58515. static CreateRibbon(name: string, options: {
  58516. pathArray: Vector3[][];
  58517. closeArray?: boolean;
  58518. closePath?: boolean;
  58519. offset?: number;
  58520. updatable?: boolean;
  58521. sideOrientation?: number;
  58522. frontUVs?: Vector4;
  58523. backUVs?: Vector4;
  58524. instance?: Mesh;
  58525. invertUV?: boolean;
  58526. uvs?: Vector2[];
  58527. colors?: Color4[];
  58528. }, scene?: Nullable<Scene>): Mesh;
  58529. /**
  58530. * Creates a cylinder or a cone mesh
  58531. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58532. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58533. * * 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.
  58534. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58535. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58536. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58537. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58538. * * 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).
  58539. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58540. * * 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).
  58541. * * 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
  58542. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58543. * * 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
  58544. * * 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.
  58545. * * If `enclose` is false, a ring surface is one element.
  58546. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58547. * * 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
  58548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58551. * @param name defines the name of the mesh
  58552. * @param options defines the options used to create the mesh
  58553. * @param scene defines the hosting scene
  58554. * @returns the cylinder mesh
  58555. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58556. */
  58557. static CreateCylinder(name: string, options: {
  58558. height?: number;
  58559. diameterTop?: number;
  58560. diameterBottom?: number;
  58561. diameter?: number;
  58562. tessellation?: number;
  58563. subdivisions?: number;
  58564. arc?: number;
  58565. faceColors?: Color4[];
  58566. faceUV?: Vector4[];
  58567. updatable?: boolean;
  58568. hasRings?: boolean;
  58569. enclose?: boolean;
  58570. cap?: number;
  58571. sideOrientation?: number;
  58572. frontUVs?: Vector4;
  58573. backUVs?: Vector4;
  58574. }, scene?: Nullable<Scene>): Mesh;
  58575. /**
  58576. * Creates a torus mesh
  58577. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58578. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58579. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58581. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58583. * @param name defines the name of the mesh
  58584. * @param options defines the options used to create the mesh
  58585. * @param scene defines the hosting scene
  58586. * @returns the torus mesh
  58587. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58588. */
  58589. static CreateTorus(name: string, options: {
  58590. diameter?: number;
  58591. thickness?: number;
  58592. tessellation?: number;
  58593. updatable?: boolean;
  58594. sideOrientation?: number;
  58595. frontUVs?: Vector4;
  58596. backUVs?: Vector4;
  58597. }, scene?: Nullable<Scene>): Mesh;
  58598. /**
  58599. * Creates a torus knot mesh
  58600. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58601. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58602. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58603. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58607. * @param name defines the name of the mesh
  58608. * @param options defines the options used to create the mesh
  58609. * @param scene defines the hosting scene
  58610. * @returns the torus knot mesh
  58611. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58612. */
  58613. static CreateTorusKnot(name: string, options: {
  58614. radius?: number;
  58615. tube?: number;
  58616. radialSegments?: number;
  58617. tubularSegments?: number;
  58618. p?: number;
  58619. q?: number;
  58620. updatable?: boolean;
  58621. sideOrientation?: number;
  58622. frontUVs?: Vector4;
  58623. backUVs?: Vector4;
  58624. }, scene?: Nullable<Scene>): Mesh;
  58625. /**
  58626. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58627. * * 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
  58628. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58629. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58630. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58631. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58632. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58633. * * 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
  58634. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58637. * @param name defines the name of the new line system
  58638. * @param options defines the options used to create the line system
  58639. * @param scene defines the hosting scene
  58640. * @returns a new line system mesh
  58641. */
  58642. static CreateLineSystem(name: string, options: {
  58643. lines: Vector3[][];
  58644. updatable?: boolean;
  58645. instance?: Nullable<LinesMesh>;
  58646. colors?: Nullable<Color4[][]>;
  58647. useVertexAlpha?: boolean;
  58648. }, scene: Nullable<Scene>): LinesMesh;
  58649. /**
  58650. * Creates a line mesh
  58651. * 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
  58652. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58653. * * The parameter `points` is an array successive Vector3
  58654. * * 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
  58655. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58656. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58657. * * When updating an instance, remember that only point positions can change, not the number of points
  58658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58659. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58660. * @param name defines the name of the new line system
  58661. * @param options defines the options used to create the line system
  58662. * @param scene defines the hosting scene
  58663. * @returns a new line mesh
  58664. */
  58665. static CreateLines(name: string, options: {
  58666. points: Vector3[];
  58667. updatable?: boolean;
  58668. instance?: Nullable<LinesMesh>;
  58669. colors?: Color4[];
  58670. useVertexAlpha?: boolean;
  58671. }, scene?: Nullable<Scene>): LinesMesh;
  58672. /**
  58673. * Creates a dashed line mesh
  58674. * * 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
  58675. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58676. * * The parameter `points` is an array successive Vector3
  58677. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58678. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58679. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58680. * * 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
  58681. * * When updating an instance, remember that only point positions can change, not the number of points
  58682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58683. * @param name defines the name of the mesh
  58684. * @param options defines the options used to create the mesh
  58685. * @param scene defines the hosting scene
  58686. * @returns the dashed line mesh
  58687. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58688. */
  58689. static CreateDashedLines(name: string, options: {
  58690. points: Vector3[];
  58691. dashSize?: number;
  58692. gapSize?: number;
  58693. dashNb?: number;
  58694. updatable?: boolean;
  58695. instance?: LinesMesh;
  58696. }, scene?: Nullable<Scene>): LinesMesh;
  58697. /**
  58698. * 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.
  58699. * * 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.
  58700. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58701. * * 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.
  58702. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58703. * * 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
  58704. * * 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
  58705. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58708. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58710. * @param name defines the name of the mesh
  58711. * @param options defines the options used to create the mesh
  58712. * @param scene defines the hosting scene
  58713. * @returns the extruded shape mesh
  58714. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58715. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58716. */
  58717. static ExtrudeShape(name: string, options: {
  58718. shape: Vector3[];
  58719. path: Vector3[];
  58720. scale?: number;
  58721. rotation?: number;
  58722. cap?: number;
  58723. updatable?: boolean;
  58724. sideOrientation?: number;
  58725. frontUVs?: Vector4;
  58726. backUVs?: Vector4;
  58727. instance?: Mesh;
  58728. invertUV?: boolean;
  58729. }, scene?: Nullable<Scene>): Mesh;
  58730. /**
  58731. * Creates an custom extruded shape mesh.
  58732. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58733. * * 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.
  58734. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58735. * * 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
  58736. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58737. * * 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
  58738. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58739. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58740. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58741. * * 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
  58742. * * 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
  58743. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58746. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58748. * @param name defines the name of the mesh
  58749. * @param options defines the options used to create the mesh
  58750. * @param scene defines the hosting scene
  58751. * @returns the custom extruded shape mesh
  58752. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58753. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58754. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58755. */
  58756. static ExtrudeShapeCustom(name: string, options: {
  58757. shape: Vector3[];
  58758. path: Vector3[];
  58759. scaleFunction?: any;
  58760. rotationFunction?: any;
  58761. ribbonCloseArray?: boolean;
  58762. ribbonClosePath?: boolean;
  58763. cap?: number;
  58764. updatable?: boolean;
  58765. sideOrientation?: number;
  58766. frontUVs?: Vector4;
  58767. backUVs?: Vector4;
  58768. instance?: Mesh;
  58769. invertUV?: boolean;
  58770. }, scene?: Nullable<Scene>): Mesh;
  58771. /**
  58772. * Creates lathe mesh.
  58773. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58774. * * 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
  58775. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58776. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58777. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58778. * * 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
  58779. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58780. * * 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
  58781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58782. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58783. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58785. * @param name defines the name of the mesh
  58786. * @param options defines the options used to create the mesh
  58787. * @param scene defines the hosting scene
  58788. * @returns the lathe mesh
  58789. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58790. */
  58791. static CreateLathe(name: string, options: {
  58792. shape: Vector3[];
  58793. radius?: number;
  58794. tessellation?: number;
  58795. clip?: number;
  58796. arc?: number;
  58797. closed?: boolean;
  58798. updatable?: boolean;
  58799. sideOrientation?: number;
  58800. frontUVs?: Vector4;
  58801. backUVs?: Vector4;
  58802. cap?: number;
  58803. invertUV?: boolean;
  58804. }, scene?: Nullable<Scene>): Mesh;
  58805. /**
  58806. * Creates a tiled plane mesh
  58807. * * You can set a limited pattern arrangement with the tiles
  58808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58811. * @param name defines the name of the mesh
  58812. * @param options defines the options used to create the mesh
  58813. * @param scene defines the hosting scene
  58814. * @returns the plane mesh
  58815. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58816. */
  58817. static CreateTiledPlane(name: string, options: {
  58818. pattern?: number;
  58819. tileSize?: number;
  58820. tileWidth?: number;
  58821. tileHeight?: number;
  58822. size?: number;
  58823. width?: number;
  58824. height?: number;
  58825. alignHorizontal?: number;
  58826. alignVertical?: number;
  58827. sideOrientation?: number;
  58828. frontUVs?: Vector4;
  58829. backUVs?: Vector4;
  58830. updatable?: boolean;
  58831. }, scene?: Nullable<Scene>): Mesh;
  58832. /**
  58833. * Creates a plane mesh
  58834. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58835. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58836. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58840. * @param name defines the name of the mesh
  58841. * @param options defines the options used to create the mesh
  58842. * @param scene defines the hosting scene
  58843. * @returns the plane mesh
  58844. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58845. */
  58846. static CreatePlane(name: string, options: {
  58847. size?: number;
  58848. width?: number;
  58849. height?: number;
  58850. sideOrientation?: number;
  58851. frontUVs?: Vector4;
  58852. backUVs?: Vector4;
  58853. updatable?: boolean;
  58854. sourcePlane?: Plane;
  58855. }, scene?: Nullable<Scene>): Mesh;
  58856. /**
  58857. * Creates a ground mesh
  58858. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58859. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58861. * @param name defines the name of the mesh
  58862. * @param options defines the options used to create the mesh
  58863. * @param scene defines the hosting scene
  58864. * @returns the ground mesh
  58865. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58866. */
  58867. static CreateGround(name: string, options: {
  58868. width?: number;
  58869. height?: number;
  58870. subdivisions?: number;
  58871. subdivisionsX?: number;
  58872. subdivisionsY?: number;
  58873. updatable?: boolean;
  58874. }, scene?: Nullable<Scene>): Mesh;
  58875. /**
  58876. * Creates a tiled ground mesh
  58877. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58878. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58879. * * 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
  58880. * * 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
  58881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58882. * @param name defines the name of the mesh
  58883. * @param options defines the options used to create the mesh
  58884. * @param scene defines the hosting scene
  58885. * @returns the tiled ground mesh
  58886. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58887. */
  58888. static CreateTiledGround(name: string, options: {
  58889. xmin: number;
  58890. zmin: number;
  58891. xmax: number;
  58892. zmax: number;
  58893. subdivisions?: {
  58894. w: number;
  58895. h: number;
  58896. };
  58897. precision?: {
  58898. w: number;
  58899. h: number;
  58900. };
  58901. updatable?: boolean;
  58902. }, scene?: Nullable<Scene>): Mesh;
  58903. /**
  58904. * Creates a ground mesh from a height map
  58905. * * The parameter `url` sets the URL of the height map image resource.
  58906. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58907. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58908. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58909. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58910. * * 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.
  58911. * * 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).
  58912. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58914. * @param name defines the name of the mesh
  58915. * @param url defines the url to the height map
  58916. * @param options defines the options used to create the mesh
  58917. * @param scene defines the hosting scene
  58918. * @returns the ground mesh
  58919. * @see https://doc.babylonjs.com/babylon101/height_map
  58920. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58921. */
  58922. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58923. width?: number;
  58924. height?: number;
  58925. subdivisions?: number;
  58926. minHeight?: number;
  58927. maxHeight?: number;
  58928. colorFilter?: Color3;
  58929. alphaFilter?: number;
  58930. updatable?: boolean;
  58931. onReady?: (mesh: GroundMesh) => void;
  58932. }, scene?: Nullable<Scene>): GroundMesh;
  58933. /**
  58934. * Creates a polygon mesh
  58935. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58936. * * 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
  58937. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58940. * * Remember you can only change the shape positions, not their number when updating a polygon
  58941. * @param name defines the name of the mesh
  58942. * @param options defines the options used to create the mesh
  58943. * @param scene defines the hosting scene
  58944. * @param earcutInjection can be used to inject your own earcut reference
  58945. * @returns the polygon mesh
  58946. */
  58947. static CreatePolygon(name: string, options: {
  58948. shape: Vector3[];
  58949. holes?: Vector3[][];
  58950. depth?: number;
  58951. faceUV?: Vector4[];
  58952. faceColors?: Color4[];
  58953. updatable?: boolean;
  58954. sideOrientation?: number;
  58955. frontUVs?: Vector4;
  58956. backUVs?: Vector4;
  58957. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58958. /**
  58959. * Creates an extruded polygon mesh, with depth in the Y direction.
  58960. * * 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)
  58961. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58962. * @param name defines the name of the mesh
  58963. * @param options defines the options used to create the mesh
  58964. * @param scene defines the hosting scene
  58965. * @param earcutInjection can be used to inject your own earcut reference
  58966. * @returns the polygon mesh
  58967. */
  58968. static ExtrudePolygon(name: string, options: {
  58969. shape: Vector3[];
  58970. holes?: Vector3[][];
  58971. depth?: number;
  58972. faceUV?: Vector4[];
  58973. faceColors?: Color4[];
  58974. updatable?: boolean;
  58975. sideOrientation?: number;
  58976. frontUVs?: Vector4;
  58977. backUVs?: Vector4;
  58978. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58979. /**
  58980. * Creates a tube mesh.
  58981. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58982. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58983. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58984. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58985. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58986. * * 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)
  58987. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58988. * * 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
  58989. * * 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
  58990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58992. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58994. * @param name defines the name of the mesh
  58995. * @param options defines the options used to create the mesh
  58996. * @param scene defines the hosting scene
  58997. * @returns the tube mesh
  58998. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58999. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59000. */
  59001. static CreateTube(name: string, options: {
  59002. path: Vector3[];
  59003. radius?: number;
  59004. tessellation?: number;
  59005. radiusFunction?: {
  59006. (i: number, distance: number): number;
  59007. };
  59008. cap?: number;
  59009. arc?: number;
  59010. updatable?: boolean;
  59011. sideOrientation?: number;
  59012. frontUVs?: Vector4;
  59013. backUVs?: Vector4;
  59014. instance?: Mesh;
  59015. invertUV?: boolean;
  59016. }, scene?: Nullable<Scene>): Mesh;
  59017. /**
  59018. * Creates a polyhedron mesh
  59019. * * 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
  59020. * * The parameter `size` (positive float, default 1) sets the polygon size
  59021. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59022. * * 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`
  59023. * * 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
  59024. * * 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)`)
  59025. * * 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
  59026. * * 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
  59027. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59028. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59030. * @param name defines the name of the mesh
  59031. * @param options defines the options used to create the mesh
  59032. * @param scene defines the hosting scene
  59033. * @returns the polyhedron mesh
  59034. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59035. */
  59036. static CreatePolyhedron(name: string, options: {
  59037. type?: number;
  59038. size?: number;
  59039. sizeX?: number;
  59040. sizeY?: number;
  59041. sizeZ?: number;
  59042. custom?: any;
  59043. faceUV?: Vector4[];
  59044. faceColors?: Color4[];
  59045. flat?: boolean;
  59046. updatable?: boolean;
  59047. sideOrientation?: number;
  59048. frontUVs?: Vector4;
  59049. backUVs?: Vector4;
  59050. }, scene?: Nullable<Scene>): Mesh;
  59051. /**
  59052. * Creates a decal mesh.
  59053. * 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
  59054. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59055. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59056. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59057. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59058. * @param name defines the name of the mesh
  59059. * @param sourceMesh defines the mesh where the decal must be applied
  59060. * @param options defines the options used to create the mesh
  59061. * @param scene defines the hosting scene
  59062. * @returns the decal mesh
  59063. * @see https://doc.babylonjs.com/how_to/decals
  59064. */
  59065. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59066. position?: Vector3;
  59067. normal?: Vector3;
  59068. size?: Vector3;
  59069. angle?: number;
  59070. }): Mesh;
  59071. }
  59072. }
  59073. declare module "babylonjs/Meshes/meshSimplification" {
  59074. import { Mesh } from "babylonjs/Meshes/mesh";
  59075. /**
  59076. * A simplifier interface for future simplification implementations
  59077. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59078. */
  59079. export interface ISimplifier {
  59080. /**
  59081. * Simplification of a given mesh according to the given settings.
  59082. * Since this requires computation, it is assumed that the function runs async.
  59083. * @param settings The settings of the simplification, including quality and distance
  59084. * @param successCallback A callback that will be called after the mesh was simplified.
  59085. * @param errorCallback in case of an error, this callback will be called. optional.
  59086. */
  59087. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59088. }
  59089. /**
  59090. * Expected simplification settings.
  59091. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59092. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59093. */
  59094. export interface ISimplificationSettings {
  59095. /**
  59096. * Gets or sets the expected quality
  59097. */
  59098. quality: number;
  59099. /**
  59100. * Gets or sets the distance when this optimized version should be used
  59101. */
  59102. distance: number;
  59103. /**
  59104. * Gets an already optimized mesh
  59105. */
  59106. optimizeMesh?: boolean;
  59107. }
  59108. /**
  59109. * Class used to specify simplification options
  59110. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59111. */
  59112. export class SimplificationSettings implements ISimplificationSettings {
  59113. /** expected quality */
  59114. quality: number;
  59115. /** distance when this optimized version should be used */
  59116. distance: number;
  59117. /** already optimized mesh */
  59118. optimizeMesh?: boolean | undefined;
  59119. /**
  59120. * Creates a SimplificationSettings
  59121. * @param quality expected quality
  59122. * @param distance distance when this optimized version should be used
  59123. * @param optimizeMesh already optimized mesh
  59124. */
  59125. constructor(
  59126. /** expected quality */
  59127. quality: number,
  59128. /** distance when this optimized version should be used */
  59129. distance: number,
  59130. /** already optimized mesh */
  59131. optimizeMesh?: boolean | undefined);
  59132. }
  59133. /**
  59134. * Interface used to define a simplification task
  59135. */
  59136. export interface ISimplificationTask {
  59137. /**
  59138. * Array of settings
  59139. */
  59140. settings: Array<ISimplificationSettings>;
  59141. /**
  59142. * Simplification type
  59143. */
  59144. simplificationType: SimplificationType;
  59145. /**
  59146. * Mesh to simplify
  59147. */
  59148. mesh: Mesh;
  59149. /**
  59150. * Callback called on success
  59151. */
  59152. successCallback?: () => void;
  59153. /**
  59154. * Defines if parallel processing can be used
  59155. */
  59156. parallelProcessing: boolean;
  59157. }
  59158. /**
  59159. * Queue used to order the simplification tasks
  59160. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59161. */
  59162. export class SimplificationQueue {
  59163. private _simplificationArray;
  59164. /**
  59165. * Gets a boolean indicating that the process is still running
  59166. */
  59167. running: boolean;
  59168. /**
  59169. * Creates a new queue
  59170. */
  59171. constructor();
  59172. /**
  59173. * Adds a new simplification task
  59174. * @param task defines a task to add
  59175. */
  59176. addTask(task: ISimplificationTask): void;
  59177. /**
  59178. * Execute next task
  59179. */
  59180. executeNext(): void;
  59181. /**
  59182. * Execute a simplification task
  59183. * @param task defines the task to run
  59184. */
  59185. runSimplification(task: ISimplificationTask): void;
  59186. private getSimplifier;
  59187. }
  59188. /**
  59189. * The implemented types of simplification
  59190. * At the moment only Quadratic Error Decimation is implemented
  59191. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59192. */
  59193. export enum SimplificationType {
  59194. /** Quadratic error decimation */
  59195. QUADRATIC = 0
  59196. }
  59197. }
  59198. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  59199. import { Scene } from "babylonjs/scene";
  59200. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  59201. import { ISceneComponent } from "babylonjs/sceneComponent";
  59202. module "babylonjs/scene" {
  59203. interface Scene {
  59204. /** @hidden (Backing field) */
  59205. _simplificationQueue: SimplificationQueue;
  59206. /**
  59207. * Gets or sets the simplification queue attached to the scene
  59208. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59209. */
  59210. simplificationQueue: SimplificationQueue;
  59211. }
  59212. }
  59213. module "babylonjs/Meshes/mesh" {
  59214. interface Mesh {
  59215. /**
  59216. * Simplify the mesh according to the given array of settings.
  59217. * Function will return immediately and will simplify async
  59218. * @param settings a collection of simplification settings
  59219. * @param parallelProcessing should all levels calculate parallel or one after the other
  59220. * @param simplificationType the type of simplification to run
  59221. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59222. * @returns the current mesh
  59223. */
  59224. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59225. }
  59226. }
  59227. /**
  59228. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59229. * created in a scene
  59230. */
  59231. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59232. /**
  59233. * The component name helpfull to identify the component in the list of scene components.
  59234. */
  59235. readonly name: string;
  59236. /**
  59237. * The scene the component belongs to.
  59238. */
  59239. scene: Scene;
  59240. /**
  59241. * Creates a new instance of the component for the given scene
  59242. * @param scene Defines the scene to register the component in
  59243. */
  59244. constructor(scene: Scene);
  59245. /**
  59246. * Registers the component in a given scene
  59247. */
  59248. register(): void;
  59249. /**
  59250. * Rebuilds the elements related to this component in case of
  59251. * context lost for instance.
  59252. */
  59253. rebuild(): void;
  59254. /**
  59255. * Disposes the component and the associated ressources
  59256. */
  59257. dispose(): void;
  59258. private _beforeCameraUpdate;
  59259. }
  59260. }
  59261. declare module "babylonjs/Meshes/Builders/index" {
  59262. export * from "babylonjs/Meshes/Builders/boxBuilder";
  59263. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  59264. export * from "babylonjs/Meshes/Builders/discBuilder";
  59265. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  59266. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  59267. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  59268. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  59269. export * from "babylonjs/Meshes/Builders/torusBuilder";
  59270. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  59271. export * from "babylonjs/Meshes/Builders/linesBuilder";
  59272. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  59273. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  59274. export * from "babylonjs/Meshes/Builders/latheBuilder";
  59275. export * from "babylonjs/Meshes/Builders/planeBuilder";
  59276. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  59277. export * from "babylonjs/Meshes/Builders/groundBuilder";
  59278. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  59279. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  59280. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  59281. export * from "babylonjs/Meshes/Builders/decalBuilder";
  59282. }
  59283. declare module "babylonjs/Meshes/index" {
  59284. export * from "babylonjs/Meshes/abstractMesh";
  59285. export * from "babylonjs/Meshes/buffer";
  59286. export * from "babylonjs/Meshes/Compression/index";
  59287. export * from "babylonjs/Meshes/csg";
  59288. export * from "babylonjs/Meshes/geometry";
  59289. export * from "babylonjs/Meshes/groundMesh";
  59290. export * from "babylonjs/Meshes/trailMesh";
  59291. export * from "babylonjs/Meshes/instancedMesh";
  59292. export * from "babylonjs/Meshes/linesMesh";
  59293. export * from "babylonjs/Meshes/mesh";
  59294. export * from "babylonjs/Meshes/mesh.vertexData";
  59295. export * from "babylonjs/Meshes/meshBuilder";
  59296. export * from "babylonjs/Meshes/meshSimplification";
  59297. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  59298. export * from "babylonjs/Meshes/polygonMesh";
  59299. export * from "babylonjs/Meshes/subMesh";
  59300. export * from "babylonjs/Meshes/meshLODLevel";
  59301. export * from "babylonjs/Meshes/transformNode";
  59302. export * from "babylonjs/Meshes/Builders/index";
  59303. export * from "babylonjs/Meshes/dataBuffer";
  59304. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  59305. }
  59306. declare module "babylonjs/Morph/index" {
  59307. export * from "babylonjs/Morph/morphTarget";
  59308. export * from "babylonjs/Morph/morphTargetManager";
  59309. }
  59310. declare module "babylonjs/Navigation/INavigationEngine" {
  59311. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59312. import { Vector3 } from "babylonjs/Maths/math";
  59313. import { Mesh } from "babylonjs/Meshes/mesh";
  59314. import { Scene } from "babylonjs/scene";
  59315. /**
  59316. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59317. */
  59318. export interface INavigationEnginePlugin {
  59319. /**
  59320. * plugin name
  59321. */
  59322. name: string;
  59323. /**
  59324. * Creates a navigation mesh
  59325. * @param meshes array of all the geometry used to compute the navigatio mesh
  59326. * @param parameters bunch of parameters used to filter geometry
  59327. */
  59328. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59329. /**
  59330. * Create a navigation mesh debug mesh
  59331. * @param scene is where the mesh will be added
  59332. * @returns debug display mesh
  59333. */
  59334. createDebugNavMesh(scene: Scene): Mesh;
  59335. /**
  59336. * Get a navigation mesh constrained position, closest to the parameter position
  59337. * @param position world position
  59338. * @returns the closest point to position constrained by the navigation mesh
  59339. */
  59340. getClosestPoint(position: Vector3): Vector3;
  59341. /**
  59342. * Get a navigation mesh constrained position, within a particular radius
  59343. * @param position world position
  59344. * @param maxRadius the maximum distance to the constrained world position
  59345. * @returns the closest point to position constrained by the navigation mesh
  59346. */
  59347. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59348. /**
  59349. * Compute the final position from a segment made of destination-position
  59350. * @param position world position
  59351. * @param destination world position
  59352. * @returns the resulting point along the navmesh
  59353. */
  59354. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59355. /**
  59356. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59357. * @param start world position
  59358. * @param end world position
  59359. * @returns array containing world position composing the path
  59360. */
  59361. computePath(start: Vector3, end: Vector3): Vector3[];
  59362. /**
  59363. * If this plugin is supported
  59364. * @returns true if plugin is supported
  59365. */
  59366. isSupported(): boolean;
  59367. /**
  59368. * Create a new Crowd so you can add agents
  59369. * @param maxAgents the maximum agent count in the crowd
  59370. * @param maxAgentRadius the maximum radius an agent can have
  59371. * @param scene to attach the crowd to
  59372. * @returns the crowd you can add agents to
  59373. */
  59374. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59375. /**
  59376. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59377. * The queries will try to find a solution within those bounds
  59378. * default is (1,1,1)
  59379. * @param extent x,y,z value that define the extent around the queries point of reference
  59380. */
  59381. setDefaultQueryExtent(extent: Vector3): void;
  59382. /**
  59383. * Get the Bounding box extent specified by setDefaultQueryExtent
  59384. * @returns the box extent values
  59385. */
  59386. getDefaultQueryExtent(): Vector3;
  59387. /**
  59388. * Release all resources
  59389. */
  59390. dispose(): void;
  59391. }
  59392. /**
  59393. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59394. */
  59395. export interface ICrowd {
  59396. /**
  59397. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59398. * You can attach anything to that node. The node position is updated in the scene update tick.
  59399. * @param pos world position that will be constrained by the navigation mesh
  59400. * @param parameters agent parameters
  59401. * @param transform hooked to the agent that will be update by the scene
  59402. * @returns agent index
  59403. */
  59404. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59405. /**
  59406. * Returns the agent position in world space
  59407. * @param index agent index returned by addAgent
  59408. * @returns world space position
  59409. */
  59410. getAgentPosition(index: number): Vector3;
  59411. /**
  59412. * Gets the agent velocity in world space
  59413. * @param index agent index returned by addAgent
  59414. * @returns world space velocity
  59415. */
  59416. getAgentVelocity(index: number): Vector3;
  59417. /**
  59418. * remove a particular agent previously created
  59419. * @param index agent index returned by addAgent
  59420. */
  59421. removeAgent(index: number): void;
  59422. /**
  59423. * get the list of all agents attached to this crowd
  59424. * @returns list of agent indices
  59425. */
  59426. getAgents(): number[];
  59427. /**
  59428. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59429. * @param deltaTime in seconds
  59430. */
  59431. update(deltaTime: number): void;
  59432. /**
  59433. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59434. * @param index agent index returned by addAgent
  59435. * @param destination targeted world position
  59436. */
  59437. agentGoto(index: number, destination: Vector3): void;
  59438. /**
  59439. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59440. * The queries will try to find a solution within those bounds
  59441. * default is (1,1,1)
  59442. * @param extent x,y,z value that define the extent around the queries point of reference
  59443. */
  59444. setDefaultQueryExtent(extent: Vector3): void;
  59445. /**
  59446. * Get the Bounding box extent specified by setDefaultQueryExtent
  59447. * @returns the box extent values
  59448. */
  59449. getDefaultQueryExtent(): Vector3;
  59450. /**
  59451. * Release all resources
  59452. */
  59453. dispose(): void;
  59454. }
  59455. /**
  59456. * Configures an agent
  59457. */
  59458. export interface IAgentParameters {
  59459. /**
  59460. * Agent radius. [Limit: >= 0]
  59461. */
  59462. radius: number;
  59463. /**
  59464. * Agent height. [Limit: > 0]
  59465. */
  59466. height: number;
  59467. /**
  59468. * Maximum allowed acceleration. [Limit: >= 0]
  59469. */
  59470. maxAcceleration: number;
  59471. /**
  59472. * Maximum allowed speed. [Limit: >= 0]
  59473. */
  59474. maxSpeed: number;
  59475. /**
  59476. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59477. */
  59478. collisionQueryRange: number;
  59479. /**
  59480. * The path visibility optimization range. [Limit: > 0]
  59481. */
  59482. pathOptimizationRange: number;
  59483. /**
  59484. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59485. */
  59486. separationWeight: number;
  59487. }
  59488. /**
  59489. * Configures the navigation mesh creation
  59490. */
  59491. export interface INavMeshParameters {
  59492. /**
  59493. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59494. */
  59495. cs: number;
  59496. /**
  59497. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59498. */
  59499. ch: number;
  59500. /**
  59501. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59502. */
  59503. walkableSlopeAngle: number;
  59504. /**
  59505. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59506. * be considered walkable. [Limit: >= 3] [Units: vx]
  59507. */
  59508. walkableHeight: number;
  59509. /**
  59510. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59511. */
  59512. walkableClimb: number;
  59513. /**
  59514. * The distance to erode/shrink the walkable area of the heightfield away from
  59515. * obstructions. [Limit: >=0] [Units: vx]
  59516. */
  59517. walkableRadius: number;
  59518. /**
  59519. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59520. */
  59521. maxEdgeLen: number;
  59522. /**
  59523. * The maximum distance a simplfied contour's border edges should deviate
  59524. * the original raw contour. [Limit: >=0] [Units: vx]
  59525. */
  59526. maxSimplificationError: number;
  59527. /**
  59528. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59529. */
  59530. minRegionArea: number;
  59531. /**
  59532. * Any regions with a span count smaller than this value will, if possible,
  59533. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59534. */
  59535. mergeRegionArea: number;
  59536. /**
  59537. * The maximum number of vertices allowed for polygons generated during the
  59538. * contour to polygon conversion process. [Limit: >= 3]
  59539. */
  59540. maxVertsPerPoly: number;
  59541. /**
  59542. * Sets the sampling distance to use when generating the detail mesh.
  59543. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59544. */
  59545. detailSampleDist: number;
  59546. /**
  59547. * The maximum distance the detail mesh surface should deviate from heightfield
  59548. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59549. */
  59550. detailSampleMaxError: number;
  59551. }
  59552. }
  59553. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  59554. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  59555. import { Mesh } from "babylonjs/Meshes/mesh";
  59556. import { Scene } from "babylonjs/scene";
  59557. import { Vector3 } from "babylonjs/Maths/math";
  59558. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59559. /**
  59560. * RecastJS navigation plugin
  59561. */
  59562. export class RecastJSPlugin implements INavigationEnginePlugin {
  59563. /**
  59564. * Reference to the Recast library
  59565. */
  59566. bjsRECAST: any;
  59567. /**
  59568. * plugin name
  59569. */
  59570. name: string;
  59571. /**
  59572. * the first navmesh created. We might extend this to support multiple navmeshes
  59573. */
  59574. navMesh: any;
  59575. /**
  59576. * Initializes the recastJS plugin
  59577. * @param recastInjection can be used to inject your own recast reference
  59578. */
  59579. constructor(recastInjection?: any);
  59580. /**
  59581. * Creates a navigation mesh
  59582. * @param meshes array of all the geometry used to compute the navigatio mesh
  59583. * @param parameters bunch of parameters used to filter geometry
  59584. */
  59585. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59586. /**
  59587. * Create a navigation mesh debug mesh
  59588. * @param scene is where the mesh will be added
  59589. * @returns debug display mesh
  59590. */
  59591. createDebugNavMesh(scene: Scene): Mesh;
  59592. /**
  59593. * Get a navigation mesh constrained position, closest to the parameter position
  59594. * @param position world position
  59595. * @returns the closest point to position constrained by the navigation mesh
  59596. */
  59597. getClosestPoint(position: Vector3): Vector3;
  59598. /**
  59599. * Get a navigation mesh constrained position, within a particular radius
  59600. * @param position world position
  59601. * @param maxRadius the maximum distance to the constrained world position
  59602. * @returns the closest point to position constrained by the navigation mesh
  59603. */
  59604. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59605. /**
  59606. * Compute the final position from a segment made of destination-position
  59607. * @param position world position
  59608. * @param destination world position
  59609. * @returns the resulting point along the navmesh
  59610. */
  59611. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59612. /**
  59613. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59614. * @param start world position
  59615. * @param end world position
  59616. * @returns array containing world position composing the path
  59617. */
  59618. computePath(start: Vector3, end: Vector3): Vector3[];
  59619. /**
  59620. * Create a new Crowd so you can add agents
  59621. * @param maxAgents the maximum agent count in the crowd
  59622. * @param maxAgentRadius the maximum radius an agent can have
  59623. * @param scene to attach the crowd to
  59624. * @returns the crowd you can add agents to
  59625. */
  59626. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59627. /**
  59628. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59629. * The queries will try to find a solution within those bounds
  59630. * default is (1,1,1)
  59631. * @param extent x,y,z value that define the extent around the queries point of reference
  59632. */
  59633. setDefaultQueryExtent(extent: Vector3): void;
  59634. /**
  59635. * Get the Bounding box extent specified by setDefaultQueryExtent
  59636. * @returns the box extent values
  59637. */
  59638. getDefaultQueryExtent(): Vector3;
  59639. /**
  59640. * Disposes
  59641. */
  59642. dispose(): void;
  59643. /**
  59644. * If this plugin is supported
  59645. * @returns true if plugin is supported
  59646. */
  59647. isSupported(): boolean;
  59648. }
  59649. /**
  59650. * Recast detour crowd implementation
  59651. */
  59652. export class RecastJSCrowd implements ICrowd {
  59653. /**
  59654. * Recast/detour plugin
  59655. */
  59656. bjsRECASTPlugin: RecastJSPlugin;
  59657. /**
  59658. * Link to the detour crowd
  59659. */
  59660. recastCrowd: any;
  59661. /**
  59662. * One transform per agent
  59663. */
  59664. transforms: TransformNode[];
  59665. /**
  59666. * All agents created
  59667. */
  59668. agents: number[];
  59669. /**
  59670. * Link to the scene is kept to unregister the crowd from the scene
  59671. */
  59672. private _scene;
  59673. /**
  59674. * Observer for crowd updates
  59675. */
  59676. private _onBeforeAnimationsObserver;
  59677. /**
  59678. * Constructor
  59679. * @param plugin recastJS plugin
  59680. * @param maxAgents the maximum agent count in the crowd
  59681. * @param maxAgentRadius the maximum radius an agent can have
  59682. * @param scene to attach the crowd to
  59683. * @returns the crowd you can add agents to
  59684. */
  59685. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59686. /**
  59687. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59688. * You can attach anything to that node. The node position is updated in the scene update tick.
  59689. * @param pos world position that will be constrained by the navigation mesh
  59690. * @param parameters agent parameters
  59691. * @param transform hooked to the agent that will be update by the scene
  59692. * @returns agent index
  59693. */
  59694. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59695. /**
  59696. * Returns the agent position in world space
  59697. * @param index agent index returned by addAgent
  59698. * @returns world space position
  59699. */
  59700. getAgentPosition(index: number): Vector3;
  59701. /**
  59702. * Returns the agent velocity in world space
  59703. * @param index agent index returned by addAgent
  59704. * @returns world space velocity
  59705. */
  59706. getAgentVelocity(index: number): Vector3;
  59707. /**
  59708. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59709. * @param index agent index returned by addAgent
  59710. * @param destination targeted world position
  59711. */
  59712. agentGoto(index: number, destination: Vector3): void;
  59713. /**
  59714. * remove a particular agent previously created
  59715. * @param index agent index returned by addAgent
  59716. */
  59717. removeAgent(index: number): void;
  59718. /**
  59719. * get the list of all agents attached to this crowd
  59720. * @returns list of agent indices
  59721. */
  59722. getAgents(): number[];
  59723. /**
  59724. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59725. * @param deltaTime in seconds
  59726. */
  59727. update(deltaTime: number): void;
  59728. /**
  59729. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59730. * The queries will try to find a solution within those bounds
  59731. * default is (1,1,1)
  59732. * @param extent x,y,z value that define the extent around the queries point of reference
  59733. */
  59734. setDefaultQueryExtent(extent: Vector3): void;
  59735. /**
  59736. * Get the Bounding box extent specified by setDefaultQueryExtent
  59737. * @returns the box extent values
  59738. */
  59739. getDefaultQueryExtent(): Vector3;
  59740. /**
  59741. * Release all resources
  59742. */
  59743. dispose(): void;
  59744. }
  59745. }
  59746. declare module "babylonjs/Navigation/Plugins/index" {
  59747. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  59748. }
  59749. declare module "babylonjs/Navigation/index" {
  59750. export * from "babylonjs/Navigation/INavigationEngine";
  59751. export * from "babylonjs/Navigation/Plugins/index";
  59752. }
  59753. declare module "babylonjs/Offline/database" {
  59754. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  59755. /**
  59756. * Class used to enable access to IndexedDB
  59757. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59758. */
  59759. export class Database implements IOfflineProvider {
  59760. private _callbackManifestChecked;
  59761. private _currentSceneUrl;
  59762. private _db;
  59763. private _enableSceneOffline;
  59764. private _enableTexturesOffline;
  59765. private _manifestVersionFound;
  59766. private _mustUpdateRessources;
  59767. private _hasReachedQuota;
  59768. private _isSupported;
  59769. private _idbFactory;
  59770. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59771. private static IsUASupportingBlobStorage;
  59772. /**
  59773. * Gets a boolean indicating if Database storate is enabled (off by default)
  59774. */
  59775. static IDBStorageEnabled: boolean;
  59776. /**
  59777. * Gets a boolean indicating if scene must be saved in the database
  59778. */
  59779. readonly enableSceneOffline: boolean;
  59780. /**
  59781. * Gets a boolean indicating if textures must be saved in the database
  59782. */
  59783. readonly enableTexturesOffline: boolean;
  59784. /**
  59785. * Creates a new Database
  59786. * @param urlToScene defines the url to load the scene
  59787. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59788. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59789. */
  59790. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59791. private static _ParseURL;
  59792. private static _ReturnFullUrlLocation;
  59793. private _checkManifestFile;
  59794. /**
  59795. * Open the database and make it available
  59796. * @param successCallback defines the callback to call on success
  59797. * @param errorCallback defines the callback to call on error
  59798. */
  59799. open(successCallback: () => void, errorCallback: () => void): void;
  59800. /**
  59801. * Loads an image from the database
  59802. * @param url defines the url to load from
  59803. * @param image defines the target DOM image
  59804. */
  59805. loadImage(url: string, image: HTMLImageElement): void;
  59806. private _loadImageFromDBAsync;
  59807. private _saveImageIntoDBAsync;
  59808. private _checkVersionFromDB;
  59809. private _loadVersionFromDBAsync;
  59810. private _saveVersionIntoDBAsync;
  59811. /**
  59812. * Loads a file from database
  59813. * @param url defines the URL to load from
  59814. * @param sceneLoaded defines a callback to call on success
  59815. * @param progressCallBack defines a callback to call when progress changed
  59816. * @param errorCallback defines a callback to call on error
  59817. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59818. */
  59819. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59820. private _loadFileAsync;
  59821. private _saveFileAsync;
  59822. /**
  59823. * Validates if xhr data is correct
  59824. * @param xhr defines the request to validate
  59825. * @param dataType defines the expected data type
  59826. * @returns true if data is correct
  59827. */
  59828. private static _ValidateXHRData;
  59829. }
  59830. }
  59831. declare module "babylonjs/Offline/index" {
  59832. export * from "babylonjs/Offline/database";
  59833. export * from "babylonjs/Offline/IOfflineProvider";
  59834. }
  59835. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  59836. /** @hidden */
  59837. export var gpuUpdateParticlesPixelShader: {
  59838. name: string;
  59839. shader: string;
  59840. };
  59841. }
  59842. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  59843. /** @hidden */
  59844. export var gpuUpdateParticlesVertexShader: {
  59845. name: string;
  59846. shader: string;
  59847. };
  59848. }
  59849. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  59850. /** @hidden */
  59851. export var clipPlaneFragmentDeclaration2: {
  59852. name: string;
  59853. shader: string;
  59854. };
  59855. }
  59856. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  59857. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  59858. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59859. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59860. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59861. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59862. /** @hidden */
  59863. export var gpuRenderParticlesPixelShader: {
  59864. name: string;
  59865. shader: string;
  59866. };
  59867. }
  59868. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  59869. /** @hidden */
  59870. export var clipPlaneVertexDeclaration2: {
  59871. name: string;
  59872. shader: string;
  59873. };
  59874. }
  59875. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  59876. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  59877. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59878. /** @hidden */
  59879. export var gpuRenderParticlesVertexShader: {
  59880. name: string;
  59881. shader: string;
  59882. };
  59883. }
  59884. declare module "babylonjs/Particles/gpuParticleSystem" {
  59885. import { Nullable } from "babylonjs/types";
  59886. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  59887. import { Observable } from "babylonjs/Misc/observable";
  59888. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59889. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59890. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59891. import { Scene, IDisposable } from "babylonjs/scene";
  59892. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59893. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59894. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59895. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59896. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59897. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59898. /**
  59899. * This represents a GPU particle system in Babylon
  59900. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59901. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59902. */
  59903. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59904. /**
  59905. * The layer mask we are rendering the particles through.
  59906. */
  59907. layerMask: number;
  59908. private _capacity;
  59909. private _activeCount;
  59910. private _currentActiveCount;
  59911. private _accumulatedCount;
  59912. private _renderEffect;
  59913. private _updateEffect;
  59914. private _buffer0;
  59915. private _buffer1;
  59916. private _spriteBuffer;
  59917. private _updateVAO;
  59918. private _renderVAO;
  59919. private _targetIndex;
  59920. private _sourceBuffer;
  59921. private _targetBuffer;
  59922. private _engine;
  59923. private _currentRenderId;
  59924. private _started;
  59925. private _stopped;
  59926. private _timeDelta;
  59927. private _randomTexture;
  59928. private _randomTexture2;
  59929. private _attributesStrideSize;
  59930. private _updateEffectOptions;
  59931. private _randomTextureSize;
  59932. private _actualFrame;
  59933. private readonly _rawTextureWidth;
  59934. /**
  59935. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59936. */
  59937. static readonly IsSupported: boolean;
  59938. /**
  59939. * An event triggered when the system is disposed.
  59940. */
  59941. onDisposeObservable: Observable<GPUParticleSystem>;
  59942. /**
  59943. * Gets the maximum number of particles active at the same time.
  59944. * @returns The max number of active particles.
  59945. */
  59946. getCapacity(): number;
  59947. /**
  59948. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59949. * to override the particles.
  59950. */
  59951. forceDepthWrite: boolean;
  59952. /**
  59953. * Gets or set the number of active particles
  59954. */
  59955. activeParticleCount: number;
  59956. private _preWarmDone;
  59957. /**
  59958. * Is this system ready to be used/rendered
  59959. * @return true if the system is ready
  59960. */
  59961. isReady(): boolean;
  59962. /**
  59963. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59964. * @returns True if it has been started, otherwise false.
  59965. */
  59966. isStarted(): boolean;
  59967. /**
  59968. * Starts the particle system and begins to emit
  59969. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59970. */
  59971. start(delay?: number): void;
  59972. /**
  59973. * Stops the particle system.
  59974. */
  59975. stop(): void;
  59976. /**
  59977. * Remove all active particles
  59978. */
  59979. reset(): void;
  59980. /**
  59981. * Returns the string "GPUParticleSystem"
  59982. * @returns a string containing the class name
  59983. */
  59984. getClassName(): string;
  59985. private _colorGradientsTexture;
  59986. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59987. /**
  59988. * Adds a new color gradient
  59989. * @param gradient defines the gradient to use (between 0 and 1)
  59990. * @param color1 defines the color to affect to the specified gradient
  59991. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59992. * @returns the current particle system
  59993. */
  59994. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59995. /**
  59996. * Remove a specific color gradient
  59997. * @param gradient defines the gradient to remove
  59998. * @returns the current particle system
  59999. */
  60000. removeColorGradient(gradient: number): GPUParticleSystem;
  60001. private _angularSpeedGradientsTexture;
  60002. private _sizeGradientsTexture;
  60003. private _velocityGradientsTexture;
  60004. private _limitVelocityGradientsTexture;
  60005. private _dragGradientsTexture;
  60006. private _addFactorGradient;
  60007. /**
  60008. * Adds a new size gradient
  60009. * @param gradient defines the gradient to use (between 0 and 1)
  60010. * @param factor defines the size factor to affect to the specified gradient
  60011. * @returns the current particle system
  60012. */
  60013. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60014. /**
  60015. * Remove a specific size gradient
  60016. * @param gradient defines the gradient to remove
  60017. * @returns the current particle system
  60018. */
  60019. removeSizeGradient(gradient: number): GPUParticleSystem;
  60020. /**
  60021. * Adds a new angular speed gradient
  60022. * @param gradient defines the gradient to use (between 0 and 1)
  60023. * @param factor defines the angular speed to affect to the specified gradient
  60024. * @returns the current particle system
  60025. */
  60026. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60027. /**
  60028. * Remove a specific angular speed gradient
  60029. * @param gradient defines the gradient to remove
  60030. * @returns the current particle system
  60031. */
  60032. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60033. /**
  60034. * Adds a new velocity gradient
  60035. * @param gradient defines the gradient to use (between 0 and 1)
  60036. * @param factor defines the velocity to affect to the specified gradient
  60037. * @returns the current particle system
  60038. */
  60039. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60040. /**
  60041. * Remove a specific velocity gradient
  60042. * @param gradient defines the gradient to remove
  60043. * @returns the current particle system
  60044. */
  60045. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60046. /**
  60047. * Adds a new limit velocity gradient
  60048. * @param gradient defines the gradient to use (between 0 and 1)
  60049. * @param factor defines the limit velocity value to affect to the specified gradient
  60050. * @returns the current particle system
  60051. */
  60052. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60053. /**
  60054. * Remove a specific limit velocity gradient
  60055. * @param gradient defines the gradient to remove
  60056. * @returns the current particle system
  60057. */
  60058. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60059. /**
  60060. * Adds a new drag gradient
  60061. * @param gradient defines the gradient to use (between 0 and 1)
  60062. * @param factor defines the drag value to affect to the specified gradient
  60063. * @returns the current particle system
  60064. */
  60065. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60066. /**
  60067. * Remove a specific drag gradient
  60068. * @param gradient defines the gradient to remove
  60069. * @returns the current particle system
  60070. */
  60071. removeDragGradient(gradient: number): GPUParticleSystem;
  60072. /**
  60073. * Not supported by GPUParticleSystem
  60074. * @param gradient defines the gradient to use (between 0 and 1)
  60075. * @param factor defines the emit rate value to affect to the specified gradient
  60076. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60077. * @returns the current particle system
  60078. */
  60079. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60080. /**
  60081. * Not supported by GPUParticleSystem
  60082. * @param gradient defines the gradient to remove
  60083. * @returns the current particle system
  60084. */
  60085. removeEmitRateGradient(gradient: number): IParticleSystem;
  60086. /**
  60087. * Not supported by GPUParticleSystem
  60088. * @param gradient defines the gradient to use (between 0 and 1)
  60089. * @param factor defines the start size value to affect to the specified gradient
  60090. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60091. * @returns the current particle system
  60092. */
  60093. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60094. /**
  60095. * Not supported by GPUParticleSystem
  60096. * @param gradient defines the gradient to remove
  60097. * @returns the current particle system
  60098. */
  60099. removeStartSizeGradient(gradient: number): IParticleSystem;
  60100. /**
  60101. * Not supported by GPUParticleSystem
  60102. * @param gradient defines the gradient to use (between 0 and 1)
  60103. * @param min defines the color remap minimal range
  60104. * @param max defines the color remap maximal range
  60105. * @returns the current particle system
  60106. */
  60107. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60108. /**
  60109. * Not supported by GPUParticleSystem
  60110. * @param gradient defines the gradient to remove
  60111. * @returns the current particle system
  60112. */
  60113. removeColorRemapGradient(): IParticleSystem;
  60114. /**
  60115. * Not supported by GPUParticleSystem
  60116. * @param gradient defines the gradient to use (between 0 and 1)
  60117. * @param min defines the alpha remap minimal range
  60118. * @param max defines the alpha remap maximal range
  60119. * @returns the current particle system
  60120. */
  60121. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60122. /**
  60123. * Not supported by GPUParticleSystem
  60124. * @param gradient defines the gradient to remove
  60125. * @returns the current particle system
  60126. */
  60127. removeAlphaRemapGradient(): IParticleSystem;
  60128. /**
  60129. * Not supported by GPUParticleSystem
  60130. * @param gradient defines the gradient to use (between 0 and 1)
  60131. * @param color defines the color to affect to the specified gradient
  60132. * @returns the current particle system
  60133. */
  60134. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60135. /**
  60136. * Not supported by GPUParticleSystem
  60137. * @param gradient defines the gradient to remove
  60138. * @returns the current particle system
  60139. */
  60140. removeRampGradient(): IParticleSystem;
  60141. /**
  60142. * Not supported by GPUParticleSystem
  60143. * @returns the list of ramp gradients
  60144. */
  60145. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60146. /**
  60147. * Not supported by GPUParticleSystem
  60148. * Gets or sets a boolean indicating that ramp gradients must be used
  60149. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60150. */
  60151. useRampGradients: boolean;
  60152. /**
  60153. * Not supported by GPUParticleSystem
  60154. * @param gradient defines the gradient to use (between 0 and 1)
  60155. * @param factor defines the life time factor to affect to the specified gradient
  60156. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60157. * @returns the current particle system
  60158. */
  60159. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60160. /**
  60161. * Not supported by GPUParticleSystem
  60162. * @param gradient defines the gradient to remove
  60163. * @returns the current particle system
  60164. */
  60165. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60166. /**
  60167. * Instantiates a GPU particle system.
  60168. * 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.
  60169. * @param name The name of the particle system
  60170. * @param options The options used to create the system
  60171. * @param scene The scene the particle system belongs to
  60172. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60173. */
  60174. constructor(name: string, options: Partial<{
  60175. capacity: number;
  60176. randomTextureSize: number;
  60177. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60178. protected _reset(): void;
  60179. private _createUpdateVAO;
  60180. private _createRenderVAO;
  60181. private _initialize;
  60182. /** @hidden */
  60183. _recreateUpdateEffect(): void;
  60184. /** @hidden */
  60185. _recreateRenderEffect(): void;
  60186. /**
  60187. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60188. * @param preWarm defines if we are in the pre-warmimg phase
  60189. */
  60190. animate(preWarm?: boolean): void;
  60191. private _createFactorGradientTexture;
  60192. private _createSizeGradientTexture;
  60193. private _createAngularSpeedGradientTexture;
  60194. private _createVelocityGradientTexture;
  60195. private _createLimitVelocityGradientTexture;
  60196. private _createDragGradientTexture;
  60197. private _createColorGradientTexture;
  60198. /**
  60199. * Renders the particle system in its current state
  60200. * @param preWarm defines if the system should only update the particles but not render them
  60201. * @returns the current number of particles
  60202. */
  60203. render(preWarm?: boolean): number;
  60204. /**
  60205. * Rebuilds the particle system
  60206. */
  60207. rebuild(): void;
  60208. private _releaseBuffers;
  60209. private _releaseVAOs;
  60210. /**
  60211. * Disposes the particle system and free the associated resources
  60212. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60213. */
  60214. dispose(disposeTexture?: boolean): void;
  60215. /**
  60216. * Clones the particle system.
  60217. * @param name The name of the cloned object
  60218. * @param newEmitter The new emitter to use
  60219. * @returns the cloned particle system
  60220. */
  60221. clone(name: string, newEmitter: any): GPUParticleSystem;
  60222. /**
  60223. * Serializes the particle system to a JSON object.
  60224. * @returns the JSON object
  60225. */
  60226. serialize(): any;
  60227. /**
  60228. * Parses a JSON object to create a GPU particle system.
  60229. * @param parsedParticleSystem The JSON object to parse
  60230. * @param scene The scene to create the particle system in
  60231. * @param rootUrl The root url to use to load external dependencies like texture
  60232. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60233. * @returns the parsed GPU particle system
  60234. */
  60235. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60236. }
  60237. }
  60238. declare module "babylonjs/Particles/particleSystemSet" {
  60239. import { Nullable } from "babylonjs/types";
  60240. import { Color3 } from "babylonjs/Maths/math.color";
  60241. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60243. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60244. import { Scene, IDisposable } from "babylonjs/scene";
  60245. /**
  60246. * Represents a set of particle systems working together to create a specific effect
  60247. */
  60248. export class ParticleSystemSet implements IDisposable {
  60249. private _emitterCreationOptions;
  60250. private _emitterNode;
  60251. /**
  60252. * Gets the particle system list
  60253. */
  60254. systems: IParticleSystem[];
  60255. /**
  60256. * Gets the emitter node used with this set
  60257. */
  60258. readonly emitterNode: Nullable<TransformNode>;
  60259. /**
  60260. * Creates a new emitter mesh as a sphere
  60261. * @param options defines the options used to create the sphere
  60262. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60263. * @param scene defines the hosting scene
  60264. */
  60265. setEmitterAsSphere(options: {
  60266. diameter: number;
  60267. segments: number;
  60268. color: Color3;
  60269. }, renderingGroupId: number, scene: Scene): void;
  60270. /**
  60271. * Starts all particle systems of the set
  60272. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60273. */
  60274. start(emitter?: AbstractMesh): void;
  60275. /**
  60276. * Release all associated resources
  60277. */
  60278. dispose(): void;
  60279. /**
  60280. * Serialize the set into a JSON compatible object
  60281. * @returns a JSON compatible representation of the set
  60282. */
  60283. serialize(): any;
  60284. /**
  60285. * Parse a new ParticleSystemSet from a serialized source
  60286. * @param data defines a JSON compatible representation of the set
  60287. * @param scene defines the hosting scene
  60288. * @param gpu defines if we want GPU particles or CPU particles
  60289. * @returns a new ParticleSystemSet
  60290. */
  60291. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60292. }
  60293. }
  60294. declare module "babylonjs/Particles/particleHelper" {
  60295. import { Nullable } from "babylonjs/types";
  60296. import { Scene } from "babylonjs/scene";
  60297. import { Vector3 } from "babylonjs/Maths/math.vector";
  60298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60299. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60300. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  60301. /**
  60302. * This class is made for on one-liner static method to help creating particle system set.
  60303. */
  60304. export class ParticleHelper {
  60305. /**
  60306. * Gets or sets base Assets URL
  60307. */
  60308. static BaseAssetsUrl: string;
  60309. /**
  60310. * Create a default particle system that you can tweak
  60311. * @param emitter defines the emitter to use
  60312. * @param capacity defines the system capacity (default is 500 particles)
  60313. * @param scene defines the hosting scene
  60314. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60315. * @returns the new Particle system
  60316. */
  60317. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60318. /**
  60319. * This is the main static method (one-liner) of this helper to create different particle systems
  60320. * @param type This string represents the type to the particle system to create
  60321. * @param scene The scene where the particle system should live
  60322. * @param gpu If the system will use gpu
  60323. * @returns the ParticleSystemSet created
  60324. */
  60325. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60326. /**
  60327. * Static function used to export a particle system to a ParticleSystemSet variable.
  60328. * Please note that the emitter shape is not exported
  60329. * @param systems defines the particle systems to export
  60330. * @returns the created particle system set
  60331. */
  60332. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60333. }
  60334. }
  60335. declare module "babylonjs/Particles/particleSystemComponent" {
  60336. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60337. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  60338. import "babylonjs/Shaders/particles.vertex";
  60339. module "babylonjs/Engines/engine" {
  60340. interface Engine {
  60341. /**
  60342. * Create an effect to use with particle systems.
  60343. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60344. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60345. * @param uniformsNames defines a list of attribute names
  60346. * @param samplers defines an array of string used to represent textures
  60347. * @param defines defines the string containing the defines to use to compile the shaders
  60348. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60349. * @param onCompiled defines a function to call when the effect creation is successful
  60350. * @param onError defines a function to call when the effect creation has failed
  60351. * @returns the new Effect
  60352. */
  60353. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60354. }
  60355. }
  60356. module "babylonjs/Meshes/mesh" {
  60357. interface Mesh {
  60358. /**
  60359. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60360. * @returns an array of IParticleSystem
  60361. */
  60362. getEmittedParticleSystems(): IParticleSystem[];
  60363. /**
  60364. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60365. * @returns an array of IParticleSystem
  60366. */
  60367. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60368. }
  60369. }
  60370. /**
  60371. * @hidden
  60372. */
  60373. export var _IDoNeedToBeInTheBuild: number;
  60374. }
  60375. declare module "babylonjs/Particles/index" {
  60376. export * from "babylonjs/Particles/baseParticleSystem";
  60377. export * from "babylonjs/Particles/EmitterTypes/index";
  60378. export * from "babylonjs/Particles/gpuParticleSystem";
  60379. export * from "babylonjs/Particles/IParticleSystem";
  60380. export * from "babylonjs/Particles/particle";
  60381. export * from "babylonjs/Particles/particleHelper";
  60382. export * from "babylonjs/Particles/particleSystem";
  60383. export * from "babylonjs/Particles/particleSystemComponent";
  60384. export * from "babylonjs/Particles/particleSystemSet";
  60385. export * from "babylonjs/Particles/solidParticle";
  60386. export * from "babylonjs/Particles/solidParticleSystem";
  60387. export * from "babylonjs/Particles/subEmitter";
  60388. }
  60389. declare module "babylonjs/Physics/physicsEngineComponent" {
  60390. import { Nullable } from "babylonjs/types";
  60391. import { Observable, Observer } from "babylonjs/Misc/observable";
  60392. import { Vector3 } from "babylonjs/Maths/math.vector";
  60393. import { Mesh } from "babylonjs/Meshes/mesh";
  60394. import { ISceneComponent } from "babylonjs/sceneComponent";
  60395. import { Scene } from "babylonjs/scene";
  60396. import { Node } from "babylonjs/node";
  60397. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60398. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60399. module "babylonjs/scene" {
  60400. interface Scene {
  60401. /** @hidden (Backing field) */
  60402. _physicsEngine: Nullable<IPhysicsEngine>;
  60403. /**
  60404. * Gets the current physics engine
  60405. * @returns a IPhysicsEngine or null if none attached
  60406. */
  60407. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60408. /**
  60409. * Enables physics to the current scene
  60410. * @param gravity defines the scene's gravity for the physics engine
  60411. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60412. * @return a boolean indicating if the physics engine was initialized
  60413. */
  60414. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60415. /**
  60416. * Disables and disposes the physics engine associated with the scene
  60417. */
  60418. disablePhysicsEngine(): void;
  60419. /**
  60420. * Gets a boolean indicating if there is an active physics engine
  60421. * @returns a boolean indicating if there is an active physics engine
  60422. */
  60423. isPhysicsEnabled(): boolean;
  60424. /**
  60425. * Deletes a physics compound impostor
  60426. * @param compound defines the compound to delete
  60427. */
  60428. deleteCompoundImpostor(compound: any): void;
  60429. /**
  60430. * An event triggered when physic simulation is about to be run
  60431. */
  60432. onBeforePhysicsObservable: Observable<Scene>;
  60433. /**
  60434. * An event triggered when physic simulation has been done
  60435. */
  60436. onAfterPhysicsObservable: Observable<Scene>;
  60437. }
  60438. }
  60439. module "babylonjs/Meshes/abstractMesh" {
  60440. interface AbstractMesh {
  60441. /** @hidden */
  60442. _physicsImpostor: Nullable<PhysicsImpostor>;
  60443. /**
  60444. * Gets or sets impostor used for physic simulation
  60445. * @see http://doc.babylonjs.com/features/physics_engine
  60446. */
  60447. physicsImpostor: Nullable<PhysicsImpostor>;
  60448. /**
  60449. * Gets the current physics impostor
  60450. * @see http://doc.babylonjs.com/features/physics_engine
  60451. * @returns a physics impostor or null
  60452. */
  60453. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60454. /** Apply a physic impulse to the mesh
  60455. * @param force defines the force to apply
  60456. * @param contactPoint defines where to apply the force
  60457. * @returns the current mesh
  60458. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60459. */
  60460. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60461. /**
  60462. * Creates a physic joint between two meshes
  60463. * @param otherMesh defines the other mesh to use
  60464. * @param pivot1 defines the pivot to use on this mesh
  60465. * @param pivot2 defines the pivot to use on the other mesh
  60466. * @param options defines additional options (can be plugin dependent)
  60467. * @returns the current mesh
  60468. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60469. */
  60470. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60471. /** @hidden */
  60472. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60473. }
  60474. }
  60475. /**
  60476. * Defines the physics engine scene component responsible to manage a physics engine
  60477. */
  60478. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60479. /**
  60480. * The component name helpful to identify the component in the list of scene components.
  60481. */
  60482. readonly name: string;
  60483. /**
  60484. * The scene the component belongs to.
  60485. */
  60486. scene: Scene;
  60487. /**
  60488. * Creates a new instance of the component for the given scene
  60489. * @param scene Defines the scene to register the component in
  60490. */
  60491. constructor(scene: Scene);
  60492. /**
  60493. * Registers the component in a given scene
  60494. */
  60495. register(): void;
  60496. /**
  60497. * Rebuilds the elements related to this component in case of
  60498. * context lost for instance.
  60499. */
  60500. rebuild(): void;
  60501. /**
  60502. * Disposes the component and the associated ressources
  60503. */
  60504. dispose(): void;
  60505. }
  60506. }
  60507. declare module "babylonjs/Physics/physicsHelper" {
  60508. import { Nullable } from "babylonjs/types";
  60509. import { Vector3 } from "babylonjs/Maths/math.vector";
  60510. import { Mesh } from "babylonjs/Meshes/mesh";
  60511. import { Scene } from "babylonjs/scene";
  60512. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60513. /**
  60514. * A helper for physics simulations
  60515. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60516. */
  60517. export class PhysicsHelper {
  60518. private _scene;
  60519. private _physicsEngine;
  60520. /**
  60521. * Initializes the Physics helper
  60522. * @param scene Babylon.js scene
  60523. */
  60524. constructor(scene: Scene);
  60525. /**
  60526. * Applies a radial explosion impulse
  60527. * @param origin the origin of the explosion
  60528. * @param radiusOrEventOptions the radius or the options of radial explosion
  60529. * @param strength the explosion strength
  60530. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60531. * @returns A physics radial explosion event, or null
  60532. */
  60533. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60534. /**
  60535. * Applies a radial explosion force
  60536. * @param origin the origin of the explosion
  60537. * @param radiusOrEventOptions the radius or the options of radial explosion
  60538. * @param strength the explosion strength
  60539. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60540. * @returns A physics radial explosion event, or null
  60541. */
  60542. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60543. /**
  60544. * Creates a gravitational field
  60545. * @param origin the origin of the explosion
  60546. * @param radiusOrEventOptions the radius or the options of radial explosion
  60547. * @param strength the explosion strength
  60548. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60549. * @returns A physics gravitational field event, or null
  60550. */
  60551. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60552. /**
  60553. * Creates a physics updraft event
  60554. * @param origin the origin of the updraft
  60555. * @param radiusOrEventOptions the radius or the options of the updraft
  60556. * @param strength the strength of the updraft
  60557. * @param height the height of the updraft
  60558. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60559. * @returns A physics updraft event, or null
  60560. */
  60561. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60562. /**
  60563. * Creates a physics vortex event
  60564. * @param origin the of the vortex
  60565. * @param radiusOrEventOptions the radius or the options of the vortex
  60566. * @param strength the strength of the vortex
  60567. * @param height the height of the vortex
  60568. * @returns a Physics vortex event, or null
  60569. * A physics vortex event or null
  60570. */
  60571. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60572. }
  60573. /**
  60574. * Represents a physics radial explosion event
  60575. */
  60576. class PhysicsRadialExplosionEvent {
  60577. private _scene;
  60578. private _options;
  60579. private _sphere;
  60580. private _dataFetched;
  60581. /**
  60582. * Initializes a radial explosioin event
  60583. * @param _scene BabylonJS scene
  60584. * @param _options The options for the vortex event
  60585. */
  60586. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60587. /**
  60588. * Returns the data related to the radial explosion event (sphere).
  60589. * @returns The radial explosion event data
  60590. */
  60591. getData(): PhysicsRadialExplosionEventData;
  60592. /**
  60593. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60594. * @param impostor A physics imposter
  60595. * @param origin the origin of the explosion
  60596. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60597. */
  60598. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60599. /**
  60600. * Triggers affecterd impostors callbacks
  60601. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60602. */
  60603. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60604. /**
  60605. * Disposes the sphere.
  60606. * @param force Specifies if the sphere should be disposed by force
  60607. */
  60608. dispose(force?: boolean): void;
  60609. /*** Helpers ***/
  60610. private _prepareSphere;
  60611. private _intersectsWithSphere;
  60612. }
  60613. /**
  60614. * Represents a gravitational field event
  60615. */
  60616. class PhysicsGravitationalFieldEvent {
  60617. private _physicsHelper;
  60618. private _scene;
  60619. private _origin;
  60620. private _options;
  60621. private _tickCallback;
  60622. private _sphere;
  60623. private _dataFetched;
  60624. /**
  60625. * Initializes the physics gravitational field event
  60626. * @param _physicsHelper A physics helper
  60627. * @param _scene BabylonJS scene
  60628. * @param _origin The origin position of the gravitational field event
  60629. * @param _options The options for the vortex event
  60630. */
  60631. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60632. /**
  60633. * Returns the data related to the gravitational field event (sphere).
  60634. * @returns A gravitational field event
  60635. */
  60636. getData(): PhysicsGravitationalFieldEventData;
  60637. /**
  60638. * Enables the gravitational field.
  60639. */
  60640. enable(): void;
  60641. /**
  60642. * Disables the gravitational field.
  60643. */
  60644. disable(): void;
  60645. /**
  60646. * Disposes the sphere.
  60647. * @param force The force to dispose from the gravitational field event
  60648. */
  60649. dispose(force?: boolean): void;
  60650. private _tick;
  60651. }
  60652. /**
  60653. * Represents a physics updraft event
  60654. */
  60655. class PhysicsUpdraftEvent {
  60656. private _scene;
  60657. private _origin;
  60658. private _options;
  60659. private _physicsEngine;
  60660. private _originTop;
  60661. private _originDirection;
  60662. private _tickCallback;
  60663. private _cylinder;
  60664. private _cylinderPosition;
  60665. private _dataFetched;
  60666. /**
  60667. * Initializes the physics updraft event
  60668. * @param _scene BabylonJS scene
  60669. * @param _origin The origin position of the updraft
  60670. * @param _options The options for the updraft event
  60671. */
  60672. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60673. /**
  60674. * Returns the data related to the updraft event (cylinder).
  60675. * @returns A physics updraft event
  60676. */
  60677. getData(): PhysicsUpdraftEventData;
  60678. /**
  60679. * Enables the updraft.
  60680. */
  60681. enable(): void;
  60682. /**
  60683. * Disables the updraft.
  60684. */
  60685. disable(): void;
  60686. /**
  60687. * Disposes the cylinder.
  60688. * @param force Specifies if the updraft should be disposed by force
  60689. */
  60690. dispose(force?: boolean): void;
  60691. private getImpostorHitData;
  60692. private _tick;
  60693. /*** Helpers ***/
  60694. private _prepareCylinder;
  60695. private _intersectsWithCylinder;
  60696. }
  60697. /**
  60698. * Represents a physics vortex event
  60699. */
  60700. class PhysicsVortexEvent {
  60701. private _scene;
  60702. private _origin;
  60703. private _options;
  60704. private _physicsEngine;
  60705. private _originTop;
  60706. private _tickCallback;
  60707. private _cylinder;
  60708. private _cylinderPosition;
  60709. private _dataFetched;
  60710. /**
  60711. * Initializes the physics vortex event
  60712. * @param _scene The BabylonJS scene
  60713. * @param _origin The origin position of the vortex
  60714. * @param _options The options for the vortex event
  60715. */
  60716. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60717. /**
  60718. * Returns the data related to the vortex event (cylinder).
  60719. * @returns The physics vortex event data
  60720. */
  60721. getData(): PhysicsVortexEventData;
  60722. /**
  60723. * Enables the vortex.
  60724. */
  60725. enable(): void;
  60726. /**
  60727. * Disables the cortex.
  60728. */
  60729. disable(): void;
  60730. /**
  60731. * Disposes the sphere.
  60732. * @param force
  60733. */
  60734. dispose(force?: boolean): void;
  60735. private getImpostorHitData;
  60736. private _tick;
  60737. /*** Helpers ***/
  60738. private _prepareCylinder;
  60739. private _intersectsWithCylinder;
  60740. }
  60741. /**
  60742. * Options fot the radial explosion event
  60743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60744. */
  60745. export class PhysicsRadialExplosionEventOptions {
  60746. /**
  60747. * The radius of the sphere for the radial explosion.
  60748. */
  60749. radius: number;
  60750. /**
  60751. * The strenth of the explosion.
  60752. */
  60753. strength: number;
  60754. /**
  60755. * The strenght of the force in correspondence to the distance of the affected object
  60756. */
  60757. falloff: PhysicsRadialImpulseFalloff;
  60758. /**
  60759. * Sphere options for the radial explosion.
  60760. */
  60761. sphere: {
  60762. segments: number;
  60763. diameter: number;
  60764. };
  60765. /**
  60766. * Sphere options for the radial explosion.
  60767. */
  60768. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60769. }
  60770. /**
  60771. * Options fot the updraft event
  60772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60773. */
  60774. export class PhysicsUpdraftEventOptions {
  60775. /**
  60776. * The radius of the cylinder for the vortex
  60777. */
  60778. radius: number;
  60779. /**
  60780. * The strenth of the updraft.
  60781. */
  60782. strength: number;
  60783. /**
  60784. * The height of the cylinder for the updraft.
  60785. */
  60786. height: number;
  60787. /**
  60788. * The mode for the the updraft.
  60789. */
  60790. updraftMode: PhysicsUpdraftMode;
  60791. }
  60792. /**
  60793. * Options fot the vortex event
  60794. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60795. */
  60796. export class PhysicsVortexEventOptions {
  60797. /**
  60798. * The radius of the cylinder for the vortex
  60799. */
  60800. radius: number;
  60801. /**
  60802. * The strenth of the vortex.
  60803. */
  60804. strength: number;
  60805. /**
  60806. * The height of the cylinder for the vortex.
  60807. */
  60808. height: number;
  60809. /**
  60810. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60811. */
  60812. centripetalForceThreshold: number;
  60813. /**
  60814. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60815. */
  60816. centripetalForceMultiplier: number;
  60817. /**
  60818. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60819. */
  60820. centrifugalForceMultiplier: number;
  60821. /**
  60822. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60823. */
  60824. updraftForceMultiplier: number;
  60825. }
  60826. /**
  60827. * The strenght of the force in correspondence to the distance of the affected object
  60828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60829. */
  60830. export enum PhysicsRadialImpulseFalloff {
  60831. /** Defines that impulse is constant in strength across it's whole radius */
  60832. Constant = 0,
  60833. /** Defines that impulse gets weaker if it's further from the origin */
  60834. Linear = 1
  60835. }
  60836. /**
  60837. * The strength of the force in correspondence to the distance of the affected object
  60838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60839. */
  60840. export enum PhysicsUpdraftMode {
  60841. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60842. Center = 0,
  60843. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60844. Perpendicular = 1
  60845. }
  60846. /**
  60847. * Interface for a physics hit data
  60848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60849. */
  60850. export interface PhysicsHitData {
  60851. /**
  60852. * The force applied at the contact point
  60853. */
  60854. force: Vector3;
  60855. /**
  60856. * The contact point
  60857. */
  60858. contactPoint: Vector3;
  60859. /**
  60860. * The distance from the origin to the contact point
  60861. */
  60862. distanceFromOrigin: number;
  60863. }
  60864. /**
  60865. * Interface for radial explosion event data
  60866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60867. */
  60868. export interface PhysicsRadialExplosionEventData {
  60869. /**
  60870. * A sphere used for the radial explosion event
  60871. */
  60872. sphere: Mesh;
  60873. }
  60874. /**
  60875. * Interface for gravitational field event data
  60876. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60877. */
  60878. export interface PhysicsGravitationalFieldEventData {
  60879. /**
  60880. * A sphere mesh used for the gravitational field event
  60881. */
  60882. sphere: Mesh;
  60883. }
  60884. /**
  60885. * Interface for updraft event data
  60886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60887. */
  60888. export interface PhysicsUpdraftEventData {
  60889. /**
  60890. * A cylinder used for the updraft event
  60891. */
  60892. cylinder: Mesh;
  60893. }
  60894. /**
  60895. * Interface for vortex event data
  60896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60897. */
  60898. export interface PhysicsVortexEventData {
  60899. /**
  60900. * A cylinder used for the vortex event
  60901. */
  60902. cylinder: Mesh;
  60903. }
  60904. /**
  60905. * Interface for an affected physics impostor
  60906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60907. */
  60908. export interface PhysicsAffectedImpostorWithData {
  60909. /**
  60910. * The impostor affected by the effect
  60911. */
  60912. impostor: PhysicsImpostor;
  60913. /**
  60914. * The data about the hit/horce from the explosion
  60915. */
  60916. hitData: PhysicsHitData;
  60917. }
  60918. }
  60919. declare module "babylonjs/Physics/Plugins/index" {
  60920. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  60921. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  60922. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  60923. }
  60924. declare module "babylonjs/Physics/index" {
  60925. export * from "babylonjs/Physics/IPhysicsEngine";
  60926. export * from "babylonjs/Physics/physicsEngine";
  60927. export * from "babylonjs/Physics/physicsEngineComponent";
  60928. export * from "babylonjs/Physics/physicsHelper";
  60929. export * from "babylonjs/Physics/physicsImpostor";
  60930. export * from "babylonjs/Physics/physicsJoint";
  60931. export * from "babylonjs/Physics/Plugins/index";
  60932. }
  60933. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  60934. /** @hidden */
  60935. export var blackAndWhitePixelShader: {
  60936. name: string;
  60937. shader: string;
  60938. };
  60939. }
  60940. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  60941. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60942. import { Camera } from "babylonjs/Cameras/camera";
  60943. import { Engine } from "babylonjs/Engines/engine";
  60944. import "babylonjs/Shaders/blackAndWhite.fragment";
  60945. /**
  60946. * Post process used to render in black and white
  60947. */
  60948. export class BlackAndWhitePostProcess extends PostProcess {
  60949. /**
  60950. * Linear about to convert he result to black and white (default: 1)
  60951. */
  60952. degree: number;
  60953. /**
  60954. * Creates a black and white post process
  60955. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60956. * @param name The name of the effect.
  60957. * @param options The required width/height ratio to downsize to before computing the render pass.
  60958. * @param camera The camera to apply the render pass to.
  60959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60960. * @param engine The engine which the post process will be applied. (default: current engine)
  60961. * @param reusable If the post process can be reused on the same frame. (default: false)
  60962. */
  60963. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60964. }
  60965. }
  60966. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  60967. import { Nullable } from "babylonjs/types";
  60968. import { Camera } from "babylonjs/Cameras/camera";
  60969. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60970. import { Engine } from "babylonjs/Engines/engine";
  60971. /**
  60972. * This represents a set of one or more post processes in Babylon.
  60973. * A post process can be used to apply a shader to a texture after it is rendered.
  60974. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60975. */
  60976. export class PostProcessRenderEffect {
  60977. private _postProcesses;
  60978. private _getPostProcesses;
  60979. private _singleInstance;
  60980. private _cameras;
  60981. private _indicesForCamera;
  60982. /**
  60983. * Name of the effect
  60984. * @hidden
  60985. */
  60986. _name: string;
  60987. /**
  60988. * Instantiates a post process render effect.
  60989. * A post process can be used to apply a shader to a texture after it is rendered.
  60990. * @param engine The engine the effect is tied to
  60991. * @param name The name of the effect
  60992. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60993. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60994. */
  60995. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60996. /**
  60997. * Checks if all the post processes in the effect are supported.
  60998. */
  60999. readonly isSupported: boolean;
  61000. /**
  61001. * Updates the current state of the effect
  61002. * @hidden
  61003. */
  61004. _update(): void;
  61005. /**
  61006. * Attaches the effect on cameras
  61007. * @param cameras The camera to attach to.
  61008. * @hidden
  61009. */
  61010. _attachCameras(cameras: Camera): void;
  61011. /**
  61012. * Attaches the effect on cameras
  61013. * @param cameras The camera to attach to.
  61014. * @hidden
  61015. */
  61016. _attachCameras(cameras: Camera[]): void;
  61017. /**
  61018. * Detaches the effect on cameras
  61019. * @param cameras The camera to detatch from.
  61020. * @hidden
  61021. */
  61022. _detachCameras(cameras: Camera): void;
  61023. /**
  61024. * Detatches the effect on cameras
  61025. * @param cameras The camera to detatch from.
  61026. * @hidden
  61027. */
  61028. _detachCameras(cameras: Camera[]): void;
  61029. /**
  61030. * Enables the effect on given cameras
  61031. * @param cameras The camera to enable.
  61032. * @hidden
  61033. */
  61034. _enable(cameras: Camera): void;
  61035. /**
  61036. * Enables the effect on given cameras
  61037. * @param cameras The camera to enable.
  61038. * @hidden
  61039. */
  61040. _enable(cameras: Nullable<Camera[]>): void;
  61041. /**
  61042. * Disables the effect on the given cameras
  61043. * @param cameras The camera to disable.
  61044. * @hidden
  61045. */
  61046. _disable(cameras: Camera): void;
  61047. /**
  61048. * Disables the effect on the given cameras
  61049. * @param cameras The camera to disable.
  61050. * @hidden
  61051. */
  61052. _disable(cameras: Nullable<Camera[]>): void;
  61053. /**
  61054. * Gets a list of the post processes contained in the effect.
  61055. * @param camera The camera to get the post processes on.
  61056. * @returns The list of the post processes in the effect.
  61057. */
  61058. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61059. }
  61060. }
  61061. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61062. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61063. /** @hidden */
  61064. export var extractHighlightsPixelShader: {
  61065. name: string;
  61066. shader: string;
  61067. };
  61068. }
  61069. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61070. import { Nullable } from "babylonjs/types";
  61071. import { Camera } from "babylonjs/Cameras/camera";
  61072. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61073. import { Engine } from "babylonjs/Engines/engine";
  61074. import "babylonjs/Shaders/extractHighlights.fragment";
  61075. /**
  61076. * 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.
  61077. */
  61078. export class ExtractHighlightsPostProcess extends PostProcess {
  61079. /**
  61080. * The luminance threshold, pixels below this value will be set to black.
  61081. */
  61082. threshold: number;
  61083. /** @hidden */
  61084. _exposure: number;
  61085. /**
  61086. * Post process which has the input texture to be used when performing highlight extraction
  61087. * @hidden
  61088. */
  61089. _inputPostProcess: Nullable<PostProcess>;
  61090. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61091. }
  61092. }
  61093. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61094. /** @hidden */
  61095. export var bloomMergePixelShader: {
  61096. name: string;
  61097. shader: string;
  61098. };
  61099. }
  61100. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61101. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61102. import { Nullable } from "babylonjs/types";
  61103. import { Engine } from "babylonjs/Engines/engine";
  61104. import { Camera } from "babylonjs/Cameras/camera";
  61105. import "babylonjs/Shaders/bloomMerge.fragment";
  61106. /**
  61107. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61108. */
  61109. export class BloomMergePostProcess extends PostProcess {
  61110. /** Weight of the bloom to be added to the original input. */
  61111. weight: number;
  61112. /**
  61113. * Creates a new instance of @see BloomMergePostProcess
  61114. * @param name The name of the effect.
  61115. * @param originalFromInput Post process which's input will be used for the merge.
  61116. * @param blurred Blurred highlights post process which's output will be used.
  61117. * @param weight Weight of the bloom to be added to the original input.
  61118. * @param options The required width/height ratio to downsize to before computing the render pass.
  61119. * @param camera The camera to apply the render pass to.
  61120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61121. * @param engine The engine which the post process will be applied. (default: current engine)
  61122. * @param reusable If the post process can be reused on the same frame. (default: false)
  61123. * @param textureType Type of textures used when performing the post process. (default: 0)
  61124. * @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)
  61125. */
  61126. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61127. /** Weight of the bloom to be added to the original input. */
  61128. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61129. }
  61130. }
  61131. declare module "babylonjs/PostProcesses/bloomEffect" {
  61132. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61133. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61134. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61135. import { Camera } from "babylonjs/Cameras/camera";
  61136. import { Scene } from "babylonjs/scene";
  61137. /**
  61138. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61139. */
  61140. export class BloomEffect extends PostProcessRenderEffect {
  61141. private bloomScale;
  61142. /**
  61143. * @hidden Internal
  61144. */
  61145. _effects: Array<PostProcess>;
  61146. /**
  61147. * @hidden Internal
  61148. */
  61149. _downscale: ExtractHighlightsPostProcess;
  61150. private _blurX;
  61151. private _blurY;
  61152. private _merge;
  61153. /**
  61154. * The luminance threshold to find bright areas of the image to bloom.
  61155. */
  61156. threshold: number;
  61157. /**
  61158. * The strength of the bloom.
  61159. */
  61160. weight: number;
  61161. /**
  61162. * Specifies the size of the bloom blur kernel, relative to the final output size
  61163. */
  61164. kernel: number;
  61165. /**
  61166. * Creates a new instance of @see BloomEffect
  61167. * @param scene The scene the effect belongs to.
  61168. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61169. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61170. * @param bloomWeight The the strength of bloom.
  61171. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61172. * @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)
  61173. */
  61174. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61175. /**
  61176. * Disposes each of the internal effects for a given camera.
  61177. * @param camera The camera to dispose the effect on.
  61178. */
  61179. disposeEffects(camera: Camera): void;
  61180. /**
  61181. * @hidden Internal
  61182. */
  61183. _updateEffects(): void;
  61184. /**
  61185. * Internal
  61186. * @returns if all the contained post processes are ready.
  61187. * @hidden
  61188. */
  61189. _isReady(): boolean;
  61190. }
  61191. }
  61192. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  61193. /** @hidden */
  61194. export var chromaticAberrationPixelShader: {
  61195. name: string;
  61196. shader: string;
  61197. };
  61198. }
  61199. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  61200. import { Vector2 } from "babylonjs/Maths/math.vector";
  61201. import { Nullable } from "babylonjs/types";
  61202. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61203. import { Camera } from "babylonjs/Cameras/camera";
  61204. import { Engine } from "babylonjs/Engines/engine";
  61205. import "babylonjs/Shaders/chromaticAberration.fragment";
  61206. /**
  61207. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61208. */
  61209. export class ChromaticAberrationPostProcess extends PostProcess {
  61210. /**
  61211. * The amount of seperation of rgb channels (default: 30)
  61212. */
  61213. aberrationAmount: number;
  61214. /**
  61215. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61216. */
  61217. radialIntensity: number;
  61218. /**
  61219. * 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))
  61220. */
  61221. direction: Vector2;
  61222. /**
  61223. * 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))
  61224. */
  61225. centerPosition: Vector2;
  61226. /**
  61227. * Creates a new instance ChromaticAberrationPostProcess
  61228. * @param name The name of the effect.
  61229. * @param screenWidth The width of the screen to apply the effect on.
  61230. * @param screenHeight The height of the screen to apply the effect on.
  61231. * @param options The required width/height ratio to downsize to before computing the render pass.
  61232. * @param camera The camera to apply the render pass to.
  61233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61234. * @param engine The engine which the post process will be applied. (default: current engine)
  61235. * @param reusable If the post process can be reused on the same frame. (default: false)
  61236. * @param textureType Type of textures used when performing the post process. (default: 0)
  61237. * @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)
  61238. */
  61239. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61240. }
  61241. }
  61242. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  61243. /** @hidden */
  61244. export var circleOfConfusionPixelShader: {
  61245. name: string;
  61246. shader: string;
  61247. };
  61248. }
  61249. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  61250. import { Nullable } from "babylonjs/types";
  61251. import { Engine } from "babylonjs/Engines/engine";
  61252. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61253. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61254. import { Camera } from "babylonjs/Cameras/camera";
  61255. import "babylonjs/Shaders/circleOfConfusion.fragment";
  61256. /**
  61257. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61258. */
  61259. export class CircleOfConfusionPostProcess extends PostProcess {
  61260. /**
  61261. * 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.
  61262. */
  61263. lensSize: number;
  61264. /**
  61265. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61266. */
  61267. fStop: number;
  61268. /**
  61269. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61270. */
  61271. focusDistance: number;
  61272. /**
  61273. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61274. */
  61275. focalLength: number;
  61276. private _depthTexture;
  61277. /**
  61278. * Creates a new instance CircleOfConfusionPostProcess
  61279. * @param name The name of the effect.
  61280. * @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.
  61281. * @param options The required width/height ratio to downsize to before computing the render pass.
  61282. * @param camera The camera to apply the render pass to.
  61283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61284. * @param engine The engine which the post process will be applied. (default: current engine)
  61285. * @param reusable If the post process can be reused on the same frame. (default: false)
  61286. * @param textureType Type of textures used when performing the post process. (default: 0)
  61287. * @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)
  61288. */
  61289. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61290. /**
  61291. * 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.
  61292. */
  61293. depthTexture: RenderTargetTexture;
  61294. }
  61295. }
  61296. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  61297. /** @hidden */
  61298. export var colorCorrectionPixelShader: {
  61299. name: string;
  61300. shader: string;
  61301. };
  61302. }
  61303. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  61304. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61305. import { Engine } from "babylonjs/Engines/engine";
  61306. import { Camera } from "babylonjs/Cameras/camera";
  61307. import "babylonjs/Shaders/colorCorrection.fragment";
  61308. /**
  61309. *
  61310. * This post-process allows the modification of rendered colors by using
  61311. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61312. *
  61313. * The object needs to be provided an url to a texture containing the color
  61314. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61315. * Use an image editing software to tweak the LUT to match your needs.
  61316. *
  61317. * For an example of a color LUT, see here:
  61318. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61319. * For explanations on color grading, see here:
  61320. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61321. *
  61322. */
  61323. export class ColorCorrectionPostProcess extends PostProcess {
  61324. private _colorTableTexture;
  61325. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61326. }
  61327. }
  61328. declare module "babylonjs/Shaders/convolution.fragment" {
  61329. /** @hidden */
  61330. export var convolutionPixelShader: {
  61331. name: string;
  61332. shader: string;
  61333. };
  61334. }
  61335. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  61336. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61337. import { Nullable } from "babylonjs/types";
  61338. import { Camera } from "babylonjs/Cameras/camera";
  61339. import { Engine } from "babylonjs/Engines/engine";
  61340. import "babylonjs/Shaders/convolution.fragment";
  61341. /**
  61342. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61343. * input texture to perform effects such as edge detection or sharpening
  61344. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61345. */
  61346. export class ConvolutionPostProcess extends PostProcess {
  61347. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61348. kernel: number[];
  61349. /**
  61350. * Creates a new instance ConvolutionPostProcess
  61351. * @param name The name of the effect.
  61352. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61353. * @param options The required width/height ratio to downsize to before computing the render pass.
  61354. * @param camera The camera to apply the render pass to.
  61355. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61356. * @param engine The engine which the post process will be applied. (default: current engine)
  61357. * @param reusable If the post process can be reused on the same frame. (default: false)
  61358. * @param textureType Type of textures used when performing the post process. (default: 0)
  61359. */
  61360. constructor(name: string,
  61361. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61362. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61363. /**
  61364. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61365. */
  61366. static EdgeDetect0Kernel: number[];
  61367. /**
  61368. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61369. */
  61370. static EdgeDetect1Kernel: number[];
  61371. /**
  61372. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61373. */
  61374. static EdgeDetect2Kernel: number[];
  61375. /**
  61376. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61377. */
  61378. static SharpenKernel: number[];
  61379. /**
  61380. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61381. */
  61382. static EmbossKernel: number[];
  61383. /**
  61384. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61385. */
  61386. static GaussianKernel: number[];
  61387. }
  61388. }
  61389. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  61390. import { Nullable } from "babylonjs/types";
  61391. import { Vector2 } from "babylonjs/Maths/math.vector";
  61392. import { Camera } from "babylonjs/Cameras/camera";
  61393. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61394. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61395. import { Engine } from "babylonjs/Engines/engine";
  61396. import { Scene } from "babylonjs/scene";
  61397. /**
  61398. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61399. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61400. * based on samples that have a large difference in distance than the center pixel.
  61401. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61402. */
  61403. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61404. direction: Vector2;
  61405. /**
  61406. * Creates a new instance CircleOfConfusionPostProcess
  61407. * @param name The name of the effect.
  61408. * @param scene The scene the effect belongs to.
  61409. * @param direction The direction the blur should be applied.
  61410. * @param kernel The size of the kernel used to blur.
  61411. * @param options The required width/height ratio to downsize to before computing the render pass.
  61412. * @param camera The camera to apply the render pass to.
  61413. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61414. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61416. * @param engine The engine which the post process will be applied. (default: current engine)
  61417. * @param reusable If the post process can be reused on the same frame. (default: false)
  61418. * @param textureType Type of textures used when performing the post process. (default: 0)
  61419. * @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)
  61420. */
  61421. 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);
  61422. }
  61423. }
  61424. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61425. /** @hidden */
  61426. export var depthOfFieldMergePixelShader: {
  61427. name: string;
  61428. shader: string;
  61429. };
  61430. }
  61431. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61432. import { Nullable } from "babylonjs/types";
  61433. import { Camera } from "babylonjs/Cameras/camera";
  61434. import { Effect } from "babylonjs/Materials/effect";
  61435. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61436. import { Engine } from "babylonjs/Engines/engine";
  61437. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61438. /**
  61439. * Options to be set when merging outputs from the default pipeline.
  61440. */
  61441. export class DepthOfFieldMergePostProcessOptions {
  61442. /**
  61443. * The original image to merge on top of
  61444. */
  61445. originalFromInput: PostProcess;
  61446. /**
  61447. * Parameters to perform the merge of the depth of field effect
  61448. */
  61449. depthOfField?: {
  61450. circleOfConfusion: PostProcess;
  61451. blurSteps: Array<PostProcess>;
  61452. };
  61453. /**
  61454. * Parameters to perform the merge of bloom effect
  61455. */
  61456. bloom?: {
  61457. blurred: PostProcess;
  61458. weight: number;
  61459. };
  61460. }
  61461. /**
  61462. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61463. */
  61464. export class DepthOfFieldMergePostProcess extends PostProcess {
  61465. private blurSteps;
  61466. /**
  61467. * Creates a new instance of DepthOfFieldMergePostProcess
  61468. * @param name The name of the effect.
  61469. * @param originalFromInput Post process which's input will be used for the merge.
  61470. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61471. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61472. * @param options The required width/height ratio to downsize to before computing the render pass.
  61473. * @param camera The camera to apply the render pass to.
  61474. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61475. * @param engine The engine which the post process will be applied. (default: current engine)
  61476. * @param reusable If the post process can be reused on the same frame. (default: false)
  61477. * @param textureType Type of textures used when performing the post process. (default: 0)
  61478. * @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)
  61479. */
  61480. 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);
  61481. /**
  61482. * Updates the effect with the current post process compile time values and recompiles the shader.
  61483. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61484. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61485. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61486. * @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
  61487. * @param onCompiled Called when the shader has been compiled.
  61488. * @param onError Called if there is an error when compiling a shader.
  61489. */
  61490. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61491. }
  61492. }
  61493. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61494. import { Nullable } from "babylonjs/types";
  61495. import { Camera } from "babylonjs/Cameras/camera";
  61496. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61497. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61498. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61499. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61500. import { Scene } from "babylonjs/scene";
  61501. /**
  61502. * Specifies the level of max blur that should be applied when using the depth of field effect
  61503. */
  61504. export enum DepthOfFieldEffectBlurLevel {
  61505. /**
  61506. * Subtle blur
  61507. */
  61508. Low = 0,
  61509. /**
  61510. * Medium blur
  61511. */
  61512. Medium = 1,
  61513. /**
  61514. * Large blur
  61515. */
  61516. High = 2
  61517. }
  61518. /**
  61519. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61520. */
  61521. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61522. private _circleOfConfusion;
  61523. /**
  61524. * @hidden Internal, blurs from high to low
  61525. */
  61526. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61527. private _depthOfFieldBlurY;
  61528. private _dofMerge;
  61529. /**
  61530. * @hidden Internal post processes in depth of field effect
  61531. */
  61532. _effects: Array<PostProcess>;
  61533. /**
  61534. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61535. */
  61536. focalLength: number;
  61537. /**
  61538. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61539. */
  61540. fStop: number;
  61541. /**
  61542. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61543. */
  61544. focusDistance: number;
  61545. /**
  61546. * 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.
  61547. */
  61548. lensSize: number;
  61549. /**
  61550. * Creates a new instance DepthOfFieldEffect
  61551. * @param scene The scene the effect belongs to.
  61552. * @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.
  61553. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61554. * @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)
  61555. */
  61556. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61557. /**
  61558. * Get the current class name of the current effet
  61559. * @returns "DepthOfFieldEffect"
  61560. */
  61561. getClassName(): string;
  61562. /**
  61563. * 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.
  61564. */
  61565. depthTexture: RenderTargetTexture;
  61566. /**
  61567. * Disposes each of the internal effects for a given camera.
  61568. * @param camera The camera to dispose the effect on.
  61569. */
  61570. disposeEffects(camera: Camera): void;
  61571. /**
  61572. * @hidden Internal
  61573. */
  61574. _updateEffects(): void;
  61575. /**
  61576. * Internal
  61577. * @returns if all the contained post processes are ready.
  61578. * @hidden
  61579. */
  61580. _isReady(): boolean;
  61581. }
  61582. }
  61583. declare module "babylonjs/Shaders/displayPass.fragment" {
  61584. /** @hidden */
  61585. export var displayPassPixelShader: {
  61586. name: string;
  61587. shader: string;
  61588. };
  61589. }
  61590. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  61591. import { Nullable } from "babylonjs/types";
  61592. import { Camera } from "babylonjs/Cameras/camera";
  61593. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61594. import { Engine } from "babylonjs/Engines/engine";
  61595. import "babylonjs/Shaders/displayPass.fragment";
  61596. /**
  61597. * DisplayPassPostProcess which produces an output the same as it's input
  61598. */
  61599. export class DisplayPassPostProcess extends PostProcess {
  61600. /**
  61601. * Creates the DisplayPassPostProcess
  61602. * @param name The name of the effect.
  61603. * @param options The required width/height ratio to downsize to before computing the render pass.
  61604. * @param camera The camera to apply the render pass to.
  61605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61606. * @param engine The engine which the post process will be applied. (default: current engine)
  61607. * @param reusable If the post process can be reused on the same frame. (default: false)
  61608. */
  61609. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61610. }
  61611. }
  61612. declare module "babylonjs/Shaders/filter.fragment" {
  61613. /** @hidden */
  61614. export var filterPixelShader: {
  61615. name: string;
  61616. shader: string;
  61617. };
  61618. }
  61619. declare module "babylonjs/PostProcesses/filterPostProcess" {
  61620. import { Nullable } from "babylonjs/types";
  61621. import { Matrix } from "babylonjs/Maths/math.vector";
  61622. import { Camera } from "babylonjs/Cameras/camera";
  61623. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61624. import { Engine } from "babylonjs/Engines/engine";
  61625. import "babylonjs/Shaders/filter.fragment";
  61626. /**
  61627. * Applies a kernel filter to the image
  61628. */
  61629. export class FilterPostProcess extends PostProcess {
  61630. /** The matrix to be applied to the image */
  61631. kernelMatrix: Matrix;
  61632. /**
  61633. *
  61634. * @param name The name of the effect.
  61635. * @param kernelMatrix The matrix to be applied to the image
  61636. * @param options The required width/height ratio to downsize to before computing the render pass.
  61637. * @param camera The camera to apply the render pass to.
  61638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61639. * @param engine The engine which the post process will be applied. (default: current engine)
  61640. * @param reusable If the post process can be reused on the same frame. (default: false)
  61641. */
  61642. constructor(name: string,
  61643. /** The matrix to be applied to the image */
  61644. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61645. }
  61646. }
  61647. declare module "babylonjs/Shaders/fxaa.fragment" {
  61648. /** @hidden */
  61649. export var fxaaPixelShader: {
  61650. name: string;
  61651. shader: string;
  61652. };
  61653. }
  61654. declare module "babylonjs/Shaders/fxaa.vertex" {
  61655. /** @hidden */
  61656. export var fxaaVertexShader: {
  61657. name: string;
  61658. shader: string;
  61659. };
  61660. }
  61661. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  61662. import { Nullable } from "babylonjs/types";
  61663. import { Camera } from "babylonjs/Cameras/camera";
  61664. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61665. import { Engine } from "babylonjs/Engines/engine";
  61666. import "babylonjs/Shaders/fxaa.fragment";
  61667. import "babylonjs/Shaders/fxaa.vertex";
  61668. /**
  61669. * Fxaa post process
  61670. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61671. */
  61672. export class FxaaPostProcess extends PostProcess {
  61673. /** @hidden */
  61674. texelWidth: number;
  61675. /** @hidden */
  61676. texelHeight: number;
  61677. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61678. private _getDefines;
  61679. }
  61680. }
  61681. declare module "babylonjs/Shaders/grain.fragment" {
  61682. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61683. /** @hidden */
  61684. export var grainPixelShader: {
  61685. name: string;
  61686. shader: string;
  61687. };
  61688. }
  61689. declare module "babylonjs/PostProcesses/grainPostProcess" {
  61690. import { Nullable } from "babylonjs/types";
  61691. import { Camera } from "babylonjs/Cameras/camera";
  61692. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61693. import { Engine } from "babylonjs/Engines/engine";
  61694. import "babylonjs/Shaders/grain.fragment";
  61695. /**
  61696. * The GrainPostProcess adds noise to the image at mid luminance levels
  61697. */
  61698. export class GrainPostProcess extends PostProcess {
  61699. /**
  61700. * The intensity of the grain added (default: 30)
  61701. */
  61702. intensity: number;
  61703. /**
  61704. * If the grain should be randomized on every frame
  61705. */
  61706. animated: boolean;
  61707. /**
  61708. * Creates a new instance of @see GrainPostProcess
  61709. * @param name The name of the effect.
  61710. * @param options The required width/height ratio to downsize to before computing the render pass.
  61711. * @param camera The camera to apply the render pass to.
  61712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61713. * @param engine The engine which the post process will be applied. (default: current engine)
  61714. * @param reusable If the post process can be reused on the same frame. (default: false)
  61715. * @param textureType Type of textures used when performing the post process. (default: 0)
  61716. * @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)
  61717. */
  61718. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61719. }
  61720. }
  61721. declare module "babylonjs/Shaders/highlights.fragment" {
  61722. /** @hidden */
  61723. export var highlightsPixelShader: {
  61724. name: string;
  61725. shader: string;
  61726. };
  61727. }
  61728. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  61729. import { Nullable } from "babylonjs/types";
  61730. import { Camera } from "babylonjs/Cameras/camera";
  61731. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61732. import { Engine } from "babylonjs/Engines/engine";
  61733. import "babylonjs/Shaders/highlights.fragment";
  61734. /**
  61735. * Extracts highlights from the image
  61736. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61737. */
  61738. export class HighlightsPostProcess extends PostProcess {
  61739. /**
  61740. * Extracts highlights from the image
  61741. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61742. * @param name The name of the effect.
  61743. * @param options The required width/height ratio to downsize to before computing the render pass.
  61744. * @param camera The camera to apply the render pass to.
  61745. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61746. * @param engine The engine which the post process will be applied. (default: current engine)
  61747. * @param reusable If the post process can be reused on the same frame. (default: false)
  61748. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61749. */
  61750. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61751. }
  61752. }
  61753. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  61754. /** @hidden */
  61755. export var mrtFragmentDeclaration: {
  61756. name: string;
  61757. shader: string;
  61758. };
  61759. }
  61760. declare module "babylonjs/Shaders/geometry.fragment" {
  61761. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  61762. /** @hidden */
  61763. export var geometryPixelShader: {
  61764. name: string;
  61765. shader: string;
  61766. };
  61767. }
  61768. declare module "babylonjs/Shaders/geometry.vertex" {
  61769. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61770. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61771. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61772. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61773. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61774. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61775. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61776. /** @hidden */
  61777. export var geometryVertexShader: {
  61778. name: string;
  61779. shader: string;
  61780. };
  61781. }
  61782. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  61783. import { Matrix } from "babylonjs/Maths/math.vector";
  61784. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61785. import { Mesh } from "babylonjs/Meshes/mesh";
  61786. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  61787. import { Effect } from "babylonjs/Materials/effect";
  61788. import { Scene } from "babylonjs/scene";
  61789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61790. import "babylonjs/Shaders/geometry.fragment";
  61791. import "babylonjs/Shaders/geometry.vertex";
  61792. /** @hidden */
  61793. interface ISavedTransformationMatrix {
  61794. world: Matrix;
  61795. viewProjection: Matrix;
  61796. }
  61797. /**
  61798. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61799. */
  61800. export class GeometryBufferRenderer {
  61801. /**
  61802. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61803. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61804. */
  61805. static readonly POSITION_TEXTURE_TYPE: number;
  61806. /**
  61807. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61808. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61809. */
  61810. static readonly VELOCITY_TEXTURE_TYPE: number;
  61811. /**
  61812. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61813. * in order to compute objects velocities when enableVelocity is set to "true"
  61814. * @hidden
  61815. */
  61816. _previousTransformationMatrices: {
  61817. [index: number]: ISavedTransformationMatrix;
  61818. };
  61819. /**
  61820. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61821. * in order to compute objects velocities when enableVelocity is set to "true"
  61822. * @hidden
  61823. */
  61824. _previousBonesTransformationMatrices: {
  61825. [index: number]: Float32Array;
  61826. };
  61827. /**
  61828. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61829. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61830. */
  61831. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61832. private _scene;
  61833. private _multiRenderTarget;
  61834. private _ratio;
  61835. private _enablePosition;
  61836. private _enableVelocity;
  61837. private _positionIndex;
  61838. private _velocityIndex;
  61839. protected _effect: Effect;
  61840. protected _cachedDefines: string;
  61841. /**
  61842. * Set the render list (meshes to be rendered) used in the G buffer.
  61843. */
  61844. renderList: Mesh[];
  61845. /**
  61846. * Gets wether or not G buffer are supported by the running hardware.
  61847. * This requires draw buffer supports
  61848. */
  61849. readonly isSupported: boolean;
  61850. /**
  61851. * Returns the index of the given texture type in the G-Buffer textures array
  61852. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61853. * @returns the index of the given texture type in the G-Buffer textures array
  61854. */
  61855. getTextureIndex(textureType: number): number;
  61856. /**
  61857. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61858. */
  61859. /**
  61860. * Sets whether or not objects positions are enabled for the G buffer.
  61861. */
  61862. enablePosition: boolean;
  61863. /**
  61864. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61865. */
  61866. /**
  61867. * Sets wether or not objects velocities are enabled for the G buffer.
  61868. */
  61869. enableVelocity: boolean;
  61870. /**
  61871. * Gets the scene associated with the buffer.
  61872. */
  61873. readonly scene: Scene;
  61874. /**
  61875. * Gets the ratio used by the buffer during its creation.
  61876. * How big is the buffer related to the main canvas.
  61877. */
  61878. readonly ratio: number;
  61879. /** @hidden */
  61880. static _SceneComponentInitialization: (scene: Scene) => void;
  61881. /**
  61882. * Creates a new G Buffer for the scene
  61883. * @param scene The scene the buffer belongs to
  61884. * @param ratio How big is the buffer related to the main canvas.
  61885. */
  61886. constructor(scene: Scene, ratio?: number);
  61887. /**
  61888. * Checks wether everything is ready to render a submesh to the G buffer.
  61889. * @param subMesh the submesh to check readiness for
  61890. * @param useInstances is the mesh drawn using instance or not
  61891. * @returns true if ready otherwise false
  61892. */
  61893. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61894. /**
  61895. * Gets the current underlying G Buffer.
  61896. * @returns the buffer
  61897. */
  61898. getGBuffer(): MultiRenderTarget;
  61899. /**
  61900. * Gets the number of samples used to render the buffer (anti aliasing).
  61901. */
  61902. /**
  61903. * Sets the number of samples used to render the buffer (anti aliasing).
  61904. */
  61905. samples: number;
  61906. /**
  61907. * Disposes the renderer and frees up associated resources.
  61908. */
  61909. dispose(): void;
  61910. protected _createRenderTargets(): void;
  61911. private _copyBonesTransformationMatrices;
  61912. }
  61913. }
  61914. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  61915. import { Nullable } from "babylonjs/types";
  61916. import { Scene } from "babylonjs/scene";
  61917. import { ISceneComponent } from "babylonjs/sceneComponent";
  61918. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  61919. module "babylonjs/scene" {
  61920. interface Scene {
  61921. /** @hidden (Backing field) */
  61922. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61923. /**
  61924. * Gets or Sets the current geometry buffer associated to the scene.
  61925. */
  61926. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61927. /**
  61928. * Enables a GeometryBufferRender and associates it with the scene
  61929. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61930. * @returns the GeometryBufferRenderer
  61931. */
  61932. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61933. /**
  61934. * Disables the GeometryBufferRender associated with the scene
  61935. */
  61936. disableGeometryBufferRenderer(): void;
  61937. }
  61938. }
  61939. /**
  61940. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61941. * in several rendering techniques.
  61942. */
  61943. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61944. /**
  61945. * The component name helpful to identify the component in the list of scene components.
  61946. */
  61947. readonly name: string;
  61948. /**
  61949. * The scene the component belongs to.
  61950. */
  61951. scene: Scene;
  61952. /**
  61953. * Creates a new instance of the component for the given scene
  61954. * @param scene Defines the scene to register the component in
  61955. */
  61956. constructor(scene: Scene);
  61957. /**
  61958. * Registers the component in a given scene
  61959. */
  61960. register(): void;
  61961. /**
  61962. * Rebuilds the elements related to this component in case of
  61963. * context lost for instance.
  61964. */
  61965. rebuild(): void;
  61966. /**
  61967. * Disposes the component and the associated ressources
  61968. */
  61969. dispose(): void;
  61970. private _gatherRenderTargets;
  61971. }
  61972. }
  61973. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61974. /** @hidden */
  61975. export var motionBlurPixelShader: {
  61976. name: string;
  61977. shader: string;
  61978. };
  61979. }
  61980. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61981. import { Nullable } from "babylonjs/types";
  61982. import { Camera } from "babylonjs/Cameras/camera";
  61983. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61984. import { Scene } from "babylonjs/scene";
  61985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61986. import "babylonjs/Animations/animatable";
  61987. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61988. import "babylonjs/Shaders/motionBlur.fragment";
  61989. import { Engine } from "babylonjs/Engines/engine";
  61990. /**
  61991. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61992. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61993. * As an example, all you have to do is to create the post-process:
  61994. * var mb = new BABYLON.MotionBlurPostProcess(
  61995. * 'mb', // The name of the effect.
  61996. * scene, // The scene containing the objects to blur according to their velocity.
  61997. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61998. * camera // The camera to apply the render pass to.
  61999. * );
  62000. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62001. */
  62002. export class MotionBlurPostProcess extends PostProcess {
  62003. /**
  62004. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62005. */
  62006. motionStrength: number;
  62007. /**
  62008. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62009. */
  62010. /**
  62011. * Sets the number of iterations to be used for motion blur quality
  62012. */
  62013. motionBlurSamples: number;
  62014. private _motionBlurSamples;
  62015. private _geometryBufferRenderer;
  62016. /**
  62017. * Creates a new instance MotionBlurPostProcess
  62018. * @param name The name of the effect.
  62019. * @param scene The scene containing the objects to blur according to their velocity.
  62020. * @param options The required width/height ratio to downsize to before computing the render pass.
  62021. * @param camera The camera to apply the render pass to.
  62022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62023. * @param engine The engine which the post process will be applied. (default: current engine)
  62024. * @param reusable If the post process can be reused on the same frame. (default: false)
  62025. * @param textureType Type of textures used when performing the post process. (default: 0)
  62026. * @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)
  62027. */
  62028. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62029. /**
  62030. * Excludes the given skinned mesh from computing bones velocities.
  62031. * 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.
  62032. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62033. */
  62034. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62035. /**
  62036. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62037. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62038. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62039. */
  62040. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62041. /**
  62042. * Disposes the post process.
  62043. * @param camera The camera to dispose the post process on.
  62044. */
  62045. dispose(camera?: Camera): void;
  62046. }
  62047. }
  62048. declare module "babylonjs/Shaders/refraction.fragment" {
  62049. /** @hidden */
  62050. export var refractionPixelShader: {
  62051. name: string;
  62052. shader: string;
  62053. };
  62054. }
  62055. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62056. import { Color3 } from "babylonjs/Maths/math.color";
  62057. import { Camera } from "babylonjs/Cameras/camera";
  62058. import { Texture } from "babylonjs/Materials/Textures/texture";
  62059. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62060. import { Engine } from "babylonjs/Engines/engine";
  62061. import "babylonjs/Shaders/refraction.fragment";
  62062. /**
  62063. * Post process which applies a refractin texture
  62064. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62065. */
  62066. export class RefractionPostProcess extends PostProcess {
  62067. /** the base color of the refraction (used to taint the rendering) */
  62068. color: Color3;
  62069. /** simulated refraction depth */
  62070. depth: number;
  62071. /** the coefficient of the base color (0 to remove base color tainting) */
  62072. colorLevel: number;
  62073. private _refTexture;
  62074. private _ownRefractionTexture;
  62075. /**
  62076. * Gets or sets the refraction texture
  62077. * Please note that you are responsible for disposing the texture if you set it manually
  62078. */
  62079. refractionTexture: Texture;
  62080. /**
  62081. * Initializes the RefractionPostProcess
  62082. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62083. * @param name The name of the effect.
  62084. * @param refractionTextureUrl Url of the refraction texture to use
  62085. * @param color the base color of the refraction (used to taint the rendering)
  62086. * @param depth simulated refraction depth
  62087. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62088. * @param camera The camera to apply the render pass to.
  62089. * @param options The required width/height ratio to downsize to before computing the render pass.
  62090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62091. * @param engine The engine which the post process will be applied. (default: current engine)
  62092. * @param reusable If the post process can be reused on the same frame. (default: false)
  62093. */
  62094. constructor(name: string, refractionTextureUrl: string,
  62095. /** the base color of the refraction (used to taint the rendering) */
  62096. color: Color3,
  62097. /** simulated refraction depth */
  62098. depth: number,
  62099. /** the coefficient of the base color (0 to remove base color tainting) */
  62100. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62101. /**
  62102. * Disposes of the post process
  62103. * @param camera Camera to dispose post process on
  62104. */
  62105. dispose(camera: Camera): void;
  62106. }
  62107. }
  62108. declare module "babylonjs/Shaders/sharpen.fragment" {
  62109. /** @hidden */
  62110. export var sharpenPixelShader: {
  62111. name: string;
  62112. shader: string;
  62113. };
  62114. }
  62115. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62116. import { Nullable } from "babylonjs/types";
  62117. import { Camera } from "babylonjs/Cameras/camera";
  62118. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62119. import "babylonjs/Shaders/sharpen.fragment";
  62120. import { Engine } from "babylonjs/Engines/engine";
  62121. /**
  62122. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62123. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62124. */
  62125. export class SharpenPostProcess extends PostProcess {
  62126. /**
  62127. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62128. */
  62129. colorAmount: number;
  62130. /**
  62131. * How much sharpness should be applied (default: 0.3)
  62132. */
  62133. edgeAmount: number;
  62134. /**
  62135. * Creates a new instance ConvolutionPostProcess
  62136. * @param name The name of the effect.
  62137. * @param options The required width/height ratio to downsize to before computing the render pass.
  62138. * @param camera The camera to apply the render pass to.
  62139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62140. * @param engine The engine which the post process will be applied. (default: current engine)
  62141. * @param reusable If the post process can be reused on the same frame. (default: false)
  62142. * @param textureType Type of textures used when performing the post process. (default: 0)
  62143. * @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)
  62144. */
  62145. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62146. }
  62147. }
  62148. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62149. import { Nullable } from "babylonjs/types";
  62150. import { Camera } from "babylonjs/Cameras/camera";
  62151. import { Engine } from "babylonjs/Engines/engine";
  62152. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62153. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62154. /**
  62155. * PostProcessRenderPipeline
  62156. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62157. */
  62158. export class PostProcessRenderPipeline {
  62159. private engine;
  62160. private _renderEffects;
  62161. private _renderEffectsForIsolatedPass;
  62162. /**
  62163. * List of inspectable custom properties (used by the Inspector)
  62164. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62165. */
  62166. inspectableCustomProperties: IInspectable[];
  62167. /**
  62168. * @hidden
  62169. */
  62170. protected _cameras: Camera[];
  62171. /** @hidden */
  62172. _name: string;
  62173. /**
  62174. * Gets pipeline name
  62175. */
  62176. readonly name: string;
  62177. /**
  62178. * Initializes a PostProcessRenderPipeline
  62179. * @param engine engine to add the pipeline to
  62180. * @param name name of the pipeline
  62181. */
  62182. constructor(engine: Engine, name: string);
  62183. /**
  62184. * Gets the class name
  62185. * @returns "PostProcessRenderPipeline"
  62186. */
  62187. getClassName(): string;
  62188. /**
  62189. * If all the render effects in the pipeline are supported
  62190. */
  62191. readonly isSupported: boolean;
  62192. /**
  62193. * Adds an effect to the pipeline
  62194. * @param renderEffect the effect to add
  62195. */
  62196. addEffect(renderEffect: PostProcessRenderEffect): void;
  62197. /** @hidden */
  62198. _rebuild(): void;
  62199. /** @hidden */
  62200. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62201. /** @hidden */
  62202. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62203. /** @hidden */
  62204. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62205. /** @hidden */
  62206. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62207. /** @hidden */
  62208. _attachCameras(cameras: Camera, unique: boolean): void;
  62209. /** @hidden */
  62210. _attachCameras(cameras: Camera[], unique: boolean): void;
  62211. /** @hidden */
  62212. _detachCameras(cameras: Camera): void;
  62213. /** @hidden */
  62214. _detachCameras(cameras: Nullable<Camera[]>): void;
  62215. /** @hidden */
  62216. _update(): void;
  62217. /** @hidden */
  62218. _reset(): void;
  62219. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62220. /**
  62221. * Disposes of the pipeline
  62222. */
  62223. dispose(): void;
  62224. }
  62225. }
  62226. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  62227. import { Camera } from "babylonjs/Cameras/camera";
  62228. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62229. /**
  62230. * PostProcessRenderPipelineManager class
  62231. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62232. */
  62233. export class PostProcessRenderPipelineManager {
  62234. private _renderPipelines;
  62235. /**
  62236. * Initializes a PostProcessRenderPipelineManager
  62237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62238. */
  62239. constructor();
  62240. /**
  62241. * Gets the list of supported render pipelines
  62242. */
  62243. readonly supportedPipelines: PostProcessRenderPipeline[];
  62244. /**
  62245. * Adds a pipeline to the manager
  62246. * @param renderPipeline The pipeline to add
  62247. */
  62248. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62249. /**
  62250. * Attaches a camera to the pipeline
  62251. * @param renderPipelineName The name of the pipeline to attach to
  62252. * @param cameras the camera to attach
  62253. * @param unique if the camera can be attached multiple times to the pipeline
  62254. */
  62255. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62256. /**
  62257. * Detaches a camera from the pipeline
  62258. * @param renderPipelineName The name of the pipeline to detach from
  62259. * @param cameras the camera to detach
  62260. */
  62261. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62262. /**
  62263. * Enables an effect by name on a pipeline
  62264. * @param renderPipelineName the name of the pipeline to enable the effect in
  62265. * @param renderEffectName the name of the effect to enable
  62266. * @param cameras the cameras that the effect should be enabled on
  62267. */
  62268. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62269. /**
  62270. * Disables an effect by name on a pipeline
  62271. * @param renderPipelineName the name of the pipeline to disable the effect in
  62272. * @param renderEffectName the name of the effect to disable
  62273. * @param cameras the cameras that the effect should be disabled on
  62274. */
  62275. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62276. /**
  62277. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62278. */
  62279. update(): void;
  62280. /** @hidden */
  62281. _rebuild(): void;
  62282. /**
  62283. * Disposes of the manager and pipelines
  62284. */
  62285. dispose(): void;
  62286. }
  62287. }
  62288. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  62289. import { ISceneComponent } from "babylonjs/sceneComponent";
  62290. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62291. import { Scene } from "babylonjs/scene";
  62292. module "babylonjs/scene" {
  62293. interface Scene {
  62294. /** @hidden (Backing field) */
  62295. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62296. /**
  62297. * Gets the postprocess render pipeline manager
  62298. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62299. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62300. */
  62301. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62302. }
  62303. }
  62304. /**
  62305. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62306. */
  62307. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62308. /**
  62309. * The component name helpfull to identify the component in the list of scene components.
  62310. */
  62311. readonly name: string;
  62312. /**
  62313. * The scene the component belongs to.
  62314. */
  62315. scene: Scene;
  62316. /**
  62317. * Creates a new instance of the component for the given scene
  62318. * @param scene Defines the scene to register the component in
  62319. */
  62320. constructor(scene: Scene);
  62321. /**
  62322. * Registers the component in a given scene
  62323. */
  62324. register(): void;
  62325. /**
  62326. * Rebuilds the elements related to this component in case of
  62327. * context lost for instance.
  62328. */
  62329. rebuild(): void;
  62330. /**
  62331. * Disposes the component and the associated ressources
  62332. */
  62333. dispose(): void;
  62334. private _gatherRenderTargets;
  62335. }
  62336. }
  62337. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  62338. import { Nullable } from "babylonjs/types";
  62339. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62340. import { Camera } from "babylonjs/Cameras/camera";
  62341. import { IDisposable } from "babylonjs/scene";
  62342. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  62343. import { Scene } from "babylonjs/scene";
  62344. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  62345. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62346. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62347. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  62348. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62349. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62350. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  62351. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62352. import { Animation } from "babylonjs/Animations/animation";
  62353. /**
  62354. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62355. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62356. */
  62357. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62358. private _scene;
  62359. private _camerasToBeAttached;
  62360. /**
  62361. * ID of the sharpen post process,
  62362. */
  62363. private readonly SharpenPostProcessId;
  62364. /**
  62365. * @ignore
  62366. * ID of the image processing post process;
  62367. */
  62368. readonly ImageProcessingPostProcessId: string;
  62369. /**
  62370. * @ignore
  62371. * ID of the Fast Approximate Anti-Aliasing post process;
  62372. */
  62373. readonly FxaaPostProcessId: string;
  62374. /**
  62375. * ID of the chromatic aberration post process,
  62376. */
  62377. private readonly ChromaticAberrationPostProcessId;
  62378. /**
  62379. * ID of the grain post process
  62380. */
  62381. private readonly GrainPostProcessId;
  62382. /**
  62383. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62384. */
  62385. sharpen: SharpenPostProcess;
  62386. private _sharpenEffect;
  62387. private bloom;
  62388. /**
  62389. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62390. */
  62391. depthOfField: DepthOfFieldEffect;
  62392. /**
  62393. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62394. */
  62395. fxaa: FxaaPostProcess;
  62396. /**
  62397. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62398. */
  62399. imageProcessing: ImageProcessingPostProcess;
  62400. /**
  62401. * Chromatic aberration post process which will shift rgb colors in the image
  62402. */
  62403. chromaticAberration: ChromaticAberrationPostProcess;
  62404. private _chromaticAberrationEffect;
  62405. /**
  62406. * Grain post process which add noise to the image
  62407. */
  62408. grain: GrainPostProcess;
  62409. private _grainEffect;
  62410. /**
  62411. * Glow post process which adds a glow to emissive areas of the image
  62412. */
  62413. private _glowLayer;
  62414. /**
  62415. * Animations which can be used to tweak settings over a period of time
  62416. */
  62417. animations: Animation[];
  62418. private _imageProcessingConfigurationObserver;
  62419. private _sharpenEnabled;
  62420. private _bloomEnabled;
  62421. private _depthOfFieldEnabled;
  62422. private _depthOfFieldBlurLevel;
  62423. private _fxaaEnabled;
  62424. private _imageProcessingEnabled;
  62425. private _defaultPipelineTextureType;
  62426. private _bloomScale;
  62427. private _chromaticAberrationEnabled;
  62428. private _grainEnabled;
  62429. private _buildAllowed;
  62430. /**
  62431. * Gets active scene
  62432. */
  62433. readonly scene: Scene;
  62434. /**
  62435. * Enable or disable the sharpen process from the pipeline
  62436. */
  62437. sharpenEnabled: boolean;
  62438. private _resizeObserver;
  62439. private _hardwareScaleLevel;
  62440. private _bloomKernel;
  62441. /**
  62442. * Specifies the size of the bloom blur kernel, relative to the final output size
  62443. */
  62444. bloomKernel: number;
  62445. /**
  62446. * Specifies the weight of the bloom in the final rendering
  62447. */
  62448. private _bloomWeight;
  62449. /**
  62450. * Specifies the luma threshold for the area that will be blurred by the bloom
  62451. */
  62452. private _bloomThreshold;
  62453. private _hdr;
  62454. /**
  62455. * The strength of the bloom.
  62456. */
  62457. bloomWeight: number;
  62458. /**
  62459. * The strength of the bloom.
  62460. */
  62461. bloomThreshold: number;
  62462. /**
  62463. * The scale of the bloom, lower value will provide better performance.
  62464. */
  62465. bloomScale: number;
  62466. /**
  62467. * Enable or disable the bloom from the pipeline
  62468. */
  62469. bloomEnabled: boolean;
  62470. private _rebuildBloom;
  62471. /**
  62472. * If the depth of field is enabled.
  62473. */
  62474. depthOfFieldEnabled: boolean;
  62475. /**
  62476. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62477. */
  62478. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62479. /**
  62480. * If the anti aliasing is enabled.
  62481. */
  62482. fxaaEnabled: boolean;
  62483. private _samples;
  62484. /**
  62485. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62486. */
  62487. samples: number;
  62488. /**
  62489. * If image processing is enabled.
  62490. */
  62491. imageProcessingEnabled: boolean;
  62492. /**
  62493. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62494. */
  62495. glowLayerEnabled: boolean;
  62496. /**
  62497. * Gets the glow layer (or null if not defined)
  62498. */
  62499. readonly glowLayer: Nullable<GlowLayer>;
  62500. /**
  62501. * Enable or disable the chromaticAberration process from the pipeline
  62502. */
  62503. chromaticAberrationEnabled: boolean;
  62504. /**
  62505. * Enable or disable the grain process from the pipeline
  62506. */
  62507. grainEnabled: boolean;
  62508. /**
  62509. * @constructor
  62510. * @param name - The rendering pipeline name (default: "")
  62511. * @param hdr - If high dynamic range textures should be used (default: true)
  62512. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62513. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62514. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62515. */
  62516. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62517. /**
  62518. * Get the class name
  62519. * @returns "DefaultRenderingPipeline"
  62520. */
  62521. getClassName(): string;
  62522. /**
  62523. * Force the compilation of the entire pipeline.
  62524. */
  62525. prepare(): void;
  62526. private _hasCleared;
  62527. private _prevPostProcess;
  62528. private _prevPrevPostProcess;
  62529. private _setAutoClearAndTextureSharing;
  62530. private _depthOfFieldSceneObserver;
  62531. private _buildPipeline;
  62532. private _disposePostProcesses;
  62533. /**
  62534. * Adds a camera to the pipeline
  62535. * @param camera the camera to be added
  62536. */
  62537. addCamera(camera: Camera): void;
  62538. /**
  62539. * Removes a camera from the pipeline
  62540. * @param camera the camera to remove
  62541. */
  62542. removeCamera(camera: Camera): void;
  62543. /**
  62544. * Dispose of the pipeline and stop all post processes
  62545. */
  62546. dispose(): void;
  62547. /**
  62548. * Serialize the rendering pipeline (Used when exporting)
  62549. * @returns the serialized object
  62550. */
  62551. serialize(): any;
  62552. /**
  62553. * Parse the serialized pipeline
  62554. * @param source Source pipeline.
  62555. * @param scene The scene to load the pipeline to.
  62556. * @param rootUrl The URL of the serialized pipeline.
  62557. * @returns An instantiated pipeline from the serialized object.
  62558. */
  62559. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62560. }
  62561. }
  62562. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  62563. /** @hidden */
  62564. export var lensHighlightsPixelShader: {
  62565. name: string;
  62566. shader: string;
  62567. };
  62568. }
  62569. declare module "babylonjs/Shaders/depthOfField.fragment" {
  62570. /** @hidden */
  62571. export var depthOfFieldPixelShader: {
  62572. name: string;
  62573. shader: string;
  62574. };
  62575. }
  62576. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  62577. import { Camera } from "babylonjs/Cameras/camera";
  62578. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62579. import { Scene } from "babylonjs/scene";
  62580. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62581. import "babylonjs/Shaders/chromaticAberration.fragment";
  62582. import "babylonjs/Shaders/lensHighlights.fragment";
  62583. import "babylonjs/Shaders/depthOfField.fragment";
  62584. /**
  62585. * BABYLON.JS Chromatic Aberration GLSL Shader
  62586. * Author: Olivier Guyot
  62587. * Separates very slightly R, G and B colors on the edges of the screen
  62588. * Inspired by Francois Tarlier & Martins Upitis
  62589. */
  62590. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62591. /**
  62592. * @ignore
  62593. * The chromatic aberration PostProcess id in the pipeline
  62594. */
  62595. LensChromaticAberrationEffect: string;
  62596. /**
  62597. * @ignore
  62598. * The highlights enhancing PostProcess id in the pipeline
  62599. */
  62600. HighlightsEnhancingEffect: string;
  62601. /**
  62602. * @ignore
  62603. * The depth-of-field PostProcess id in the pipeline
  62604. */
  62605. LensDepthOfFieldEffect: string;
  62606. private _scene;
  62607. private _depthTexture;
  62608. private _grainTexture;
  62609. private _chromaticAberrationPostProcess;
  62610. private _highlightsPostProcess;
  62611. private _depthOfFieldPostProcess;
  62612. private _edgeBlur;
  62613. private _grainAmount;
  62614. private _chromaticAberration;
  62615. private _distortion;
  62616. private _highlightsGain;
  62617. private _highlightsThreshold;
  62618. private _dofDistance;
  62619. private _dofAperture;
  62620. private _dofDarken;
  62621. private _dofPentagon;
  62622. private _blurNoise;
  62623. /**
  62624. * @constructor
  62625. *
  62626. * Effect parameters are as follow:
  62627. * {
  62628. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62629. * edge_blur: number; // from 0 to x (1 for realism)
  62630. * distortion: number; // from 0 to x (1 for realism)
  62631. * grain_amount: number; // from 0 to 1
  62632. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62633. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62634. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62635. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62636. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62637. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62638. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62639. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62640. * }
  62641. * Note: if an effect parameter is unset, effect is disabled
  62642. *
  62643. * @param name The rendering pipeline name
  62644. * @param parameters - An object containing all parameters (see above)
  62645. * @param scene The scene linked to this pipeline
  62646. * @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)
  62647. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62648. */
  62649. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62650. /**
  62651. * Get the class name
  62652. * @returns "LensRenderingPipeline"
  62653. */
  62654. getClassName(): string;
  62655. /**
  62656. * Gets associated scene
  62657. */
  62658. readonly scene: Scene;
  62659. /**
  62660. * Gets or sets the edge blur
  62661. */
  62662. edgeBlur: number;
  62663. /**
  62664. * Gets or sets the grain amount
  62665. */
  62666. grainAmount: number;
  62667. /**
  62668. * Gets or sets the chromatic aberration amount
  62669. */
  62670. chromaticAberration: number;
  62671. /**
  62672. * Gets or sets the depth of field aperture
  62673. */
  62674. dofAperture: number;
  62675. /**
  62676. * Gets or sets the edge distortion
  62677. */
  62678. edgeDistortion: number;
  62679. /**
  62680. * Gets or sets the depth of field distortion
  62681. */
  62682. dofDistortion: number;
  62683. /**
  62684. * Gets or sets the darken out of focus amount
  62685. */
  62686. darkenOutOfFocus: number;
  62687. /**
  62688. * Gets or sets a boolean indicating if blur noise is enabled
  62689. */
  62690. blurNoise: boolean;
  62691. /**
  62692. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62693. */
  62694. pentagonBokeh: boolean;
  62695. /**
  62696. * Gets or sets the highlight grain amount
  62697. */
  62698. highlightsGain: number;
  62699. /**
  62700. * Gets or sets the highlight threshold
  62701. */
  62702. highlightsThreshold: number;
  62703. /**
  62704. * Sets the amount of blur at the edges
  62705. * @param amount blur amount
  62706. */
  62707. setEdgeBlur(amount: number): void;
  62708. /**
  62709. * Sets edge blur to 0
  62710. */
  62711. disableEdgeBlur(): void;
  62712. /**
  62713. * Sets the amout of grain
  62714. * @param amount Amount of grain
  62715. */
  62716. setGrainAmount(amount: number): void;
  62717. /**
  62718. * Set grain amount to 0
  62719. */
  62720. disableGrain(): void;
  62721. /**
  62722. * Sets the chromatic aberration amount
  62723. * @param amount amount of chromatic aberration
  62724. */
  62725. setChromaticAberration(amount: number): void;
  62726. /**
  62727. * Sets chromatic aberration amount to 0
  62728. */
  62729. disableChromaticAberration(): void;
  62730. /**
  62731. * Sets the EdgeDistortion amount
  62732. * @param amount amount of EdgeDistortion
  62733. */
  62734. setEdgeDistortion(amount: number): void;
  62735. /**
  62736. * Sets edge distortion to 0
  62737. */
  62738. disableEdgeDistortion(): void;
  62739. /**
  62740. * Sets the FocusDistance amount
  62741. * @param amount amount of FocusDistance
  62742. */
  62743. setFocusDistance(amount: number): void;
  62744. /**
  62745. * Disables depth of field
  62746. */
  62747. disableDepthOfField(): void;
  62748. /**
  62749. * Sets the Aperture amount
  62750. * @param amount amount of Aperture
  62751. */
  62752. setAperture(amount: number): void;
  62753. /**
  62754. * Sets the DarkenOutOfFocus amount
  62755. * @param amount amount of DarkenOutOfFocus
  62756. */
  62757. setDarkenOutOfFocus(amount: number): void;
  62758. private _pentagonBokehIsEnabled;
  62759. /**
  62760. * Creates a pentagon bokeh effect
  62761. */
  62762. enablePentagonBokeh(): void;
  62763. /**
  62764. * Disables the pentagon bokeh effect
  62765. */
  62766. disablePentagonBokeh(): void;
  62767. /**
  62768. * Enables noise blur
  62769. */
  62770. enableNoiseBlur(): void;
  62771. /**
  62772. * Disables noise blur
  62773. */
  62774. disableNoiseBlur(): void;
  62775. /**
  62776. * Sets the HighlightsGain amount
  62777. * @param amount amount of HighlightsGain
  62778. */
  62779. setHighlightsGain(amount: number): void;
  62780. /**
  62781. * Sets the HighlightsThreshold amount
  62782. * @param amount amount of HighlightsThreshold
  62783. */
  62784. setHighlightsThreshold(amount: number): void;
  62785. /**
  62786. * Disables highlights
  62787. */
  62788. disableHighlights(): void;
  62789. /**
  62790. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62791. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62792. */
  62793. dispose(disableDepthRender?: boolean): void;
  62794. private _createChromaticAberrationPostProcess;
  62795. private _createHighlightsPostProcess;
  62796. private _createDepthOfFieldPostProcess;
  62797. private _createGrainTexture;
  62798. }
  62799. }
  62800. declare module "babylonjs/Shaders/ssao2.fragment" {
  62801. /** @hidden */
  62802. export var ssao2PixelShader: {
  62803. name: string;
  62804. shader: string;
  62805. };
  62806. }
  62807. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  62808. /** @hidden */
  62809. export var ssaoCombinePixelShader: {
  62810. name: string;
  62811. shader: string;
  62812. };
  62813. }
  62814. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  62815. import { Camera } from "babylonjs/Cameras/camera";
  62816. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62817. import { Scene } from "babylonjs/scene";
  62818. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62819. import "babylonjs/Shaders/ssao2.fragment";
  62820. import "babylonjs/Shaders/ssaoCombine.fragment";
  62821. /**
  62822. * Render pipeline to produce ssao effect
  62823. */
  62824. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62825. /**
  62826. * @ignore
  62827. * The PassPostProcess id in the pipeline that contains the original scene color
  62828. */
  62829. SSAOOriginalSceneColorEffect: string;
  62830. /**
  62831. * @ignore
  62832. * The SSAO PostProcess id in the pipeline
  62833. */
  62834. SSAORenderEffect: string;
  62835. /**
  62836. * @ignore
  62837. * The horizontal blur PostProcess id in the pipeline
  62838. */
  62839. SSAOBlurHRenderEffect: string;
  62840. /**
  62841. * @ignore
  62842. * The vertical blur PostProcess id in the pipeline
  62843. */
  62844. SSAOBlurVRenderEffect: string;
  62845. /**
  62846. * @ignore
  62847. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62848. */
  62849. SSAOCombineRenderEffect: string;
  62850. /**
  62851. * The output strength of the SSAO post-process. Default value is 1.0.
  62852. */
  62853. totalStrength: number;
  62854. /**
  62855. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62856. */
  62857. maxZ: number;
  62858. /**
  62859. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62860. */
  62861. minZAspect: number;
  62862. private _samples;
  62863. /**
  62864. * Number of samples used for the SSAO calculations. Default value is 8
  62865. */
  62866. samples: number;
  62867. private _textureSamples;
  62868. /**
  62869. * Number of samples to use for antialiasing
  62870. */
  62871. textureSamples: number;
  62872. /**
  62873. * Ratio object used for SSAO ratio and blur ratio
  62874. */
  62875. private _ratio;
  62876. /**
  62877. * Dynamically generated sphere sampler.
  62878. */
  62879. private _sampleSphere;
  62880. /**
  62881. * Blur filter offsets
  62882. */
  62883. private _samplerOffsets;
  62884. private _expensiveBlur;
  62885. /**
  62886. * If bilateral blur should be used
  62887. */
  62888. expensiveBlur: boolean;
  62889. /**
  62890. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62891. */
  62892. radius: number;
  62893. /**
  62894. * The base color of the SSAO post-process
  62895. * The final result is "base + ssao" between [0, 1]
  62896. */
  62897. base: number;
  62898. /**
  62899. * Support test.
  62900. */
  62901. static readonly IsSupported: boolean;
  62902. private _scene;
  62903. private _depthTexture;
  62904. private _normalTexture;
  62905. private _randomTexture;
  62906. private _originalColorPostProcess;
  62907. private _ssaoPostProcess;
  62908. private _blurHPostProcess;
  62909. private _blurVPostProcess;
  62910. private _ssaoCombinePostProcess;
  62911. private _firstUpdate;
  62912. /**
  62913. * Gets active scene
  62914. */
  62915. readonly scene: Scene;
  62916. /**
  62917. * @constructor
  62918. * @param name The rendering pipeline name
  62919. * @param scene The scene linked to this pipeline
  62920. * @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 }
  62921. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62922. */
  62923. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62924. /**
  62925. * Get the class name
  62926. * @returns "SSAO2RenderingPipeline"
  62927. */
  62928. getClassName(): string;
  62929. /**
  62930. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62931. */
  62932. dispose(disableGeometryBufferRenderer?: boolean): void;
  62933. private _createBlurPostProcess;
  62934. /** @hidden */
  62935. _rebuild(): void;
  62936. private _bits;
  62937. private _radicalInverse_VdC;
  62938. private _hammersley;
  62939. private _hemisphereSample_uniform;
  62940. private _generateHemisphere;
  62941. private _createSSAOPostProcess;
  62942. private _createSSAOCombinePostProcess;
  62943. private _createRandomTexture;
  62944. /**
  62945. * Serialize the rendering pipeline (Used when exporting)
  62946. * @returns the serialized object
  62947. */
  62948. serialize(): any;
  62949. /**
  62950. * Parse the serialized pipeline
  62951. * @param source Source pipeline.
  62952. * @param scene The scene to load the pipeline to.
  62953. * @param rootUrl The URL of the serialized pipeline.
  62954. * @returns An instantiated pipeline from the serialized object.
  62955. */
  62956. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62957. }
  62958. }
  62959. declare module "babylonjs/Shaders/ssao.fragment" {
  62960. /** @hidden */
  62961. export var ssaoPixelShader: {
  62962. name: string;
  62963. shader: string;
  62964. };
  62965. }
  62966. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  62967. import { Camera } from "babylonjs/Cameras/camera";
  62968. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62969. import { Scene } from "babylonjs/scene";
  62970. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62971. import "babylonjs/Shaders/ssao.fragment";
  62972. import "babylonjs/Shaders/ssaoCombine.fragment";
  62973. /**
  62974. * Render pipeline to produce ssao effect
  62975. */
  62976. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62977. /**
  62978. * @ignore
  62979. * The PassPostProcess id in the pipeline that contains the original scene color
  62980. */
  62981. SSAOOriginalSceneColorEffect: string;
  62982. /**
  62983. * @ignore
  62984. * The SSAO PostProcess id in the pipeline
  62985. */
  62986. SSAORenderEffect: string;
  62987. /**
  62988. * @ignore
  62989. * The horizontal blur PostProcess id in the pipeline
  62990. */
  62991. SSAOBlurHRenderEffect: string;
  62992. /**
  62993. * @ignore
  62994. * The vertical blur PostProcess id in the pipeline
  62995. */
  62996. SSAOBlurVRenderEffect: string;
  62997. /**
  62998. * @ignore
  62999. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63000. */
  63001. SSAOCombineRenderEffect: string;
  63002. /**
  63003. * The output strength of the SSAO post-process. Default value is 1.0.
  63004. */
  63005. totalStrength: number;
  63006. /**
  63007. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63008. */
  63009. radius: number;
  63010. /**
  63011. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63012. * Must not be equal to fallOff and superior to fallOff.
  63013. * Default value is 0.0075
  63014. */
  63015. area: number;
  63016. /**
  63017. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63018. * Must not be equal to area and inferior to area.
  63019. * Default value is 0.000001
  63020. */
  63021. fallOff: number;
  63022. /**
  63023. * The base color of the SSAO post-process
  63024. * The final result is "base + ssao" between [0, 1]
  63025. */
  63026. base: number;
  63027. private _scene;
  63028. private _depthTexture;
  63029. private _randomTexture;
  63030. private _originalColorPostProcess;
  63031. private _ssaoPostProcess;
  63032. private _blurHPostProcess;
  63033. private _blurVPostProcess;
  63034. private _ssaoCombinePostProcess;
  63035. private _firstUpdate;
  63036. /**
  63037. * Gets active scene
  63038. */
  63039. readonly scene: Scene;
  63040. /**
  63041. * @constructor
  63042. * @param name - The rendering pipeline name
  63043. * @param scene - The scene linked to this pipeline
  63044. * @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 }
  63045. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63046. */
  63047. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63048. /**
  63049. * Get the class name
  63050. * @returns "SSAORenderingPipeline"
  63051. */
  63052. getClassName(): string;
  63053. /**
  63054. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63055. */
  63056. dispose(disableDepthRender?: boolean): void;
  63057. private _createBlurPostProcess;
  63058. /** @hidden */
  63059. _rebuild(): void;
  63060. private _createSSAOPostProcess;
  63061. private _createSSAOCombinePostProcess;
  63062. private _createRandomTexture;
  63063. }
  63064. }
  63065. declare module "babylonjs/Shaders/standard.fragment" {
  63066. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63067. /** @hidden */
  63068. export var standardPixelShader: {
  63069. name: string;
  63070. shader: string;
  63071. };
  63072. }
  63073. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  63074. import { Nullable } from "babylonjs/types";
  63075. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63076. import { Camera } from "babylonjs/Cameras/camera";
  63077. import { Texture } from "babylonjs/Materials/Textures/texture";
  63078. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63079. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63080. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63081. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63082. import { IDisposable } from "babylonjs/scene";
  63083. import { SpotLight } from "babylonjs/Lights/spotLight";
  63084. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63085. import { Scene } from "babylonjs/scene";
  63086. import { Animation } from "babylonjs/Animations/animation";
  63087. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63088. import "babylonjs/Shaders/standard.fragment";
  63089. /**
  63090. * Standard rendering pipeline
  63091. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63092. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63093. */
  63094. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63095. /**
  63096. * Public members
  63097. */
  63098. /**
  63099. * Post-process which contains the original scene color before the pipeline applies all the effects
  63100. */
  63101. originalPostProcess: Nullable<PostProcess>;
  63102. /**
  63103. * Post-process used to down scale an image x4
  63104. */
  63105. downSampleX4PostProcess: Nullable<PostProcess>;
  63106. /**
  63107. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63108. */
  63109. brightPassPostProcess: Nullable<PostProcess>;
  63110. /**
  63111. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63112. */
  63113. blurHPostProcesses: PostProcess[];
  63114. /**
  63115. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63116. */
  63117. blurVPostProcesses: PostProcess[];
  63118. /**
  63119. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63120. */
  63121. textureAdderPostProcess: Nullable<PostProcess>;
  63122. /**
  63123. * Post-process used to create volumetric lighting effect
  63124. */
  63125. volumetricLightPostProcess: Nullable<PostProcess>;
  63126. /**
  63127. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63128. */
  63129. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63130. /**
  63131. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63132. */
  63133. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63134. /**
  63135. * Post-process used to merge the volumetric light effect and the real scene color
  63136. */
  63137. volumetricLightMergePostProces: Nullable<PostProcess>;
  63138. /**
  63139. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63140. */
  63141. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63142. /**
  63143. * Base post-process used to calculate the average luminance of the final image for HDR
  63144. */
  63145. luminancePostProcess: Nullable<PostProcess>;
  63146. /**
  63147. * Post-processes used to create down sample post-processes in order to get
  63148. * the average luminance of the final image for HDR
  63149. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63150. */
  63151. luminanceDownSamplePostProcesses: PostProcess[];
  63152. /**
  63153. * Post-process used to create a HDR effect (light adaptation)
  63154. */
  63155. hdrPostProcess: Nullable<PostProcess>;
  63156. /**
  63157. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63158. */
  63159. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63160. /**
  63161. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63162. */
  63163. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63164. /**
  63165. * Post-process used to merge the final HDR post-process and the real scene color
  63166. */
  63167. hdrFinalPostProcess: Nullable<PostProcess>;
  63168. /**
  63169. * Post-process used to create a lens flare effect
  63170. */
  63171. lensFlarePostProcess: Nullable<PostProcess>;
  63172. /**
  63173. * Post-process that merges the result of the lens flare post-process and the real scene color
  63174. */
  63175. lensFlareComposePostProcess: Nullable<PostProcess>;
  63176. /**
  63177. * Post-process used to create a motion blur effect
  63178. */
  63179. motionBlurPostProcess: Nullable<PostProcess>;
  63180. /**
  63181. * Post-process used to create a depth of field effect
  63182. */
  63183. depthOfFieldPostProcess: Nullable<PostProcess>;
  63184. /**
  63185. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63186. */
  63187. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63188. /**
  63189. * Represents the brightness threshold in order to configure the illuminated surfaces
  63190. */
  63191. brightThreshold: number;
  63192. /**
  63193. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63194. */
  63195. blurWidth: number;
  63196. /**
  63197. * Sets if the blur for highlighted surfaces must be only horizontal
  63198. */
  63199. horizontalBlur: boolean;
  63200. /**
  63201. * Gets the overall exposure used by the pipeline
  63202. */
  63203. /**
  63204. * Sets the overall exposure used by the pipeline
  63205. */
  63206. exposure: number;
  63207. /**
  63208. * Texture used typically to simulate "dirty" on camera lens
  63209. */
  63210. lensTexture: Nullable<Texture>;
  63211. /**
  63212. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63213. */
  63214. volumetricLightCoefficient: number;
  63215. /**
  63216. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63217. */
  63218. volumetricLightPower: number;
  63219. /**
  63220. * Used the set the blur intensity to smooth the volumetric lights
  63221. */
  63222. volumetricLightBlurScale: number;
  63223. /**
  63224. * Light (spot or directional) used to generate the volumetric lights rays
  63225. * The source light must have a shadow generate so the pipeline can get its
  63226. * depth map
  63227. */
  63228. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63229. /**
  63230. * For eye adaptation, represents the minimum luminance the eye can see
  63231. */
  63232. hdrMinimumLuminance: number;
  63233. /**
  63234. * For eye adaptation, represents the decrease luminance speed
  63235. */
  63236. hdrDecreaseRate: number;
  63237. /**
  63238. * For eye adaptation, represents the increase luminance speed
  63239. */
  63240. hdrIncreaseRate: number;
  63241. /**
  63242. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63243. */
  63244. /**
  63245. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63246. */
  63247. hdrAutoExposure: boolean;
  63248. /**
  63249. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63250. */
  63251. lensColorTexture: Nullable<Texture>;
  63252. /**
  63253. * The overall strengh for the lens flare effect
  63254. */
  63255. lensFlareStrength: number;
  63256. /**
  63257. * Dispersion coefficient for lens flare ghosts
  63258. */
  63259. lensFlareGhostDispersal: number;
  63260. /**
  63261. * Main lens flare halo width
  63262. */
  63263. lensFlareHaloWidth: number;
  63264. /**
  63265. * Based on the lens distortion effect, defines how much the lens flare result
  63266. * is distorted
  63267. */
  63268. lensFlareDistortionStrength: number;
  63269. /**
  63270. * Configures the blur intensity used for for lens flare (halo)
  63271. */
  63272. lensFlareBlurWidth: number;
  63273. /**
  63274. * Lens star texture must be used to simulate rays on the flares and is available
  63275. * in the documentation
  63276. */
  63277. lensStarTexture: Nullable<Texture>;
  63278. /**
  63279. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63280. * flare effect by taking account of the dirt texture
  63281. */
  63282. lensFlareDirtTexture: Nullable<Texture>;
  63283. /**
  63284. * Represents the focal length for the depth of field effect
  63285. */
  63286. depthOfFieldDistance: number;
  63287. /**
  63288. * Represents the blur intensity for the blurred part of the depth of field effect
  63289. */
  63290. depthOfFieldBlurWidth: number;
  63291. /**
  63292. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63293. */
  63294. /**
  63295. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63296. */
  63297. motionStrength: number;
  63298. /**
  63299. * Gets wether or not the motion blur post-process is object based or screen based.
  63300. */
  63301. /**
  63302. * Sets wether or not the motion blur post-process should be object based or screen based
  63303. */
  63304. objectBasedMotionBlur: boolean;
  63305. /**
  63306. * List of animations for the pipeline (IAnimatable implementation)
  63307. */
  63308. animations: Animation[];
  63309. /**
  63310. * Private members
  63311. */
  63312. private _scene;
  63313. private _currentDepthOfFieldSource;
  63314. private _basePostProcess;
  63315. private _fixedExposure;
  63316. private _currentExposure;
  63317. private _hdrAutoExposure;
  63318. private _hdrCurrentLuminance;
  63319. private _motionStrength;
  63320. private _isObjectBasedMotionBlur;
  63321. private _floatTextureType;
  63322. private _camerasToBeAttached;
  63323. private _ratio;
  63324. private _bloomEnabled;
  63325. private _depthOfFieldEnabled;
  63326. private _vlsEnabled;
  63327. private _lensFlareEnabled;
  63328. private _hdrEnabled;
  63329. private _motionBlurEnabled;
  63330. private _fxaaEnabled;
  63331. private _motionBlurSamples;
  63332. private _volumetricLightStepsCount;
  63333. private _samples;
  63334. /**
  63335. * @ignore
  63336. * Specifies if the bloom pipeline is enabled
  63337. */
  63338. BloomEnabled: boolean;
  63339. /**
  63340. * @ignore
  63341. * Specifies if the depth of field pipeline is enabed
  63342. */
  63343. DepthOfFieldEnabled: boolean;
  63344. /**
  63345. * @ignore
  63346. * Specifies if the lens flare pipeline is enabed
  63347. */
  63348. LensFlareEnabled: boolean;
  63349. /**
  63350. * @ignore
  63351. * Specifies if the HDR pipeline is enabled
  63352. */
  63353. HDREnabled: boolean;
  63354. /**
  63355. * @ignore
  63356. * Specifies if the volumetric lights scattering effect is enabled
  63357. */
  63358. VLSEnabled: boolean;
  63359. /**
  63360. * @ignore
  63361. * Specifies if the motion blur effect is enabled
  63362. */
  63363. MotionBlurEnabled: boolean;
  63364. /**
  63365. * Specifies if anti-aliasing is enabled
  63366. */
  63367. fxaaEnabled: boolean;
  63368. /**
  63369. * Specifies the number of steps used to calculate the volumetric lights
  63370. * Typically in interval [50, 200]
  63371. */
  63372. volumetricLightStepsCount: number;
  63373. /**
  63374. * Specifies the number of samples used for the motion blur effect
  63375. * Typically in interval [16, 64]
  63376. */
  63377. motionBlurSamples: number;
  63378. /**
  63379. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63380. */
  63381. samples: number;
  63382. /**
  63383. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63384. * @constructor
  63385. * @param name The rendering pipeline name
  63386. * @param scene The scene linked to this pipeline
  63387. * @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)
  63388. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63389. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63390. */
  63391. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63392. private _buildPipeline;
  63393. private _createDownSampleX4PostProcess;
  63394. private _createBrightPassPostProcess;
  63395. private _createBlurPostProcesses;
  63396. private _createTextureAdderPostProcess;
  63397. private _createVolumetricLightPostProcess;
  63398. private _createLuminancePostProcesses;
  63399. private _createHdrPostProcess;
  63400. private _createLensFlarePostProcess;
  63401. private _createDepthOfFieldPostProcess;
  63402. private _createMotionBlurPostProcess;
  63403. private _getDepthTexture;
  63404. private _disposePostProcesses;
  63405. /**
  63406. * Dispose of the pipeline and stop all post processes
  63407. */
  63408. dispose(): void;
  63409. /**
  63410. * Serialize the rendering pipeline (Used when exporting)
  63411. * @returns the serialized object
  63412. */
  63413. serialize(): any;
  63414. /**
  63415. * Parse the serialized pipeline
  63416. * @param source Source pipeline.
  63417. * @param scene The scene to load the pipeline to.
  63418. * @param rootUrl The URL of the serialized pipeline.
  63419. * @returns An instantiated pipeline from the serialized object.
  63420. */
  63421. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63422. /**
  63423. * Luminance steps
  63424. */
  63425. static LuminanceSteps: number;
  63426. }
  63427. }
  63428. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63429. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63430. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63431. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63432. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63433. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63434. }
  63435. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63436. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63437. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63438. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63439. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63440. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63441. }
  63442. declare module "babylonjs/Shaders/tonemap.fragment" {
  63443. /** @hidden */
  63444. export var tonemapPixelShader: {
  63445. name: string;
  63446. shader: string;
  63447. };
  63448. }
  63449. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63450. import { Camera } from "babylonjs/Cameras/camera";
  63451. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63452. import "babylonjs/Shaders/tonemap.fragment";
  63453. import { Engine } from "babylonjs/Engines/engine";
  63454. /** Defines operator used for tonemapping */
  63455. export enum TonemappingOperator {
  63456. /** Hable */
  63457. Hable = 0,
  63458. /** Reinhard */
  63459. Reinhard = 1,
  63460. /** HejiDawson */
  63461. HejiDawson = 2,
  63462. /** Photographic */
  63463. Photographic = 3
  63464. }
  63465. /**
  63466. * Defines a post process to apply tone mapping
  63467. */
  63468. export class TonemapPostProcess extends PostProcess {
  63469. private _operator;
  63470. /** Defines the required exposure adjustement */
  63471. exposureAdjustment: number;
  63472. /**
  63473. * Creates a new TonemapPostProcess
  63474. * @param name defines the name of the postprocess
  63475. * @param _operator defines the operator to use
  63476. * @param exposureAdjustment defines the required exposure adjustement
  63477. * @param camera defines the camera to use (can be null)
  63478. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63479. * @param engine defines the hosting engine (can be ignore if camera is set)
  63480. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63481. */
  63482. constructor(name: string, _operator: TonemappingOperator,
  63483. /** Defines the required exposure adjustement */
  63484. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63485. }
  63486. }
  63487. declare module "babylonjs/Shaders/depth.vertex" {
  63488. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63489. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63490. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63491. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63492. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63493. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63494. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63495. /** @hidden */
  63496. export var depthVertexShader: {
  63497. name: string;
  63498. shader: string;
  63499. };
  63500. }
  63501. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63502. /** @hidden */
  63503. export var volumetricLightScatteringPixelShader: {
  63504. name: string;
  63505. shader: string;
  63506. };
  63507. }
  63508. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  63509. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63510. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63511. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63512. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63513. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63514. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63515. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63516. /** @hidden */
  63517. export var volumetricLightScatteringPassVertexShader: {
  63518. name: string;
  63519. shader: string;
  63520. };
  63521. }
  63522. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  63523. /** @hidden */
  63524. export var volumetricLightScatteringPassPixelShader: {
  63525. name: string;
  63526. shader: string;
  63527. };
  63528. }
  63529. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  63530. import { Vector3 } from "babylonjs/Maths/math.vector";
  63531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63532. import { Mesh } from "babylonjs/Meshes/mesh";
  63533. import { Camera } from "babylonjs/Cameras/camera";
  63534. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63535. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63536. import { Scene } from "babylonjs/scene";
  63537. import "babylonjs/Meshes/Builders/planeBuilder";
  63538. import "babylonjs/Shaders/depth.vertex";
  63539. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  63540. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  63541. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  63542. import { Engine } from "babylonjs/Engines/engine";
  63543. /**
  63544. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63545. */
  63546. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63547. private _volumetricLightScatteringPass;
  63548. private _volumetricLightScatteringRTT;
  63549. private _viewPort;
  63550. private _screenCoordinates;
  63551. private _cachedDefines;
  63552. /**
  63553. * If not undefined, the mesh position is computed from the attached node position
  63554. */
  63555. attachedNode: {
  63556. position: Vector3;
  63557. };
  63558. /**
  63559. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63560. */
  63561. customMeshPosition: Vector3;
  63562. /**
  63563. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63564. */
  63565. useCustomMeshPosition: boolean;
  63566. /**
  63567. * If the post-process should inverse the light scattering direction
  63568. */
  63569. invert: boolean;
  63570. /**
  63571. * The internal mesh used by the post-process
  63572. */
  63573. mesh: Mesh;
  63574. /**
  63575. * @hidden
  63576. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63577. */
  63578. useDiffuseColor: boolean;
  63579. /**
  63580. * Array containing the excluded meshes not rendered in the internal pass
  63581. */
  63582. excludedMeshes: AbstractMesh[];
  63583. /**
  63584. * Controls the overall intensity of the post-process
  63585. */
  63586. exposure: number;
  63587. /**
  63588. * Dissipates each sample's contribution in range [0, 1]
  63589. */
  63590. decay: number;
  63591. /**
  63592. * Controls the overall intensity of each sample
  63593. */
  63594. weight: number;
  63595. /**
  63596. * Controls the density of each sample
  63597. */
  63598. density: number;
  63599. /**
  63600. * @constructor
  63601. * @param name The post-process name
  63602. * @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)
  63603. * @param camera The camera that the post-process will be attached to
  63604. * @param mesh The mesh used to create the light scattering
  63605. * @param samples The post-process quality, default 100
  63606. * @param samplingModeThe post-process filtering mode
  63607. * @param engine The babylon engine
  63608. * @param reusable If the post-process is reusable
  63609. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63610. */
  63611. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63612. /**
  63613. * Returns the string "VolumetricLightScatteringPostProcess"
  63614. * @returns "VolumetricLightScatteringPostProcess"
  63615. */
  63616. getClassName(): string;
  63617. private _isReady;
  63618. /**
  63619. * Sets the new light position for light scattering effect
  63620. * @param position The new custom light position
  63621. */
  63622. setCustomMeshPosition(position: Vector3): void;
  63623. /**
  63624. * Returns the light position for light scattering effect
  63625. * @return Vector3 The custom light position
  63626. */
  63627. getCustomMeshPosition(): Vector3;
  63628. /**
  63629. * Disposes the internal assets and detaches the post-process from the camera
  63630. */
  63631. dispose(camera: Camera): void;
  63632. /**
  63633. * Returns the render target texture used by the post-process
  63634. * @return the render target texture used by the post-process
  63635. */
  63636. getPass(): RenderTargetTexture;
  63637. private _meshExcluded;
  63638. private _createPass;
  63639. private _updateMeshScreenCoordinates;
  63640. /**
  63641. * Creates a default mesh for the Volumeric Light Scattering post-process
  63642. * @param name The mesh name
  63643. * @param scene The scene where to create the mesh
  63644. * @return the default mesh
  63645. */
  63646. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63647. }
  63648. }
  63649. declare module "babylonjs/PostProcesses/index" {
  63650. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  63651. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  63652. export * from "babylonjs/PostProcesses/bloomEffect";
  63653. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  63654. export * from "babylonjs/PostProcesses/blurPostProcess";
  63655. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63656. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  63657. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  63658. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  63659. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63660. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  63661. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  63662. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  63663. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63664. export * from "babylonjs/PostProcesses/filterPostProcess";
  63665. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  63666. export * from "babylonjs/PostProcesses/grainPostProcess";
  63667. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  63668. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63669. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  63670. export * from "babylonjs/PostProcesses/passPostProcess";
  63671. export * from "babylonjs/PostProcesses/postProcess";
  63672. export * from "babylonjs/PostProcesses/postProcessManager";
  63673. export * from "babylonjs/PostProcesses/refractionPostProcess";
  63674. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  63675. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  63676. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  63677. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  63678. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  63679. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  63680. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  63681. }
  63682. declare module "babylonjs/Probes/index" {
  63683. export * from "babylonjs/Probes/reflectionProbe";
  63684. }
  63685. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  63686. import { Scene } from "babylonjs/scene";
  63687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63688. import { SmartArray } from "babylonjs/Misc/smartArray";
  63689. import { ISceneComponent } from "babylonjs/sceneComponent";
  63690. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  63691. import "babylonjs/Meshes/Builders/boxBuilder";
  63692. import "babylonjs/Shaders/color.fragment";
  63693. import "babylonjs/Shaders/color.vertex";
  63694. import { Color3 } from "babylonjs/Maths/math.color";
  63695. module "babylonjs/scene" {
  63696. interface Scene {
  63697. /** @hidden (Backing field) */
  63698. _boundingBoxRenderer: BoundingBoxRenderer;
  63699. /** @hidden (Backing field) */
  63700. _forceShowBoundingBoxes: boolean;
  63701. /**
  63702. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63703. */
  63704. forceShowBoundingBoxes: boolean;
  63705. /**
  63706. * Gets the bounding box renderer associated with the scene
  63707. * @returns a BoundingBoxRenderer
  63708. */
  63709. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63710. }
  63711. }
  63712. module "babylonjs/Meshes/abstractMesh" {
  63713. interface AbstractMesh {
  63714. /** @hidden (Backing field) */
  63715. _showBoundingBox: boolean;
  63716. /**
  63717. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63718. */
  63719. showBoundingBox: boolean;
  63720. }
  63721. }
  63722. /**
  63723. * Component responsible of rendering the bounding box of the meshes in a scene.
  63724. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63725. */
  63726. export class BoundingBoxRenderer implements ISceneComponent {
  63727. /**
  63728. * The component name helpfull to identify the component in the list of scene components.
  63729. */
  63730. readonly name: string;
  63731. /**
  63732. * The scene the component belongs to.
  63733. */
  63734. scene: Scene;
  63735. /**
  63736. * Color of the bounding box lines placed in front of an object
  63737. */
  63738. frontColor: Color3;
  63739. /**
  63740. * Color of the bounding box lines placed behind an object
  63741. */
  63742. backColor: Color3;
  63743. /**
  63744. * Defines if the renderer should show the back lines or not
  63745. */
  63746. showBackLines: boolean;
  63747. /**
  63748. * @hidden
  63749. */
  63750. renderList: SmartArray<BoundingBox>;
  63751. private _colorShader;
  63752. private _vertexBuffers;
  63753. private _indexBuffer;
  63754. private _fillIndexBuffer;
  63755. private _fillIndexData;
  63756. /**
  63757. * Instantiates a new bounding box renderer in a scene.
  63758. * @param scene the scene the renderer renders in
  63759. */
  63760. constructor(scene: Scene);
  63761. /**
  63762. * Registers the component in a given scene
  63763. */
  63764. register(): void;
  63765. private _evaluateSubMesh;
  63766. private _activeMesh;
  63767. private _prepareRessources;
  63768. private _createIndexBuffer;
  63769. /**
  63770. * Rebuilds the elements related to this component in case of
  63771. * context lost for instance.
  63772. */
  63773. rebuild(): void;
  63774. /**
  63775. * @hidden
  63776. */
  63777. reset(): void;
  63778. /**
  63779. * Render the bounding boxes of a specific rendering group
  63780. * @param renderingGroupId defines the rendering group to render
  63781. */
  63782. render(renderingGroupId: number): void;
  63783. /**
  63784. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63785. * @param mesh Define the mesh to render the occlusion bounding box for
  63786. */
  63787. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63788. /**
  63789. * Dispose and release the resources attached to this renderer.
  63790. */
  63791. dispose(): void;
  63792. }
  63793. }
  63794. declare module "babylonjs/Shaders/depth.fragment" {
  63795. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63796. /** @hidden */
  63797. export var depthPixelShader: {
  63798. name: string;
  63799. shader: string;
  63800. };
  63801. }
  63802. declare module "babylonjs/Rendering/depthRenderer" {
  63803. import { Nullable } from "babylonjs/types";
  63804. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63805. import { Scene } from "babylonjs/scene";
  63806. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63807. import { Camera } from "babylonjs/Cameras/camera";
  63808. import "babylonjs/Shaders/depth.fragment";
  63809. import "babylonjs/Shaders/depth.vertex";
  63810. /**
  63811. * This represents a depth renderer in Babylon.
  63812. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63813. */
  63814. export class DepthRenderer {
  63815. private _scene;
  63816. private _depthMap;
  63817. private _effect;
  63818. private readonly _storeNonLinearDepth;
  63819. private readonly _clearColor;
  63820. /** Get if the depth renderer is using packed depth or not */
  63821. readonly isPacked: boolean;
  63822. private _cachedDefines;
  63823. private _camera;
  63824. /**
  63825. * Specifiess that the depth renderer will only be used within
  63826. * the camera it is created for.
  63827. * This can help forcing its rendering during the camera processing.
  63828. */
  63829. useOnlyInActiveCamera: boolean;
  63830. /** @hidden */
  63831. static _SceneComponentInitialization: (scene: Scene) => void;
  63832. /**
  63833. * Instantiates a depth renderer
  63834. * @param scene The scene the renderer belongs to
  63835. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63836. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63837. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63838. */
  63839. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63840. /**
  63841. * Creates the depth rendering effect and checks if the effect is ready.
  63842. * @param subMesh The submesh to be used to render the depth map of
  63843. * @param useInstances If multiple world instances should be used
  63844. * @returns if the depth renderer is ready to render the depth map
  63845. */
  63846. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63847. /**
  63848. * Gets the texture which the depth map will be written to.
  63849. * @returns The depth map texture
  63850. */
  63851. getDepthMap(): RenderTargetTexture;
  63852. /**
  63853. * Disposes of the depth renderer.
  63854. */
  63855. dispose(): void;
  63856. }
  63857. }
  63858. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  63859. import { Nullable } from "babylonjs/types";
  63860. import { Scene } from "babylonjs/scene";
  63861. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63862. import { Camera } from "babylonjs/Cameras/camera";
  63863. import { ISceneComponent } from "babylonjs/sceneComponent";
  63864. module "babylonjs/scene" {
  63865. interface Scene {
  63866. /** @hidden (Backing field) */
  63867. _depthRenderer: {
  63868. [id: string]: DepthRenderer;
  63869. };
  63870. /**
  63871. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63872. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63873. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63874. * @returns the created depth renderer
  63875. */
  63876. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63877. /**
  63878. * Disables a depth renderer for a given camera
  63879. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63880. */
  63881. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63882. }
  63883. }
  63884. /**
  63885. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63886. * in several rendering techniques.
  63887. */
  63888. export class DepthRendererSceneComponent implements ISceneComponent {
  63889. /**
  63890. * The component name helpfull to identify the component in the list of scene components.
  63891. */
  63892. readonly name: string;
  63893. /**
  63894. * The scene the component belongs to.
  63895. */
  63896. scene: Scene;
  63897. /**
  63898. * Creates a new instance of the component for the given scene
  63899. * @param scene Defines the scene to register the component in
  63900. */
  63901. constructor(scene: Scene);
  63902. /**
  63903. * Registers the component in a given scene
  63904. */
  63905. register(): void;
  63906. /**
  63907. * Rebuilds the elements related to this component in case of
  63908. * context lost for instance.
  63909. */
  63910. rebuild(): void;
  63911. /**
  63912. * Disposes the component and the associated ressources
  63913. */
  63914. dispose(): void;
  63915. private _gatherRenderTargets;
  63916. private _gatherActiveCameraRenderTargets;
  63917. }
  63918. }
  63919. declare module "babylonjs/Shaders/outline.fragment" {
  63920. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63921. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  63922. /** @hidden */
  63923. export var outlinePixelShader: {
  63924. name: string;
  63925. shader: string;
  63926. };
  63927. }
  63928. declare module "babylonjs/Shaders/outline.vertex" {
  63929. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63930. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63931. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63932. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63933. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63934. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63935. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63936. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63937. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  63938. /** @hidden */
  63939. export var outlineVertexShader: {
  63940. name: string;
  63941. shader: string;
  63942. };
  63943. }
  63944. declare module "babylonjs/Rendering/outlineRenderer" {
  63945. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63946. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  63947. import { Scene } from "babylonjs/scene";
  63948. import { ISceneComponent } from "babylonjs/sceneComponent";
  63949. import "babylonjs/Shaders/outline.fragment";
  63950. import "babylonjs/Shaders/outline.vertex";
  63951. module "babylonjs/scene" {
  63952. interface Scene {
  63953. /** @hidden */
  63954. _outlineRenderer: OutlineRenderer;
  63955. /**
  63956. * Gets the outline renderer associated with the scene
  63957. * @returns a OutlineRenderer
  63958. */
  63959. getOutlineRenderer(): OutlineRenderer;
  63960. }
  63961. }
  63962. module "babylonjs/Meshes/abstractMesh" {
  63963. interface AbstractMesh {
  63964. /** @hidden (Backing field) */
  63965. _renderOutline: boolean;
  63966. /**
  63967. * Gets or sets a boolean indicating if the outline must be rendered as well
  63968. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63969. */
  63970. renderOutline: boolean;
  63971. /** @hidden (Backing field) */
  63972. _renderOverlay: boolean;
  63973. /**
  63974. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63975. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63976. */
  63977. renderOverlay: boolean;
  63978. }
  63979. }
  63980. /**
  63981. * This class is responsible to draw bothe outline/overlay of meshes.
  63982. * It should not be used directly but through the available method on mesh.
  63983. */
  63984. export class OutlineRenderer implements ISceneComponent {
  63985. /**
  63986. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63987. */
  63988. private static _StencilReference;
  63989. /**
  63990. * The name of the component. Each component must have a unique name.
  63991. */
  63992. name: string;
  63993. /**
  63994. * The scene the component belongs to.
  63995. */
  63996. scene: Scene;
  63997. /**
  63998. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63999. */
  64000. zOffset: number;
  64001. private _engine;
  64002. private _effect;
  64003. private _cachedDefines;
  64004. private _savedDepthWrite;
  64005. /**
  64006. * Instantiates a new outline renderer. (There could be only one per scene).
  64007. * @param scene Defines the scene it belongs to
  64008. */
  64009. constructor(scene: Scene);
  64010. /**
  64011. * Register the component to one instance of a scene.
  64012. */
  64013. register(): void;
  64014. /**
  64015. * Rebuilds the elements related to this component in case of
  64016. * context lost for instance.
  64017. */
  64018. rebuild(): void;
  64019. /**
  64020. * Disposes the component and the associated ressources.
  64021. */
  64022. dispose(): void;
  64023. /**
  64024. * Renders the outline in the canvas.
  64025. * @param subMesh Defines the sumesh to render
  64026. * @param batch Defines the batch of meshes in case of instances
  64027. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64028. */
  64029. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64030. /**
  64031. * Returns whether or not the outline renderer is ready for a given submesh.
  64032. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64033. * @param subMesh Defines the submesh to check readyness for
  64034. * @param useInstances Defines wheter wee are trying to render instances or not
  64035. * @returns true if ready otherwise false
  64036. */
  64037. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64038. private _beforeRenderingMesh;
  64039. private _afterRenderingMesh;
  64040. }
  64041. }
  64042. declare module "babylonjs/Rendering/index" {
  64043. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64044. export * from "babylonjs/Rendering/depthRenderer";
  64045. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64046. export * from "babylonjs/Rendering/edgesRenderer";
  64047. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64048. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64049. export * from "babylonjs/Rendering/outlineRenderer";
  64050. export * from "babylonjs/Rendering/renderingGroup";
  64051. export * from "babylonjs/Rendering/renderingManager";
  64052. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64053. }
  64054. declare module "babylonjs/Sprites/spritePackedManager" {
  64055. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64056. import { Scene } from "babylonjs/scene";
  64057. /**
  64058. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64059. * @see http://doc.babylonjs.com/babylon101/sprites
  64060. */
  64061. export class SpritePackedManager extends SpriteManager {
  64062. /** defines the packed manager's name */
  64063. name: string;
  64064. /**
  64065. * Creates a new sprite manager from a packed sprite sheet
  64066. * @param name defines the manager's name
  64067. * @param imgUrl defines the sprite sheet url
  64068. * @param capacity defines the maximum allowed number of sprites
  64069. * @param scene defines the hosting scene
  64070. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64071. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64072. * @param samplingMode defines the smapling mode to use with spritesheet
  64073. * @param fromPacked set to true; do not alter
  64074. */
  64075. constructor(
  64076. /** defines the packed manager's name */
  64077. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64078. }
  64079. }
  64080. declare module "babylonjs/Sprites/index" {
  64081. export * from "babylonjs/Sprites/sprite";
  64082. export * from "babylonjs/Sprites/spriteManager";
  64083. export * from "babylonjs/Sprites/spritePackedManager";
  64084. export * from "babylonjs/Sprites/spriteSceneComponent";
  64085. }
  64086. declare module "babylonjs/Misc/assetsManager" {
  64087. import { Scene } from "babylonjs/scene";
  64088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64089. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64090. import { Skeleton } from "babylonjs/Bones/skeleton";
  64091. import { Observable } from "babylonjs/Misc/observable";
  64092. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64093. import { Texture } from "babylonjs/Materials/Textures/texture";
  64094. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64095. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64096. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64097. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64098. /**
  64099. * Defines the list of states available for a task inside a AssetsManager
  64100. */
  64101. export enum AssetTaskState {
  64102. /**
  64103. * Initialization
  64104. */
  64105. INIT = 0,
  64106. /**
  64107. * Running
  64108. */
  64109. RUNNING = 1,
  64110. /**
  64111. * Done
  64112. */
  64113. DONE = 2,
  64114. /**
  64115. * Error
  64116. */
  64117. ERROR = 3
  64118. }
  64119. /**
  64120. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64121. */
  64122. export abstract class AbstractAssetTask {
  64123. /**
  64124. * Task name
  64125. */ name: string;
  64126. /**
  64127. * Callback called when the task is successful
  64128. */
  64129. onSuccess: (task: any) => void;
  64130. /**
  64131. * Callback called when the task is not successful
  64132. */
  64133. onError: (task: any, message?: string, exception?: any) => void;
  64134. /**
  64135. * Creates a new AssetsManager
  64136. * @param name defines the name of the task
  64137. */
  64138. constructor(
  64139. /**
  64140. * Task name
  64141. */ name: string);
  64142. private _isCompleted;
  64143. private _taskState;
  64144. private _errorObject;
  64145. /**
  64146. * Get if the task is completed
  64147. */
  64148. readonly isCompleted: boolean;
  64149. /**
  64150. * Gets the current state of the task
  64151. */
  64152. readonly taskState: AssetTaskState;
  64153. /**
  64154. * Gets the current error object (if task is in error)
  64155. */
  64156. readonly errorObject: {
  64157. message?: string;
  64158. exception?: any;
  64159. };
  64160. /**
  64161. * Internal only
  64162. * @hidden
  64163. */
  64164. _setErrorObject(message?: string, exception?: any): void;
  64165. /**
  64166. * Execute the current task
  64167. * @param scene defines the scene where you want your assets to be loaded
  64168. * @param onSuccess is a callback called when the task is successfully executed
  64169. * @param onError is a callback called if an error occurs
  64170. */
  64171. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64172. /**
  64173. * Execute the current task
  64174. * @param scene defines the scene where you want your assets to be loaded
  64175. * @param onSuccess is a callback called when the task is successfully executed
  64176. * @param onError is a callback called if an error occurs
  64177. */
  64178. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64179. /**
  64180. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64181. * This can be used with failed tasks that have the reason for failure fixed.
  64182. */
  64183. reset(): void;
  64184. private onErrorCallback;
  64185. private onDoneCallback;
  64186. }
  64187. /**
  64188. * Define the interface used by progress events raised during assets loading
  64189. */
  64190. export interface IAssetsProgressEvent {
  64191. /**
  64192. * Defines the number of remaining tasks to process
  64193. */
  64194. remainingCount: number;
  64195. /**
  64196. * Defines the total number of tasks
  64197. */
  64198. totalCount: number;
  64199. /**
  64200. * Defines the task that was just processed
  64201. */
  64202. task: AbstractAssetTask;
  64203. }
  64204. /**
  64205. * Class used to share progress information about assets loading
  64206. */
  64207. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64208. /**
  64209. * Defines the number of remaining tasks to process
  64210. */
  64211. remainingCount: number;
  64212. /**
  64213. * Defines the total number of tasks
  64214. */
  64215. totalCount: number;
  64216. /**
  64217. * Defines the task that was just processed
  64218. */
  64219. task: AbstractAssetTask;
  64220. /**
  64221. * Creates a AssetsProgressEvent
  64222. * @param remainingCount defines the number of remaining tasks to process
  64223. * @param totalCount defines the total number of tasks
  64224. * @param task defines the task that was just processed
  64225. */
  64226. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64227. }
  64228. /**
  64229. * Define a task used by AssetsManager to load meshes
  64230. */
  64231. export class MeshAssetTask extends AbstractAssetTask {
  64232. /**
  64233. * Defines the name of the task
  64234. */
  64235. name: string;
  64236. /**
  64237. * Defines the list of mesh's names you want to load
  64238. */
  64239. meshesNames: any;
  64240. /**
  64241. * Defines the root url to use as a base to load your meshes and associated resources
  64242. */
  64243. rootUrl: string;
  64244. /**
  64245. * Defines the filename of the scene to load from
  64246. */
  64247. sceneFilename: string;
  64248. /**
  64249. * Gets the list of loaded meshes
  64250. */
  64251. loadedMeshes: Array<AbstractMesh>;
  64252. /**
  64253. * Gets the list of loaded particle systems
  64254. */
  64255. loadedParticleSystems: Array<IParticleSystem>;
  64256. /**
  64257. * Gets the list of loaded skeletons
  64258. */
  64259. loadedSkeletons: Array<Skeleton>;
  64260. /**
  64261. * Gets the list of loaded animation groups
  64262. */
  64263. loadedAnimationGroups: Array<AnimationGroup>;
  64264. /**
  64265. * Callback called when the task is successful
  64266. */
  64267. onSuccess: (task: MeshAssetTask) => void;
  64268. /**
  64269. * Callback called when the task is successful
  64270. */
  64271. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64272. /**
  64273. * Creates a new MeshAssetTask
  64274. * @param name defines the name of the task
  64275. * @param meshesNames defines the list of mesh's names you want to load
  64276. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64277. * @param sceneFilename defines the filename of the scene to load from
  64278. */
  64279. constructor(
  64280. /**
  64281. * Defines the name of the task
  64282. */
  64283. name: string,
  64284. /**
  64285. * Defines the list of mesh's names you want to load
  64286. */
  64287. meshesNames: any,
  64288. /**
  64289. * Defines the root url to use as a base to load your meshes and associated resources
  64290. */
  64291. rootUrl: string,
  64292. /**
  64293. * Defines the filename of the scene to load from
  64294. */
  64295. sceneFilename: string);
  64296. /**
  64297. * Execute the current task
  64298. * @param scene defines the scene where you want your assets to be loaded
  64299. * @param onSuccess is a callback called when the task is successfully executed
  64300. * @param onError is a callback called if an error occurs
  64301. */
  64302. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64303. }
  64304. /**
  64305. * Define a task used by AssetsManager to load text content
  64306. */
  64307. export class TextFileAssetTask extends AbstractAssetTask {
  64308. /**
  64309. * Defines the name of the task
  64310. */
  64311. name: string;
  64312. /**
  64313. * Defines the location of the file to load
  64314. */
  64315. url: string;
  64316. /**
  64317. * Gets the loaded text string
  64318. */
  64319. text: string;
  64320. /**
  64321. * Callback called when the task is successful
  64322. */
  64323. onSuccess: (task: TextFileAssetTask) => void;
  64324. /**
  64325. * Callback called when the task is successful
  64326. */
  64327. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64328. /**
  64329. * Creates a new TextFileAssetTask object
  64330. * @param name defines the name of the task
  64331. * @param url defines the location of the file to load
  64332. */
  64333. constructor(
  64334. /**
  64335. * Defines the name of the task
  64336. */
  64337. name: string,
  64338. /**
  64339. * Defines the location of the file to load
  64340. */
  64341. url: string);
  64342. /**
  64343. * Execute the current task
  64344. * @param scene defines the scene where you want your assets to be loaded
  64345. * @param onSuccess is a callback called when the task is successfully executed
  64346. * @param onError is a callback called if an error occurs
  64347. */
  64348. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64349. }
  64350. /**
  64351. * Define a task used by AssetsManager to load binary data
  64352. */
  64353. export class BinaryFileAssetTask extends AbstractAssetTask {
  64354. /**
  64355. * Defines the name of the task
  64356. */
  64357. name: string;
  64358. /**
  64359. * Defines the location of the file to load
  64360. */
  64361. url: string;
  64362. /**
  64363. * Gets the lodaded data (as an array buffer)
  64364. */
  64365. data: ArrayBuffer;
  64366. /**
  64367. * Callback called when the task is successful
  64368. */
  64369. onSuccess: (task: BinaryFileAssetTask) => void;
  64370. /**
  64371. * Callback called when the task is successful
  64372. */
  64373. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64374. /**
  64375. * Creates a new BinaryFileAssetTask object
  64376. * @param name defines the name of the new task
  64377. * @param url defines the location of the file to load
  64378. */
  64379. constructor(
  64380. /**
  64381. * Defines the name of the task
  64382. */
  64383. name: string,
  64384. /**
  64385. * Defines the location of the file to load
  64386. */
  64387. url: string);
  64388. /**
  64389. * Execute the current task
  64390. * @param scene defines the scene where you want your assets to be loaded
  64391. * @param onSuccess is a callback called when the task is successfully executed
  64392. * @param onError is a callback called if an error occurs
  64393. */
  64394. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64395. }
  64396. /**
  64397. * Define a task used by AssetsManager to load images
  64398. */
  64399. export class ImageAssetTask extends AbstractAssetTask {
  64400. /**
  64401. * Defines the name of the task
  64402. */
  64403. name: string;
  64404. /**
  64405. * Defines the location of the image to load
  64406. */
  64407. url: string;
  64408. /**
  64409. * Gets the loaded images
  64410. */
  64411. image: HTMLImageElement;
  64412. /**
  64413. * Callback called when the task is successful
  64414. */
  64415. onSuccess: (task: ImageAssetTask) => void;
  64416. /**
  64417. * Callback called when the task is successful
  64418. */
  64419. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64420. /**
  64421. * Creates a new ImageAssetTask
  64422. * @param name defines the name of the task
  64423. * @param url defines the location of the image to load
  64424. */
  64425. constructor(
  64426. /**
  64427. * Defines the name of the task
  64428. */
  64429. name: string,
  64430. /**
  64431. * Defines the location of the image to load
  64432. */
  64433. url: string);
  64434. /**
  64435. * Execute the current task
  64436. * @param scene defines the scene where you want your assets to be loaded
  64437. * @param onSuccess is a callback called when the task is successfully executed
  64438. * @param onError is a callback called if an error occurs
  64439. */
  64440. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64441. }
  64442. /**
  64443. * Defines the interface used by texture loading tasks
  64444. */
  64445. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64446. /**
  64447. * Gets the loaded texture
  64448. */
  64449. texture: TEX;
  64450. }
  64451. /**
  64452. * Define a task used by AssetsManager to load 2D textures
  64453. */
  64454. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64455. /**
  64456. * Defines the name of the task
  64457. */
  64458. name: string;
  64459. /**
  64460. * Defines the location of the file to load
  64461. */
  64462. url: string;
  64463. /**
  64464. * Defines if mipmap should not be generated (default is false)
  64465. */
  64466. noMipmap?: boolean | undefined;
  64467. /**
  64468. * Defines if texture must be inverted on Y axis (default is false)
  64469. */
  64470. invertY?: boolean | undefined;
  64471. /**
  64472. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64473. */
  64474. samplingMode: number;
  64475. /**
  64476. * Gets the loaded texture
  64477. */
  64478. texture: Texture;
  64479. /**
  64480. * Callback called when the task is successful
  64481. */
  64482. onSuccess: (task: TextureAssetTask) => void;
  64483. /**
  64484. * Callback called when the task is successful
  64485. */
  64486. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64487. /**
  64488. * Creates a new TextureAssetTask object
  64489. * @param name defines the name of the task
  64490. * @param url defines the location of the file to load
  64491. * @param noMipmap defines if mipmap should not be generated (default is false)
  64492. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64493. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64494. */
  64495. constructor(
  64496. /**
  64497. * Defines the name of the task
  64498. */
  64499. name: string,
  64500. /**
  64501. * Defines the location of the file to load
  64502. */
  64503. url: string,
  64504. /**
  64505. * Defines if mipmap should not be generated (default is false)
  64506. */
  64507. noMipmap?: boolean | undefined,
  64508. /**
  64509. * Defines if texture must be inverted on Y axis (default is false)
  64510. */
  64511. invertY?: boolean | undefined,
  64512. /**
  64513. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64514. */
  64515. samplingMode?: number);
  64516. /**
  64517. * Execute the current task
  64518. * @param scene defines the scene where you want your assets to be loaded
  64519. * @param onSuccess is a callback called when the task is successfully executed
  64520. * @param onError is a callback called if an error occurs
  64521. */
  64522. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64523. }
  64524. /**
  64525. * Define a task used by AssetsManager to load cube textures
  64526. */
  64527. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64528. /**
  64529. * Defines the name of the task
  64530. */
  64531. name: string;
  64532. /**
  64533. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64534. */
  64535. url: string;
  64536. /**
  64537. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64538. */
  64539. extensions?: string[] | undefined;
  64540. /**
  64541. * Defines if mipmaps should not be generated (default is false)
  64542. */
  64543. noMipmap?: boolean | undefined;
  64544. /**
  64545. * Defines the explicit list of files (undefined by default)
  64546. */
  64547. files?: string[] | undefined;
  64548. /**
  64549. * Gets the loaded texture
  64550. */
  64551. texture: CubeTexture;
  64552. /**
  64553. * Callback called when the task is successful
  64554. */
  64555. onSuccess: (task: CubeTextureAssetTask) => void;
  64556. /**
  64557. * Callback called when the task is successful
  64558. */
  64559. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64560. /**
  64561. * Creates a new CubeTextureAssetTask
  64562. * @param name defines the name of the task
  64563. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64564. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64565. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64566. * @param files defines the explicit list of files (undefined by default)
  64567. */
  64568. constructor(
  64569. /**
  64570. * Defines the name of the task
  64571. */
  64572. name: string,
  64573. /**
  64574. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64575. */
  64576. url: string,
  64577. /**
  64578. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64579. */
  64580. extensions?: string[] | undefined,
  64581. /**
  64582. * Defines if mipmaps should not be generated (default is false)
  64583. */
  64584. noMipmap?: boolean | undefined,
  64585. /**
  64586. * Defines the explicit list of files (undefined by default)
  64587. */
  64588. files?: string[] | undefined);
  64589. /**
  64590. * Execute the current task
  64591. * @param scene defines the scene where you want your assets to be loaded
  64592. * @param onSuccess is a callback called when the task is successfully executed
  64593. * @param onError is a callback called if an error occurs
  64594. */
  64595. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64596. }
  64597. /**
  64598. * Define a task used by AssetsManager to load HDR cube textures
  64599. */
  64600. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64601. /**
  64602. * Defines the name of the task
  64603. */
  64604. name: string;
  64605. /**
  64606. * Defines the location of the file to load
  64607. */
  64608. url: string;
  64609. /**
  64610. * Defines the desired size (the more it increases the longer the generation will be)
  64611. */
  64612. size: number;
  64613. /**
  64614. * Defines if mipmaps should not be generated (default is false)
  64615. */
  64616. noMipmap: boolean;
  64617. /**
  64618. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64619. */
  64620. generateHarmonics: boolean;
  64621. /**
  64622. * 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)
  64623. */
  64624. gammaSpace: boolean;
  64625. /**
  64626. * Internal Use Only
  64627. */
  64628. reserved: boolean;
  64629. /**
  64630. * Gets the loaded texture
  64631. */
  64632. texture: HDRCubeTexture;
  64633. /**
  64634. * Callback called when the task is successful
  64635. */
  64636. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64637. /**
  64638. * Callback called when the task is successful
  64639. */
  64640. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64641. /**
  64642. * Creates a new HDRCubeTextureAssetTask object
  64643. * @param name defines the name of the task
  64644. * @param url defines the location of the file to load
  64645. * @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.
  64646. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64647. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64648. * @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)
  64649. * @param reserved Internal use only
  64650. */
  64651. constructor(
  64652. /**
  64653. * Defines the name of the task
  64654. */
  64655. name: string,
  64656. /**
  64657. * Defines the location of the file to load
  64658. */
  64659. url: string,
  64660. /**
  64661. * Defines the desired size (the more it increases the longer the generation will be)
  64662. */
  64663. size: number,
  64664. /**
  64665. * Defines if mipmaps should not be generated (default is false)
  64666. */
  64667. noMipmap?: boolean,
  64668. /**
  64669. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64670. */
  64671. generateHarmonics?: boolean,
  64672. /**
  64673. * 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)
  64674. */
  64675. gammaSpace?: boolean,
  64676. /**
  64677. * Internal Use Only
  64678. */
  64679. reserved?: boolean);
  64680. /**
  64681. * Execute the current task
  64682. * @param scene defines the scene where you want your assets to be loaded
  64683. * @param onSuccess is a callback called when the task is successfully executed
  64684. * @param onError is a callback called if an error occurs
  64685. */
  64686. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64687. }
  64688. /**
  64689. * Define a task used by AssetsManager to load Equirectangular cube textures
  64690. */
  64691. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64692. /**
  64693. * Defines the name of the task
  64694. */
  64695. name: string;
  64696. /**
  64697. * Defines the location of the file to load
  64698. */
  64699. url: string;
  64700. /**
  64701. * Defines the desired size (the more it increases the longer the generation will be)
  64702. */
  64703. size: number;
  64704. /**
  64705. * Defines if mipmaps should not be generated (default is false)
  64706. */
  64707. noMipmap: boolean;
  64708. /**
  64709. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64710. * but the standard material would require them in Gamma space) (default is true)
  64711. */
  64712. gammaSpace: boolean;
  64713. /**
  64714. * Gets the loaded texture
  64715. */
  64716. texture: EquiRectangularCubeTexture;
  64717. /**
  64718. * Callback called when the task is successful
  64719. */
  64720. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64721. /**
  64722. * Callback called when the task is successful
  64723. */
  64724. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64725. /**
  64726. * Creates a new EquiRectangularCubeTextureAssetTask object
  64727. * @param name defines the name of the task
  64728. * @param url defines the location of the file to load
  64729. * @param size defines the desired size (the more it increases the longer the generation will be)
  64730. * If the size is omitted this implies you are using a preprocessed cubemap.
  64731. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64732. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64733. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64734. * (default is true)
  64735. */
  64736. constructor(
  64737. /**
  64738. * Defines the name of the task
  64739. */
  64740. name: string,
  64741. /**
  64742. * Defines the location of the file to load
  64743. */
  64744. url: string,
  64745. /**
  64746. * Defines the desired size (the more it increases the longer the generation will be)
  64747. */
  64748. size: number,
  64749. /**
  64750. * Defines if mipmaps should not be generated (default is false)
  64751. */
  64752. noMipmap?: boolean,
  64753. /**
  64754. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64755. * but the standard material would require them in Gamma space) (default is true)
  64756. */
  64757. gammaSpace?: boolean);
  64758. /**
  64759. * Execute the current task
  64760. * @param scene defines the scene where you want your assets to be loaded
  64761. * @param onSuccess is a callback called when the task is successfully executed
  64762. * @param onError is a callback called if an error occurs
  64763. */
  64764. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64765. }
  64766. /**
  64767. * This class can be used to easily import assets into a scene
  64768. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64769. */
  64770. export class AssetsManager {
  64771. private _scene;
  64772. private _isLoading;
  64773. protected _tasks: AbstractAssetTask[];
  64774. protected _waitingTasksCount: number;
  64775. protected _totalTasksCount: number;
  64776. /**
  64777. * Callback called when all tasks are processed
  64778. */
  64779. onFinish: (tasks: AbstractAssetTask[]) => void;
  64780. /**
  64781. * Callback called when a task is successful
  64782. */
  64783. onTaskSuccess: (task: AbstractAssetTask) => void;
  64784. /**
  64785. * Callback called when a task had an error
  64786. */
  64787. onTaskError: (task: AbstractAssetTask) => void;
  64788. /**
  64789. * Callback called when a task is done (whatever the result is)
  64790. */
  64791. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64792. /**
  64793. * Observable called when all tasks are processed
  64794. */
  64795. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64796. /**
  64797. * Observable called when a task had an error
  64798. */
  64799. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64800. /**
  64801. * Observable called when all tasks were executed
  64802. */
  64803. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64804. /**
  64805. * Observable called when a task is done (whatever the result is)
  64806. */
  64807. onProgressObservable: Observable<IAssetsProgressEvent>;
  64808. /**
  64809. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64810. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64811. */
  64812. useDefaultLoadingScreen: boolean;
  64813. /**
  64814. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64815. * when all assets have been downloaded.
  64816. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64817. */
  64818. autoHideLoadingUI: boolean;
  64819. /**
  64820. * Creates a new AssetsManager
  64821. * @param scene defines the scene to work on
  64822. */
  64823. constructor(scene: Scene);
  64824. /**
  64825. * Add a MeshAssetTask to the list of active tasks
  64826. * @param taskName defines the name of the new task
  64827. * @param meshesNames defines the name of meshes to load
  64828. * @param rootUrl defines the root url to use to locate files
  64829. * @param sceneFilename defines the filename of the scene file
  64830. * @returns a new MeshAssetTask object
  64831. */
  64832. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64833. /**
  64834. * Add a TextFileAssetTask to the list of active tasks
  64835. * @param taskName defines the name of the new task
  64836. * @param url defines the url of the file to load
  64837. * @returns a new TextFileAssetTask object
  64838. */
  64839. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64840. /**
  64841. * Add a BinaryFileAssetTask to the list of active tasks
  64842. * @param taskName defines the name of the new task
  64843. * @param url defines the url of the file to load
  64844. * @returns a new BinaryFileAssetTask object
  64845. */
  64846. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64847. /**
  64848. * Add a ImageAssetTask to the list of active tasks
  64849. * @param taskName defines the name of the new task
  64850. * @param url defines the url of the file to load
  64851. * @returns a new ImageAssetTask object
  64852. */
  64853. addImageTask(taskName: string, url: string): ImageAssetTask;
  64854. /**
  64855. * Add a TextureAssetTask to the list of active tasks
  64856. * @param taskName defines the name of the new task
  64857. * @param url defines the url of the file to load
  64858. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64859. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64860. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64861. * @returns a new TextureAssetTask object
  64862. */
  64863. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64864. /**
  64865. * Add a CubeTextureAssetTask to the list of active tasks
  64866. * @param taskName defines the name of the new task
  64867. * @param url defines the url of the file to load
  64868. * @param extensions defines the extension to use to load the cube map (can be null)
  64869. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64870. * @param files defines the list of files to load (can be null)
  64871. * @returns a new CubeTextureAssetTask object
  64872. */
  64873. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64874. /**
  64875. *
  64876. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64877. * @param taskName defines the name of the new task
  64878. * @param url defines the url of the file to load
  64879. * @param size defines the size you want for the cubemap (can be null)
  64880. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64881. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64882. * @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)
  64883. * @param reserved Internal use only
  64884. * @returns a new HDRCubeTextureAssetTask object
  64885. */
  64886. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64887. /**
  64888. *
  64889. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64890. * @param taskName defines the name of the new task
  64891. * @param url defines the url of the file to load
  64892. * @param size defines the size you want for the cubemap (can be null)
  64893. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64894. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64895. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64896. * @returns a new EquiRectangularCubeTextureAssetTask object
  64897. */
  64898. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64899. /**
  64900. * Remove a task from the assets manager.
  64901. * @param task the task to remove
  64902. */
  64903. removeTask(task: AbstractAssetTask): void;
  64904. private _decreaseWaitingTasksCount;
  64905. private _runTask;
  64906. /**
  64907. * Reset the AssetsManager and remove all tasks
  64908. * @return the current instance of the AssetsManager
  64909. */
  64910. reset(): AssetsManager;
  64911. /**
  64912. * Start the loading process
  64913. * @return the current instance of the AssetsManager
  64914. */
  64915. load(): AssetsManager;
  64916. /**
  64917. * Start the loading process as an async operation
  64918. * @return a promise returning the list of failed tasks
  64919. */
  64920. loadAsync(): Promise<void>;
  64921. }
  64922. }
  64923. declare module "babylonjs/Misc/deferred" {
  64924. /**
  64925. * Wrapper class for promise with external resolve and reject.
  64926. */
  64927. export class Deferred<T> {
  64928. /**
  64929. * The promise associated with this deferred object.
  64930. */
  64931. readonly promise: Promise<T>;
  64932. private _resolve;
  64933. private _reject;
  64934. /**
  64935. * The resolve method of the promise associated with this deferred object.
  64936. */
  64937. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64938. /**
  64939. * The reject method of the promise associated with this deferred object.
  64940. */
  64941. readonly reject: (reason?: any) => void;
  64942. /**
  64943. * Constructor for this deferred object.
  64944. */
  64945. constructor();
  64946. }
  64947. }
  64948. declare module "babylonjs/Misc/meshExploder" {
  64949. import { Mesh } from "babylonjs/Meshes/mesh";
  64950. /**
  64951. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64952. */
  64953. export class MeshExploder {
  64954. private _centerMesh;
  64955. private _meshes;
  64956. private _meshesOrigins;
  64957. private _toCenterVectors;
  64958. private _scaledDirection;
  64959. private _newPosition;
  64960. private _centerPosition;
  64961. /**
  64962. * Explodes meshes from a center mesh.
  64963. * @param meshes The meshes to explode.
  64964. * @param centerMesh The mesh to be center of explosion.
  64965. */
  64966. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64967. private _setCenterMesh;
  64968. /**
  64969. * Get class name
  64970. * @returns "MeshExploder"
  64971. */
  64972. getClassName(): string;
  64973. /**
  64974. * "Exploded meshes"
  64975. * @returns Array of meshes with the centerMesh at index 0.
  64976. */
  64977. getMeshes(): Array<Mesh>;
  64978. /**
  64979. * Explodes meshes giving a specific direction
  64980. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64981. */
  64982. explode(direction?: number): void;
  64983. }
  64984. }
  64985. declare module "babylonjs/Misc/filesInput" {
  64986. import { Engine } from "babylonjs/Engines/engine";
  64987. import { Scene } from "babylonjs/scene";
  64988. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64989. /**
  64990. * Class used to help managing file picking and drag'n'drop
  64991. */
  64992. export class FilesInput {
  64993. /**
  64994. * List of files ready to be loaded
  64995. */
  64996. static readonly FilesToLoad: {
  64997. [key: string]: File;
  64998. };
  64999. /**
  65000. * Callback called when a file is processed
  65001. */
  65002. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65003. private _engine;
  65004. private _currentScene;
  65005. private _sceneLoadedCallback;
  65006. private _progressCallback;
  65007. private _additionalRenderLoopLogicCallback;
  65008. private _textureLoadingCallback;
  65009. private _startingProcessingFilesCallback;
  65010. private _onReloadCallback;
  65011. private _errorCallback;
  65012. private _elementToMonitor;
  65013. private _sceneFileToLoad;
  65014. private _filesToLoad;
  65015. /**
  65016. * Creates a new FilesInput
  65017. * @param engine defines the rendering engine
  65018. * @param scene defines the hosting scene
  65019. * @param sceneLoadedCallback callback called when scene is loaded
  65020. * @param progressCallback callback called to track progress
  65021. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65022. * @param textureLoadingCallback callback called when a texture is loading
  65023. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65024. * @param onReloadCallback callback called when a reload is requested
  65025. * @param errorCallback callback call if an error occurs
  65026. */
  65027. 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);
  65028. private _dragEnterHandler;
  65029. private _dragOverHandler;
  65030. private _dropHandler;
  65031. /**
  65032. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65033. * @param elementToMonitor defines the DOM element to track
  65034. */
  65035. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65036. /**
  65037. * Release all associated resources
  65038. */
  65039. dispose(): void;
  65040. private renderFunction;
  65041. private drag;
  65042. private drop;
  65043. private _traverseFolder;
  65044. private _processFiles;
  65045. /**
  65046. * Load files from a drop event
  65047. * @param event defines the drop event to use as source
  65048. */
  65049. loadFiles(event: any): void;
  65050. private _processReload;
  65051. /**
  65052. * Reload the current scene from the loaded files
  65053. */
  65054. reload(): void;
  65055. }
  65056. }
  65057. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65058. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65059. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65060. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65061. }
  65062. declare module "babylonjs/Misc/sceneOptimizer" {
  65063. import { Scene, IDisposable } from "babylonjs/scene";
  65064. import { Observable } from "babylonjs/Misc/observable";
  65065. /**
  65066. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65067. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65068. */
  65069. export class SceneOptimization {
  65070. /**
  65071. * Defines the priority of this optimization (0 by default which means first in the list)
  65072. */
  65073. priority: number;
  65074. /**
  65075. * Gets a string describing the action executed by the current optimization
  65076. * @returns description string
  65077. */
  65078. getDescription(): string;
  65079. /**
  65080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65081. * @param scene defines the current scene where to apply this optimization
  65082. * @param optimizer defines the current optimizer
  65083. * @returns true if everything that can be done was applied
  65084. */
  65085. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65086. /**
  65087. * Creates the SceneOptimization object
  65088. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65089. * @param desc defines the description associated with the optimization
  65090. */
  65091. constructor(
  65092. /**
  65093. * Defines the priority of this optimization (0 by default which means first in the list)
  65094. */
  65095. priority?: number);
  65096. }
  65097. /**
  65098. * Defines an optimization used to reduce the size of render target textures
  65099. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65100. */
  65101. export class TextureOptimization extends SceneOptimization {
  65102. /**
  65103. * Defines the priority of this optimization (0 by default which means first in the list)
  65104. */
  65105. priority: number;
  65106. /**
  65107. * 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
  65108. */
  65109. maximumSize: number;
  65110. /**
  65111. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65112. */
  65113. step: number;
  65114. /**
  65115. * Gets a string describing the action executed by the current optimization
  65116. * @returns description string
  65117. */
  65118. getDescription(): string;
  65119. /**
  65120. * Creates the TextureOptimization object
  65121. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65122. * @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
  65123. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65124. */
  65125. constructor(
  65126. /**
  65127. * Defines the priority of this optimization (0 by default which means first in the list)
  65128. */
  65129. priority?: number,
  65130. /**
  65131. * 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
  65132. */
  65133. maximumSize?: number,
  65134. /**
  65135. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65136. */
  65137. step?: number);
  65138. /**
  65139. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65140. * @param scene defines the current scene where to apply this optimization
  65141. * @param optimizer defines the current optimizer
  65142. * @returns true if everything that can be done was applied
  65143. */
  65144. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65145. }
  65146. /**
  65147. * Defines an optimization used to increase or decrease the rendering resolution
  65148. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65149. */
  65150. export class HardwareScalingOptimization extends SceneOptimization {
  65151. /**
  65152. * Defines the priority of this optimization (0 by default which means first in the list)
  65153. */
  65154. priority: number;
  65155. /**
  65156. * Defines the maximum scale to use (2 by default)
  65157. */
  65158. maximumScale: number;
  65159. /**
  65160. * Defines the step to use between two passes (0.5 by default)
  65161. */
  65162. step: number;
  65163. private _currentScale;
  65164. private _directionOffset;
  65165. /**
  65166. * Gets a string describing the action executed by the current optimization
  65167. * @return description string
  65168. */
  65169. getDescription(): string;
  65170. /**
  65171. * Creates the HardwareScalingOptimization object
  65172. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65173. * @param maximumScale defines the maximum scale to use (2 by default)
  65174. * @param step defines the step to use between two passes (0.5 by default)
  65175. */
  65176. constructor(
  65177. /**
  65178. * Defines the priority of this optimization (0 by default which means first in the list)
  65179. */
  65180. priority?: number,
  65181. /**
  65182. * Defines the maximum scale to use (2 by default)
  65183. */
  65184. maximumScale?: number,
  65185. /**
  65186. * Defines the step to use between two passes (0.5 by default)
  65187. */
  65188. step?: number);
  65189. /**
  65190. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65191. * @param scene defines the current scene where to apply this optimization
  65192. * @param optimizer defines the current optimizer
  65193. * @returns true if everything that can be done was applied
  65194. */
  65195. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65196. }
  65197. /**
  65198. * Defines an optimization used to remove shadows
  65199. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65200. */
  65201. export class ShadowsOptimization extends SceneOptimization {
  65202. /**
  65203. * Gets a string describing the action executed by the current optimization
  65204. * @return description string
  65205. */
  65206. getDescription(): string;
  65207. /**
  65208. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65209. * @param scene defines the current scene where to apply this optimization
  65210. * @param optimizer defines the current optimizer
  65211. * @returns true if everything that can be done was applied
  65212. */
  65213. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65214. }
  65215. /**
  65216. * Defines an optimization used to turn post-processes off
  65217. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65218. */
  65219. export class PostProcessesOptimization extends SceneOptimization {
  65220. /**
  65221. * Gets a string describing the action executed by the current optimization
  65222. * @return description string
  65223. */
  65224. getDescription(): string;
  65225. /**
  65226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65227. * @param scene defines the current scene where to apply this optimization
  65228. * @param optimizer defines the current optimizer
  65229. * @returns true if everything that can be done was applied
  65230. */
  65231. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65232. }
  65233. /**
  65234. * Defines an optimization used to turn lens flares off
  65235. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65236. */
  65237. export class LensFlaresOptimization extends SceneOptimization {
  65238. /**
  65239. * Gets a string describing the action executed by the current optimization
  65240. * @return description string
  65241. */
  65242. getDescription(): string;
  65243. /**
  65244. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65245. * @param scene defines the current scene where to apply this optimization
  65246. * @param optimizer defines the current optimizer
  65247. * @returns true if everything that can be done was applied
  65248. */
  65249. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65250. }
  65251. /**
  65252. * Defines an optimization based on user defined callback.
  65253. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65254. */
  65255. export class CustomOptimization extends SceneOptimization {
  65256. /**
  65257. * Callback called to apply the custom optimization.
  65258. */
  65259. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65260. /**
  65261. * Callback called to get custom description
  65262. */
  65263. onGetDescription: () => string;
  65264. /**
  65265. * Gets a string describing the action executed by the current optimization
  65266. * @returns description string
  65267. */
  65268. getDescription(): string;
  65269. /**
  65270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65271. * @param scene defines the current scene where to apply this optimization
  65272. * @param optimizer defines the current optimizer
  65273. * @returns true if everything that can be done was applied
  65274. */
  65275. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65276. }
  65277. /**
  65278. * Defines an optimization used to turn particles off
  65279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65280. */
  65281. export class ParticlesOptimization extends SceneOptimization {
  65282. /**
  65283. * Gets a string describing the action executed by the current optimization
  65284. * @return description string
  65285. */
  65286. getDescription(): string;
  65287. /**
  65288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65289. * @param scene defines the current scene where to apply this optimization
  65290. * @param optimizer defines the current optimizer
  65291. * @returns true if everything that can be done was applied
  65292. */
  65293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65294. }
  65295. /**
  65296. * Defines an optimization used to turn render targets off
  65297. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65298. */
  65299. export class RenderTargetsOptimization extends SceneOptimization {
  65300. /**
  65301. * Gets a string describing the action executed by the current optimization
  65302. * @return description string
  65303. */
  65304. getDescription(): string;
  65305. /**
  65306. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65307. * @param scene defines the current scene where to apply this optimization
  65308. * @param optimizer defines the current optimizer
  65309. * @returns true if everything that can be done was applied
  65310. */
  65311. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65312. }
  65313. /**
  65314. * Defines an optimization used to merge meshes with compatible materials
  65315. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65316. */
  65317. export class MergeMeshesOptimization extends SceneOptimization {
  65318. private static _UpdateSelectionTree;
  65319. /**
  65320. * Gets or sets a boolean which defines if optimization octree has to be updated
  65321. */
  65322. /**
  65323. * Gets or sets a boolean which defines if optimization octree has to be updated
  65324. */
  65325. static UpdateSelectionTree: boolean;
  65326. /**
  65327. * Gets a string describing the action executed by the current optimization
  65328. * @return description string
  65329. */
  65330. getDescription(): string;
  65331. private _canBeMerged;
  65332. /**
  65333. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65334. * @param scene defines the current scene where to apply this optimization
  65335. * @param optimizer defines the current optimizer
  65336. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65337. * @returns true if everything that can be done was applied
  65338. */
  65339. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65340. }
  65341. /**
  65342. * Defines a list of options used by SceneOptimizer
  65343. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65344. */
  65345. export class SceneOptimizerOptions {
  65346. /**
  65347. * Defines the target frame rate to reach (60 by default)
  65348. */
  65349. targetFrameRate: number;
  65350. /**
  65351. * Defines the interval between two checkes (2000ms by default)
  65352. */
  65353. trackerDuration: number;
  65354. /**
  65355. * Gets the list of optimizations to apply
  65356. */
  65357. optimizations: SceneOptimization[];
  65358. /**
  65359. * Creates a new list of options used by SceneOptimizer
  65360. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65361. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65362. */
  65363. constructor(
  65364. /**
  65365. * Defines the target frame rate to reach (60 by default)
  65366. */
  65367. targetFrameRate?: number,
  65368. /**
  65369. * Defines the interval between two checkes (2000ms by default)
  65370. */
  65371. trackerDuration?: number);
  65372. /**
  65373. * Add a new optimization
  65374. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65375. * @returns the current SceneOptimizerOptions
  65376. */
  65377. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65378. /**
  65379. * Add a new custom optimization
  65380. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65381. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65382. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65383. * @returns the current SceneOptimizerOptions
  65384. */
  65385. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65386. /**
  65387. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65388. * @param targetFrameRate defines the target frame rate (60 by default)
  65389. * @returns a SceneOptimizerOptions object
  65390. */
  65391. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65392. /**
  65393. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65394. * @param targetFrameRate defines the target frame rate (60 by default)
  65395. * @returns a SceneOptimizerOptions object
  65396. */
  65397. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65398. /**
  65399. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65400. * @param targetFrameRate defines the target frame rate (60 by default)
  65401. * @returns a SceneOptimizerOptions object
  65402. */
  65403. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65404. }
  65405. /**
  65406. * Class used to run optimizations in order to reach a target frame rate
  65407. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65408. */
  65409. export class SceneOptimizer implements IDisposable {
  65410. private _isRunning;
  65411. private _options;
  65412. private _scene;
  65413. private _currentPriorityLevel;
  65414. private _targetFrameRate;
  65415. private _trackerDuration;
  65416. private _currentFrameRate;
  65417. private _sceneDisposeObserver;
  65418. private _improvementMode;
  65419. /**
  65420. * Defines an observable called when the optimizer reaches the target frame rate
  65421. */
  65422. onSuccessObservable: Observable<SceneOptimizer>;
  65423. /**
  65424. * Defines an observable called when the optimizer enables an optimization
  65425. */
  65426. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65427. /**
  65428. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65429. */
  65430. onFailureObservable: Observable<SceneOptimizer>;
  65431. /**
  65432. * Gets a boolean indicating if the optimizer is in improvement mode
  65433. */
  65434. readonly isInImprovementMode: boolean;
  65435. /**
  65436. * Gets the current priority level (0 at start)
  65437. */
  65438. readonly currentPriorityLevel: number;
  65439. /**
  65440. * Gets the current frame rate checked by the SceneOptimizer
  65441. */
  65442. readonly currentFrameRate: number;
  65443. /**
  65444. * Gets or sets the current target frame rate (60 by default)
  65445. */
  65446. /**
  65447. * Gets or sets the current target frame rate (60 by default)
  65448. */
  65449. targetFrameRate: number;
  65450. /**
  65451. * Gets or sets the current interval between two checks (every 2000ms by default)
  65452. */
  65453. /**
  65454. * Gets or sets the current interval between two checks (every 2000ms by default)
  65455. */
  65456. trackerDuration: number;
  65457. /**
  65458. * Gets the list of active optimizations
  65459. */
  65460. readonly optimizations: SceneOptimization[];
  65461. /**
  65462. * Creates a new SceneOptimizer
  65463. * @param scene defines the scene to work on
  65464. * @param options defines the options to use with the SceneOptimizer
  65465. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65466. * @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)
  65467. */
  65468. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65469. /**
  65470. * Stops the current optimizer
  65471. */
  65472. stop(): void;
  65473. /**
  65474. * Reset the optimizer to initial step (current priority level = 0)
  65475. */
  65476. reset(): void;
  65477. /**
  65478. * Start the optimizer. By default it will try to reach a specific framerate
  65479. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65480. */
  65481. start(): void;
  65482. private _checkCurrentState;
  65483. /**
  65484. * Release all resources
  65485. */
  65486. dispose(): void;
  65487. /**
  65488. * Helper function to create a SceneOptimizer with one single line of code
  65489. * @param scene defines the scene to work on
  65490. * @param options defines the options to use with the SceneOptimizer
  65491. * @param onSuccess defines a callback to call on success
  65492. * @param onFailure defines a callback to call on failure
  65493. * @returns the new SceneOptimizer object
  65494. */
  65495. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65496. }
  65497. }
  65498. declare module "babylonjs/Misc/sceneSerializer" {
  65499. import { Scene } from "babylonjs/scene";
  65500. /**
  65501. * Class used to serialize a scene into a string
  65502. */
  65503. export class SceneSerializer {
  65504. /**
  65505. * Clear cache used by a previous serialization
  65506. */
  65507. static ClearCache(): void;
  65508. /**
  65509. * Serialize a scene into a JSON compatible object
  65510. * @param scene defines the scene to serialize
  65511. * @returns a JSON compatible object
  65512. */
  65513. static Serialize(scene: Scene): any;
  65514. /**
  65515. * Serialize a mesh into a JSON compatible object
  65516. * @param toSerialize defines the mesh to serialize
  65517. * @param withParents defines if parents must be serialized as well
  65518. * @param withChildren defines if children must be serialized as well
  65519. * @returns a JSON compatible object
  65520. */
  65521. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65522. }
  65523. }
  65524. declare module "babylonjs/Misc/textureTools" {
  65525. import { Texture } from "babylonjs/Materials/Textures/texture";
  65526. /**
  65527. * Class used to host texture specific utilities
  65528. */
  65529. export class TextureTools {
  65530. /**
  65531. * Uses the GPU to create a copy texture rescaled at a given size
  65532. * @param texture Texture to copy from
  65533. * @param width defines the desired width
  65534. * @param height defines the desired height
  65535. * @param useBilinearMode defines if bilinear mode has to be used
  65536. * @return the generated texture
  65537. */
  65538. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65539. }
  65540. }
  65541. declare module "babylonjs/Misc/videoRecorder" {
  65542. import { Nullable } from "babylonjs/types";
  65543. import { Engine } from "babylonjs/Engines/engine";
  65544. /**
  65545. * This represents the different options available for the video capture.
  65546. */
  65547. export interface VideoRecorderOptions {
  65548. /** Defines the mime type of the video. */
  65549. mimeType: string;
  65550. /** Defines the FPS the video should be recorded at. */
  65551. fps: number;
  65552. /** Defines the chunk size for the recording data. */
  65553. recordChunckSize: number;
  65554. /** The audio tracks to attach to the recording. */
  65555. audioTracks?: MediaStreamTrack[];
  65556. }
  65557. /**
  65558. * This can help with recording videos from BabylonJS.
  65559. * This is based on the available WebRTC functionalities of the browser.
  65560. *
  65561. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65562. */
  65563. export class VideoRecorder {
  65564. private static readonly _defaultOptions;
  65565. /**
  65566. * Returns whether or not the VideoRecorder is available in your browser.
  65567. * @param engine Defines the Babylon Engine.
  65568. * @returns true if supported otherwise false.
  65569. */
  65570. static IsSupported(engine: Engine): boolean;
  65571. private readonly _options;
  65572. private _canvas;
  65573. private _mediaRecorder;
  65574. private _recordedChunks;
  65575. private _fileName;
  65576. private _resolve;
  65577. private _reject;
  65578. /**
  65579. * True when a recording is already in progress.
  65580. */
  65581. readonly isRecording: boolean;
  65582. /**
  65583. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65584. * @param engine Defines the BabylonJS Engine you wish to record.
  65585. * @param options Defines options that can be used to customize the capture.
  65586. */
  65587. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65588. /**
  65589. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65590. */
  65591. stopRecording(): void;
  65592. /**
  65593. * Starts recording the canvas for a max duration specified in parameters.
  65594. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65595. * If null no automatic download will start and you can rely on the promise to get the data back.
  65596. * @param maxDuration Defines the maximum recording time in seconds.
  65597. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65598. * @return A promise callback at the end of the recording with the video data in Blob.
  65599. */
  65600. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65601. /**
  65602. * Releases internal resources used during the recording.
  65603. */
  65604. dispose(): void;
  65605. private _handleDataAvailable;
  65606. private _handleError;
  65607. private _handleStop;
  65608. }
  65609. }
  65610. declare module "babylonjs/Misc/screenshotTools" {
  65611. import { Camera } from "babylonjs/Cameras/camera";
  65612. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  65613. import { Engine } from "babylonjs/Engines/engine";
  65614. /**
  65615. * Class containing a set of static utilities functions for screenshots
  65616. */
  65617. export class ScreenshotTools {
  65618. /**
  65619. * Captures a screenshot of the current rendering
  65620. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65621. * @param engine defines the rendering engine
  65622. * @param camera defines the source camera
  65623. * @param size This parameter can be set to a single number or to an object with the
  65624. * following (optional) properties: precision, width, height. If a single number is passed,
  65625. * it will be used for both width and height. If an object is passed, the screenshot size
  65626. * will be derived from the parameters. The precision property is a multiplier allowing
  65627. * rendering at a higher or lower resolution
  65628. * @param successCallback defines the callback receives a single parameter which contains the
  65629. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65630. * src parameter of an <img> to display it
  65631. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65632. * Check your browser for supported MIME types
  65633. */
  65634. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65635. /**
  65636. * Captures a screenshot of the current rendering
  65637. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65638. * @param engine defines the rendering engine
  65639. * @param camera defines the source camera
  65640. * @param size This parameter can be set to a single number or to an object with the
  65641. * following (optional) properties: precision, width, height. If a single number is passed,
  65642. * it will be used for both width and height. If an object is passed, the screenshot size
  65643. * will be derived from the parameters. The precision property is a multiplier allowing
  65644. * rendering at a higher or lower resolution
  65645. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65646. * Check your browser for supported MIME types
  65647. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65648. * to the src parameter of an <img> to display it
  65649. */
  65650. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65651. /**
  65652. * Generates an image screenshot from the specified camera.
  65653. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65654. * @param engine The engine to use for rendering
  65655. * @param camera The camera to use for rendering
  65656. * @param size This parameter can be set to a single number or to an object with the
  65657. * following (optional) properties: precision, width, height. If a single number is passed,
  65658. * it will be used for both width and height. If an object is passed, the screenshot size
  65659. * will be derived from the parameters. The precision property is a multiplier allowing
  65660. * rendering at a higher or lower resolution
  65661. * @param successCallback The callback receives a single parameter which contains the
  65662. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65663. * src parameter of an <img> to display it
  65664. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65665. * Check your browser for supported MIME types
  65666. * @param samples Texture samples (default: 1)
  65667. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65668. * @param fileName A name for for the downloaded file.
  65669. */
  65670. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65671. /**
  65672. * Generates an image screenshot from the specified camera.
  65673. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65674. * @param engine The engine to use for rendering
  65675. * @param camera The camera to use for rendering
  65676. * @param size This parameter can be set to a single number or to an object with the
  65677. * following (optional) properties: precision, width, height. If a single number is passed,
  65678. * it will be used for both width and height. If an object is passed, the screenshot size
  65679. * will be derived from the parameters. The precision property is a multiplier allowing
  65680. * rendering at a higher or lower resolution
  65681. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65682. * Check your browser for supported MIME types
  65683. * @param samples Texture samples (default: 1)
  65684. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65685. * @param fileName A name for for the downloaded file.
  65686. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65687. * to the src parameter of an <img> to display it
  65688. */
  65689. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65690. /**
  65691. * Gets height and width for screenshot size
  65692. * @private
  65693. */
  65694. private static _getScreenshotSize;
  65695. }
  65696. }
  65697. declare module "babylonjs/Misc/index" {
  65698. export * from "babylonjs/Misc/andOrNotEvaluator";
  65699. export * from "babylonjs/Misc/assetsManager";
  65700. export * from "babylonjs/Misc/dds";
  65701. export * from "babylonjs/Misc/decorators";
  65702. export * from "babylonjs/Misc/deferred";
  65703. export * from "babylonjs/Misc/environmentTextureTools";
  65704. export * from "babylonjs/Misc/meshExploder";
  65705. export * from "babylonjs/Misc/filesInput";
  65706. export * from "babylonjs/Misc/HighDynamicRange/index";
  65707. export * from "babylonjs/Misc/khronosTextureContainer";
  65708. export * from "babylonjs/Misc/observable";
  65709. export * from "babylonjs/Misc/performanceMonitor";
  65710. export * from "babylonjs/Misc/promise";
  65711. export * from "babylonjs/Misc/sceneOptimizer";
  65712. export * from "babylonjs/Misc/sceneSerializer";
  65713. export * from "babylonjs/Misc/smartArray";
  65714. export * from "babylonjs/Misc/stringDictionary";
  65715. export * from "babylonjs/Misc/tags";
  65716. export * from "babylonjs/Misc/textureTools";
  65717. export * from "babylonjs/Misc/tga";
  65718. export * from "babylonjs/Misc/tools";
  65719. export * from "babylonjs/Misc/videoRecorder";
  65720. export * from "babylonjs/Misc/virtualJoystick";
  65721. export * from "babylonjs/Misc/workerPool";
  65722. export * from "babylonjs/Misc/logger";
  65723. export * from "babylonjs/Misc/typeStore";
  65724. export * from "babylonjs/Misc/filesInputStore";
  65725. export * from "babylonjs/Misc/deepCopier";
  65726. export * from "babylonjs/Misc/pivotTools";
  65727. export * from "babylonjs/Misc/precisionDate";
  65728. export * from "babylonjs/Misc/screenshotTools";
  65729. export * from "babylonjs/Misc/typeStore";
  65730. export * from "babylonjs/Misc/webRequest";
  65731. export * from "babylonjs/Misc/iInspectable";
  65732. export * from "babylonjs/Misc/brdfTextureTools";
  65733. export * from "babylonjs/Misc/rgbdTextureTools";
  65734. export * from "babylonjs/Misc/gradients";
  65735. export * from "babylonjs/Misc/perfCounter";
  65736. export * from "babylonjs/Misc/fileRequest";
  65737. export * from "babylonjs/Misc/customAnimationFrameRequester";
  65738. export * from "babylonjs/Misc/retryStrategy";
  65739. export * from "babylonjs/Misc/loadFileError";
  65740. export * from "babylonjs/Misc/interfaces/screenshotSize";
  65741. }
  65742. declare module "babylonjs/index" {
  65743. export * from "babylonjs/abstractScene";
  65744. export * from "babylonjs/Actions/index";
  65745. export * from "babylonjs/Animations/index";
  65746. export * from "babylonjs/assetContainer";
  65747. export * from "babylonjs/Audio/index";
  65748. export * from "babylonjs/Behaviors/index";
  65749. export * from "babylonjs/Bones/index";
  65750. export * from "babylonjs/Cameras/index";
  65751. export * from "babylonjs/Collisions/index";
  65752. export * from "babylonjs/Culling/index";
  65753. export * from "babylonjs/Debug/index";
  65754. export * from "babylonjs/Engines/index";
  65755. export * from "babylonjs/Events/index";
  65756. export * from "babylonjs/Gamepads/index";
  65757. export * from "babylonjs/Gizmos/index";
  65758. export * from "babylonjs/Helpers/index";
  65759. export * from "babylonjs/Instrumentation/index";
  65760. export * from "babylonjs/Layers/index";
  65761. export * from "babylonjs/LensFlares/index";
  65762. export * from "babylonjs/Lights/index";
  65763. export * from "babylonjs/Loading/index";
  65764. export * from "babylonjs/Materials/index";
  65765. export * from "babylonjs/Maths/index";
  65766. export * from "babylonjs/Meshes/index";
  65767. export * from "babylonjs/Morph/index";
  65768. export * from "babylonjs/Navigation/index";
  65769. export * from "babylonjs/node";
  65770. export * from "babylonjs/Offline/index";
  65771. export * from "babylonjs/Particles/index";
  65772. export * from "babylonjs/Physics/index";
  65773. export * from "babylonjs/PostProcesses/index";
  65774. export * from "babylonjs/Probes/index";
  65775. export * from "babylonjs/Rendering/index";
  65776. export * from "babylonjs/scene";
  65777. export * from "babylonjs/sceneComponent";
  65778. export * from "babylonjs/Sprites/index";
  65779. export * from "babylonjs/States/index";
  65780. export * from "babylonjs/Misc/index";
  65781. export * from "babylonjs/types";
  65782. }
  65783. declare module "babylonjs/Animations/pathCursor" {
  65784. import { Vector3 } from "babylonjs/Maths/math.vector";
  65785. import { Path2 } from "babylonjs/Maths/math.path";
  65786. /**
  65787. * A cursor which tracks a point on a path
  65788. */
  65789. export class PathCursor {
  65790. private path;
  65791. /**
  65792. * Stores path cursor callbacks for when an onchange event is triggered
  65793. */
  65794. private _onchange;
  65795. /**
  65796. * The value of the path cursor
  65797. */
  65798. value: number;
  65799. /**
  65800. * The animation array of the path cursor
  65801. */
  65802. animations: Animation[];
  65803. /**
  65804. * Initializes the path cursor
  65805. * @param path The path to track
  65806. */
  65807. constructor(path: Path2);
  65808. /**
  65809. * Gets the cursor point on the path
  65810. * @returns A point on the path cursor at the cursor location
  65811. */
  65812. getPoint(): Vector3;
  65813. /**
  65814. * Moves the cursor ahead by the step amount
  65815. * @param step The amount to move the cursor forward
  65816. * @returns This path cursor
  65817. */
  65818. moveAhead(step?: number): PathCursor;
  65819. /**
  65820. * Moves the cursor behind by the step amount
  65821. * @param step The amount to move the cursor back
  65822. * @returns This path cursor
  65823. */
  65824. moveBack(step?: number): PathCursor;
  65825. /**
  65826. * Moves the cursor by the step amount
  65827. * If the step amount is greater than one, an exception is thrown
  65828. * @param step The amount to move the cursor
  65829. * @returns This path cursor
  65830. */
  65831. move(step: number): PathCursor;
  65832. /**
  65833. * Ensures that the value is limited between zero and one
  65834. * @returns This path cursor
  65835. */
  65836. private ensureLimits;
  65837. /**
  65838. * Runs onchange callbacks on change (used by the animation engine)
  65839. * @returns This path cursor
  65840. */
  65841. private raiseOnChange;
  65842. /**
  65843. * Executes a function on change
  65844. * @param f A path cursor onchange callback
  65845. * @returns This path cursor
  65846. */
  65847. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65848. }
  65849. }
  65850. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  65851. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  65852. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  65853. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  65854. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  65855. }
  65856. declare module "babylonjs/Engines/Processors/Expressions/index" {
  65857. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  65858. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  65859. }
  65860. declare module "babylonjs/Engines/Processors/index" {
  65861. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  65862. export * from "babylonjs/Engines/Processors/Expressions/index";
  65863. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  65864. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  65865. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  65866. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  65867. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  65868. export * from "babylonjs/Engines/Processors/shaderProcessor";
  65869. }
  65870. declare module "babylonjs/Legacy/legacy" {
  65871. import * as Babylon from "babylonjs/index";
  65872. export * from "babylonjs/index";
  65873. }
  65874. declare module "babylonjs/Shaders/blur.fragment" {
  65875. /** @hidden */
  65876. export var blurPixelShader: {
  65877. name: string;
  65878. shader: string;
  65879. };
  65880. }
  65881. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  65882. /** @hidden */
  65883. export var pointCloudVertexDeclaration: {
  65884. name: string;
  65885. shader: string;
  65886. };
  65887. }
  65888. declare module "babylonjs" {
  65889. export * from "babylonjs/Legacy/legacy";
  65890. }
  65891. declare module BABYLON {
  65892. /** Alias type for value that can be null */
  65893. export type Nullable<T> = T | null;
  65894. /**
  65895. * Alias type for number that are floats
  65896. * @ignorenaming
  65897. */
  65898. export type float = number;
  65899. /**
  65900. * Alias type for number that are doubles.
  65901. * @ignorenaming
  65902. */
  65903. export type double = number;
  65904. /**
  65905. * Alias type for number that are integer
  65906. * @ignorenaming
  65907. */
  65908. export type int = number;
  65909. /** Alias type for number array or Float32Array */
  65910. export type FloatArray = number[] | Float32Array;
  65911. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  65912. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  65913. /**
  65914. * Alias for types that can be used by a Buffer or VertexBuffer.
  65915. */
  65916. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  65917. /**
  65918. * Alias type for primitive types
  65919. * @ignorenaming
  65920. */
  65921. type Primitive = undefined | null | boolean | string | number | Function;
  65922. /**
  65923. * Type modifier to make all the properties of an object Readonly
  65924. */
  65925. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  65926. /**
  65927. * Type modifier to make all the properties of an object Readonly recursively
  65928. */
  65929. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  65930. /** @hidden */
  65931. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  65932. }
  65933. /** @hidden */
  65934. /** @hidden */
  65935. type DeepImmutableObject<T> = {
  65936. readonly [K in keyof T]: DeepImmutable<T[K]>;
  65937. };
  65938. }
  65939. declare module BABYLON {
  65940. /**
  65941. * A class serves as a medium between the observable and its observers
  65942. */
  65943. export class EventState {
  65944. /**
  65945. * Create a new EventState
  65946. * @param mask defines the mask associated with this state
  65947. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65948. * @param target defines the original target of the state
  65949. * @param currentTarget defines the current target of the state
  65950. */
  65951. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  65952. /**
  65953. * Initialize the current event state
  65954. * @param mask defines the mask associated with this state
  65955. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65956. * @param target defines the original target of the state
  65957. * @param currentTarget defines the current target of the state
  65958. * @returns the current event state
  65959. */
  65960. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  65961. /**
  65962. * An Observer can set this property to true to prevent subsequent observers of being notified
  65963. */
  65964. skipNextObservers: boolean;
  65965. /**
  65966. * Get the mask value that were used to trigger the event corresponding to this EventState object
  65967. */
  65968. mask: number;
  65969. /**
  65970. * The object that originally notified the event
  65971. */
  65972. target?: any;
  65973. /**
  65974. * The current object in the bubbling phase
  65975. */
  65976. currentTarget?: any;
  65977. /**
  65978. * This will be populated with the return value of the last function that was executed.
  65979. * If it is the first function in the callback chain it will be the event data.
  65980. */
  65981. lastReturnValue?: any;
  65982. }
  65983. /**
  65984. * Represent an Observer registered to a given Observable object.
  65985. */
  65986. export class Observer<T> {
  65987. /**
  65988. * Defines the callback to call when the observer is notified
  65989. */
  65990. callback: (eventData: T, eventState: EventState) => void;
  65991. /**
  65992. * Defines the mask of the observer (used to filter notifications)
  65993. */
  65994. mask: number;
  65995. /**
  65996. * Defines the current scope used to restore the JS context
  65997. */
  65998. scope: any;
  65999. /** @hidden */
  66000. _willBeUnregistered: boolean;
  66001. /**
  66002. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66003. */
  66004. unregisterOnNextCall: boolean;
  66005. /**
  66006. * Creates a new observer
  66007. * @param callback defines the callback to call when the observer is notified
  66008. * @param mask defines the mask of the observer (used to filter notifications)
  66009. * @param scope defines the current scope used to restore the JS context
  66010. */
  66011. constructor(
  66012. /**
  66013. * Defines the callback to call when the observer is notified
  66014. */
  66015. callback: (eventData: T, eventState: EventState) => void,
  66016. /**
  66017. * Defines the mask of the observer (used to filter notifications)
  66018. */
  66019. mask: number,
  66020. /**
  66021. * Defines the current scope used to restore the JS context
  66022. */
  66023. scope?: any);
  66024. }
  66025. /**
  66026. * Represent a list of observers registered to multiple Observables object.
  66027. */
  66028. export class MultiObserver<T> {
  66029. private _observers;
  66030. private _observables;
  66031. /**
  66032. * Release associated resources
  66033. */
  66034. dispose(): void;
  66035. /**
  66036. * Raise a callback when one of the observable will notify
  66037. * @param observables defines a list of observables to watch
  66038. * @param callback defines the callback to call on notification
  66039. * @param mask defines the mask used to filter notifications
  66040. * @param scope defines the current scope used to restore the JS context
  66041. * @returns the new MultiObserver
  66042. */
  66043. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66044. }
  66045. /**
  66046. * The Observable class is a simple implementation of the Observable pattern.
  66047. *
  66048. * 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.
  66049. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66050. * 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).
  66051. * 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.
  66052. */
  66053. export class Observable<T> {
  66054. private _observers;
  66055. private _eventState;
  66056. private _onObserverAdded;
  66057. /**
  66058. * Gets the list of observers
  66059. */
  66060. readonly observers: Array<Observer<T>>;
  66061. /**
  66062. * Creates a new observable
  66063. * @param onObserverAdded defines a callback to call when a new observer is added
  66064. */
  66065. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66066. /**
  66067. * Create a new Observer with the specified callback
  66068. * @param callback the callback that will be executed for that Observer
  66069. * @param mask the mask used to filter observers
  66070. * @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.
  66071. * @param scope optional scope for the callback to be called from
  66072. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66073. * @returns the new observer created for the callback
  66074. */
  66075. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66076. /**
  66077. * Create a new Observer with the specified callback and unregisters after the next notification
  66078. * @param callback the callback that will be executed for that Observer
  66079. * @returns the new observer created for the callback
  66080. */
  66081. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66082. /**
  66083. * Remove an Observer from the Observable object
  66084. * @param observer the instance of the Observer to remove
  66085. * @returns false if it doesn't belong to this Observable
  66086. */
  66087. remove(observer: Nullable<Observer<T>>): boolean;
  66088. /**
  66089. * Remove a callback from the Observable object
  66090. * @param callback the callback to remove
  66091. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66092. * @returns false if it doesn't belong to this Observable
  66093. */
  66094. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66095. private _deferUnregister;
  66096. private _remove;
  66097. /**
  66098. * Moves the observable to the top of the observer list making it get called first when notified
  66099. * @param observer the observer to move
  66100. */
  66101. makeObserverTopPriority(observer: Observer<T>): void;
  66102. /**
  66103. * Moves the observable to the bottom of the observer list making it get called last when notified
  66104. * @param observer the observer to move
  66105. */
  66106. makeObserverBottomPriority(observer: Observer<T>): void;
  66107. /**
  66108. * Notify all Observers by calling their respective callback with the given data
  66109. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66110. * @param eventData defines the data to send to all observers
  66111. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66112. * @param target defines the original target of the state
  66113. * @param currentTarget defines the current target of the state
  66114. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66115. */
  66116. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66117. /**
  66118. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66119. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66120. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66121. * and it is crucial that all callbacks will be executed.
  66122. * The order of the callbacks is kept, callbacks are not executed parallel.
  66123. *
  66124. * @param eventData The data to be sent to each callback
  66125. * @param mask is used to filter observers defaults to -1
  66126. * @param target defines the callback target (see EventState)
  66127. * @param currentTarget defines he current object in the bubbling phase
  66128. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66129. */
  66130. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66131. /**
  66132. * Notify a specific observer
  66133. * @param observer defines the observer to notify
  66134. * @param eventData defines the data to be sent to each callback
  66135. * @param mask is used to filter observers defaults to -1
  66136. */
  66137. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66138. /**
  66139. * Gets a boolean indicating if the observable has at least one observer
  66140. * @returns true is the Observable has at least one Observer registered
  66141. */
  66142. hasObservers(): boolean;
  66143. /**
  66144. * Clear the list of observers
  66145. */
  66146. clear(): void;
  66147. /**
  66148. * Clone the current observable
  66149. * @returns a new observable
  66150. */
  66151. clone(): Observable<T>;
  66152. /**
  66153. * Does this observable handles observer registered with a given mask
  66154. * @param mask defines the mask to be tested
  66155. * @return whether or not one observer registered with the given mask is handeled
  66156. **/
  66157. hasSpecificMask(mask?: number): boolean;
  66158. }
  66159. }
  66160. declare module BABYLON {
  66161. /**
  66162. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66163. * Babylon.js
  66164. */
  66165. export class DomManagement {
  66166. /**
  66167. * Checks if the window object exists
  66168. * @returns true if the window object exists
  66169. */
  66170. static IsWindowObjectExist(): boolean;
  66171. /**
  66172. * Checks if the navigator object exists
  66173. * @returns true if the navigator object exists
  66174. */
  66175. static IsNavigatorAvailable(): boolean;
  66176. /**
  66177. * Extracts text content from a DOM element hierarchy
  66178. * @param element defines the root element
  66179. * @returns a string
  66180. */
  66181. static GetDOMTextContent(element: HTMLElement): string;
  66182. }
  66183. }
  66184. declare module BABYLON {
  66185. /**
  66186. * Logger used througouht the application to allow configuration of
  66187. * the log level required for the messages.
  66188. */
  66189. export class Logger {
  66190. /**
  66191. * No log
  66192. */
  66193. static readonly NoneLogLevel: number;
  66194. /**
  66195. * Only message logs
  66196. */
  66197. static readonly MessageLogLevel: number;
  66198. /**
  66199. * Only warning logs
  66200. */
  66201. static readonly WarningLogLevel: number;
  66202. /**
  66203. * Only error logs
  66204. */
  66205. static readonly ErrorLogLevel: number;
  66206. /**
  66207. * All logs
  66208. */
  66209. static readonly AllLogLevel: number;
  66210. private static _LogCache;
  66211. /**
  66212. * Gets a value indicating the number of loading errors
  66213. * @ignorenaming
  66214. */
  66215. static errorsCount: number;
  66216. /**
  66217. * Callback called when a new log is added
  66218. */
  66219. static OnNewCacheEntry: (entry: string) => void;
  66220. private static _AddLogEntry;
  66221. private static _FormatMessage;
  66222. private static _LogDisabled;
  66223. private static _LogEnabled;
  66224. private static _WarnDisabled;
  66225. private static _WarnEnabled;
  66226. private static _ErrorDisabled;
  66227. private static _ErrorEnabled;
  66228. /**
  66229. * Log a message to the console
  66230. */
  66231. static Log: (message: string) => void;
  66232. /**
  66233. * Write a warning message to the console
  66234. */
  66235. static Warn: (message: string) => void;
  66236. /**
  66237. * Write an error message to the console
  66238. */
  66239. static Error: (message: string) => void;
  66240. /**
  66241. * Gets current log cache (list of logs)
  66242. */
  66243. static readonly LogCache: string;
  66244. /**
  66245. * Clears the log cache
  66246. */
  66247. static ClearLogCache(): void;
  66248. /**
  66249. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66250. */
  66251. static LogLevels: number;
  66252. }
  66253. }
  66254. declare module BABYLON {
  66255. /** @hidden */
  66256. export class _TypeStore {
  66257. /** @hidden */
  66258. static RegisteredTypes: {
  66259. [key: string]: Object;
  66260. };
  66261. /** @hidden */
  66262. static GetClass(fqdn: string): any;
  66263. }
  66264. }
  66265. declare module BABYLON {
  66266. /**
  66267. * Class containing a set of static utilities functions for deep copy.
  66268. */
  66269. export class DeepCopier {
  66270. /**
  66271. * Tries to copy an object by duplicating every property
  66272. * @param source defines the source object
  66273. * @param destination defines the target object
  66274. * @param doNotCopyList defines a list of properties to avoid
  66275. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  66276. */
  66277. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  66278. }
  66279. }
  66280. declare module BABYLON {
  66281. /**
  66282. * Class containing a set of static utilities functions for precision date
  66283. */
  66284. export class PrecisionDate {
  66285. /**
  66286. * Gets either window.performance.now() if supported or Date.now() else
  66287. */
  66288. static readonly Now: number;
  66289. }
  66290. }
  66291. declare module BABYLON {
  66292. /** @hidden */
  66293. export class _DevTools {
  66294. static WarnImport(name: string): string;
  66295. }
  66296. }
  66297. declare module BABYLON {
  66298. /**
  66299. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66300. */
  66301. export class WebRequest {
  66302. private _xhr;
  66303. /**
  66304. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  66305. * i.e. when loading files, where the server/service expects an Authorization header
  66306. */
  66307. static CustomRequestHeaders: {
  66308. [key: string]: string;
  66309. };
  66310. /**
  66311. * Add callback functions in this array to update all the requests before they get sent to the network
  66312. */
  66313. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  66314. private _injectCustomRequestHeaders;
  66315. /**
  66316. * Gets or sets a function to be called when loading progress changes
  66317. */
  66318. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  66319. /**
  66320. * Returns client's state
  66321. */
  66322. readonly readyState: number;
  66323. /**
  66324. * Returns client's status
  66325. */
  66326. readonly status: number;
  66327. /**
  66328. * Returns client's status as a text
  66329. */
  66330. readonly statusText: string;
  66331. /**
  66332. * Returns client's response
  66333. */
  66334. readonly response: any;
  66335. /**
  66336. * Returns client's response url
  66337. */
  66338. readonly responseURL: string;
  66339. /**
  66340. * Returns client's response as text
  66341. */
  66342. readonly responseText: string;
  66343. /**
  66344. * Gets or sets the expected response type
  66345. */
  66346. responseType: XMLHttpRequestResponseType;
  66347. /** @hidden */
  66348. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  66349. /** @hidden */
  66350. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  66351. /**
  66352. * Cancels any network activity
  66353. */
  66354. abort(): void;
  66355. /**
  66356. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  66357. * @param body defines an optional request body
  66358. */
  66359. send(body?: Document | BodyInit | null): void;
  66360. /**
  66361. * Sets the request method, request URL
  66362. * @param method defines the method to use (GET, POST, etc..)
  66363. * @param url defines the url to connect with
  66364. */
  66365. open(method: string, url: string): void;
  66366. }
  66367. }
  66368. declare module BABYLON {
  66369. /**
  66370. * File request interface
  66371. */
  66372. export interface IFileRequest {
  66373. /**
  66374. * Raised when the request is complete (success or error).
  66375. */
  66376. onCompleteObservable: Observable<IFileRequest>;
  66377. /**
  66378. * Aborts the request for a file.
  66379. */
  66380. abort: () => void;
  66381. }
  66382. }
  66383. declare module BABYLON {
  66384. /**
  66385. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  66386. */
  66387. export class PerformanceMonitor {
  66388. private _enabled;
  66389. private _rollingFrameTime;
  66390. private _lastFrameTimeMs;
  66391. /**
  66392. * constructor
  66393. * @param frameSampleSize The number of samples required to saturate the sliding window
  66394. */
  66395. constructor(frameSampleSize?: number);
  66396. /**
  66397. * Samples current frame
  66398. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  66399. */
  66400. sampleFrame(timeMs?: number): void;
  66401. /**
  66402. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66403. */
  66404. readonly averageFrameTime: number;
  66405. /**
  66406. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66407. */
  66408. readonly averageFrameTimeVariance: number;
  66409. /**
  66410. * Returns the frame time of the most recent frame
  66411. */
  66412. readonly instantaneousFrameTime: number;
  66413. /**
  66414. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  66415. */
  66416. readonly averageFPS: number;
  66417. /**
  66418. * Returns the average framerate in frames per second using the most recent frame time
  66419. */
  66420. readonly instantaneousFPS: number;
  66421. /**
  66422. * Returns true if enough samples have been taken to completely fill the sliding window
  66423. */
  66424. readonly isSaturated: boolean;
  66425. /**
  66426. * Enables contributions to the sliding window sample set
  66427. */
  66428. enable(): void;
  66429. /**
  66430. * Disables contributions to the sliding window sample set
  66431. * Samples will not be interpolated over the disabled period
  66432. */
  66433. disable(): void;
  66434. /**
  66435. * Returns true if sampling is enabled
  66436. */
  66437. readonly isEnabled: boolean;
  66438. /**
  66439. * Resets performance monitor
  66440. */
  66441. reset(): void;
  66442. }
  66443. /**
  66444. * RollingAverage
  66445. *
  66446. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  66447. */
  66448. export class RollingAverage {
  66449. /**
  66450. * Current average
  66451. */
  66452. average: number;
  66453. /**
  66454. * Current variance
  66455. */
  66456. variance: number;
  66457. protected _samples: Array<number>;
  66458. protected _sampleCount: number;
  66459. protected _pos: number;
  66460. protected _m2: number;
  66461. /**
  66462. * constructor
  66463. * @param length The number of samples required to saturate the sliding window
  66464. */
  66465. constructor(length: number);
  66466. /**
  66467. * Adds a sample to the sample set
  66468. * @param v The sample value
  66469. */
  66470. add(v: number): void;
  66471. /**
  66472. * Returns previously added values or null if outside of history or outside the sliding window domain
  66473. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  66474. * @return Value previously recorded with add() or null if outside of range
  66475. */
  66476. history(i: number): number;
  66477. /**
  66478. * Returns true if enough samples have been taken to completely fill the sliding window
  66479. * @return true if sample-set saturated
  66480. */
  66481. isSaturated(): boolean;
  66482. /**
  66483. * Resets the rolling average (equivalent to 0 samples taken so far)
  66484. */
  66485. reset(): void;
  66486. /**
  66487. * Wraps a value around the sample range boundaries
  66488. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  66489. * @return Wrapped position in sample range
  66490. */
  66491. protected _wrapPosition(i: number): number;
  66492. }
  66493. }
  66494. declare module BABYLON {
  66495. /**
  66496. * This class implement a typical dictionary using a string as key and the generic type T as value.
  66497. * The underlying implementation relies on an associative array to ensure the best performances.
  66498. * The value can be anything including 'null' but except 'undefined'
  66499. */
  66500. export class StringDictionary<T> {
  66501. /**
  66502. * This will clear this dictionary and copy the content from the 'source' one.
  66503. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  66504. * @param source the dictionary to take the content from and copy to this dictionary
  66505. */
  66506. copyFrom(source: StringDictionary<T>): void;
  66507. /**
  66508. * Get a value based from its key
  66509. * @param key the given key to get the matching value from
  66510. * @return the value if found, otherwise undefined is returned
  66511. */
  66512. get(key: string): T | undefined;
  66513. /**
  66514. * Get a value from its key or add it if it doesn't exist.
  66515. * This method will ensure you that a given key/data will be present in the dictionary.
  66516. * @param key the given key to get the matching value from
  66517. * @param factory the factory that will create the value if the key is not present in the dictionary.
  66518. * The factory will only be invoked if there's no data for the given key.
  66519. * @return the value corresponding to the key.
  66520. */
  66521. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  66522. /**
  66523. * Get a value from its key if present in the dictionary otherwise add it
  66524. * @param key the key to get the value from
  66525. * @param val if there's no such key/value pair in the dictionary add it with this value
  66526. * @return the value corresponding to the key
  66527. */
  66528. getOrAdd(key: string, val: T): T;
  66529. /**
  66530. * Check if there's a given key in the dictionary
  66531. * @param key the key to check for
  66532. * @return true if the key is present, false otherwise
  66533. */
  66534. contains(key: string): boolean;
  66535. /**
  66536. * Add a new key and its corresponding value
  66537. * @param key the key to add
  66538. * @param value the value corresponding to the key
  66539. * @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
  66540. */
  66541. add(key: string, value: T): boolean;
  66542. /**
  66543. * Update a specific value associated to a key
  66544. * @param key defines the key to use
  66545. * @param value defines the value to store
  66546. * @returns true if the value was updated (or false if the key was not found)
  66547. */
  66548. set(key: string, value: T): boolean;
  66549. /**
  66550. * Get the element of the given key and remove it from the dictionary
  66551. * @param key defines the key to search
  66552. * @returns the value associated with the key or null if not found
  66553. */
  66554. getAndRemove(key: string): Nullable<T>;
  66555. /**
  66556. * Remove a key/value from the dictionary.
  66557. * @param key the key to remove
  66558. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  66559. */
  66560. remove(key: string): boolean;
  66561. /**
  66562. * Clear the whole content of the dictionary
  66563. */
  66564. clear(): void;
  66565. /**
  66566. * Gets the current count
  66567. */
  66568. readonly count: number;
  66569. /**
  66570. * Execute a callback on each key/val of the dictionary.
  66571. * Note that you can remove any element in this dictionary in the callback implementation
  66572. * @param callback the callback to execute on a given key/value pair
  66573. */
  66574. forEach(callback: (key: string, val: T) => void): void;
  66575. /**
  66576. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  66577. * If the callback returns null or undefined the method will iterate to the next key/value pair
  66578. * Note that you can remove any element in this dictionary in the callback implementation
  66579. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  66580. * @returns the first item
  66581. */
  66582. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  66583. private _count;
  66584. private _data;
  66585. }
  66586. }
  66587. declare module BABYLON {
  66588. /**
  66589. * Class used to store gfx data (like WebGLBuffer)
  66590. */
  66591. export class DataBuffer {
  66592. /**
  66593. * Gets or sets the number of objects referencing this buffer
  66594. */
  66595. references: number;
  66596. /** Gets or sets the size of the underlying buffer */
  66597. capacity: number;
  66598. /**
  66599. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  66600. */
  66601. is32Bits: boolean;
  66602. /**
  66603. * Gets the underlying buffer
  66604. */
  66605. readonly underlyingResource: any;
  66606. }
  66607. }
  66608. declare module BABYLON {
  66609. /**
  66610. * Class used to store data that will be store in GPU memory
  66611. */
  66612. export class Buffer {
  66613. private _engine;
  66614. private _buffer;
  66615. /** @hidden */
  66616. _data: Nullable<DataArray>;
  66617. private _updatable;
  66618. private _instanced;
  66619. /**
  66620. * Gets the byte stride.
  66621. */
  66622. readonly byteStride: number;
  66623. /**
  66624. * Constructor
  66625. * @param engine the engine
  66626. * @param data the data to use for this buffer
  66627. * @param updatable whether the data is updatable
  66628. * @param stride the stride (optional)
  66629. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66630. * @param instanced whether the buffer is instanced (optional)
  66631. * @param useBytes set to true if the stride in in bytes (optional)
  66632. */
  66633. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  66634. /**
  66635. * Create a new VertexBuffer based on the current buffer
  66636. * @param kind defines the vertex buffer kind (position, normal, etc.)
  66637. * @param offset defines offset in the buffer (0 by default)
  66638. * @param size defines the size in floats of attributes (position is 3 for instance)
  66639. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  66640. * @param instanced defines if the vertex buffer contains indexed data
  66641. * @param useBytes defines if the offset and stride are in bytes
  66642. * @returns the new vertex buffer
  66643. */
  66644. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  66645. /**
  66646. * Gets a boolean indicating if the Buffer is updatable?
  66647. * @returns true if the buffer is updatable
  66648. */
  66649. isUpdatable(): boolean;
  66650. /**
  66651. * Gets current buffer's data
  66652. * @returns a DataArray or null
  66653. */
  66654. getData(): Nullable<DataArray>;
  66655. /**
  66656. * Gets underlying native buffer
  66657. * @returns underlying native buffer
  66658. */
  66659. getBuffer(): Nullable<DataBuffer>;
  66660. /**
  66661. * Gets the stride in float32 units (i.e. byte stride / 4).
  66662. * May not be an integer if the byte stride is not divisible by 4.
  66663. * DEPRECATED. Use byteStride instead.
  66664. * @returns the stride in float32 units
  66665. */
  66666. getStrideSize(): number;
  66667. /**
  66668. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66669. * @param data defines the data to store
  66670. */
  66671. create(data?: Nullable<DataArray>): void;
  66672. /** @hidden */
  66673. _rebuild(): void;
  66674. /**
  66675. * Update current buffer data
  66676. * @param data defines the data to store
  66677. */
  66678. update(data: DataArray): void;
  66679. /**
  66680. * Updates the data directly.
  66681. * @param data the new data
  66682. * @param offset the new offset
  66683. * @param vertexCount the vertex count (optional)
  66684. * @param useBytes set to true if the offset is in bytes
  66685. */
  66686. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  66687. /**
  66688. * Release all resources
  66689. */
  66690. dispose(): void;
  66691. }
  66692. /**
  66693. * Specialized buffer used to store vertex data
  66694. */
  66695. export class VertexBuffer {
  66696. /** @hidden */
  66697. _buffer: Buffer;
  66698. private _kind;
  66699. private _size;
  66700. private _ownsBuffer;
  66701. private _instanced;
  66702. private _instanceDivisor;
  66703. /**
  66704. * The byte type.
  66705. */
  66706. static readonly BYTE: number;
  66707. /**
  66708. * The unsigned byte type.
  66709. */
  66710. static readonly UNSIGNED_BYTE: number;
  66711. /**
  66712. * The short type.
  66713. */
  66714. static readonly SHORT: number;
  66715. /**
  66716. * The unsigned short type.
  66717. */
  66718. static readonly UNSIGNED_SHORT: number;
  66719. /**
  66720. * The integer type.
  66721. */
  66722. static readonly INT: number;
  66723. /**
  66724. * The unsigned integer type.
  66725. */
  66726. static readonly UNSIGNED_INT: number;
  66727. /**
  66728. * The float type.
  66729. */
  66730. static readonly FLOAT: number;
  66731. /**
  66732. * Gets or sets the instance divisor when in instanced mode
  66733. */
  66734. instanceDivisor: number;
  66735. /**
  66736. * Gets the byte stride.
  66737. */
  66738. readonly byteStride: number;
  66739. /**
  66740. * Gets the byte offset.
  66741. */
  66742. readonly byteOffset: number;
  66743. /**
  66744. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  66745. */
  66746. readonly normalized: boolean;
  66747. /**
  66748. * Gets the data type of each component in the array.
  66749. */
  66750. readonly type: number;
  66751. /**
  66752. * Constructor
  66753. * @param engine the engine
  66754. * @param data the data to use for this vertex buffer
  66755. * @param kind the vertex buffer kind
  66756. * @param updatable whether the data is updatable
  66757. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66758. * @param stride the stride (optional)
  66759. * @param instanced whether the buffer is instanced (optional)
  66760. * @param offset the offset of the data (optional)
  66761. * @param size the number of components (optional)
  66762. * @param type the type of the component (optional)
  66763. * @param normalized whether the data contains normalized data (optional)
  66764. * @param useBytes set to true if stride and offset are in bytes (optional)
  66765. */
  66766. 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);
  66767. /** @hidden */
  66768. _rebuild(): void;
  66769. /**
  66770. * Returns the kind of the VertexBuffer (string)
  66771. * @returns a string
  66772. */
  66773. getKind(): string;
  66774. /**
  66775. * Gets a boolean indicating if the VertexBuffer is updatable?
  66776. * @returns true if the buffer is updatable
  66777. */
  66778. isUpdatable(): boolean;
  66779. /**
  66780. * Gets current buffer's data
  66781. * @returns a DataArray or null
  66782. */
  66783. getData(): Nullable<DataArray>;
  66784. /**
  66785. * Gets underlying native buffer
  66786. * @returns underlying native buffer
  66787. */
  66788. getBuffer(): Nullable<DataBuffer>;
  66789. /**
  66790. * Gets the stride in float32 units (i.e. byte stride / 4).
  66791. * May not be an integer if the byte stride is not divisible by 4.
  66792. * DEPRECATED. Use byteStride instead.
  66793. * @returns the stride in float32 units
  66794. */
  66795. getStrideSize(): number;
  66796. /**
  66797. * Returns the offset as a multiple of the type byte length.
  66798. * DEPRECATED. Use byteOffset instead.
  66799. * @returns the offset in bytes
  66800. */
  66801. getOffset(): number;
  66802. /**
  66803. * Returns the number of components per vertex attribute (integer)
  66804. * @returns the size in float
  66805. */
  66806. getSize(): number;
  66807. /**
  66808. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  66809. * @returns true if this buffer is instanced
  66810. */
  66811. getIsInstanced(): boolean;
  66812. /**
  66813. * Returns the instancing divisor, zero for non-instanced (integer).
  66814. * @returns a number
  66815. */
  66816. getInstanceDivisor(): number;
  66817. /**
  66818. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66819. * @param data defines the data to store
  66820. */
  66821. create(data?: DataArray): void;
  66822. /**
  66823. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  66824. * This function will create a new buffer if the current one is not updatable
  66825. * @param data defines the data to store
  66826. */
  66827. update(data: DataArray): void;
  66828. /**
  66829. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  66830. * Returns the directly updated WebGLBuffer.
  66831. * @param data the new data
  66832. * @param offset the new offset
  66833. * @param useBytes set to true if the offset is in bytes
  66834. */
  66835. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  66836. /**
  66837. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  66838. */
  66839. dispose(): void;
  66840. /**
  66841. * Enumerates each value of this vertex buffer as numbers.
  66842. * @param count the number of values to enumerate
  66843. * @param callback the callback function called for each value
  66844. */
  66845. forEach(count: number, callback: (value: number, index: number) => void): void;
  66846. /**
  66847. * Positions
  66848. */
  66849. static readonly PositionKind: string;
  66850. /**
  66851. * Normals
  66852. */
  66853. static readonly NormalKind: string;
  66854. /**
  66855. * Tangents
  66856. */
  66857. static readonly TangentKind: string;
  66858. /**
  66859. * Texture coordinates
  66860. */
  66861. static readonly UVKind: string;
  66862. /**
  66863. * Texture coordinates 2
  66864. */
  66865. static readonly UV2Kind: string;
  66866. /**
  66867. * Texture coordinates 3
  66868. */
  66869. static readonly UV3Kind: string;
  66870. /**
  66871. * Texture coordinates 4
  66872. */
  66873. static readonly UV4Kind: string;
  66874. /**
  66875. * Texture coordinates 5
  66876. */
  66877. static readonly UV5Kind: string;
  66878. /**
  66879. * Texture coordinates 6
  66880. */
  66881. static readonly UV6Kind: string;
  66882. /**
  66883. * Colors
  66884. */
  66885. static readonly ColorKind: string;
  66886. /**
  66887. * Matrix indices (for bones)
  66888. */
  66889. static readonly MatricesIndicesKind: string;
  66890. /**
  66891. * Matrix weights (for bones)
  66892. */
  66893. static readonly MatricesWeightsKind: string;
  66894. /**
  66895. * Additional matrix indices (for bones)
  66896. */
  66897. static readonly MatricesIndicesExtraKind: string;
  66898. /**
  66899. * Additional matrix weights (for bones)
  66900. */
  66901. static readonly MatricesWeightsExtraKind: string;
  66902. /**
  66903. * Deduces the stride given a kind.
  66904. * @param kind The kind string to deduce
  66905. * @returns The deduced stride
  66906. */
  66907. static DeduceStride(kind: string): number;
  66908. /**
  66909. * Gets the byte length of the given type.
  66910. * @param type the type
  66911. * @returns the number of bytes
  66912. */
  66913. static GetTypeByteLength(type: number): number;
  66914. /**
  66915. * Enumerates each value of the given parameters as numbers.
  66916. * @param data the data to enumerate
  66917. * @param byteOffset the byte offset of the data
  66918. * @param byteStride the byte stride of the data
  66919. * @param componentCount the number of components per element
  66920. * @param componentType the type of the component
  66921. * @param count the number of values to enumerate
  66922. * @param normalized whether the data is normalized
  66923. * @param callback the callback function called for each value
  66924. */
  66925. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  66926. private static _GetFloatValue;
  66927. }
  66928. }
  66929. declare module BABYLON {
  66930. /**
  66931. * Scalar computation library
  66932. */
  66933. export class Scalar {
  66934. /**
  66935. * Two pi constants convenient for computation.
  66936. */
  66937. static TwoPi: number;
  66938. /**
  66939. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66940. * @param a number
  66941. * @param b number
  66942. * @param epsilon (default = 1.401298E-45)
  66943. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66944. */
  66945. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66946. /**
  66947. * Returns a string : the upper case translation of the number i to hexadecimal.
  66948. * @param i number
  66949. * @returns the upper case translation of the number i to hexadecimal.
  66950. */
  66951. static ToHex(i: number): string;
  66952. /**
  66953. * Returns -1 if value is negative and +1 is value is positive.
  66954. * @param value the value
  66955. * @returns the value itself if it's equal to zero.
  66956. */
  66957. static Sign(value: number): number;
  66958. /**
  66959. * Returns the value itself if it's between min and max.
  66960. * Returns min if the value is lower than min.
  66961. * Returns max if the value is greater than max.
  66962. * @param value the value to clmap
  66963. * @param min the min value to clamp to (default: 0)
  66964. * @param max the max value to clamp to (default: 1)
  66965. * @returns the clamped value
  66966. */
  66967. static Clamp(value: number, min?: number, max?: number): number;
  66968. /**
  66969. * the log2 of value.
  66970. * @param value the value to compute log2 of
  66971. * @returns the log2 of value.
  66972. */
  66973. static Log2(value: number): number;
  66974. /**
  66975. * Loops the value, so that it is never larger than length and never smaller than 0.
  66976. *
  66977. * This is similar to the modulo operator but it works with floating point numbers.
  66978. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66979. * With t = 5 and length = 2.5, the result would be 0.0.
  66980. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66981. * @param value the value
  66982. * @param length the length
  66983. * @returns the looped value
  66984. */
  66985. static Repeat(value: number, length: number): number;
  66986. /**
  66987. * Normalize the value between 0.0 and 1.0 using min and max values
  66988. * @param value value to normalize
  66989. * @param min max to normalize between
  66990. * @param max min to normalize between
  66991. * @returns the normalized value
  66992. */
  66993. static Normalize(value: number, min: number, max: number): number;
  66994. /**
  66995. * Denormalize the value from 0.0 and 1.0 using min and max values
  66996. * @param normalized value to denormalize
  66997. * @param min max to denormalize between
  66998. * @param max min to denormalize between
  66999. * @returns the denormalized value
  67000. */
  67001. static Denormalize(normalized: number, min: number, max: number): number;
  67002. /**
  67003. * Calculates the shortest difference between two given angles given in degrees.
  67004. * @param current current angle in degrees
  67005. * @param target target angle in degrees
  67006. * @returns the delta
  67007. */
  67008. static DeltaAngle(current: number, target: number): number;
  67009. /**
  67010. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  67011. * @param tx value
  67012. * @param length length
  67013. * @returns The returned value will move back and forth between 0 and length
  67014. */
  67015. static PingPong(tx: number, length: number): number;
  67016. /**
  67017. * Interpolates between min and max with smoothing at the limits.
  67018. *
  67019. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  67020. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  67021. * @param from from
  67022. * @param to to
  67023. * @param tx value
  67024. * @returns the smooth stepped value
  67025. */
  67026. static SmoothStep(from: number, to: number, tx: number): number;
  67027. /**
  67028. * Moves a value current towards target.
  67029. *
  67030. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  67031. * Negative values of maxDelta pushes the value away from target.
  67032. * @param current current value
  67033. * @param target target value
  67034. * @param maxDelta max distance to move
  67035. * @returns resulting value
  67036. */
  67037. static MoveTowards(current: number, target: number, maxDelta: number): number;
  67038. /**
  67039. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67040. *
  67041. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  67042. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  67043. * @param current current value
  67044. * @param target target value
  67045. * @param maxDelta max distance to move
  67046. * @returns resulting angle
  67047. */
  67048. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  67049. /**
  67050. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67051. * @param start start value
  67052. * @param end target value
  67053. * @param amount amount to lerp between
  67054. * @returns the lerped value
  67055. */
  67056. static Lerp(start: number, end: number, amount: number): number;
  67057. /**
  67058. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67059. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67060. * @param start start value
  67061. * @param end target value
  67062. * @param amount amount to lerp between
  67063. * @returns the lerped value
  67064. */
  67065. static LerpAngle(start: number, end: number, amount: number): number;
  67066. /**
  67067. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67068. * @param a start value
  67069. * @param b target value
  67070. * @param value value between a and b
  67071. * @returns the inverseLerp value
  67072. */
  67073. static InverseLerp(a: number, b: number, value: number): number;
  67074. /**
  67075. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67076. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67077. * @param value1 spline value
  67078. * @param tangent1 spline value
  67079. * @param value2 spline value
  67080. * @param tangent2 spline value
  67081. * @param amount input value
  67082. * @returns hermite result
  67083. */
  67084. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  67085. /**
  67086. * Returns a random float number between and min and max values
  67087. * @param min min value of random
  67088. * @param max max value of random
  67089. * @returns random value
  67090. */
  67091. static RandomRange(min: number, max: number): number;
  67092. /**
  67093. * This function returns percentage of a number in a given range.
  67094. *
  67095. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67096. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67097. * @param number to convert to percentage
  67098. * @param min min range
  67099. * @param max max range
  67100. * @returns the percentage
  67101. */
  67102. static RangeToPercent(number: number, min: number, max: number): number;
  67103. /**
  67104. * This function returns number that corresponds to the percentage in a given range.
  67105. *
  67106. * PercentToRange(0.34,0,100) will return 34.
  67107. * @param percent to convert to number
  67108. * @param min min range
  67109. * @param max max range
  67110. * @returns the number
  67111. */
  67112. static PercentToRange(percent: number, min: number, max: number): number;
  67113. /**
  67114. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67115. * @param angle The angle to normalize in radian.
  67116. * @return The converted angle.
  67117. */
  67118. static NormalizeRadians(angle: number): number;
  67119. }
  67120. }
  67121. declare module BABYLON {
  67122. /**
  67123. * Constant used to convert a value to gamma space
  67124. * @ignorenaming
  67125. */
  67126. export const ToGammaSpace: number;
  67127. /**
  67128. * Constant used to convert a value to linear space
  67129. * @ignorenaming
  67130. */
  67131. export const ToLinearSpace = 2.2;
  67132. /**
  67133. * Constant used to define the minimal number value in Babylon.js
  67134. * @ignorenaming
  67135. */
  67136. let Epsilon: number;
  67137. }
  67138. declare module BABYLON {
  67139. /**
  67140. * Class used to represent a viewport on screen
  67141. */
  67142. export class Viewport {
  67143. /** viewport left coordinate */
  67144. x: number;
  67145. /** viewport top coordinate */
  67146. y: number;
  67147. /**viewport width */
  67148. width: number;
  67149. /** viewport height */
  67150. height: number;
  67151. /**
  67152. * Creates a Viewport object located at (x, y) and sized (width, height)
  67153. * @param x defines viewport left coordinate
  67154. * @param y defines viewport top coordinate
  67155. * @param width defines the viewport width
  67156. * @param height defines the viewport height
  67157. */
  67158. constructor(
  67159. /** viewport left coordinate */
  67160. x: number,
  67161. /** viewport top coordinate */
  67162. y: number,
  67163. /**viewport width */
  67164. width: number,
  67165. /** viewport height */
  67166. height: number);
  67167. /**
  67168. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67169. * @param renderWidth defines the rendering width
  67170. * @param renderHeight defines the rendering height
  67171. * @returns a new Viewport
  67172. */
  67173. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67174. /**
  67175. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67176. * @param renderWidth defines the rendering width
  67177. * @param renderHeight defines the rendering height
  67178. * @param ref defines the target viewport
  67179. * @returns the current viewport
  67180. */
  67181. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67182. /**
  67183. * Returns a new Viewport copied from the current one
  67184. * @returns a new Viewport
  67185. */
  67186. clone(): Viewport;
  67187. }
  67188. }
  67189. declare module BABYLON {
  67190. /**
  67191. * Class containing a set of static utilities functions for arrays.
  67192. */
  67193. export class ArrayTools {
  67194. /**
  67195. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67196. * @param size the number of element to construct and put in the array
  67197. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67198. * @returns a new array filled with new objects
  67199. */
  67200. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67201. }
  67202. }
  67203. declare module BABYLON {
  67204. /**
  67205. * @hidden
  67206. */
  67207. export interface IColor4Like {
  67208. r: float;
  67209. g: float;
  67210. b: float;
  67211. a: float;
  67212. }
  67213. /**
  67214. * @hidden
  67215. */
  67216. export interface IColor3Like {
  67217. r: float;
  67218. g: float;
  67219. b: float;
  67220. }
  67221. /**
  67222. * @hidden
  67223. */
  67224. export interface IVector4Like {
  67225. x: float;
  67226. y: float;
  67227. z: float;
  67228. w: float;
  67229. }
  67230. /**
  67231. * @hidden
  67232. */
  67233. export interface IVector3Like {
  67234. x: float;
  67235. y: float;
  67236. z: float;
  67237. }
  67238. /**
  67239. * @hidden
  67240. */
  67241. export interface IVector2Like {
  67242. x: float;
  67243. y: float;
  67244. }
  67245. /**
  67246. * @hidden
  67247. */
  67248. export interface IMatrixLike {
  67249. toArray(): DeepImmutable<Float32Array>;
  67250. updateFlag: int;
  67251. }
  67252. /**
  67253. * @hidden
  67254. */
  67255. export interface IViewportLike {
  67256. x: float;
  67257. y: float;
  67258. width: float;
  67259. height: float;
  67260. }
  67261. /**
  67262. * @hidden
  67263. */
  67264. export interface IPlaneLike {
  67265. normal: IVector3Like;
  67266. d: float;
  67267. normalize(): void;
  67268. }
  67269. }
  67270. declare module BABYLON {
  67271. /**
  67272. * Class representing a vector containing 2 coordinates
  67273. */
  67274. export class Vector2 {
  67275. /** defines the first coordinate */
  67276. x: number;
  67277. /** defines the second coordinate */
  67278. y: number;
  67279. /**
  67280. * Creates a new Vector2 from the given x and y coordinates
  67281. * @param x defines the first coordinate
  67282. * @param y defines the second coordinate
  67283. */
  67284. constructor(
  67285. /** defines the first coordinate */
  67286. x?: number,
  67287. /** defines the second coordinate */
  67288. y?: number);
  67289. /**
  67290. * Gets a string with the Vector2 coordinates
  67291. * @returns a string with the Vector2 coordinates
  67292. */
  67293. toString(): string;
  67294. /**
  67295. * Gets class name
  67296. * @returns the string "Vector2"
  67297. */
  67298. getClassName(): string;
  67299. /**
  67300. * Gets current vector hash code
  67301. * @returns the Vector2 hash code as a number
  67302. */
  67303. getHashCode(): number;
  67304. /**
  67305. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67306. * @param array defines the source array
  67307. * @param index defines the offset in source array
  67308. * @returns the current Vector2
  67309. */
  67310. toArray(array: FloatArray, index?: number): Vector2;
  67311. /**
  67312. * Copy the current vector to an array
  67313. * @returns a new array with 2 elements: the Vector2 coordinates.
  67314. */
  67315. asArray(): number[];
  67316. /**
  67317. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67318. * @param source defines the source Vector2
  67319. * @returns the current updated Vector2
  67320. */
  67321. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67322. /**
  67323. * Sets the Vector2 coordinates with the given floats
  67324. * @param x defines the first coordinate
  67325. * @param y defines the second coordinate
  67326. * @returns the current updated Vector2
  67327. */
  67328. copyFromFloats(x: number, y: number): Vector2;
  67329. /**
  67330. * Sets the Vector2 coordinates with the given floats
  67331. * @param x defines the first coordinate
  67332. * @param y defines the second coordinate
  67333. * @returns the current updated Vector2
  67334. */
  67335. set(x: number, y: number): Vector2;
  67336. /**
  67337. * Add another vector with the current one
  67338. * @param otherVector defines the other vector
  67339. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67340. */
  67341. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67342. /**
  67343. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67344. * @param otherVector defines the other vector
  67345. * @param result defines the target vector
  67346. * @returns the unmodified current Vector2
  67347. */
  67348. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67349. /**
  67350. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67351. * @param otherVector defines the other vector
  67352. * @returns the current updated Vector2
  67353. */
  67354. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67355. /**
  67356. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67357. * @param otherVector defines the other vector
  67358. * @returns a new Vector2
  67359. */
  67360. addVector3(otherVector: Vector3): Vector2;
  67361. /**
  67362. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67363. * @param otherVector defines the other vector
  67364. * @returns a new Vector2
  67365. */
  67366. subtract(otherVector: Vector2): Vector2;
  67367. /**
  67368. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67369. * @param otherVector defines the other vector
  67370. * @param result defines the target vector
  67371. * @returns the unmodified current Vector2
  67372. */
  67373. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67374. /**
  67375. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67376. * @param otherVector defines the other vector
  67377. * @returns the current updated Vector2
  67378. */
  67379. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67380. /**
  67381. * Multiplies in place the current Vector2 coordinates by the given ones
  67382. * @param otherVector defines the other vector
  67383. * @returns the current updated Vector2
  67384. */
  67385. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67386. /**
  67387. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67388. * @param otherVector defines the other vector
  67389. * @returns a new Vector2
  67390. */
  67391. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67392. /**
  67393. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67394. * @param otherVector defines the other vector
  67395. * @param result defines the target vector
  67396. * @returns the unmodified current Vector2
  67397. */
  67398. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67399. /**
  67400. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67401. * @param x defines the first coordinate
  67402. * @param y defines the second coordinate
  67403. * @returns a new Vector2
  67404. */
  67405. multiplyByFloats(x: number, y: number): Vector2;
  67406. /**
  67407. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67408. * @param otherVector defines the other vector
  67409. * @returns a new Vector2
  67410. */
  67411. divide(otherVector: Vector2): Vector2;
  67412. /**
  67413. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67414. * @param otherVector defines the other vector
  67415. * @param result defines the target vector
  67416. * @returns the unmodified current Vector2
  67417. */
  67418. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67419. /**
  67420. * Divides the current Vector2 coordinates by the given ones
  67421. * @param otherVector defines the other vector
  67422. * @returns the current updated Vector2
  67423. */
  67424. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67425. /**
  67426. * Gets a new Vector2 with current Vector2 negated coordinates
  67427. * @returns a new Vector2
  67428. */
  67429. negate(): Vector2;
  67430. /**
  67431. * Multiply the Vector2 coordinates by scale
  67432. * @param scale defines the scaling factor
  67433. * @returns the current updated Vector2
  67434. */
  67435. scaleInPlace(scale: number): Vector2;
  67436. /**
  67437. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67438. * @param scale defines the scaling factor
  67439. * @returns a new Vector2
  67440. */
  67441. scale(scale: number): Vector2;
  67442. /**
  67443. * Scale the current Vector2 values by a factor to a given Vector2
  67444. * @param scale defines the scale factor
  67445. * @param result defines the Vector2 object where to store the result
  67446. * @returns the unmodified current Vector2
  67447. */
  67448. scaleToRef(scale: number, result: Vector2): Vector2;
  67449. /**
  67450. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67451. * @param scale defines the scale factor
  67452. * @param result defines the Vector2 object where to store the result
  67453. * @returns the unmodified current Vector2
  67454. */
  67455. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67456. /**
  67457. * Gets a boolean if two vectors are equals
  67458. * @param otherVector defines the other vector
  67459. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67460. */
  67461. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67462. /**
  67463. * Gets a boolean if two vectors are equals (using an epsilon value)
  67464. * @param otherVector defines the other vector
  67465. * @param epsilon defines the minimal distance to consider equality
  67466. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67467. */
  67468. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67469. /**
  67470. * Gets a new Vector2 from current Vector2 floored values
  67471. * @returns a new Vector2
  67472. */
  67473. floor(): Vector2;
  67474. /**
  67475. * Gets a new Vector2 from current Vector2 floored values
  67476. * @returns a new Vector2
  67477. */
  67478. fract(): Vector2;
  67479. /**
  67480. * Gets the length of the vector
  67481. * @returns the vector length (float)
  67482. */
  67483. length(): number;
  67484. /**
  67485. * Gets the vector squared length
  67486. * @returns the vector squared length (float)
  67487. */
  67488. lengthSquared(): number;
  67489. /**
  67490. * Normalize the vector
  67491. * @returns the current updated Vector2
  67492. */
  67493. normalize(): Vector2;
  67494. /**
  67495. * Gets a new Vector2 copied from the Vector2
  67496. * @returns a new Vector2
  67497. */
  67498. clone(): Vector2;
  67499. /**
  67500. * Gets a new Vector2(0, 0)
  67501. * @returns a new Vector2
  67502. */
  67503. static Zero(): Vector2;
  67504. /**
  67505. * Gets a new Vector2(1, 1)
  67506. * @returns a new Vector2
  67507. */
  67508. static One(): Vector2;
  67509. /**
  67510. * Gets a new Vector2 set from the given index element of the given array
  67511. * @param array defines the data source
  67512. * @param offset defines the offset in the data source
  67513. * @returns a new Vector2
  67514. */
  67515. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67516. /**
  67517. * Sets "result" from the given index element of the given array
  67518. * @param array defines the data source
  67519. * @param offset defines the offset in the data source
  67520. * @param result defines the target vector
  67521. */
  67522. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67523. /**
  67524. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67525. * @param value1 defines 1st point of control
  67526. * @param value2 defines 2nd point of control
  67527. * @param value3 defines 3rd point of control
  67528. * @param value4 defines 4th point of control
  67529. * @param amount defines the interpolation factor
  67530. * @returns a new Vector2
  67531. */
  67532. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67533. /**
  67534. * 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".
  67535. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67536. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67537. * @param value defines the value to clamp
  67538. * @param min defines the lower limit
  67539. * @param max defines the upper limit
  67540. * @returns a new Vector2
  67541. */
  67542. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67543. /**
  67544. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67545. * @param value1 defines the 1st control point
  67546. * @param tangent1 defines the outgoing tangent
  67547. * @param value2 defines the 2nd control point
  67548. * @param tangent2 defines the incoming tangent
  67549. * @param amount defines the interpolation factor
  67550. * @returns a new Vector2
  67551. */
  67552. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67553. /**
  67554. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67555. * @param start defines the start vector
  67556. * @param end defines the end vector
  67557. * @param amount defines the interpolation factor
  67558. * @returns a new Vector2
  67559. */
  67560. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67561. /**
  67562. * Gets the dot product of the vector "left" and the vector "right"
  67563. * @param left defines first vector
  67564. * @param right defines second vector
  67565. * @returns the dot product (float)
  67566. */
  67567. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67568. /**
  67569. * Returns a new Vector2 equal to the normalized given vector
  67570. * @param vector defines the vector to normalize
  67571. * @returns a new Vector2
  67572. */
  67573. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67574. /**
  67575. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67576. * @param left defines 1st vector
  67577. * @param right defines 2nd vector
  67578. * @returns a new Vector2
  67579. */
  67580. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67581. /**
  67582. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67583. * @param left defines 1st vector
  67584. * @param right defines 2nd vector
  67585. * @returns a new Vector2
  67586. */
  67587. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67588. /**
  67589. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67590. * @param vector defines the vector to transform
  67591. * @param transformation defines the matrix to apply
  67592. * @returns a new Vector2
  67593. */
  67594. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67595. /**
  67596. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67597. * @param vector defines the vector to transform
  67598. * @param transformation defines the matrix to apply
  67599. * @param result defines the target vector
  67600. */
  67601. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67602. /**
  67603. * Determines if a given vector is included in a triangle
  67604. * @param p defines the vector to test
  67605. * @param p0 defines 1st triangle point
  67606. * @param p1 defines 2nd triangle point
  67607. * @param p2 defines 3rd triangle point
  67608. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67609. */
  67610. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67611. /**
  67612. * Gets the distance between the vectors "value1" and "value2"
  67613. * @param value1 defines first vector
  67614. * @param value2 defines second vector
  67615. * @returns the distance between vectors
  67616. */
  67617. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67618. /**
  67619. * Returns the squared distance between the vectors "value1" and "value2"
  67620. * @param value1 defines first vector
  67621. * @param value2 defines second vector
  67622. * @returns the squared distance between vectors
  67623. */
  67624. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67625. /**
  67626. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67627. * @param value1 defines first vector
  67628. * @param value2 defines second vector
  67629. * @returns a new Vector2
  67630. */
  67631. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67632. /**
  67633. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67634. * @param p defines the middle point
  67635. * @param segA defines one point of the segment
  67636. * @param segB defines the other point of the segment
  67637. * @returns the shortest distance
  67638. */
  67639. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67640. }
  67641. /**
  67642. * Classed used to store (x,y,z) vector representation
  67643. * A Vector3 is the main object used in 3D geometry
  67644. * It can represent etiher the coordinates of a point the space, either a direction
  67645. * Reminder: js uses a left handed forward facing system
  67646. */
  67647. export class Vector3 {
  67648. /**
  67649. * Defines the first coordinates (on X axis)
  67650. */
  67651. x: number;
  67652. /**
  67653. * Defines the second coordinates (on Y axis)
  67654. */
  67655. y: number;
  67656. /**
  67657. * Defines the third coordinates (on Z axis)
  67658. */
  67659. z: number;
  67660. private static _UpReadOnly;
  67661. private static _ZeroReadOnly;
  67662. /**
  67663. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67664. * @param x defines the first coordinates (on X axis)
  67665. * @param y defines the second coordinates (on Y axis)
  67666. * @param z defines the third coordinates (on Z axis)
  67667. */
  67668. constructor(
  67669. /**
  67670. * Defines the first coordinates (on X axis)
  67671. */
  67672. x?: number,
  67673. /**
  67674. * Defines the second coordinates (on Y axis)
  67675. */
  67676. y?: number,
  67677. /**
  67678. * Defines the third coordinates (on Z axis)
  67679. */
  67680. z?: number);
  67681. /**
  67682. * Creates a string representation of the Vector3
  67683. * @returns a string with the Vector3 coordinates.
  67684. */
  67685. toString(): string;
  67686. /**
  67687. * Gets the class name
  67688. * @returns the string "Vector3"
  67689. */
  67690. getClassName(): string;
  67691. /**
  67692. * Creates the Vector3 hash code
  67693. * @returns a number which tends to be unique between Vector3 instances
  67694. */
  67695. getHashCode(): number;
  67696. /**
  67697. * Creates an array containing three elements : the coordinates of the Vector3
  67698. * @returns a new array of numbers
  67699. */
  67700. asArray(): number[];
  67701. /**
  67702. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67703. * @param array defines the destination array
  67704. * @param index defines the offset in the destination array
  67705. * @returns the current Vector3
  67706. */
  67707. toArray(array: FloatArray, index?: number): Vector3;
  67708. /**
  67709. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67710. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67711. */
  67712. toQuaternion(): Quaternion;
  67713. /**
  67714. * Adds the given vector to the current Vector3
  67715. * @param otherVector defines the second operand
  67716. * @returns the current updated Vector3
  67717. */
  67718. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67719. /**
  67720. * Adds the given coordinates to the current Vector3
  67721. * @param x defines the x coordinate of the operand
  67722. * @param y defines the y coordinate of the operand
  67723. * @param z defines the z coordinate of the operand
  67724. * @returns the current updated Vector3
  67725. */
  67726. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67727. /**
  67728. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67729. * @param otherVector defines the second operand
  67730. * @returns the resulting Vector3
  67731. */
  67732. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67733. /**
  67734. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67735. * @param otherVector defines the second operand
  67736. * @param result defines the Vector3 object where to store the result
  67737. * @returns the current Vector3
  67738. */
  67739. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67740. /**
  67741. * Subtract the given vector from the current Vector3
  67742. * @param otherVector defines the second operand
  67743. * @returns the current updated Vector3
  67744. */
  67745. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67746. /**
  67747. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67748. * @param otherVector defines the second operand
  67749. * @returns the resulting Vector3
  67750. */
  67751. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67752. /**
  67753. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67754. * @param otherVector defines the second operand
  67755. * @param result defines the Vector3 object where to store the result
  67756. * @returns the current Vector3
  67757. */
  67758. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67759. /**
  67760. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67761. * @param x defines the x coordinate of the operand
  67762. * @param y defines the y coordinate of the operand
  67763. * @param z defines the z coordinate of the operand
  67764. * @returns the resulting Vector3
  67765. */
  67766. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67767. /**
  67768. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67769. * @param x defines the x coordinate of the operand
  67770. * @param y defines the y coordinate of the operand
  67771. * @param z defines the z coordinate of the operand
  67772. * @param result defines the Vector3 object where to store the result
  67773. * @returns the current Vector3
  67774. */
  67775. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67776. /**
  67777. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67778. * @returns a new Vector3
  67779. */
  67780. negate(): Vector3;
  67781. /**
  67782. * Multiplies the Vector3 coordinates by the float "scale"
  67783. * @param scale defines the multiplier factor
  67784. * @returns the current updated Vector3
  67785. */
  67786. scaleInPlace(scale: number): Vector3;
  67787. /**
  67788. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67789. * @param scale defines the multiplier factor
  67790. * @returns a new Vector3
  67791. */
  67792. scale(scale: number): Vector3;
  67793. /**
  67794. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67795. * @param scale defines the multiplier factor
  67796. * @param result defines the Vector3 object where to store the result
  67797. * @returns the current Vector3
  67798. */
  67799. scaleToRef(scale: number, result: Vector3): Vector3;
  67800. /**
  67801. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67802. * @param scale defines the scale factor
  67803. * @param result defines the Vector3 object where to store the result
  67804. * @returns the unmodified current Vector3
  67805. */
  67806. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67807. /**
  67808. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67809. * @param otherVector defines the second operand
  67810. * @returns true if both vectors are equals
  67811. */
  67812. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67813. /**
  67814. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67815. * @param otherVector defines the second operand
  67816. * @param epsilon defines the minimal distance to define values as equals
  67817. * @returns true if both vectors are distant less than epsilon
  67818. */
  67819. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67820. /**
  67821. * Returns true if the current Vector3 coordinates equals the given floats
  67822. * @param x defines the x coordinate of the operand
  67823. * @param y defines the y coordinate of the operand
  67824. * @param z defines the z coordinate of the operand
  67825. * @returns true if both vectors are equals
  67826. */
  67827. equalsToFloats(x: number, y: number, z: number): boolean;
  67828. /**
  67829. * Multiplies the current Vector3 coordinates by the given ones
  67830. * @param otherVector defines the second operand
  67831. * @returns the current updated Vector3
  67832. */
  67833. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67834. /**
  67835. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67836. * @param otherVector defines the second operand
  67837. * @returns the new Vector3
  67838. */
  67839. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67840. /**
  67841. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67842. * @param otherVector defines the second operand
  67843. * @param result defines the Vector3 object where to store the result
  67844. * @returns the current Vector3
  67845. */
  67846. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67847. /**
  67848. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67849. * @param x defines the x coordinate of the operand
  67850. * @param y defines the y coordinate of the operand
  67851. * @param z defines the z coordinate of the operand
  67852. * @returns the new Vector3
  67853. */
  67854. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67855. /**
  67856. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67857. * @param otherVector defines the second operand
  67858. * @returns the new Vector3
  67859. */
  67860. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67861. /**
  67862. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67863. * @param otherVector defines the second operand
  67864. * @param result defines the Vector3 object where to store the result
  67865. * @returns the current Vector3
  67866. */
  67867. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67868. /**
  67869. * Divides the current Vector3 coordinates by the given ones.
  67870. * @param otherVector defines the second operand
  67871. * @returns the current updated Vector3
  67872. */
  67873. divideInPlace(otherVector: Vector3): Vector3;
  67874. /**
  67875. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67876. * @param other defines the second operand
  67877. * @returns the current updated Vector3
  67878. */
  67879. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67880. /**
  67881. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67882. * @param other defines the second operand
  67883. * @returns the current updated Vector3
  67884. */
  67885. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67886. /**
  67887. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67888. * @param x defines the x coordinate of the operand
  67889. * @param y defines the y coordinate of the operand
  67890. * @param z defines the z coordinate of the operand
  67891. * @returns the current updated Vector3
  67892. */
  67893. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67894. /**
  67895. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67896. * @param x defines the x coordinate of the operand
  67897. * @param y defines the y coordinate of the operand
  67898. * @param z defines the z coordinate of the operand
  67899. * @returns the current updated Vector3
  67900. */
  67901. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67902. /**
  67903. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67904. * Check if is non uniform within a certain amount of decimal places to account for this
  67905. * @param epsilon the amount the values can differ
  67906. * @returns if the the vector is non uniform to a certain number of decimal places
  67907. */
  67908. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67909. /**
  67910. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67911. */
  67912. readonly isNonUniform: boolean;
  67913. /**
  67914. * Gets a new Vector3 from current Vector3 floored values
  67915. * @returns a new Vector3
  67916. */
  67917. floor(): Vector3;
  67918. /**
  67919. * Gets a new Vector3 from current Vector3 floored values
  67920. * @returns a new Vector3
  67921. */
  67922. fract(): Vector3;
  67923. /**
  67924. * Gets the length of the Vector3
  67925. * @returns the length of the Vector3
  67926. */
  67927. length(): number;
  67928. /**
  67929. * Gets the squared length of the Vector3
  67930. * @returns squared length of the Vector3
  67931. */
  67932. lengthSquared(): number;
  67933. /**
  67934. * Normalize the current Vector3.
  67935. * Please note that this is an in place operation.
  67936. * @returns the current updated Vector3
  67937. */
  67938. normalize(): Vector3;
  67939. /**
  67940. * Reorders the x y z properties of the vector in place
  67941. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67942. * @returns the current updated vector
  67943. */
  67944. reorderInPlace(order: string): this;
  67945. /**
  67946. * Rotates the vector around 0,0,0 by a quaternion
  67947. * @param quaternion the rotation quaternion
  67948. * @param result vector to store the result
  67949. * @returns the resulting vector
  67950. */
  67951. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67952. /**
  67953. * Rotates a vector around a given point
  67954. * @param quaternion the rotation quaternion
  67955. * @param point the point to rotate around
  67956. * @param result vector to store the result
  67957. * @returns the resulting vector
  67958. */
  67959. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67960. /**
  67961. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  67962. * The cross product is then orthogonal to both current and "other"
  67963. * @param other defines the right operand
  67964. * @returns the cross product
  67965. */
  67966. cross(other: Vector3): Vector3;
  67967. /**
  67968. * Normalize the current Vector3 with the given input length.
  67969. * Please note that this is an in place operation.
  67970. * @param len the length of the vector
  67971. * @returns the current updated Vector3
  67972. */
  67973. normalizeFromLength(len: number): Vector3;
  67974. /**
  67975. * Normalize the current Vector3 to a new vector
  67976. * @returns the new Vector3
  67977. */
  67978. normalizeToNew(): Vector3;
  67979. /**
  67980. * Normalize the current Vector3 to the reference
  67981. * @param reference define the Vector3 to update
  67982. * @returns the updated Vector3
  67983. */
  67984. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67985. /**
  67986. * Creates a new Vector3 copied from the current Vector3
  67987. * @returns the new Vector3
  67988. */
  67989. clone(): Vector3;
  67990. /**
  67991. * Copies the given vector coordinates to the current Vector3 ones
  67992. * @param source defines the source Vector3
  67993. * @returns the current updated Vector3
  67994. */
  67995. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67996. /**
  67997. * Copies the given floats to the current Vector3 coordinates
  67998. * @param x defines the x coordinate of the operand
  67999. * @param y defines the y coordinate of the operand
  68000. * @param z defines the z coordinate of the operand
  68001. * @returns the current updated Vector3
  68002. */
  68003. copyFromFloats(x: number, y: number, z: number): Vector3;
  68004. /**
  68005. * Copies the given floats to the current Vector3 coordinates
  68006. * @param x defines the x coordinate of the operand
  68007. * @param y defines the y coordinate of the operand
  68008. * @param z defines the z coordinate of the operand
  68009. * @returns the current updated Vector3
  68010. */
  68011. set(x: number, y: number, z: number): Vector3;
  68012. /**
  68013. * Copies the given float to the current Vector3 coordinates
  68014. * @param v defines the x, y and z coordinates of the operand
  68015. * @returns the current updated Vector3
  68016. */
  68017. setAll(v: number): Vector3;
  68018. /**
  68019. * Get the clip factor between two vectors
  68020. * @param vector0 defines the first operand
  68021. * @param vector1 defines the second operand
  68022. * @param axis defines the axis to use
  68023. * @param size defines the size along the axis
  68024. * @returns the clip factor
  68025. */
  68026. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  68027. /**
  68028. * Get angle between two vectors
  68029. * @param vector0 angle between vector0 and vector1
  68030. * @param vector1 angle between vector0 and vector1
  68031. * @param normal direction of the normal
  68032. * @return the angle between vector0 and vector1
  68033. */
  68034. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  68035. /**
  68036. * Returns a new Vector3 set from the index "offset" of the given array
  68037. * @param array defines the source array
  68038. * @param offset defines the offset in the source array
  68039. * @returns the new Vector3
  68040. */
  68041. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  68042. /**
  68043. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  68044. * This function is deprecated. Use FromArray instead
  68045. * @param array defines the source array
  68046. * @param offset defines the offset in the source array
  68047. * @returns the new Vector3
  68048. */
  68049. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  68050. /**
  68051. * Sets the given vector "result" with the element values from the index "offset" of the given array
  68052. * @param array defines the source array
  68053. * @param offset defines the offset in the source array
  68054. * @param result defines the Vector3 where to store the result
  68055. */
  68056. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  68057. /**
  68058. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  68059. * This function is deprecated. Use FromArrayToRef instead.
  68060. * @param array defines the source array
  68061. * @param offset defines the offset in the source array
  68062. * @param result defines the Vector3 where to store the result
  68063. */
  68064. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  68065. /**
  68066. * Sets the given vector "result" with the given floats.
  68067. * @param x defines the x coordinate of the source
  68068. * @param y defines the y coordinate of the source
  68069. * @param z defines the z coordinate of the source
  68070. * @param result defines the Vector3 where to store the result
  68071. */
  68072. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  68073. /**
  68074. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  68075. * @returns a new empty Vector3
  68076. */
  68077. static Zero(): Vector3;
  68078. /**
  68079. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  68080. * @returns a new unit Vector3
  68081. */
  68082. static One(): Vector3;
  68083. /**
  68084. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  68085. * @returns a new up Vector3
  68086. */
  68087. static Up(): Vector3;
  68088. /**
  68089. * Gets a up Vector3 that must not be updated
  68090. */
  68091. static readonly UpReadOnly: DeepImmutable<Vector3>;
  68092. /**
  68093. * Gets a zero Vector3 that must not be updated
  68094. */
  68095. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  68096. /**
  68097. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68098. * @returns a new down Vector3
  68099. */
  68100. static Down(): Vector3;
  68101. /**
  68102. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68103. * @returns a new forward Vector3
  68104. */
  68105. static Forward(): Vector3;
  68106. /**
  68107. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68108. * @returns a new forward Vector3
  68109. */
  68110. static Backward(): Vector3;
  68111. /**
  68112. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68113. * @returns a new right Vector3
  68114. */
  68115. static Right(): Vector3;
  68116. /**
  68117. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68118. * @returns a new left Vector3
  68119. */
  68120. static Left(): Vector3;
  68121. /**
  68122. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68123. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68124. * @param vector defines the Vector3 to transform
  68125. * @param transformation defines the transformation matrix
  68126. * @returns the transformed Vector3
  68127. */
  68128. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68129. /**
  68130. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68131. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68132. * @param vector defines the Vector3 to transform
  68133. * @param transformation defines the transformation matrix
  68134. * @param result defines the Vector3 where to store the result
  68135. */
  68136. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68137. /**
  68138. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68139. * This method computes tranformed coordinates only, not transformed direction vectors
  68140. * @param x define the x coordinate of the source vector
  68141. * @param y define the y coordinate of the source vector
  68142. * @param z define the z coordinate of the source vector
  68143. * @param transformation defines the transformation matrix
  68144. * @param result defines the Vector3 where to store the result
  68145. */
  68146. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68147. /**
  68148. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68149. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68150. * @param vector defines the Vector3 to transform
  68151. * @param transformation defines the transformation matrix
  68152. * @returns the new Vector3
  68153. */
  68154. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68155. /**
  68156. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68157. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68158. * @param vector defines the Vector3 to transform
  68159. * @param transformation defines the transformation matrix
  68160. * @param result defines the Vector3 where to store the result
  68161. */
  68162. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68163. /**
  68164. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68165. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68166. * @param x define the x coordinate of the source vector
  68167. * @param y define the y coordinate of the source vector
  68168. * @param z define the z coordinate of the source vector
  68169. * @param transformation defines the transformation matrix
  68170. * @param result defines the Vector3 where to store the result
  68171. */
  68172. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68173. /**
  68174. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68175. * @param value1 defines the first control point
  68176. * @param value2 defines the second control point
  68177. * @param value3 defines the third control point
  68178. * @param value4 defines the fourth control point
  68179. * @param amount defines the amount on the spline to use
  68180. * @returns the new Vector3
  68181. */
  68182. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68183. /**
  68184. * 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"
  68185. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68186. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68187. * @param value defines the current value
  68188. * @param min defines the lower range value
  68189. * @param max defines the upper range value
  68190. * @returns the new Vector3
  68191. */
  68192. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68193. /**
  68194. * 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"
  68195. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68196. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68197. * @param value defines the current value
  68198. * @param min defines the lower range value
  68199. * @param max defines the upper range value
  68200. * @param result defines the Vector3 where to store the result
  68201. */
  68202. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68203. /**
  68204. * Checks if a given vector is inside a specific range
  68205. * @param v defines the vector to test
  68206. * @param min defines the minimum range
  68207. * @param max defines the maximum range
  68208. */
  68209. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68210. /**
  68211. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68212. * @param value1 defines the first control point
  68213. * @param tangent1 defines the first tangent vector
  68214. * @param value2 defines the second control point
  68215. * @param tangent2 defines the second tangent vector
  68216. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68217. * @returns the new Vector3
  68218. */
  68219. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68220. /**
  68221. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68222. * @param start defines the start value
  68223. * @param end defines the end value
  68224. * @param amount max defines amount between both (between 0 and 1)
  68225. * @returns the new Vector3
  68226. */
  68227. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68228. /**
  68229. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68230. * @param start defines the start value
  68231. * @param end defines the end value
  68232. * @param amount max defines amount between both (between 0 and 1)
  68233. * @param result defines the Vector3 where to store the result
  68234. */
  68235. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68236. /**
  68237. * Returns the dot product (float) between the vectors "left" and "right"
  68238. * @param left defines the left operand
  68239. * @param right defines the right operand
  68240. * @returns the dot product
  68241. */
  68242. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68243. /**
  68244. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68245. * The cross product is then orthogonal to both "left" and "right"
  68246. * @param left defines the left operand
  68247. * @param right defines the right operand
  68248. * @returns the cross product
  68249. */
  68250. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68251. /**
  68252. * Sets the given vector "result" with the cross product of "left" and "right"
  68253. * The cross product is then orthogonal to both "left" and "right"
  68254. * @param left defines the left operand
  68255. * @param right defines the right operand
  68256. * @param result defines the Vector3 where to store the result
  68257. */
  68258. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68259. /**
  68260. * Returns a new Vector3 as the normalization of the given vector
  68261. * @param vector defines the Vector3 to normalize
  68262. * @returns the new Vector3
  68263. */
  68264. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68265. /**
  68266. * Sets the given vector "result" with the normalization of the given first vector
  68267. * @param vector defines the Vector3 to normalize
  68268. * @param result defines the Vector3 where to store the result
  68269. */
  68270. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68271. /**
  68272. * Project a Vector3 onto screen space
  68273. * @param vector defines the Vector3 to project
  68274. * @param world defines the world matrix to use
  68275. * @param transform defines the transform (view x projection) matrix to use
  68276. * @param viewport defines the screen viewport to use
  68277. * @returns the new Vector3
  68278. */
  68279. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68280. /** @hidden */
  68281. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68282. /**
  68283. * Unproject from screen space to object space
  68284. * @param source defines the screen space Vector3 to use
  68285. * @param viewportWidth defines the current width of the viewport
  68286. * @param viewportHeight defines the current height of the viewport
  68287. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68288. * @param transform defines the transform (view x projection) matrix to use
  68289. * @returns the new Vector3
  68290. */
  68291. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68292. /**
  68293. * Unproject from screen space to object space
  68294. * @param source defines the screen space Vector3 to use
  68295. * @param viewportWidth defines the current width of the viewport
  68296. * @param viewportHeight defines the current height of the viewport
  68297. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68298. * @param view defines the view matrix to use
  68299. * @param projection defines the projection matrix to use
  68300. * @returns the new Vector3
  68301. */
  68302. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68303. /**
  68304. * Unproject from screen space to object space
  68305. * @param source defines the screen space Vector3 to use
  68306. * @param viewportWidth defines the current width of the viewport
  68307. * @param viewportHeight defines the current height of the viewport
  68308. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68309. * @param view defines the view matrix to use
  68310. * @param projection defines the projection matrix to use
  68311. * @param result defines the Vector3 where to store the result
  68312. */
  68313. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68314. /**
  68315. * Unproject from screen space to object space
  68316. * @param sourceX defines the screen space x coordinate to use
  68317. * @param sourceY defines the screen space y coordinate to use
  68318. * @param sourceZ defines the screen space z coordinate to use
  68319. * @param viewportWidth defines the current width of the viewport
  68320. * @param viewportHeight defines the current height of the viewport
  68321. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68322. * @param view defines the view matrix to use
  68323. * @param projection defines the projection matrix to use
  68324. * @param result defines the Vector3 where to store the result
  68325. */
  68326. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68327. /**
  68328. * Gets the minimal coordinate values between two Vector3
  68329. * @param left defines the first operand
  68330. * @param right defines the second operand
  68331. * @returns the new Vector3
  68332. */
  68333. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68334. /**
  68335. * Gets the maximal coordinate values between two Vector3
  68336. * @param left defines the first operand
  68337. * @param right defines the second operand
  68338. * @returns the new Vector3
  68339. */
  68340. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68341. /**
  68342. * Returns the distance between the vectors "value1" and "value2"
  68343. * @param value1 defines the first operand
  68344. * @param value2 defines the second operand
  68345. * @returns the distance
  68346. */
  68347. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68348. /**
  68349. * Returns the squared distance between the vectors "value1" and "value2"
  68350. * @param value1 defines the first operand
  68351. * @param value2 defines the second operand
  68352. * @returns the squared distance
  68353. */
  68354. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68355. /**
  68356. * Returns a new Vector3 located at the center between "value1" and "value2"
  68357. * @param value1 defines the first operand
  68358. * @param value2 defines the second operand
  68359. * @returns the new Vector3
  68360. */
  68361. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68362. /**
  68363. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68364. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68365. * to something in order to rotate it from its local system to the given target system
  68366. * Note: axis1, axis2 and axis3 are normalized during this operation
  68367. * @param axis1 defines the first axis
  68368. * @param axis2 defines the second axis
  68369. * @param axis3 defines the third axis
  68370. * @returns a new Vector3
  68371. */
  68372. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68373. /**
  68374. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68375. * @param axis1 defines the first axis
  68376. * @param axis2 defines the second axis
  68377. * @param axis3 defines the third axis
  68378. * @param ref defines the Vector3 where to store the result
  68379. */
  68380. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68381. }
  68382. /**
  68383. * Vector4 class created for EulerAngle class conversion to Quaternion
  68384. */
  68385. export class Vector4 {
  68386. /** x value of the vector */
  68387. x: number;
  68388. /** y value of the vector */
  68389. y: number;
  68390. /** z value of the vector */
  68391. z: number;
  68392. /** w value of the vector */
  68393. w: number;
  68394. /**
  68395. * Creates a Vector4 object from the given floats.
  68396. * @param x x value of the vector
  68397. * @param y y value of the vector
  68398. * @param z z value of the vector
  68399. * @param w w value of the vector
  68400. */
  68401. constructor(
  68402. /** x value of the vector */
  68403. x: number,
  68404. /** y value of the vector */
  68405. y: number,
  68406. /** z value of the vector */
  68407. z: number,
  68408. /** w value of the vector */
  68409. w: number);
  68410. /**
  68411. * Returns the string with the Vector4 coordinates.
  68412. * @returns a string containing all the vector values
  68413. */
  68414. toString(): string;
  68415. /**
  68416. * Returns the string "Vector4".
  68417. * @returns "Vector4"
  68418. */
  68419. getClassName(): string;
  68420. /**
  68421. * Returns the Vector4 hash code.
  68422. * @returns a unique hash code
  68423. */
  68424. getHashCode(): number;
  68425. /**
  68426. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68427. * @returns the resulting array
  68428. */
  68429. asArray(): number[];
  68430. /**
  68431. * Populates the given array from the given index with the Vector4 coordinates.
  68432. * @param array array to populate
  68433. * @param index index of the array to start at (default: 0)
  68434. * @returns the Vector4.
  68435. */
  68436. toArray(array: FloatArray, index?: number): Vector4;
  68437. /**
  68438. * Adds the given vector to the current Vector4.
  68439. * @param otherVector the vector to add
  68440. * @returns the updated Vector4.
  68441. */
  68442. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68443. /**
  68444. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68445. * @param otherVector the vector to add
  68446. * @returns the resulting vector
  68447. */
  68448. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68449. /**
  68450. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68451. * @param otherVector the vector to add
  68452. * @param result the vector to store the result
  68453. * @returns the current Vector4.
  68454. */
  68455. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68456. /**
  68457. * Subtract in place the given vector from the current Vector4.
  68458. * @param otherVector the vector to subtract
  68459. * @returns the updated Vector4.
  68460. */
  68461. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68462. /**
  68463. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68464. * @param otherVector the vector to add
  68465. * @returns the new vector with the result
  68466. */
  68467. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68468. /**
  68469. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68470. * @param otherVector the vector to subtract
  68471. * @param result the vector to store the result
  68472. * @returns the current Vector4.
  68473. */
  68474. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68475. /**
  68476. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68477. */
  68478. /**
  68479. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68480. * @param x value to subtract
  68481. * @param y value to subtract
  68482. * @param z value to subtract
  68483. * @param w value to subtract
  68484. * @returns new vector containing the result
  68485. */
  68486. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68487. /**
  68488. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68489. * @param x value to subtract
  68490. * @param y value to subtract
  68491. * @param z value to subtract
  68492. * @param w value to subtract
  68493. * @param result the vector to store the result in
  68494. * @returns the current Vector4.
  68495. */
  68496. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68497. /**
  68498. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68499. * @returns a new vector with the negated values
  68500. */
  68501. negate(): Vector4;
  68502. /**
  68503. * Multiplies the current Vector4 coordinates by scale (float).
  68504. * @param scale the number to scale with
  68505. * @returns the updated Vector4.
  68506. */
  68507. scaleInPlace(scale: number): Vector4;
  68508. /**
  68509. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68510. * @param scale the number to scale with
  68511. * @returns a new vector with the result
  68512. */
  68513. scale(scale: number): Vector4;
  68514. /**
  68515. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68516. * @param scale the number to scale with
  68517. * @param result a vector to store the result in
  68518. * @returns the current Vector4.
  68519. */
  68520. scaleToRef(scale: number, result: Vector4): Vector4;
  68521. /**
  68522. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68523. * @param scale defines the scale factor
  68524. * @param result defines the Vector4 object where to store the result
  68525. * @returns the unmodified current Vector4
  68526. */
  68527. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68528. /**
  68529. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68530. * @param otherVector the vector to compare against
  68531. * @returns true if they are equal
  68532. */
  68533. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68534. /**
  68535. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68536. * @param otherVector vector to compare against
  68537. * @param epsilon (Default: very small number)
  68538. * @returns true if they are equal
  68539. */
  68540. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68541. /**
  68542. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68543. * @param x x value to compare against
  68544. * @param y y value to compare against
  68545. * @param z z value to compare against
  68546. * @param w w value to compare against
  68547. * @returns true if equal
  68548. */
  68549. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68550. /**
  68551. * Multiplies in place the current Vector4 by the given one.
  68552. * @param otherVector vector to multiple with
  68553. * @returns the updated Vector4.
  68554. */
  68555. multiplyInPlace(otherVector: Vector4): Vector4;
  68556. /**
  68557. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68558. * @param otherVector vector to multiple with
  68559. * @returns resulting new vector
  68560. */
  68561. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68562. /**
  68563. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68564. * @param otherVector vector to multiple with
  68565. * @param result vector to store the result
  68566. * @returns the current Vector4.
  68567. */
  68568. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68569. /**
  68570. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68571. * @param x x value multiply with
  68572. * @param y y value multiply with
  68573. * @param z z value multiply with
  68574. * @param w w value multiply with
  68575. * @returns resulting new vector
  68576. */
  68577. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68578. /**
  68579. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68580. * @param otherVector vector to devide with
  68581. * @returns resulting new vector
  68582. */
  68583. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68584. /**
  68585. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68586. * @param otherVector vector to devide with
  68587. * @param result vector to store the result
  68588. * @returns the current Vector4.
  68589. */
  68590. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68591. /**
  68592. * Divides the current Vector3 coordinates by the given ones.
  68593. * @param otherVector vector to devide with
  68594. * @returns the updated Vector3.
  68595. */
  68596. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68597. /**
  68598. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68599. * @param other defines the second operand
  68600. * @returns the current updated Vector4
  68601. */
  68602. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68603. /**
  68604. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68605. * @param other defines the second operand
  68606. * @returns the current updated Vector4
  68607. */
  68608. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68609. /**
  68610. * Gets a new Vector4 from current Vector4 floored values
  68611. * @returns a new Vector4
  68612. */
  68613. floor(): Vector4;
  68614. /**
  68615. * Gets a new Vector4 from current Vector3 floored values
  68616. * @returns a new Vector4
  68617. */
  68618. fract(): Vector4;
  68619. /**
  68620. * Returns the Vector4 length (float).
  68621. * @returns the length
  68622. */
  68623. length(): number;
  68624. /**
  68625. * Returns the Vector4 squared length (float).
  68626. * @returns the length squared
  68627. */
  68628. lengthSquared(): number;
  68629. /**
  68630. * Normalizes in place the Vector4.
  68631. * @returns the updated Vector4.
  68632. */
  68633. normalize(): Vector4;
  68634. /**
  68635. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68636. * @returns this converted to a new vector3
  68637. */
  68638. toVector3(): Vector3;
  68639. /**
  68640. * Returns a new Vector4 copied from the current one.
  68641. * @returns the new cloned vector
  68642. */
  68643. clone(): Vector4;
  68644. /**
  68645. * Updates the current Vector4 with the given one coordinates.
  68646. * @param source the source vector to copy from
  68647. * @returns the updated Vector4.
  68648. */
  68649. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68650. /**
  68651. * Updates the current Vector4 coordinates with the given floats.
  68652. * @param x float to copy from
  68653. * @param y float to copy from
  68654. * @param z float to copy from
  68655. * @param w float to copy from
  68656. * @returns the updated Vector4.
  68657. */
  68658. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68659. /**
  68660. * Updates the current Vector4 coordinates with the given floats.
  68661. * @param x float to set from
  68662. * @param y float to set from
  68663. * @param z float to set from
  68664. * @param w float to set from
  68665. * @returns the updated Vector4.
  68666. */
  68667. set(x: number, y: number, z: number, w: number): Vector4;
  68668. /**
  68669. * Copies the given float to the current Vector3 coordinates
  68670. * @param v defines the x, y, z and w coordinates of the operand
  68671. * @returns the current updated Vector3
  68672. */
  68673. setAll(v: number): Vector4;
  68674. /**
  68675. * Returns a new Vector4 set from the starting index of the given array.
  68676. * @param array the array to pull values from
  68677. * @param offset the offset into the array to start at
  68678. * @returns the new vector
  68679. */
  68680. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68681. /**
  68682. * Updates the given vector "result" from the starting index of the given array.
  68683. * @param array the array to pull values from
  68684. * @param offset the offset into the array to start at
  68685. * @param result the vector to store the result in
  68686. */
  68687. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68688. /**
  68689. * Updates the given vector "result" from the starting index of the given Float32Array.
  68690. * @param array the array to pull values from
  68691. * @param offset the offset into the array to start at
  68692. * @param result the vector to store the result in
  68693. */
  68694. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68695. /**
  68696. * Updates the given vector "result" coordinates from the given floats.
  68697. * @param x float to set from
  68698. * @param y float to set from
  68699. * @param z float to set from
  68700. * @param w float to set from
  68701. * @param result the vector to the floats in
  68702. */
  68703. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68704. /**
  68705. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68706. * @returns the new vector
  68707. */
  68708. static Zero(): Vector4;
  68709. /**
  68710. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68711. * @returns the new vector
  68712. */
  68713. static One(): Vector4;
  68714. /**
  68715. * Returns a new normalized Vector4 from the given one.
  68716. * @param vector the vector to normalize
  68717. * @returns the vector
  68718. */
  68719. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68720. /**
  68721. * Updates the given vector "result" from the normalization of the given one.
  68722. * @param vector the vector to normalize
  68723. * @param result the vector to store the result in
  68724. */
  68725. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68726. /**
  68727. * Returns a vector with the minimum values from the left and right vectors
  68728. * @param left left vector to minimize
  68729. * @param right right vector to minimize
  68730. * @returns a new vector with the minimum of the left and right vector values
  68731. */
  68732. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68733. /**
  68734. * Returns a vector with the maximum values from the left and right vectors
  68735. * @param left left vector to maximize
  68736. * @param right right vector to maximize
  68737. * @returns a new vector with the maximum of the left and right vector values
  68738. */
  68739. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68740. /**
  68741. * Returns the distance (float) between the vectors "value1" and "value2".
  68742. * @param value1 value to calulate the distance between
  68743. * @param value2 value to calulate the distance between
  68744. * @return the distance between the two vectors
  68745. */
  68746. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68747. /**
  68748. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68749. * @param value1 value to calulate the distance between
  68750. * @param value2 value to calulate the distance between
  68751. * @return the distance between the two vectors squared
  68752. */
  68753. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68754. /**
  68755. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68756. * @param value1 value to calulate the center between
  68757. * @param value2 value to calulate the center between
  68758. * @return the center between the two vectors
  68759. */
  68760. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68761. /**
  68762. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68763. * This methods computes transformed normalized direction vectors only.
  68764. * @param vector the vector to transform
  68765. * @param transformation the transformation matrix to apply
  68766. * @returns the new vector
  68767. */
  68768. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68769. /**
  68770. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68771. * This methods computes transformed normalized direction vectors only.
  68772. * @param vector the vector to transform
  68773. * @param transformation the transformation matrix to apply
  68774. * @param result the vector to store the result in
  68775. */
  68776. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68777. /**
  68778. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68779. * This methods computes transformed normalized direction vectors only.
  68780. * @param x value to transform
  68781. * @param y value to transform
  68782. * @param z value to transform
  68783. * @param w value to transform
  68784. * @param transformation the transformation matrix to apply
  68785. * @param result the vector to store the results in
  68786. */
  68787. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68788. /**
  68789. * Creates a new Vector4 from a Vector3
  68790. * @param source defines the source data
  68791. * @param w defines the 4th component (default is 0)
  68792. * @returns a new Vector4
  68793. */
  68794. static FromVector3(source: Vector3, w?: number): Vector4;
  68795. }
  68796. /**
  68797. * Class used to store quaternion data
  68798. * @see https://en.wikipedia.org/wiki/Quaternion
  68799. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68800. */
  68801. export class Quaternion {
  68802. /** defines the first component (0 by default) */
  68803. x: number;
  68804. /** defines the second component (0 by default) */
  68805. y: number;
  68806. /** defines the third component (0 by default) */
  68807. z: number;
  68808. /** defines the fourth component (1.0 by default) */
  68809. w: number;
  68810. /**
  68811. * Creates a new Quaternion from the given floats
  68812. * @param x defines the first component (0 by default)
  68813. * @param y defines the second component (0 by default)
  68814. * @param z defines the third component (0 by default)
  68815. * @param w defines the fourth component (1.0 by default)
  68816. */
  68817. constructor(
  68818. /** defines the first component (0 by default) */
  68819. x?: number,
  68820. /** defines the second component (0 by default) */
  68821. y?: number,
  68822. /** defines the third component (0 by default) */
  68823. z?: number,
  68824. /** defines the fourth component (1.0 by default) */
  68825. w?: number);
  68826. /**
  68827. * Gets a string representation for the current quaternion
  68828. * @returns a string with the Quaternion coordinates
  68829. */
  68830. toString(): string;
  68831. /**
  68832. * Gets the class name of the quaternion
  68833. * @returns the string "Quaternion"
  68834. */
  68835. getClassName(): string;
  68836. /**
  68837. * Gets a hash code for this quaternion
  68838. * @returns the quaternion hash code
  68839. */
  68840. getHashCode(): number;
  68841. /**
  68842. * Copy the quaternion to an array
  68843. * @returns a new array populated with 4 elements from the quaternion coordinates
  68844. */
  68845. asArray(): number[];
  68846. /**
  68847. * Check if two quaternions are equals
  68848. * @param otherQuaternion defines the second operand
  68849. * @return true if the current quaternion and the given one coordinates are strictly equals
  68850. */
  68851. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68852. /**
  68853. * Clone the current quaternion
  68854. * @returns a new quaternion copied from the current one
  68855. */
  68856. clone(): Quaternion;
  68857. /**
  68858. * Copy a quaternion to the current one
  68859. * @param other defines the other quaternion
  68860. * @returns the updated current quaternion
  68861. */
  68862. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68863. /**
  68864. * Updates the current quaternion with the given float coordinates
  68865. * @param x defines the x coordinate
  68866. * @param y defines the y coordinate
  68867. * @param z defines the z coordinate
  68868. * @param w defines the w coordinate
  68869. * @returns the updated current quaternion
  68870. */
  68871. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68872. /**
  68873. * Updates the current quaternion from the given float coordinates
  68874. * @param x defines the x coordinate
  68875. * @param y defines the y coordinate
  68876. * @param z defines the z coordinate
  68877. * @param w defines the w coordinate
  68878. * @returns the updated current quaternion
  68879. */
  68880. set(x: number, y: number, z: number, w: number): Quaternion;
  68881. /**
  68882. * Adds two quaternions
  68883. * @param other defines the second operand
  68884. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68885. */
  68886. add(other: DeepImmutable<Quaternion>): Quaternion;
  68887. /**
  68888. * Add a quaternion to the current one
  68889. * @param other defines the quaternion to add
  68890. * @returns the current quaternion
  68891. */
  68892. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68893. /**
  68894. * Subtract two quaternions
  68895. * @param other defines the second operand
  68896. * @returns a new quaternion as the subtraction result of the given one from the current one
  68897. */
  68898. subtract(other: Quaternion): Quaternion;
  68899. /**
  68900. * Multiplies the current quaternion by a scale factor
  68901. * @param value defines the scale factor
  68902. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68903. */
  68904. scale(value: number): Quaternion;
  68905. /**
  68906. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68907. * @param scale defines the scale factor
  68908. * @param result defines the Quaternion object where to store the result
  68909. * @returns the unmodified current quaternion
  68910. */
  68911. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68912. /**
  68913. * Multiplies in place the current quaternion by a scale factor
  68914. * @param value defines the scale factor
  68915. * @returns the current modified quaternion
  68916. */
  68917. scaleInPlace(value: number): Quaternion;
  68918. /**
  68919. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68920. * @param scale defines the scale factor
  68921. * @param result defines the Quaternion object where to store the result
  68922. * @returns the unmodified current quaternion
  68923. */
  68924. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68925. /**
  68926. * Multiplies two quaternions
  68927. * @param q1 defines the second operand
  68928. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68929. */
  68930. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68931. /**
  68932. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68933. * @param q1 defines the second operand
  68934. * @param result defines the target quaternion
  68935. * @returns the current quaternion
  68936. */
  68937. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68938. /**
  68939. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68940. * @param q1 defines the second operand
  68941. * @returns the currentupdated quaternion
  68942. */
  68943. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68944. /**
  68945. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68946. * @param ref defines the target quaternion
  68947. * @returns the current quaternion
  68948. */
  68949. conjugateToRef(ref: Quaternion): Quaternion;
  68950. /**
  68951. * Conjugates in place (1-q) the current quaternion
  68952. * @returns the current updated quaternion
  68953. */
  68954. conjugateInPlace(): Quaternion;
  68955. /**
  68956. * Conjugates in place (1-q) the current quaternion
  68957. * @returns a new quaternion
  68958. */
  68959. conjugate(): Quaternion;
  68960. /**
  68961. * Gets length of current quaternion
  68962. * @returns the quaternion length (float)
  68963. */
  68964. length(): number;
  68965. /**
  68966. * Normalize in place the current quaternion
  68967. * @returns the current updated quaternion
  68968. */
  68969. normalize(): Quaternion;
  68970. /**
  68971. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68972. * @param order is a reserved parameter and is ignore for now
  68973. * @returns a new Vector3 containing the Euler angles
  68974. */
  68975. toEulerAngles(order?: string): Vector3;
  68976. /**
  68977. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68978. * @param result defines the vector which will be filled with the Euler angles
  68979. * @param order is a reserved parameter and is ignore for now
  68980. * @returns the current unchanged quaternion
  68981. */
  68982. toEulerAnglesToRef(result: Vector3): Quaternion;
  68983. /**
  68984. * Updates the given rotation matrix with the current quaternion values
  68985. * @param result defines the target matrix
  68986. * @returns the current unchanged quaternion
  68987. */
  68988. toRotationMatrix(result: Matrix): Quaternion;
  68989. /**
  68990. * Updates the current quaternion from the given rotation matrix values
  68991. * @param matrix defines the source matrix
  68992. * @returns the current updated quaternion
  68993. */
  68994. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68995. /**
  68996. * Creates a new quaternion from a rotation matrix
  68997. * @param matrix defines the source matrix
  68998. * @returns a new quaternion created from the given rotation matrix values
  68999. */
  69000. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69001. /**
  69002. * Updates the given quaternion with the given rotation matrix values
  69003. * @param matrix defines the source matrix
  69004. * @param result defines the target quaternion
  69005. */
  69006. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  69007. /**
  69008. * Returns the dot product (float) between the quaternions "left" and "right"
  69009. * @param left defines the left operand
  69010. * @param right defines the right operand
  69011. * @returns the dot product
  69012. */
  69013. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  69014. /**
  69015. * Checks if the two quaternions are close to each other
  69016. * @param quat0 defines the first quaternion to check
  69017. * @param quat1 defines the second quaternion to check
  69018. * @returns true if the two quaternions are close to each other
  69019. */
  69020. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  69021. /**
  69022. * Creates an empty quaternion
  69023. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  69024. */
  69025. static Zero(): Quaternion;
  69026. /**
  69027. * Inverse a given quaternion
  69028. * @param q defines the source quaternion
  69029. * @returns a new quaternion as the inverted current quaternion
  69030. */
  69031. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  69032. /**
  69033. * Inverse a given quaternion
  69034. * @param q defines the source quaternion
  69035. * @param result the quaternion the result will be stored in
  69036. * @returns the result quaternion
  69037. */
  69038. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  69039. /**
  69040. * Creates an identity quaternion
  69041. * @returns the identity quaternion
  69042. */
  69043. static Identity(): Quaternion;
  69044. /**
  69045. * Gets a boolean indicating if the given quaternion is identity
  69046. * @param quaternion defines the quaternion to check
  69047. * @returns true if the quaternion is identity
  69048. */
  69049. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  69050. /**
  69051. * Creates a quaternion from a rotation around an axis
  69052. * @param axis defines the axis to use
  69053. * @param angle defines the angle to use
  69054. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  69055. */
  69056. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  69057. /**
  69058. * Creates a rotation around an axis and stores it into the given quaternion
  69059. * @param axis defines the axis to use
  69060. * @param angle defines the angle to use
  69061. * @param result defines the target quaternion
  69062. * @returns the target quaternion
  69063. */
  69064. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  69065. /**
  69066. * Creates a new quaternion from data stored into an array
  69067. * @param array defines the data source
  69068. * @param offset defines the offset in the source array where the data starts
  69069. * @returns a new quaternion
  69070. */
  69071. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  69072. /**
  69073. * Create a quaternion from Euler rotation angles
  69074. * @param x Pitch
  69075. * @param y Yaw
  69076. * @param z Roll
  69077. * @returns the new Quaternion
  69078. */
  69079. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  69080. /**
  69081. * Updates a quaternion from Euler rotation angles
  69082. * @param x Pitch
  69083. * @param y Yaw
  69084. * @param z Roll
  69085. * @param result the quaternion to store the result
  69086. * @returns the updated quaternion
  69087. */
  69088. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  69089. /**
  69090. * Create a quaternion from Euler rotation vector
  69091. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69092. * @returns the new Quaternion
  69093. */
  69094. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  69095. /**
  69096. * Updates a quaternion from Euler rotation vector
  69097. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69098. * @param result the quaternion to store the result
  69099. * @returns the updated quaternion
  69100. */
  69101. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69102. /**
  69103. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69104. * @param yaw defines the rotation around Y axis
  69105. * @param pitch defines the rotation around X axis
  69106. * @param roll defines the rotation around Z axis
  69107. * @returns the new quaternion
  69108. */
  69109. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69110. /**
  69111. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69112. * @param yaw defines the rotation around Y axis
  69113. * @param pitch defines the rotation around X axis
  69114. * @param roll defines the rotation around Z axis
  69115. * @param result defines the target quaternion
  69116. */
  69117. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69118. /**
  69119. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69120. * @param alpha defines the rotation around first axis
  69121. * @param beta defines the rotation around second axis
  69122. * @param gamma defines the rotation around third axis
  69123. * @returns the new quaternion
  69124. */
  69125. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69126. /**
  69127. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69128. * @param alpha defines the rotation around first axis
  69129. * @param beta defines the rotation around second axis
  69130. * @param gamma defines the rotation around third axis
  69131. * @param result defines the target quaternion
  69132. */
  69133. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69134. /**
  69135. * 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)
  69136. * @param axis1 defines the first axis
  69137. * @param axis2 defines the second axis
  69138. * @param axis3 defines the third axis
  69139. * @returns the new quaternion
  69140. */
  69141. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69142. /**
  69143. * 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
  69144. * @param axis1 defines the first axis
  69145. * @param axis2 defines the second axis
  69146. * @param axis3 defines the third axis
  69147. * @param ref defines the target quaternion
  69148. */
  69149. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69150. /**
  69151. * Interpolates between two quaternions
  69152. * @param left defines first quaternion
  69153. * @param right defines second quaternion
  69154. * @param amount defines the gradient to use
  69155. * @returns the new interpolated quaternion
  69156. */
  69157. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69158. /**
  69159. * Interpolates between two quaternions and stores it into a target quaternion
  69160. * @param left defines first quaternion
  69161. * @param right defines second quaternion
  69162. * @param amount defines the gradient to use
  69163. * @param result defines the target quaternion
  69164. */
  69165. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69166. /**
  69167. * Interpolate between two quaternions using Hermite interpolation
  69168. * @param value1 defines first quaternion
  69169. * @param tangent1 defines the incoming tangent
  69170. * @param value2 defines second quaternion
  69171. * @param tangent2 defines the outgoing tangent
  69172. * @param amount defines the target quaternion
  69173. * @returns the new interpolated quaternion
  69174. */
  69175. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69176. }
  69177. /**
  69178. * Class used to store matrix data (4x4)
  69179. */
  69180. export class Matrix {
  69181. private static _updateFlagSeed;
  69182. private static _identityReadOnly;
  69183. private _isIdentity;
  69184. private _isIdentityDirty;
  69185. private _isIdentity3x2;
  69186. private _isIdentity3x2Dirty;
  69187. /**
  69188. * Gets the update flag of the matrix which is an unique number for the matrix.
  69189. * It will be incremented every time the matrix data change.
  69190. * You can use it to speed the comparison between two versions of the same matrix.
  69191. */
  69192. updateFlag: number;
  69193. private readonly _m;
  69194. /**
  69195. * Gets the internal data of the matrix
  69196. */
  69197. readonly m: DeepImmutable<Float32Array>;
  69198. /** @hidden */
  69199. _markAsUpdated(): void;
  69200. /** @hidden */
  69201. private _updateIdentityStatus;
  69202. /**
  69203. * Creates an empty matrix (filled with zeros)
  69204. */
  69205. constructor();
  69206. /**
  69207. * Check if the current matrix is identity
  69208. * @returns true is the matrix is the identity matrix
  69209. */
  69210. isIdentity(): boolean;
  69211. /**
  69212. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69213. * @returns true is the matrix is the identity matrix
  69214. */
  69215. isIdentityAs3x2(): boolean;
  69216. /**
  69217. * Gets the determinant of the matrix
  69218. * @returns the matrix determinant
  69219. */
  69220. determinant(): number;
  69221. /**
  69222. * Returns the matrix as a Float32Array
  69223. * @returns the matrix underlying array
  69224. */
  69225. toArray(): DeepImmutable<Float32Array>;
  69226. /**
  69227. * Returns the matrix as a Float32Array
  69228. * @returns the matrix underlying array.
  69229. */
  69230. asArray(): DeepImmutable<Float32Array>;
  69231. /**
  69232. * Inverts the current matrix in place
  69233. * @returns the current inverted matrix
  69234. */
  69235. invert(): Matrix;
  69236. /**
  69237. * Sets all the matrix elements to zero
  69238. * @returns the current matrix
  69239. */
  69240. reset(): Matrix;
  69241. /**
  69242. * Adds the current matrix with a second one
  69243. * @param other defines the matrix to add
  69244. * @returns a new matrix as the addition of the current matrix and the given one
  69245. */
  69246. add(other: DeepImmutable<Matrix>): Matrix;
  69247. /**
  69248. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69249. * @param other defines the matrix to add
  69250. * @param result defines the target matrix
  69251. * @returns the current matrix
  69252. */
  69253. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69254. /**
  69255. * Adds in place the given matrix to the current matrix
  69256. * @param other defines the second operand
  69257. * @returns the current updated matrix
  69258. */
  69259. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69260. /**
  69261. * Sets the given matrix to the current inverted Matrix
  69262. * @param other defines the target matrix
  69263. * @returns the unmodified current matrix
  69264. */
  69265. invertToRef(other: Matrix): Matrix;
  69266. /**
  69267. * add a value at the specified position in the current Matrix
  69268. * @param index the index of the value within the matrix. between 0 and 15.
  69269. * @param value the value to be added
  69270. * @returns the current updated matrix
  69271. */
  69272. addAtIndex(index: number, value: number): Matrix;
  69273. /**
  69274. * mutiply the specified position in the current Matrix by a value
  69275. * @param index the index of the value within the matrix. between 0 and 15.
  69276. * @param value the value to be added
  69277. * @returns the current updated matrix
  69278. */
  69279. multiplyAtIndex(index: number, value: number): Matrix;
  69280. /**
  69281. * Inserts the translation vector (using 3 floats) in the current matrix
  69282. * @param x defines the 1st component of the translation
  69283. * @param y defines the 2nd component of the translation
  69284. * @param z defines the 3rd component of the translation
  69285. * @returns the current updated matrix
  69286. */
  69287. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69288. /**
  69289. * Adds the translation vector (using 3 floats) in the current matrix
  69290. * @param x defines the 1st component of the translation
  69291. * @param y defines the 2nd component of the translation
  69292. * @param z defines the 3rd component of the translation
  69293. * @returns the current updated matrix
  69294. */
  69295. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69296. /**
  69297. * Inserts the translation vector in the current matrix
  69298. * @param vector3 defines the translation to insert
  69299. * @returns the current updated matrix
  69300. */
  69301. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69302. /**
  69303. * Gets the translation value of the current matrix
  69304. * @returns a new Vector3 as the extracted translation from the matrix
  69305. */
  69306. getTranslation(): Vector3;
  69307. /**
  69308. * Fill a Vector3 with the extracted translation from the matrix
  69309. * @param result defines the Vector3 where to store the translation
  69310. * @returns the current matrix
  69311. */
  69312. getTranslationToRef(result: Vector3): Matrix;
  69313. /**
  69314. * Remove rotation and scaling part from the matrix
  69315. * @returns the updated matrix
  69316. */
  69317. removeRotationAndScaling(): Matrix;
  69318. /**
  69319. * Multiply two matrices
  69320. * @param other defines the second operand
  69321. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69322. */
  69323. multiply(other: DeepImmutable<Matrix>): Matrix;
  69324. /**
  69325. * Copy the current matrix from the given one
  69326. * @param other defines the source matrix
  69327. * @returns the current updated matrix
  69328. */
  69329. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69330. /**
  69331. * Populates the given array from the starting index with the current matrix values
  69332. * @param array defines the target array
  69333. * @param offset defines the offset in the target array where to start storing values
  69334. * @returns the current matrix
  69335. */
  69336. copyToArray(array: Float32Array, offset?: number): Matrix;
  69337. /**
  69338. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69339. * @param other defines the second operand
  69340. * @param result defines the matrix where to store the multiplication
  69341. * @returns the current matrix
  69342. */
  69343. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69344. /**
  69345. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69346. * @param other defines the second operand
  69347. * @param result defines the array where to store the multiplication
  69348. * @param offset defines the offset in the target array where to start storing values
  69349. * @returns the current matrix
  69350. */
  69351. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69352. /**
  69353. * Check equality between this matrix and a second one
  69354. * @param value defines the second matrix to compare
  69355. * @returns true is the current matrix and the given one values are strictly equal
  69356. */
  69357. equals(value: DeepImmutable<Matrix>): boolean;
  69358. /**
  69359. * Clone the current matrix
  69360. * @returns a new matrix from the current matrix
  69361. */
  69362. clone(): Matrix;
  69363. /**
  69364. * Returns the name of the current matrix class
  69365. * @returns the string "Matrix"
  69366. */
  69367. getClassName(): string;
  69368. /**
  69369. * Gets the hash code of the current matrix
  69370. * @returns the hash code
  69371. */
  69372. getHashCode(): number;
  69373. /**
  69374. * Decomposes the current Matrix into a translation, rotation and scaling components
  69375. * @param scale defines the scale vector3 given as a reference to update
  69376. * @param rotation defines the rotation quaternion given as a reference to update
  69377. * @param translation defines the translation vector3 given as a reference to update
  69378. * @returns true if operation was successful
  69379. */
  69380. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69381. /**
  69382. * Gets specific row of the matrix
  69383. * @param index defines the number of the row to get
  69384. * @returns the index-th row of the current matrix as a new Vector4
  69385. */
  69386. getRow(index: number): Nullable<Vector4>;
  69387. /**
  69388. * Sets the index-th row of the current matrix to the vector4 values
  69389. * @param index defines the number of the row to set
  69390. * @param row defines the target vector4
  69391. * @returns the updated current matrix
  69392. */
  69393. setRow(index: number, row: Vector4): Matrix;
  69394. /**
  69395. * Compute the transpose of the matrix
  69396. * @returns the new transposed matrix
  69397. */
  69398. transpose(): Matrix;
  69399. /**
  69400. * Compute the transpose of the matrix and store it in a given matrix
  69401. * @param result defines the target matrix
  69402. * @returns the current matrix
  69403. */
  69404. transposeToRef(result: Matrix): Matrix;
  69405. /**
  69406. * Sets the index-th row of the current matrix with the given 4 x float values
  69407. * @param index defines the row index
  69408. * @param x defines the x component to set
  69409. * @param y defines the y component to set
  69410. * @param z defines the z component to set
  69411. * @param w defines the w component to set
  69412. * @returns the updated current matrix
  69413. */
  69414. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69415. /**
  69416. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69417. * @param scale defines the scale factor
  69418. * @returns a new matrix
  69419. */
  69420. scale(scale: number): Matrix;
  69421. /**
  69422. * Scale the current matrix values by a factor to a given result matrix
  69423. * @param scale defines the scale factor
  69424. * @param result defines the matrix to store the result
  69425. * @returns the current matrix
  69426. */
  69427. scaleToRef(scale: number, result: Matrix): Matrix;
  69428. /**
  69429. * Scale the current matrix values by a factor and add the result to a given matrix
  69430. * @param scale defines the scale factor
  69431. * @param result defines the Matrix to store the result
  69432. * @returns the current matrix
  69433. */
  69434. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69435. /**
  69436. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69437. * @param ref matrix to store the result
  69438. */
  69439. toNormalMatrix(ref: Matrix): void;
  69440. /**
  69441. * Gets only rotation part of the current matrix
  69442. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69443. */
  69444. getRotationMatrix(): Matrix;
  69445. /**
  69446. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69447. * @param result defines the target matrix to store data to
  69448. * @returns the current matrix
  69449. */
  69450. getRotationMatrixToRef(result: Matrix): Matrix;
  69451. /**
  69452. * Toggles model matrix from being right handed to left handed in place and vice versa
  69453. */
  69454. toggleModelMatrixHandInPlace(): void;
  69455. /**
  69456. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69457. */
  69458. toggleProjectionMatrixHandInPlace(): void;
  69459. /**
  69460. * Creates a matrix from an array
  69461. * @param array defines the source array
  69462. * @param offset defines an offset in the source array
  69463. * @returns a new Matrix set from the starting index of the given array
  69464. */
  69465. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69466. /**
  69467. * Copy the content of an array into a given matrix
  69468. * @param array defines the source array
  69469. * @param offset defines an offset in the source array
  69470. * @param result defines the target matrix
  69471. */
  69472. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69473. /**
  69474. * Stores an array into a matrix after having multiplied each component by a given factor
  69475. * @param array defines the source array
  69476. * @param offset defines the offset in the source array
  69477. * @param scale defines the scaling factor
  69478. * @param result defines the target matrix
  69479. */
  69480. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69481. /**
  69482. * Gets an identity matrix that must not be updated
  69483. */
  69484. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69485. /**
  69486. * Stores a list of values (16) inside a given matrix
  69487. * @param initialM11 defines 1st value of 1st row
  69488. * @param initialM12 defines 2nd value of 1st row
  69489. * @param initialM13 defines 3rd value of 1st row
  69490. * @param initialM14 defines 4th value of 1st row
  69491. * @param initialM21 defines 1st value of 2nd row
  69492. * @param initialM22 defines 2nd value of 2nd row
  69493. * @param initialM23 defines 3rd value of 2nd row
  69494. * @param initialM24 defines 4th value of 2nd row
  69495. * @param initialM31 defines 1st value of 3rd row
  69496. * @param initialM32 defines 2nd value of 3rd row
  69497. * @param initialM33 defines 3rd value of 3rd row
  69498. * @param initialM34 defines 4th value of 3rd row
  69499. * @param initialM41 defines 1st value of 4th row
  69500. * @param initialM42 defines 2nd value of 4th row
  69501. * @param initialM43 defines 3rd value of 4th row
  69502. * @param initialM44 defines 4th value of 4th row
  69503. * @param result defines the target matrix
  69504. */
  69505. 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;
  69506. /**
  69507. * Creates new matrix from a list of values (16)
  69508. * @param initialM11 defines 1st value of 1st row
  69509. * @param initialM12 defines 2nd value of 1st row
  69510. * @param initialM13 defines 3rd value of 1st row
  69511. * @param initialM14 defines 4th value of 1st row
  69512. * @param initialM21 defines 1st value of 2nd row
  69513. * @param initialM22 defines 2nd value of 2nd row
  69514. * @param initialM23 defines 3rd value of 2nd row
  69515. * @param initialM24 defines 4th value of 2nd row
  69516. * @param initialM31 defines 1st value of 3rd row
  69517. * @param initialM32 defines 2nd value of 3rd row
  69518. * @param initialM33 defines 3rd value of 3rd row
  69519. * @param initialM34 defines 4th value of 3rd row
  69520. * @param initialM41 defines 1st value of 4th row
  69521. * @param initialM42 defines 2nd value of 4th row
  69522. * @param initialM43 defines 3rd value of 4th row
  69523. * @param initialM44 defines 4th value of 4th row
  69524. * @returns the new matrix
  69525. */
  69526. 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;
  69527. /**
  69528. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69529. * @param scale defines the scale vector3
  69530. * @param rotation defines the rotation quaternion
  69531. * @param translation defines the translation vector3
  69532. * @returns a new matrix
  69533. */
  69534. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69535. /**
  69536. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69537. * @param scale defines the scale vector3
  69538. * @param rotation defines the rotation quaternion
  69539. * @param translation defines the translation vector3
  69540. * @param result defines the target matrix
  69541. */
  69542. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69543. /**
  69544. * Creates a new identity matrix
  69545. * @returns a new identity matrix
  69546. */
  69547. static Identity(): Matrix;
  69548. /**
  69549. * Creates a new identity matrix and stores the result in a given matrix
  69550. * @param result defines the target matrix
  69551. */
  69552. static IdentityToRef(result: Matrix): void;
  69553. /**
  69554. * Creates a new zero matrix
  69555. * @returns a new zero matrix
  69556. */
  69557. static Zero(): Matrix;
  69558. /**
  69559. * Creates a new rotation matrix for "angle" radians around the X axis
  69560. * @param angle defines the angle (in radians) to use
  69561. * @return the new matrix
  69562. */
  69563. static RotationX(angle: number): Matrix;
  69564. /**
  69565. * Creates a new matrix as the invert of a given matrix
  69566. * @param source defines the source matrix
  69567. * @returns the new matrix
  69568. */
  69569. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69570. /**
  69571. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69572. * @param angle defines the angle (in radians) to use
  69573. * @param result defines the target matrix
  69574. */
  69575. static RotationXToRef(angle: number, result: Matrix): void;
  69576. /**
  69577. * Creates a new rotation matrix for "angle" radians around the Y axis
  69578. * @param angle defines the angle (in radians) to use
  69579. * @return the new matrix
  69580. */
  69581. static RotationY(angle: number): Matrix;
  69582. /**
  69583. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69584. * @param angle defines the angle (in radians) to use
  69585. * @param result defines the target matrix
  69586. */
  69587. static RotationYToRef(angle: number, result: Matrix): void;
  69588. /**
  69589. * Creates a new rotation matrix for "angle" radians around the Z axis
  69590. * @param angle defines the angle (in radians) to use
  69591. * @return the new matrix
  69592. */
  69593. static RotationZ(angle: number): Matrix;
  69594. /**
  69595. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69596. * @param angle defines the angle (in radians) to use
  69597. * @param result defines the target matrix
  69598. */
  69599. static RotationZToRef(angle: number, result: Matrix): void;
  69600. /**
  69601. * Creates a new rotation matrix for "angle" radians around the given axis
  69602. * @param axis defines the axis to use
  69603. * @param angle defines the angle (in radians) to use
  69604. * @return the new matrix
  69605. */
  69606. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69607. /**
  69608. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69609. * @param axis defines the axis to use
  69610. * @param angle defines the angle (in radians) to use
  69611. * @param result defines the target matrix
  69612. */
  69613. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69614. /**
  69615. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69616. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69617. * @param from defines the vector to align
  69618. * @param to defines the vector to align to
  69619. * @param result defines the target matrix
  69620. */
  69621. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69622. /**
  69623. * Creates a rotation matrix
  69624. * @param yaw defines the yaw angle in radians (Y axis)
  69625. * @param pitch defines the pitch angle in radians (X axis)
  69626. * @param roll defines the roll angle in radians (X axis)
  69627. * @returns the new rotation matrix
  69628. */
  69629. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69630. /**
  69631. * Creates a rotation matrix and stores it in a given matrix
  69632. * @param yaw defines the yaw angle in radians (Y axis)
  69633. * @param pitch defines the pitch angle in radians (X axis)
  69634. * @param roll defines the roll angle in radians (X axis)
  69635. * @param result defines the target matrix
  69636. */
  69637. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69638. /**
  69639. * Creates a scaling matrix
  69640. * @param x defines the scale factor on X axis
  69641. * @param y defines the scale factor on Y axis
  69642. * @param z defines the scale factor on Z axis
  69643. * @returns the new matrix
  69644. */
  69645. static Scaling(x: number, y: number, z: number): Matrix;
  69646. /**
  69647. * Creates a scaling matrix and stores it in a given matrix
  69648. * @param x defines the scale factor on X axis
  69649. * @param y defines the scale factor on Y axis
  69650. * @param z defines the scale factor on Z axis
  69651. * @param result defines the target matrix
  69652. */
  69653. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69654. /**
  69655. * Creates a translation matrix
  69656. * @param x defines the translation on X axis
  69657. * @param y defines the translation on Y axis
  69658. * @param z defines the translationon Z axis
  69659. * @returns the new matrix
  69660. */
  69661. static Translation(x: number, y: number, z: number): Matrix;
  69662. /**
  69663. * Creates a translation matrix and stores it in a given matrix
  69664. * @param x defines the translation on X axis
  69665. * @param y defines the translation on Y axis
  69666. * @param z defines the translationon Z axis
  69667. * @param result defines the target matrix
  69668. */
  69669. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69670. /**
  69671. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69672. * @param startValue defines the start value
  69673. * @param endValue defines the end value
  69674. * @param gradient defines the gradient factor
  69675. * @returns the new matrix
  69676. */
  69677. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69678. /**
  69679. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69680. * @param startValue defines the start value
  69681. * @param endValue defines the end value
  69682. * @param gradient defines the gradient factor
  69683. * @param result defines the Matrix object where to store data
  69684. */
  69685. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69686. /**
  69687. * Builds a new matrix whose values are computed by:
  69688. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69689. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69690. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69691. * @param startValue defines the first matrix
  69692. * @param endValue defines the second matrix
  69693. * @param gradient defines the gradient between the two matrices
  69694. * @returns the new matrix
  69695. */
  69696. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69697. /**
  69698. * Update a matrix to values which are computed by:
  69699. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69700. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69701. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69702. * @param startValue defines the first matrix
  69703. * @param endValue defines the second matrix
  69704. * @param gradient defines the gradient between the two matrices
  69705. * @param result defines the target matrix
  69706. */
  69707. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69708. /**
  69709. * 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"
  69710. * This function works in left handed mode
  69711. * @param eye defines the final position of the entity
  69712. * @param target defines where the entity should look at
  69713. * @param up defines the up vector for the entity
  69714. * @returns the new matrix
  69715. */
  69716. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69717. /**
  69718. * 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".
  69719. * This function works in left handed mode
  69720. * @param eye defines the final position of the entity
  69721. * @param target defines where the entity should look at
  69722. * @param up defines the up vector for the entity
  69723. * @param result defines the target matrix
  69724. */
  69725. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69726. /**
  69727. * 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"
  69728. * This function works in right handed mode
  69729. * @param eye defines the final position of the entity
  69730. * @param target defines where the entity should look at
  69731. * @param up defines the up vector for the entity
  69732. * @returns the new matrix
  69733. */
  69734. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69735. /**
  69736. * 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".
  69737. * This function works in right handed mode
  69738. * @param eye defines the final position of the entity
  69739. * @param target defines where the entity should look at
  69740. * @param up defines the up vector for the entity
  69741. * @param result defines the target matrix
  69742. */
  69743. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69744. /**
  69745. * Create a left-handed orthographic projection matrix
  69746. * @param width defines the viewport width
  69747. * @param height defines the viewport height
  69748. * @param znear defines the near clip plane
  69749. * @param zfar defines the far clip plane
  69750. * @returns a new matrix as a left-handed orthographic projection matrix
  69751. */
  69752. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69753. /**
  69754. * Store a left-handed orthographic projection to a given matrix
  69755. * @param width defines the viewport width
  69756. * @param height defines the viewport height
  69757. * @param znear defines the near clip plane
  69758. * @param zfar defines the far clip plane
  69759. * @param result defines the target matrix
  69760. */
  69761. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69762. /**
  69763. * Create a left-handed orthographic projection matrix
  69764. * @param left defines the viewport left coordinate
  69765. * @param right defines the viewport right coordinate
  69766. * @param bottom defines the viewport bottom coordinate
  69767. * @param top defines the viewport top coordinate
  69768. * @param znear defines the near clip plane
  69769. * @param zfar defines the far clip plane
  69770. * @returns a new matrix as a left-handed orthographic projection matrix
  69771. */
  69772. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69773. /**
  69774. * Stores a left-handed orthographic projection into a given matrix
  69775. * @param left defines the viewport left coordinate
  69776. * @param right defines the viewport right coordinate
  69777. * @param bottom defines the viewport bottom coordinate
  69778. * @param top defines the viewport top coordinate
  69779. * @param znear defines the near clip plane
  69780. * @param zfar defines the far clip plane
  69781. * @param result defines the target matrix
  69782. */
  69783. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69784. /**
  69785. * Creates a right-handed orthographic projection matrix
  69786. * @param left defines the viewport left coordinate
  69787. * @param right defines the viewport right coordinate
  69788. * @param bottom defines the viewport bottom coordinate
  69789. * @param top defines the viewport top coordinate
  69790. * @param znear defines the near clip plane
  69791. * @param zfar defines the far clip plane
  69792. * @returns a new matrix as a right-handed orthographic projection matrix
  69793. */
  69794. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69795. /**
  69796. * Stores a right-handed orthographic projection into a given matrix
  69797. * @param left defines the viewport left coordinate
  69798. * @param right defines the viewport right coordinate
  69799. * @param bottom defines the viewport bottom coordinate
  69800. * @param top defines the viewport top coordinate
  69801. * @param znear defines the near clip plane
  69802. * @param zfar defines the far clip plane
  69803. * @param result defines the target matrix
  69804. */
  69805. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69806. /**
  69807. * Creates a left-handed perspective projection matrix
  69808. * @param width defines the viewport width
  69809. * @param height defines the viewport height
  69810. * @param znear defines the near clip plane
  69811. * @param zfar defines the far clip plane
  69812. * @returns a new matrix as a left-handed perspective projection matrix
  69813. */
  69814. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69815. /**
  69816. * Creates a left-handed perspective projection matrix
  69817. * @param fov defines the horizontal field of view
  69818. * @param aspect defines the aspect ratio
  69819. * @param znear defines the near clip plane
  69820. * @param zfar defines the far clip plane
  69821. * @returns a new matrix as a left-handed perspective projection matrix
  69822. */
  69823. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69824. /**
  69825. * Stores a left-handed perspective projection into a given matrix
  69826. * @param fov defines the horizontal field of view
  69827. * @param aspect defines the aspect ratio
  69828. * @param znear defines the near clip plane
  69829. * @param zfar defines the far clip plane
  69830. * @param result defines the target matrix
  69831. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69832. */
  69833. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69834. /**
  69835. * Creates a right-handed perspective projection matrix
  69836. * @param fov defines the horizontal field of view
  69837. * @param aspect defines the aspect ratio
  69838. * @param znear defines the near clip plane
  69839. * @param zfar defines the far clip plane
  69840. * @returns a new matrix as a right-handed perspective projection matrix
  69841. */
  69842. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69843. /**
  69844. * Stores a right-handed perspective projection into a given matrix
  69845. * @param fov defines the horizontal field of view
  69846. * @param aspect defines the aspect ratio
  69847. * @param znear defines the near clip plane
  69848. * @param zfar defines the far clip plane
  69849. * @param result defines the target matrix
  69850. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69851. */
  69852. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69853. /**
  69854. * Stores a perspective projection for WebVR info a given matrix
  69855. * @param fov defines the field of view
  69856. * @param znear defines the near clip plane
  69857. * @param zfar defines the far clip plane
  69858. * @param result defines the target matrix
  69859. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69860. */
  69861. static PerspectiveFovWebVRToRef(fov: {
  69862. upDegrees: number;
  69863. downDegrees: number;
  69864. leftDegrees: number;
  69865. rightDegrees: number;
  69866. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69867. /**
  69868. * Computes a complete transformation matrix
  69869. * @param viewport defines the viewport to use
  69870. * @param world defines the world matrix
  69871. * @param view defines the view matrix
  69872. * @param projection defines the projection matrix
  69873. * @param zmin defines the near clip plane
  69874. * @param zmax defines the far clip plane
  69875. * @returns the transformation matrix
  69876. */
  69877. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69878. /**
  69879. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69880. * @param matrix defines the matrix to use
  69881. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69882. */
  69883. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69884. /**
  69885. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69886. * @param matrix defines the matrix to use
  69887. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69888. */
  69889. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69890. /**
  69891. * Compute the transpose of a given matrix
  69892. * @param matrix defines the matrix to transpose
  69893. * @returns the new matrix
  69894. */
  69895. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69896. /**
  69897. * Compute the transpose of a matrix and store it in a target matrix
  69898. * @param matrix defines the matrix to transpose
  69899. * @param result defines the target matrix
  69900. */
  69901. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69902. /**
  69903. * Computes a reflection matrix from a plane
  69904. * @param plane defines the reflection plane
  69905. * @returns a new matrix
  69906. */
  69907. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69908. /**
  69909. * Computes a reflection matrix from a plane
  69910. * @param plane defines the reflection plane
  69911. * @param result defines the target matrix
  69912. */
  69913. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69914. /**
  69915. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69916. * @param xaxis defines the value of the 1st axis
  69917. * @param yaxis defines the value of the 2nd axis
  69918. * @param zaxis defines the value of the 3rd axis
  69919. * @param result defines the target matrix
  69920. */
  69921. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69922. /**
  69923. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69924. * @param quat defines the quaternion to use
  69925. * @param result defines the target matrix
  69926. */
  69927. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69928. }
  69929. /**
  69930. * @hidden
  69931. */
  69932. export class TmpVectors {
  69933. static Vector2: Vector2[];
  69934. static Vector3: Vector3[];
  69935. static Vector4: Vector4[];
  69936. static Quaternion: Quaternion[];
  69937. static Matrix: Matrix[];
  69938. }
  69939. }
  69940. declare module BABYLON {
  69941. /** Defines the cross module used constants to avoid circular dependncies */
  69942. export class Constants {
  69943. /** Defines that alpha blending is disabled */
  69944. static readonly ALPHA_DISABLE: number;
  69945. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69946. static readonly ALPHA_ADD: number;
  69947. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69948. static readonly ALPHA_COMBINE: number;
  69949. /** Defines that alpha blending to DEST - SRC * DEST */
  69950. static readonly ALPHA_SUBTRACT: number;
  69951. /** Defines that alpha blending to SRC * DEST */
  69952. static readonly ALPHA_MULTIPLY: number;
  69953. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69954. static readonly ALPHA_MAXIMIZED: number;
  69955. /** Defines that alpha blending to SRC + DEST */
  69956. static readonly ALPHA_ONEONE: number;
  69957. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69958. static readonly ALPHA_PREMULTIPLIED: number;
  69959. /**
  69960. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69961. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69962. */
  69963. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69964. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69965. static readonly ALPHA_INTERPOLATE: number;
  69966. /**
  69967. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69968. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69969. */
  69970. static readonly ALPHA_SCREENMODE: number;
  69971. /**
  69972. * Defines that alpha blending to SRC + DST
  69973. * Alpha will be set to SRC ALPHA + DST ALPHA
  69974. */
  69975. static readonly ALPHA_ONEONE_ONEONE: number;
  69976. /**
  69977. * Defines that alpha blending to SRC * DST ALPHA + DST
  69978. * Alpha will be set to 0
  69979. */
  69980. static readonly ALPHA_ALPHATOCOLOR: number;
  69981. /**
  69982. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  69983. */
  69984. static readonly ALPHA_REVERSEONEMINUS: number;
  69985. /**
  69986. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  69987. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  69988. */
  69989. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  69990. /**
  69991. * Defines that alpha blending to SRC + DST
  69992. * Alpha will be set to SRC ALPHA
  69993. */
  69994. static readonly ALPHA_ONEONE_ONEZERO: number;
  69995. /** Defines that alpha blending equation a SUM */
  69996. static readonly ALPHA_EQUATION_ADD: number;
  69997. /** Defines that alpha blending equation a SUBSTRACTION */
  69998. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  69999. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  70000. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  70001. /** Defines that alpha blending equation a MAX operation */
  70002. static readonly ALPHA_EQUATION_MAX: number;
  70003. /** Defines that alpha blending equation a MIN operation */
  70004. static readonly ALPHA_EQUATION_MIN: number;
  70005. /**
  70006. * Defines that alpha blending equation a DARKEN operation:
  70007. * It takes the min of the src and sums the alpha channels.
  70008. */
  70009. static readonly ALPHA_EQUATION_DARKEN: number;
  70010. /** Defines that the ressource is not delayed*/
  70011. static readonly DELAYLOADSTATE_NONE: number;
  70012. /** Defines that the ressource was successfully delay loaded */
  70013. static readonly DELAYLOADSTATE_LOADED: number;
  70014. /** Defines that the ressource is currently delay loading */
  70015. static readonly DELAYLOADSTATE_LOADING: number;
  70016. /** Defines that the ressource is delayed and has not started loading */
  70017. static readonly DELAYLOADSTATE_NOTLOADED: number;
  70018. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  70019. static readonly NEVER: number;
  70020. /** 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 */
  70021. static readonly ALWAYS: number;
  70022. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  70023. static readonly LESS: number;
  70024. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  70025. static readonly EQUAL: number;
  70026. /** 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 */
  70027. static readonly LEQUAL: number;
  70028. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  70029. static readonly GREATER: number;
  70030. /** 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 */
  70031. static readonly GEQUAL: number;
  70032. /** 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 */
  70033. static readonly NOTEQUAL: number;
  70034. /** Passed to stencilOperation to specify that stencil value must be kept */
  70035. static readonly KEEP: number;
  70036. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70037. static readonly REPLACE: number;
  70038. /** Passed to stencilOperation to specify that stencil value must be incremented */
  70039. static readonly INCR: number;
  70040. /** Passed to stencilOperation to specify that stencil value must be decremented */
  70041. static readonly DECR: number;
  70042. /** Passed to stencilOperation to specify that stencil value must be inverted */
  70043. static readonly INVERT: number;
  70044. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  70045. static readonly INCR_WRAP: number;
  70046. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  70047. static readonly DECR_WRAP: number;
  70048. /** Texture is not repeating outside of 0..1 UVs */
  70049. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  70050. /** Texture is repeating outside of 0..1 UVs */
  70051. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  70052. /** Texture is repeating and mirrored */
  70053. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  70054. /** ALPHA */
  70055. static readonly TEXTUREFORMAT_ALPHA: number;
  70056. /** LUMINANCE */
  70057. static readonly TEXTUREFORMAT_LUMINANCE: number;
  70058. /** LUMINANCE_ALPHA */
  70059. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  70060. /** RGB */
  70061. static readonly TEXTUREFORMAT_RGB: number;
  70062. /** RGBA */
  70063. static readonly TEXTUREFORMAT_RGBA: number;
  70064. /** RED */
  70065. static readonly TEXTUREFORMAT_RED: number;
  70066. /** RED (2nd reference) */
  70067. static readonly TEXTUREFORMAT_R: number;
  70068. /** RG */
  70069. static readonly TEXTUREFORMAT_RG: number;
  70070. /** RED_INTEGER */
  70071. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  70072. /** RED_INTEGER (2nd reference) */
  70073. static readonly TEXTUREFORMAT_R_INTEGER: number;
  70074. /** RG_INTEGER */
  70075. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  70076. /** RGB_INTEGER */
  70077. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  70078. /** RGBA_INTEGER */
  70079. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  70080. /** UNSIGNED_BYTE */
  70081. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  70082. /** UNSIGNED_BYTE (2nd reference) */
  70083. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  70084. /** FLOAT */
  70085. static readonly TEXTURETYPE_FLOAT: number;
  70086. /** HALF_FLOAT */
  70087. static readonly TEXTURETYPE_HALF_FLOAT: number;
  70088. /** BYTE */
  70089. static readonly TEXTURETYPE_BYTE: number;
  70090. /** SHORT */
  70091. static readonly TEXTURETYPE_SHORT: number;
  70092. /** UNSIGNED_SHORT */
  70093. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  70094. /** INT */
  70095. static readonly TEXTURETYPE_INT: number;
  70096. /** UNSIGNED_INT */
  70097. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  70098. /** UNSIGNED_SHORT_4_4_4_4 */
  70099. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  70100. /** UNSIGNED_SHORT_5_5_5_1 */
  70101. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  70102. /** UNSIGNED_SHORT_5_6_5 */
  70103. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  70104. /** UNSIGNED_INT_2_10_10_10_REV */
  70105. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  70106. /** UNSIGNED_INT_24_8 */
  70107. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  70108. /** UNSIGNED_INT_10F_11F_11F_REV */
  70109. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  70110. /** UNSIGNED_INT_5_9_9_9_REV */
  70111. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  70112. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  70113. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70114. /** nearest is mag = nearest and min = nearest and mip = linear */
  70115. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  70116. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70117. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  70118. /** Trilinear is mag = linear and min = linear and mip = linear */
  70119. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  70120. /** nearest is mag = nearest and min = nearest and mip = linear */
  70121. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  70122. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70123. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  70124. /** Trilinear is mag = linear and min = linear and mip = linear */
  70125. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  70126. /** mag = nearest and min = nearest and mip = nearest */
  70127. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  70128. /** mag = nearest and min = linear and mip = nearest */
  70129. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  70130. /** mag = nearest and min = linear and mip = linear */
  70131. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  70132. /** mag = nearest and min = linear and mip = none */
  70133. static readonly TEXTURE_NEAREST_LINEAR: number;
  70134. /** mag = nearest and min = nearest and mip = none */
  70135. static readonly TEXTURE_NEAREST_NEAREST: number;
  70136. /** mag = linear and min = nearest and mip = nearest */
  70137. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  70138. /** mag = linear and min = nearest and mip = linear */
  70139. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  70140. /** mag = linear and min = linear and mip = none */
  70141. static readonly TEXTURE_LINEAR_LINEAR: number;
  70142. /** mag = linear and min = nearest and mip = none */
  70143. static readonly TEXTURE_LINEAR_NEAREST: number;
  70144. /** Explicit coordinates mode */
  70145. static readonly TEXTURE_EXPLICIT_MODE: number;
  70146. /** Spherical coordinates mode */
  70147. static readonly TEXTURE_SPHERICAL_MODE: number;
  70148. /** Planar coordinates mode */
  70149. static readonly TEXTURE_PLANAR_MODE: number;
  70150. /** Cubic coordinates mode */
  70151. static readonly TEXTURE_CUBIC_MODE: number;
  70152. /** Projection coordinates mode */
  70153. static readonly TEXTURE_PROJECTION_MODE: number;
  70154. /** Skybox coordinates mode */
  70155. static readonly TEXTURE_SKYBOX_MODE: number;
  70156. /** Inverse Cubic coordinates mode */
  70157. static readonly TEXTURE_INVCUBIC_MODE: number;
  70158. /** Equirectangular coordinates mode */
  70159. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  70160. /** Equirectangular Fixed coordinates mode */
  70161. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  70162. /** Equirectangular Fixed Mirrored coordinates mode */
  70163. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  70164. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  70165. static readonly SCALEMODE_FLOOR: number;
  70166. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70167. static readonly SCALEMODE_NEAREST: number;
  70168. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70169. static readonly SCALEMODE_CEILING: number;
  70170. /**
  70171. * The dirty texture flag value
  70172. */
  70173. static readonly MATERIAL_TextureDirtyFlag: number;
  70174. /**
  70175. * The dirty light flag value
  70176. */
  70177. static readonly MATERIAL_LightDirtyFlag: number;
  70178. /**
  70179. * The dirty fresnel flag value
  70180. */
  70181. static readonly MATERIAL_FresnelDirtyFlag: number;
  70182. /**
  70183. * The dirty attribute flag value
  70184. */
  70185. static readonly MATERIAL_AttributesDirtyFlag: number;
  70186. /**
  70187. * The dirty misc flag value
  70188. */
  70189. static readonly MATERIAL_MiscDirtyFlag: number;
  70190. /**
  70191. * The all dirty flag value
  70192. */
  70193. static readonly MATERIAL_AllDirtyFlag: number;
  70194. /**
  70195. * Returns the triangle fill mode
  70196. */
  70197. static readonly MATERIAL_TriangleFillMode: number;
  70198. /**
  70199. * Returns the wireframe mode
  70200. */
  70201. static readonly MATERIAL_WireFrameFillMode: number;
  70202. /**
  70203. * Returns the point fill mode
  70204. */
  70205. static readonly MATERIAL_PointFillMode: number;
  70206. /**
  70207. * Returns the point list draw mode
  70208. */
  70209. static readonly MATERIAL_PointListDrawMode: number;
  70210. /**
  70211. * Returns the line list draw mode
  70212. */
  70213. static readonly MATERIAL_LineListDrawMode: number;
  70214. /**
  70215. * Returns the line loop draw mode
  70216. */
  70217. static readonly MATERIAL_LineLoopDrawMode: number;
  70218. /**
  70219. * Returns the line strip draw mode
  70220. */
  70221. static readonly MATERIAL_LineStripDrawMode: number;
  70222. /**
  70223. * Returns the triangle strip draw mode
  70224. */
  70225. static readonly MATERIAL_TriangleStripDrawMode: number;
  70226. /**
  70227. * Returns the triangle fan draw mode
  70228. */
  70229. static readonly MATERIAL_TriangleFanDrawMode: number;
  70230. /**
  70231. * Stores the clock-wise side orientation
  70232. */
  70233. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70234. /**
  70235. * Stores the counter clock-wise side orientation
  70236. */
  70237. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70238. /**
  70239. * Nothing
  70240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70241. */
  70242. static readonly ACTION_NothingTrigger: number;
  70243. /**
  70244. * On pick
  70245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70246. */
  70247. static readonly ACTION_OnPickTrigger: number;
  70248. /**
  70249. * On left pick
  70250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70251. */
  70252. static readonly ACTION_OnLeftPickTrigger: number;
  70253. /**
  70254. * On right pick
  70255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70256. */
  70257. static readonly ACTION_OnRightPickTrigger: number;
  70258. /**
  70259. * On center pick
  70260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70261. */
  70262. static readonly ACTION_OnCenterPickTrigger: number;
  70263. /**
  70264. * On pick down
  70265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70266. */
  70267. static readonly ACTION_OnPickDownTrigger: number;
  70268. /**
  70269. * On double pick
  70270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70271. */
  70272. static readonly ACTION_OnDoublePickTrigger: number;
  70273. /**
  70274. * On pick up
  70275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70276. */
  70277. static readonly ACTION_OnPickUpTrigger: number;
  70278. /**
  70279. * On pick out.
  70280. * This trigger will only be raised if you also declared a OnPickDown
  70281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70282. */
  70283. static readonly ACTION_OnPickOutTrigger: number;
  70284. /**
  70285. * On long press
  70286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70287. */
  70288. static readonly ACTION_OnLongPressTrigger: number;
  70289. /**
  70290. * On pointer over
  70291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70292. */
  70293. static readonly ACTION_OnPointerOverTrigger: number;
  70294. /**
  70295. * On pointer out
  70296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70297. */
  70298. static readonly ACTION_OnPointerOutTrigger: number;
  70299. /**
  70300. * On every frame
  70301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70302. */
  70303. static readonly ACTION_OnEveryFrameTrigger: number;
  70304. /**
  70305. * On intersection enter
  70306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70307. */
  70308. static readonly ACTION_OnIntersectionEnterTrigger: number;
  70309. /**
  70310. * On intersection exit
  70311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70312. */
  70313. static readonly ACTION_OnIntersectionExitTrigger: number;
  70314. /**
  70315. * On key down
  70316. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70317. */
  70318. static readonly ACTION_OnKeyDownTrigger: number;
  70319. /**
  70320. * On key up
  70321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70322. */
  70323. static readonly ACTION_OnKeyUpTrigger: number;
  70324. /**
  70325. * Billboard mode will only apply to Y axis
  70326. */
  70327. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  70328. /**
  70329. * Billboard mode will apply to all axes
  70330. */
  70331. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  70332. /**
  70333. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70334. */
  70335. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70336. /**
  70337. * Gets or sets base Assets URL
  70338. */
  70339. static PARTICLES_BaseAssetsUrl: string;
  70340. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70341. * Test order :
  70342. * Is the bounding sphere outside the frustum ?
  70343. * If not, are the bounding box vertices outside the frustum ?
  70344. * It not, then the cullable object is in the frustum.
  70345. */
  70346. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70347. /** Culling strategy : Bounding Sphere Only.
  70348. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70349. * It's also less accurate than the standard because some not visible objects can still be selected.
  70350. * Test : is the bounding sphere outside the frustum ?
  70351. * If not, then the cullable object is in the frustum.
  70352. */
  70353. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70354. /** Culling strategy : Optimistic Inclusion.
  70355. * This in an inclusion test first, then the standard exclusion test.
  70356. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70357. * 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.
  70358. * Anyway, it's as accurate as the standard strategy.
  70359. * Test :
  70360. * Is the cullable object bounding sphere center in the frustum ?
  70361. * If not, apply the default culling strategy.
  70362. */
  70363. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  70364. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  70365. * This in an inclusion test first, then the bounding sphere only exclusion test.
  70366. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  70367. * 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.
  70368. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  70369. * Test :
  70370. * Is the cullable object bounding sphere center in the frustum ?
  70371. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  70372. */
  70373. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  70374. /**
  70375. * No logging while loading
  70376. */
  70377. static readonly SCENELOADER_NO_LOGGING: number;
  70378. /**
  70379. * Minimal logging while loading
  70380. */
  70381. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  70382. /**
  70383. * Summary logging while loading
  70384. */
  70385. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  70386. /**
  70387. * Detailled logging while loading
  70388. */
  70389. static readonly SCENELOADER_DETAILED_LOGGING: number;
  70390. }
  70391. }
  70392. declare module BABYLON {
  70393. /**
  70394. * Class used to store and describe the pipeline context associated with an effect
  70395. */
  70396. export interface IPipelineContext {
  70397. /**
  70398. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70399. */
  70400. isAsync: boolean;
  70401. /**
  70402. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70403. */
  70404. isReady: boolean;
  70405. /** @hidden */
  70406. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70407. }
  70408. }
  70409. declare module BABYLON {
  70410. /** @hidden */
  70411. export interface IShaderProcessor {
  70412. attributeProcessor?: (attribute: string) => string;
  70413. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70414. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70415. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70416. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70417. lineProcessor?: (line: string, isFragment: boolean) => string;
  70418. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70419. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70420. }
  70421. }
  70422. declare module BABYLON {
  70423. /** @hidden */
  70424. export interface ProcessingOptions {
  70425. defines: string[];
  70426. indexParameters: any;
  70427. isFragment: boolean;
  70428. shouldUseHighPrecisionShader: boolean;
  70429. supportsUniformBuffers: boolean;
  70430. shadersRepository: string;
  70431. includesShadersStore: {
  70432. [key: string]: string;
  70433. };
  70434. processor?: IShaderProcessor;
  70435. version: string;
  70436. platformName: string;
  70437. lookForClosingBracketForUniformBuffer?: boolean;
  70438. }
  70439. }
  70440. declare module BABYLON {
  70441. /**
  70442. * Helper to manipulate strings
  70443. */
  70444. export class StringTools {
  70445. /**
  70446. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70447. * @param str Source string
  70448. * @param suffix Suffix to search for in the source string
  70449. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70450. */
  70451. static EndsWith(str: string, suffix: string): boolean;
  70452. /**
  70453. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70454. * @param str Source string
  70455. * @param suffix Suffix to search for in the source string
  70456. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70457. */
  70458. static StartsWith(str: string, suffix: string): boolean;
  70459. }
  70460. }
  70461. declare module BABYLON {
  70462. /** @hidden */
  70463. export class ShaderCodeNode {
  70464. line: string;
  70465. children: ShaderCodeNode[];
  70466. additionalDefineKey?: string;
  70467. additionalDefineValue?: string;
  70468. isValid(preprocessors: {
  70469. [key: string]: string;
  70470. }): boolean;
  70471. process(preprocessors: {
  70472. [key: string]: string;
  70473. }, options: ProcessingOptions): string;
  70474. }
  70475. }
  70476. declare module BABYLON {
  70477. /** @hidden */
  70478. export class ShaderCodeCursor {
  70479. private _lines;
  70480. lineIndex: number;
  70481. readonly currentLine: string;
  70482. readonly canRead: boolean;
  70483. lines: string[];
  70484. }
  70485. }
  70486. declare module BABYLON {
  70487. /** @hidden */
  70488. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70489. process(preprocessors: {
  70490. [key: string]: string;
  70491. }, options: ProcessingOptions): string;
  70492. }
  70493. }
  70494. declare module BABYLON {
  70495. /** @hidden */
  70496. export class ShaderDefineExpression {
  70497. isTrue(preprocessors: {
  70498. [key: string]: string;
  70499. }): boolean;
  70500. }
  70501. }
  70502. declare module BABYLON {
  70503. /** @hidden */
  70504. export class ShaderCodeTestNode extends ShaderCodeNode {
  70505. testExpression: ShaderDefineExpression;
  70506. isValid(preprocessors: {
  70507. [key: string]: string;
  70508. }): boolean;
  70509. }
  70510. }
  70511. declare module BABYLON {
  70512. /** @hidden */
  70513. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70514. define: string;
  70515. not: boolean;
  70516. constructor(define: string, not?: boolean);
  70517. isTrue(preprocessors: {
  70518. [key: string]: string;
  70519. }): boolean;
  70520. }
  70521. }
  70522. declare module BABYLON {
  70523. /** @hidden */
  70524. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70525. leftOperand: ShaderDefineExpression;
  70526. rightOperand: ShaderDefineExpression;
  70527. isTrue(preprocessors: {
  70528. [key: string]: string;
  70529. }): boolean;
  70530. }
  70531. }
  70532. declare module BABYLON {
  70533. /** @hidden */
  70534. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70535. leftOperand: ShaderDefineExpression;
  70536. rightOperand: ShaderDefineExpression;
  70537. isTrue(preprocessors: {
  70538. [key: string]: string;
  70539. }): boolean;
  70540. }
  70541. }
  70542. declare module BABYLON {
  70543. /** @hidden */
  70544. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70545. define: string;
  70546. operand: string;
  70547. testValue: string;
  70548. constructor(define: string, operand: string, testValue: string);
  70549. isTrue(preprocessors: {
  70550. [key: string]: string;
  70551. }): boolean;
  70552. }
  70553. }
  70554. declare module BABYLON {
  70555. /**
  70556. * @ignore
  70557. * Application error to support additional information when loading a file
  70558. */
  70559. export class LoadFileError extends Error {
  70560. /** defines the optional web request */
  70561. request?: WebRequest | undefined;
  70562. private static _setPrototypeOf;
  70563. /**
  70564. * Creates a new LoadFileError
  70565. * @param message defines the message of the error
  70566. * @param request defines the optional web request
  70567. */
  70568. constructor(message: string,
  70569. /** defines the optional web request */
  70570. request?: WebRequest | undefined);
  70571. }
  70572. }
  70573. declare module BABYLON {
  70574. /**
  70575. * Class used to enable access to offline support
  70576. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70577. */
  70578. export interface IOfflineProvider {
  70579. /**
  70580. * Gets a boolean indicating if scene must be saved in the database
  70581. */
  70582. enableSceneOffline: boolean;
  70583. /**
  70584. * Gets a boolean indicating if textures must be saved in the database
  70585. */
  70586. enableTexturesOffline: boolean;
  70587. /**
  70588. * Open the offline support and make it available
  70589. * @param successCallback defines the callback to call on success
  70590. * @param errorCallback defines the callback to call on error
  70591. */
  70592. open(successCallback: () => void, errorCallback: () => void): void;
  70593. /**
  70594. * Loads an image from the offline support
  70595. * @param url defines the url to load from
  70596. * @param image defines the target DOM image
  70597. */
  70598. loadImage(url: string, image: HTMLImageElement): void;
  70599. /**
  70600. * Loads a file from offline support
  70601. * @param url defines the URL to load from
  70602. * @param sceneLoaded defines a callback to call on success
  70603. * @param progressCallBack defines a callback to call when progress changed
  70604. * @param errorCallback defines a callback to call on error
  70605. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70606. */
  70607. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70608. }
  70609. }
  70610. declare module BABYLON {
  70611. /**
  70612. * Class used to help managing file picking and drag'n'drop
  70613. * File Storage
  70614. */
  70615. export class FilesInputStore {
  70616. /**
  70617. * List of files ready to be loaded
  70618. */
  70619. static FilesToLoad: {
  70620. [key: string]: File;
  70621. };
  70622. }
  70623. }
  70624. declare module BABYLON {
  70625. /**
  70626. * Class used to define a retry strategy when error happens while loading assets
  70627. */
  70628. export class RetryStrategy {
  70629. /**
  70630. * Function used to defines an exponential back off strategy
  70631. * @param maxRetries defines the maximum number of retries (3 by default)
  70632. * @param baseInterval defines the interval between retries
  70633. * @returns the strategy function to use
  70634. */
  70635. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70636. }
  70637. }
  70638. declare module BABYLON {
  70639. /**
  70640. * @hidden
  70641. */
  70642. export class FileTools {
  70643. /**
  70644. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70645. */
  70646. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70647. /**
  70648. * Gets or sets the base URL to use to load assets
  70649. */
  70650. static BaseUrl: string;
  70651. /**
  70652. * Default behaviour for cors in the application.
  70653. * It can be a string if the expected behavior is identical in the entire app.
  70654. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70655. */
  70656. static CorsBehavior: string | ((url: string | string[]) => string);
  70657. /**
  70658. * Gets or sets a function used to pre-process url before using them to load assets
  70659. */
  70660. static PreprocessUrl: (url: string) => string;
  70661. /**
  70662. * Removes unwanted characters from an url
  70663. * @param url defines the url to clean
  70664. * @returns the cleaned url
  70665. */
  70666. private static _CleanUrl;
  70667. /**
  70668. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70669. * @param url define the url we are trying
  70670. * @param element define the dom element where to configure the cors policy
  70671. */
  70672. static SetCorsBehavior(url: string | string[], element: {
  70673. crossOrigin: string | null;
  70674. }): void;
  70675. /**
  70676. * Loads an image as an HTMLImageElement.
  70677. * @param input url string, ArrayBuffer, or Blob to load
  70678. * @param onLoad callback called when the image successfully loads
  70679. * @param onError callback called when the image fails to load
  70680. * @param offlineProvider offline provider for caching
  70681. * @returns the HTMLImageElement of the loaded image
  70682. */
  70683. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  70684. /**
  70685. * Loads a file
  70686. * @param fileToLoad defines the file to load
  70687. * @param callback defines the callback to call when data is loaded
  70688. * @param progressCallBack defines the callback to call during loading process
  70689. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70690. * @returns a file request object
  70691. */
  70692. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  70693. /**
  70694. * Loads a file
  70695. * @param url url string, ArrayBuffer, or Blob to load
  70696. * @param onSuccess callback called when the file successfully loads
  70697. * @param onProgress callback called while file is loading (if the server supports this mode)
  70698. * @param offlineProvider defines the offline provider for caching
  70699. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70700. * @param onError callback called when the file fails to load
  70701. * @returns a file request object
  70702. */
  70703. 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;
  70704. /**
  70705. * Checks if the loaded document was accessed via `file:`-Protocol.
  70706. * @returns boolean
  70707. */
  70708. static IsFileURL(): boolean;
  70709. }
  70710. }
  70711. declare module BABYLON {
  70712. /** @hidden */
  70713. export class ShaderProcessor {
  70714. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70715. private static _ProcessPrecision;
  70716. private static _ExtractOperation;
  70717. private static _BuildSubExpression;
  70718. private static _BuildExpression;
  70719. private static _MoveCursorWithinIf;
  70720. private static _MoveCursor;
  70721. private static _EvaluatePreProcessors;
  70722. private static _PreparePreProcessors;
  70723. private static _ProcessShaderConversion;
  70724. private static _ProcessIncludes;
  70725. }
  70726. }
  70727. declare module BABYLON {
  70728. /**
  70729. * Class used to hold a RBG color
  70730. */
  70731. export class Color3 {
  70732. /**
  70733. * Defines the red component (between 0 and 1, default is 0)
  70734. */
  70735. r: number;
  70736. /**
  70737. * Defines the green component (between 0 and 1, default is 0)
  70738. */
  70739. g: number;
  70740. /**
  70741. * Defines the blue component (between 0 and 1, default is 0)
  70742. */
  70743. b: number;
  70744. /**
  70745. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70746. * @param r defines the red component (between 0 and 1, default is 0)
  70747. * @param g defines the green component (between 0 and 1, default is 0)
  70748. * @param b defines the blue component (between 0 and 1, default is 0)
  70749. */
  70750. constructor(
  70751. /**
  70752. * Defines the red component (between 0 and 1, default is 0)
  70753. */
  70754. r?: number,
  70755. /**
  70756. * Defines the green component (between 0 and 1, default is 0)
  70757. */
  70758. g?: number,
  70759. /**
  70760. * Defines the blue component (between 0 and 1, default is 0)
  70761. */
  70762. b?: number);
  70763. /**
  70764. * Creates a string with the Color3 current values
  70765. * @returns the string representation of the Color3 object
  70766. */
  70767. toString(): string;
  70768. /**
  70769. * Returns the string "Color3"
  70770. * @returns "Color3"
  70771. */
  70772. getClassName(): string;
  70773. /**
  70774. * Compute the Color3 hash code
  70775. * @returns an unique number that can be used to hash Color3 objects
  70776. */
  70777. getHashCode(): number;
  70778. /**
  70779. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70780. * @param array defines the array where to store the r,g,b components
  70781. * @param index defines an optional index in the target array to define where to start storing values
  70782. * @returns the current Color3 object
  70783. */
  70784. toArray(array: FloatArray, index?: number): Color3;
  70785. /**
  70786. * Returns a new Color4 object from the current Color3 and the given alpha
  70787. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70788. * @returns a new Color4 object
  70789. */
  70790. toColor4(alpha?: number): Color4;
  70791. /**
  70792. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70793. * @returns the new array
  70794. */
  70795. asArray(): number[];
  70796. /**
  70797. * Returns the luminance value
  70798. * @returns a float value
  70799. */
  70800. toLuminance(): number;
  70801. /**
  70802. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70803. * @param otherColor defines the second operand
  70804. * @returns the new Color3 object
  70805. */
  70806. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70807. /**
  70808. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70809. * @param otherColor defines the second operand
  70810. * @param result defines the Color3 object where to store the result
  70811. * @returns the current Color3
  70812. */
  70813. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70814. /**
  70815. * Determines equality between Color3 objects
  70816. * @param otherColor defines the second operand
  70817. * @returns true if the rgb values are equal to the given ones
  70818. */
  70819. equals(otherColor: DeepImmutable<Color3>): boolean;
  70820. /**
  70821. * Determines equality between the current Color3 object and a set of r,b,g values
  70822. * @param r defines the red component to check
  70823. * @param g defines the green component to check
  70824. * @param b defines the blue component to check
  70825. * @returns true if the rgb values are equal to the given ones
  70826. */
  70827. equalsFloats(r: number, g: number, b: number): boolean;
  70828. /**
  70829. * Multiplies in place each rgb value by scale
  70830. * @param scale defines the scaling factor
  70831. * @returns the updated Color3
  70832. */
  70833. scale(scale: number): Color3;
  70834. /**
  70835. * Multiplies the rgb values by scale and stores the result into "result"
  70836. * @param scale defines the scaling factor
  70837. * @param result defines the Color3 object where to store the result
  70838. * @returns the unmodified current Color3
  70839. */
  70840. scaleToRef(scale: number, result: Color3): Color3;
  70841. /**
  70842. * Scale the current Color3 values by a factor and add the result to a given Color3
  70843. * @param scale defines the scale factor
  70844. * @param result defines color to store the result into
  70845. * @returns the unmodified current Color3
  70846. */
  70847. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70848. /**
  70849. * Clamps the rgb values by the min and max values and stores the result into "result"
  70850. * @param min defines minimum clamping value (default is 0)
  70851. * @param max defines maximum clamping value (default is 1)
  70852. * @param result defines color to store the result into
  70853. * @returns the original Color3
  70854. */
  70855. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70856. /**
  70857. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70858. * @param otherColor defines the second operand
  70859. * @returns the new Color3
  70860. */
  70861. add(otherColor: DeepImmutable<Color3>): Color3;
  70862. /**
  70863. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70864. * @param otherColor defines the second operand
  70865. * @param result defines Color3 object to store the result into
  70866. * @returns the unmodified current Color3
  70867. */
  70868. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70869. /**
  70870. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70871. * @param otherColor defines the second operand
  70872. * @returns the new Color3
  70873. */
  70874. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70875. /**
  70876. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70877. * @param otherColor defines the second operand
  70878. * @param result defines Color3 object to store the result into
  70879. * @returns the unmodified current Color3
  70880. */
  70881. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70882. /**
  70883. * Copy the current object
  70884. * @returns a new Color3 copied the current one
  70885. */
  70886. clone(): Color3;
  70887. /**
  70888. * Copies the rgb values from the source in the current Color3
  70889. * @param source defines the source Color3 object
  70890. * @returns the updated Color3 object
  70891. */
  70892. copyFrom(source: DeepImmutable<Color3>): Color3;
  70893. /**
  70894. * Updates the Color3 rgb values from the given floats
  70895. * @param r defines the red component to read from
  70896. * @param g defines the green component to read from
  70897. * @param b defines the blue component to read from
  70898. * @returns the current Color3 object
  70899. */
  70900. copyFromFloats(r: number, g: number, b: number): Color3;
  70901. /**
  70902. * Updates the Color3 rgb values from the given floats
  70903. * @param r defines the red component to read from
  70904. * @param g defines the green component to read from
  70905. * @param b defines the blue component to read from
  70906. * @returns the current Color3 object
  70907. */
  70908. set(r: number, g: number, b: number): Color3;
  70909. /**
  70910. * Compute the Color3 hexadecimal code as a string
  70911. * @returns a string containing the hexadecimal representation of the Color3 object
  70912. */
  70913. toHexString(): string;
  70914. /**
  70915. * Computes a new Color3 converted from the current one to linear space
  70916. * @returns a new Color3 object
  70917. */
  70918. toLinearSpace(): Color3;
  70919. /**
  70920. * Converts current color in rgb space to HSV values
  70921. * @returns a new color3 representing the HSV values
  70922. */
  70923. toHSV(): Color3;
  70924. /**
  70925. * Converts current color in rgb space to HSV values
  70926. * @param result defines the Color3 where to store the HSV values
  70927. */
  70928. toHSVToRef(result: Color3): void;
  70929. /**
  70930. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70931. * @param convertedColor defines the Color3 object where to store the linear space version
  70932. * @returns the unmodified Color3
  70933. */
  70934. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70935. /**
  70936. * Computes a new Color3 converted from the current one to gamma space
  70937. * @returns a new Color3 object
  70938. */
  70939. toGammaSpace(): Color3;
  70940. /**
  70941. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70942. * @param convertedColor defines the Color3 object where to store the gamma space version
  70943. * @returns the unmodified Color3
  70944. */
  70945. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70946. private static _BlackReadOnly;
  70947. /**
  70948. * Convert Hue, saturation and value to a Color3 (RGB)
  70949. * @param hue defines the hue
  70950. * @param saturation defines the saturation
  70951. * @param value defines the value
  70952. * @param result defines the Color3 where to store the RGB values
  70953. */
  70954. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70955. /**
  70956. * Creates a new Color3 from the string containing valid hexadecimal values
  70957. * @param hex defines a string containing valid hexadecimal values
  70958. * @returns a new Color3 object
  70959. */
  70960. static FromHexString(hex: string): Color3;
  70961. /**
  70962. * Creates a new Color3 from the starting index of the given array
  70963. * @param array defines the source array
  70964. * @param offset defines an offset in the source array
  70965. * @returns a new Color3 object
  70966. */
  70967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70968. /**
  70969. * Creates a new Color3 from integer values (< 256)
  70970. * @param r defines the red component to read from (value between 0 and 255)
  70971. * @param g defines the green component to read from (value between 0 and 255)
  70972. * @param b defines the blue component to read from (value between 0 and 255)
  70973. * @returns a new Color3 object
  70974. */
  70975. static FromInts(r: number, g: number, b: number): Color3;
  70976. /**
  70977. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70978. * @param start defines the start Color3 value
  70979. * @param end defines the end Color3 value
  70980. * @param amount defines the gradient value between start and end
  70981. * @returns a new Color3 object
  70982. */
  70983. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70984. /**
  70985. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70986. * @param left defines the start value
  70987. * @param right defines the end value
  70988. * @param amount defines the gradient factor
  70989. * @param result defines the Color3 object where to store the result
  70990. */
  70991. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70992. /**
  70993. * Returns a Color3 value containing a red color
  70994. * @returns a new Color3 object
  70995. */
  70996. static Red(): Color3;
  70997. /**
  70998. * Returns a Color3 value containing a green color
  70999. * @returns a new Color3 object
  71000. */
  71001. static Green(): Color3;
  71002. /**
  71003. * Returns a Color3 value containing a blue color
  71004. * @returns a new Color3 object
  71005. */
  71006. static Blue(): Color3;
  71007. /**
  71008. * Returns a Color3 value containing a black color
  71009. * @returns a new Color3 object
  71010. */
  71011. static Black(): Color3;
  71012. /**
  71013. * Gets a Color3 value containing a black color that must not be updated
  71014. */
  71015. static readonly BlackReadOnly: DeepImmutable<Color3>;
  71016. /**
  71017. * Returns a Color3 value containing a white color
  71018. * @returns a new Color3 object
  71019. */
  71020. static White(): Color3;
  71021. /**
  71022. * Returns a Color3 value containing a purple color
  71023. * @returns a new Color3 object
  71024. */
  71025. static Purple(): Color3;
  71026. /**
  71027. * Returns a Color3 value containing a magenta color
  71028. * @returns a new Color3 object
  71029. */
  71030. static Magenta(): Color3;
  71031. /**
  71032. * Returns a Color3 value containing a yellow color
  71033. * @returns a new Color3 object
  71034. */
  71035. static Yellow(): Color3;
  71036. /**
  71037. * Returns a Color3 value containing a gray color
  71038. * @returns a new Color3 object
  71039. */
  71040. static Gray(): Color3;
  71041. /**
  71042. * Returns a Color3 value containing a teal color
  71043. * @returns a new Color3 object
  71044. */
  71045. static Teal(): Color3;
  71046. /**
  71047. * Returns a Color3 value containing a random color
  71048. * @returns a new Color3 object
  71049. */
  71050. static Random(): Color3;
  71051. }
  71052. /**
  71053. * Class used to hold a RBGA color
  71054. */
  71055. export class Color4 {
  71056. /**
  71057. * Defines the red component (between 0 and 1, default is 0)
  71058. */
  71059. r: number;
  71060. /**
  71061. * Defines the green component (between 0 and 1, default is 0)
  71062. */
  71063. g: number;
  71064. /**
  71065. * Defines the blue component (between 0 and 1, default is 0)
  71066. */
  71067. b: number;
  71068. /**
  71069. * Defines the alpha component (between 0 and 1, default is 1)
  71070. */
  71071. a: number;
  71072. /**
  71073. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  71074. * @param r defines the red component (between 0 and 1, default is 0)
  71075. * @param g defines the green component (between 0 and 1, default is 0)
  71076. * @param b defines the blue component (between 0 and 1, default is 0)
  71077. * @param a defines the alpha component (between 0 and 1, default is 1)
  71078. */
  71079. constructor(
  71080. /**
  71081. * Defines the red component (between 0 and 1, default is 0)
  71082. */
  71083. r?: number,
  71084. /**
  71085. * Defines the green component (between 0 and 1, default is 0)
  71086. */
  71087. g?: number,
  71088. /**
  71089. * Defines the blue component (between 0 and 1, default is 0)
  71090. */
  71091. b?: number,
  71092. /**
  71093. * Defines the alpha component (between 0 and 1, default is 1)
  71094. */
  71095. a?: number);
  71096. /**
  71097. * Adds in place the given Color4 values to the current Color4 object
  71098. * @param right defines the second operand
  71099. * @returns the current updated Color4 object
  71100. */
  71101. addInPlace(right: DeepImmutable<Color4>): Color4;
  71102. /**
  71103. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  71104. * @returns the new array
  71105. */
  71106. asArray(): number[];
  71107. /**
  71108. * Stores from the starting index in the given array the Color4 successive values
  71109. * @param array defines the array where to store the r,g,b components
  71110. * @param index defines an optional index in the target array to define where to start storing values
  71111. * @returns the current Color4 object
  71112. */
  71113. toArray(array: number[], index?: number): Color4;
  71114. /**
  71115. * Determines equality between Color4 objects
  71116. * @param otherColor defines the second operand
  71117. * @returns true if the rgba values are equal to the given ones
  71118. */
  71119. equals(otherColor: DeepImmutable<Color4>): boolean;
  71120. /**
  71121. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  71122. * @param right defines the second operand
  71123. * @returns a new Color4 object
  71124. */
  71125. add(right: DeepImmutable<Color4>): Color4;
  71126. /**
  71127. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  71128. * @param right defines the second operand
  71129. * @returns a new Color4 object
  71130. */
  71131. subtract(right: DeepImmutable<Color4>): Color4;
  71132. /**
  71133. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  71134. * @param right defines the second operand
  71135. * @param result defines the Color4 object where to store the result
  71136. * @returns the current Color4 object
  71137. */
  71138. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  71139. /**
  71140. * Creates a new Color4 with the current Color4 values multiplied by scale
  71141. * @param scale defines the scaling factor to apply
  71142. * @returns a new Color4 object
  71143. */
  71144. scale(scale: number): Color4;
  71145. /**
  71146. * Multiplies the current Color4 values by scale and stores the result in "result"
  71147. * @param scale defines the scaling factor to apply
  71148. * @param result defines the Color4 object where to store the result
  71149. * @returns the current unmodified Color4
  71150. */
  71151. scaleToRef(scale: number, result: Color4): Color4;
  71152. /**
  71153. * Scale the current Color4 values by a factor and add the result to a given Color4
  71154. * @param scale defines the scale factor
  71155. * @param result defines the Color4 object where to store the result
  71156. * @returns the unmodified current Color4
  71157. */
  71158. scaleAndAddToRef(scale: number, result: Color4): Color4;
  71159. /**
  71160. * Clamps the rgb values by the min and max values and stores the result into "result"
  71161. * @param min defines minimum clamping value (default is 0)
  71162. * @param max defines maximum clamping value (default is 1)
  71163. * @param result defines color to store the result into.
  71164. * @returns the cuurent Color4
  71165. */
  71166. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  71167. /**
  71168. * Multipy an Color4 value by another and return a new Color4 object
  71169. * @param color defines the Color4 value to multiply by
  71170. * @returns a new Color4 object
  71171. */
  71172. multiply(color: Color4): Color4;
  71173. /**
  71174. * Multipy a Color4 value by another and push the result in a reference value
  71175. * @param color defines the Color4 value to multiply by
  71176. * @param result defines the Color4 to fill the result in
  71177. * @returns the result Color4
  71178. */
  71179. multiplyToRef(color: Color4, result: Color4): Color4;
  71180. /**
  71181. * Creates a string with the Color4 current values
  71182. * @returns the string representation of the Color4 object
  71183. */
  71184. toString(): string;
  71185. /**
  71186. * Returns the string "Color4"
  71187. * @returns "Color4"
  71188. */
  71189. getClassName(): string;
  71190. /**
  71191. * Compute the Color4 hash code
  71192. * @returns an unique number that can be used to hash Color4 objects
  71193. */
  71194. getHashCode(): number;
  71195. /**
  71196. * Creates a new Color4 copied from the current one
  71197. * @returns a new Color4 object
  71198. */
  71199. clone(): Color4;
  71200. /**
  71201. * Copies the given Color4 values into the current one
  71202. * @param source defines the source Color4 object
  71203. * @returns the current updated Color4 object
  71204. */
  71205. copyFrom(source: Color4): Color4;
  71206. /**
  71207. * Copies the given float values into the current one
  71208. * @param r defines the red component to read from
  71209. * @param g defines the green component to read from
  71210. * @param b defines the blue component to read from
  71211. * @param a defines the alpha component to read from
  71212. * @returns the current updated Color4 object
  71213. */
  71214. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  71215. /**
  71216. * Copies the given float values into the current one
  71217. * @param r defines the red component to read from
  71218. * @param g defines the green component to read from
  71219. * @param b defines the blue component to read from
  71220. * @param a defines the alpha component to read from
  71221. * @returns the current updated Color4 object
  71222. */
  71223. set(r: number, g: number, b: number, a: number): Color4;
  71224. /**
  71225. * Compute the Color4 hexadecimal code as a string
  71226. * @returns a string containing the hexadecimal representation of the Color4 object
  71227. */
  71228. toHexString(): string;
  71229. /**
  71230. * Computes a new Color4 converted from the current one to linear space
  71231. * @returns a new Color4 object
  71232. */
  71233. toLinearSpace(): Color4;
  71234. /**
  71235. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  71236. * @param convertedColor defines the Color4 object where to store the linear space version
  71237. * @returns the unmodified Color4
  71238. */
  71239. toLinearSpaceToRef(convertedColor: Color4): Color4;
  71240. /**
  71241. * Computes a new Color4 converted from the current one to gamma space
  71242. * @returns a new Color4 object
  71243. */
  71244. toGammaSpace(): Color4;
  71245. /**
  71246. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  71247. * @param convertedColor defines the Color4 object where to store the gamma space version
  71248. * @returns the unmodified Color4
  71249. */
  71250. toGammaSpaceToRef(convertedColor: Color4): Color4;
  71251. /**
  71252. * Creates a new Color4 from the string containing valid hexadecimal values
  71253. * @param hex defines a string containing valid hexadecimal values
  71254. * @returns a new Color4 object
  71255. */
  71256. static FromHexString(hex: string): Color4;
  71257. /**
  71258. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71259. * @param left defines the start value
  71260. * @param right defines the end value
  71261. * @param amount defines the gradient factor
  71262. * @returns a new Color4 object
  71263. */
  71264. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  71265. /**
  71266. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71267. * @param left defines the start value
  71268. * @param right defines the end value
  71269. * @param amount defines the gradient factor
  71270. * @param result defines the Color4 object where to store data
  71271. */
  71272. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  71273. /**
  71274. * Creates a new Color4 from a Color3 and an alpha value
  71275. * @param color3 defines the source Color3 to read from
  71276. * @param alpha defines the alpha component (1.0 by default)
  71277. * @returns a new Color4 object
  71278. */
  71279. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  71280. /**
  71281. * Creates a new Color4 from the starting index element of the given array
  71282. * @param array defines the source array to read from
  71283. * @param offset defines the offset in the source array
  71284. * @returns a new Color4 object
  71285. */
  71286. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  71287. /**
  71288. * Creates a new Color3 from integer values (< 256)
  71289. * @param r defines the red component to read from (value between 0 and 255)
  71290. * @param g defines the green component to read from (value between 0 and 255)
  71291. * @param b defines the blue component to read from (value between 0 and 255)
  71292. * @param a defines the alpha component to read from (value between 0 and 255)
  71293. * @returns a new Color3 object
  71294. */
  71295. static FromInts(r: number, g: number, b: number, a: number): Color4;
  71296. /**
  71297. * Check the content of a given array and convert it to an array containing RGBA data
  71298. * If the original array was already containing count * 4 values then it is returned directly
  71299. * @param colors defines the array to check
  71300. * @param count defines the number of RGBA data to expect
  71301. * @returns an array containing count * 4 values (RGBA)
  71302. */
  71303. static CheckColors4(colors: number[], count: number): number[];
  71304. }
  71305. /**
  71306. * @hidden
  71307. */
  71308. export class TmpColors {
  71309. static Color3: Color3[];
  71310. static Color4: Color4[];
  71311. }
  71312. }
  71313. declare module BABYLON {
  71314. /**
  71315. * Class representing spherical harmonics coefficients to the 3rd degree
  71316. */
  71317. export class SphericalHarmonics {
  71318. /**
  71319. * Defines whether or not the harmonics have been prescaled for rendering.
  71320. */
  71321. preScaled: boolean;
  71322. /**
  71323. * The l0,0 coefficients of the spherical harmonics
  71324. */
  71325. l00: Vector3;
  71326. /**
  71327. * The l1,-1 coefficients of the spherical harmonics
  71328. */
  71329. l1_1: Vector3;
  71330. /**
  71331. * The l1,0 coefficients of the spherical harmonics
  71332. */
  71333. l10: Vector3;
  71334. /**
  71335. * The l1,1 coefficients of the spherical harmonics
  71336. */
  71337. l11: Vector3;
  71338. /**
  71339. * The l2,-2 coefficients of the spherical harmonics
  71340. */
  71341. l2_2: Vector3;
  71342. /**
  71343. * The l2,-1 coefficients of the spherical harmonics
  71344. */
  71345. l2_1: Vector3;
  71346. /**
  71347. * The l2,0 coefficients of the spherical harmonics
  71348. */
  71349. l20: Vector3;
  71350. /**
  71351. * The l2,1 coefficients of the spherical harmonics
  71352. */
  71353. l21: Vector3;
  71354. /**
  71355. * The l2,2 coefficients of the spherical harmonics
  71356. */
  71357. l22: Vector3;
  71358. /**
  71359. * Adds a light to the spherical harmonics
  71360. * @param direction the direction of the light
  71361. * @param color the color of the light
  71362. * @param deltaSolidAngle the delta solid angle of the light
  71363. */
  71364. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  71365. /**
  71366. * Scales the spherical harmonics by the given amount
  71367. * @param scale the amount to scale
  71368. */
  71369. scaleInPlace(scale: number): void;
  71370. /**
  71371. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  71372. *
  71373. * ```
  71374. * E_lm = A_l * L_lm
  71375. * ```
  71376. *
  71377. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  71378. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  71379. * the scaling factors are given in equation 9.
  71380. */
  71381. convertIncidentRadianceToIrradiance(): void;
  71382. /**
  71383. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  71384. *
  71385. * ```
  71386. * L = (1/pi) * E * rho
  71387. * ```
  71388. *
  71389. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  71390. */
  71391. convertIrradianceToLambertianRadiance(): void;
  71392. /**
  71393. * Integrates the reconstruction coefficients directly in to the SH preventing further
  71394. * required operations at run time.
  71395. *
  71396. * This is simply done by scaling back the SH with Ylm constants parameter.
  71397. * The trigonometric part being applied by the shader at run time.
  71398. */
  71399. preScaleForRendering(): void;
  71400. /**
  71401. * Constructs a spherical harmonics from an array.
  71402. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  71403. * @returns the spherical harmonics
  71404. */
  71405. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  71406. /**
  71407. * Gets the spherical harmonics from polynomial
  71408. * @param polynomial the spherical polynomial
  71409. * @returns the spherical harmonics
  71410. */
  71411. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  71412. }
  71413. /**
  71414. * Class representing spherical polynomial coefficients to the 3rd degree
  71415. */
  71416. export class SphericalPolynomial {
  71417. private _harmonics;
  71418. /**
  71419. * The spherical harmonics used to create the polynomials.
  71420. */
  71421. readonly preScaledHarmonics: SphericalHarmonics;
  71422. /**
  71423. * The x coefficients of the spherical polynomial
  71424. */
  71425. x: Vector3;
  71426. /**
  71427. * The y coefficients of the spherical polynomial
  71428. */
  71429. y: Vector3;
  71430. /**
  71431. * The z coefficients of the spherical polynomial
  71432. */
  71433. z: Vector3;
  71434. /**
  71435. * The xx coefficients of the spherical polynomial
  71436. */
  71437. xx: Vector3;
  71438. /**
  71439. * The yy coefficients of the spherical polynomial
  71440. */
  71441. yy: Vector3;
  71442. /**
  71443. * The zz coefficients of the spherical polynomial
  71444. */
  71445. zz: Vector3;
  71446. /**
  71447. * The xy coefficients of the spherical polynomial
  71448. */
  71449. xy: Vector3;
  71450. /**
  71451. * The yz coefficients of the spherical polynomial
  71452. */
  71453. yz: Vector3;
  71454. /**
  71455. * The zx coefficients of the spherical polynomial
  71456. */
  71457. zx: Vector3;
  71458. /**
  71459. * Adds an ambient color to the spherical polynomial
  71460. * @param color the color to add
  71461. */
  71462. addAmbient(color: Color3): void;
  71463. /**
  71464. * Scales the spherical polynomial by the given amount
  71465. * @param scale the amount to scale
  71466. */
  71467. scaleInPlace(scale: number): void;
  71468. /**
  71469. * Gets the spherical polynomial from harmonics
  71470. * @param harmonics the spherical harmonics
  71471. * @returns the spherical polynomial
  71472. */
  71473. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71474. /**
  71475. * Constructs a spherical polynomial from an array.
  71476. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71477. * @returns the spherical polynomial
  71478. */
  71479. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71480. }
  71481. }
  71482. declare module BABYLON {
  71483. /**
  71484. * Define options used to create a render target texture
  71485. */
  71486. export class RenderTargetCreationOptions {
  71487. /**
  71488. * Specifies is mipmaps must be generated
  71489. */
  71490. generateMipMaps?: boolean;
  71491. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71492. generateDepthBuffer?: boolean;
  71493. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71494. generateStencilBuffer?: boolean;
  71495. /** Defines texture type (int by default) */
  71496. type?: number;
  71497. /** Defines sampling mode (trilinear by default) */
  71498. samplingMode?: number;
  71499. /** Defines format (RGBA by default) */
  71500. format?: number;
  71501. }
  71502. }
  71503. declare module BABYLON {
  71504. /**
  71505. * @hidden
  71506. **/
  71507. export class _AlphaState {
  71508. private _isAlphaBlendDirty;
  71509. private _isBlendFunctionParametersDirty;
  71510. private _isBlendEquationParametersDirty;
  71511. private _isBlendConstantsDirty;
  71512. private _alphaBlend;
  71513. private _blendFunctionParameters;
  71514. private _blendEquationParameters;
  71515. private _blendConstants;
  71516. /**
  71517. * Initializes the state.
  71518. */
  71519. constructor();
  71520. readonly isDirty: boolean;
  71521. alphaBlend: boolean;
  71522. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  71523. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  71524. setAlphaEquationParameters(rgb: number, alpha: number): void;
  71525. reset(): void;
  71526. apply(gl: WebGLRenderingContext): void;
  71527. }
  71528. }
  71529. declare module BABYLON {
  71530. /**
  71531. * @hidden
  71532. **/
  71533. export class _DepthCullingState {
  71534. private _isDepthTestDirty;
  71535. private _isDepthMaskDirty;
  71536. private _isDepthFuncDirty;
  71537. private _isCullFaceDirty;
  71538. private _isCullDirty;
  71539. private _isZOffsetDirty;
  71540. private _isFrontFaceDirty;
  71541. private _depthTest;
  71542. private _depthMask;
  71543. private _depthFunc;
  71544. private _cull;
  71545. private _cullFace;
  71546. private _zOffset;
  71547. private _frontFace;
  71548. /**
  71549. * Initializes the state.
  71550. */
  71551. constructor();
  71552. readonly isDirty: boolean;
  71553. zOffset: number;
  71554. cullFace: Nullable<number>;
  71555. cull: Nullable<boolean>;
  71556. depthFunc: Nullable<number>;
  71557. depthMask: boolean;
  71558. depthTest: boolean;
  71559. frontFace: Nullable<number>;
  71560. reset(): void;
  71561. apply(gl: WebGLRenderingContext): void;
  71562. }
  71563. }
  71564. declare module BABYLON {
  71565. /**
  71566. * @hidden
  71567. **/
  71568. export class _StencilState {
  71569. /** 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 */
  71570. static readonly ALWAYS: number;
  71571. /** Passed to stencilOperation to specify that stencil value must be kept */
  71572. static readonly KEEP: number;
  71573. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71574. static readonly REPLACE: number;
  71575. private _isStencilTestDirty;
  71576. private _isStencilMaskDirty;
  71577. private _isStencilFuncDirty;
  71578. private _isStencilOpDirty;
  71579. private _stencilTest;
  71580. private _stencilMask;
  71581. private _stencilFunc;
  71582. private _stencilFuncRef;
  71583. private _stencilFuncMask;
  71584. private _stencilOpStencilFail;
  71585. private _stencilOpDepthFail;
  71586. private _stencilOpStencilDepthPass;
  71587. readonly isDirty: boolean;
  71588. stencilFunc: number;
  71589. stencilFuncRef: number;
  71590. stencilFuncMask: number;
  71591. stencilOpStencilFail: number;
  71592. stencilOpDepthFail: number;
  71593. stencilOpStencilDepthPass: number;
  71594. stencilMask: number;
  71595. stencilTest: boolean;
  71596. constructor();
  71597. reset(): void;
  71598. apply(gl: WebGLRenderingContext): void;
  71599. }
  71600. }
  71601. declare module BABYLON {
  71602. /**
  71603. * @hidden
  71604. **/
  71605. export class _TimeToken {
  71606. _startTimeQuery: Nullable<WebGLQuery>;
  71607. _endTimeQuery: Nullable<WebGLQuery>;
  71608. _timeElapsedQuery: Nullable<WebGLQuery>;
  71609. _timeElapsedQueryEnded: boolean;
  71610. }
  71611. }
  71612. declare module BABYLON {
  71613. /**
  71614. * Class used to evalaute queries containing `and` and `or` operators
  71615. */
  71616. export class AndOrNotEvaluator {
  71617. /**
  71618. * Evaluate a query
  71619. * @param query defines the query to evaluate
  71620. * @param evaluateCallback defines the callback used to filter result
  71621. * @returns true if the query matches
  71622. */
  71623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71624. private static _HandleParenthesisContent;
  71625. private static _SimplifyNegation;
  71626. }
  71627. }
  71628. declare module BABYLON {
  71629. /**
  71630. * Class used to store custom tags
  71631. */
  71632. export class Tags {
  71633. /**
  71634. * Adds support for tags on the given object
  71635. * @param obj defines the object to use
  71636. */
  71637. static EnableFor(obj: any): void;
  71638. /**
  71639. * Removes tags support
  71640. * @param obj defines the object to use
  71641. */
  71642. static DisableFor(obj: any): void;
  71643. /**
  71644. * Gets a boolean indicating if the given object has tags
  71645. * @param obj defines the object to use
  71646. * @returns a boolean
  71647. */
  71648. static HasTags(obj: any): boolean;
  71649. /**
  71650. * Gets the tags available on a given object
  71651. * @param obj defines the object to use
  71652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71653. * @returns the tags
  71654. */
  71655. static GetTags(obj: any, asString?: boolean): any;
  71656. /**
  71657. * Adds tags to an object
  71658. * @param obj defines the object to use
  71659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71661. */
  71662. static AddTagsTo(obj: any, tagsString: string): void;
  71663. /**
  71664. * @hidden
  71665. */
  71666. static _AddTagTo(obj: any, tag: string): void;
  71667. /**
  71668. * Removes specific tags from a specific object
  71669. * @param obj defines the object to use
  71670. * @param tagsString defines the tags to remove
  71671. */
  71672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71673. /**
  71674. * @hidden
  71675. */
  71676. static _RemoveTagFrom(obj: any, tag: string): void;
  71677. /**
  71678. * Defines if tags hosted on an object match a given query
  71679. * @param obj defines the object to use
  71680. * @param tagsQuery defines the tag query
  71681. * @returns a boolean
  71682. */
  71683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71684. }
  71685. }
  71686. declare module BABYLON {
  71687. /**
  71688. * Defines potential orientation for back face culling
  71689. */
  71690. export enum Orientation {
  71691. /**
  71692. * Clockwise
  71693. */
  71694. CW = 0,
  71695. /** Counter clockwise */
  71696. CCW = 1
  71697. }
  71698. /** Class used to represent a Bezier curve */
  71699. export class BezierCurve {
  71700. /**
  71701. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71702. * @param t defines the time
  71703. * @param x1 defines the left coordinate on X axis
  71704. * @param y1 defines the left coordinate on Y axis
  71705. * @param x2 defines the right coordinate on X axis
  71706. * @param y2 defines the right coordinate on Y axis
  71707. * @returns the interpolated value
  71708. */
  71709. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71710. }
  71711. /**
  71712. * Defines angle representation
  71713. */
  71714. export class Angle {
  71715. private _radians;
  71716. /**
  71717. * Creates an Angle object of "radians" radians (float).
  71718. * @param radians the angle in radians
  71719. */
  71720. constructor(radians: number);
  71721. /**
  71722. * Get value in degrees
  71723. * @returns the Angle value in degrees (float)
  71724. */
  71725. degrees(): number;
  71726. /**
  71727. * Get value in radians
  71728. * @returns the Angle value in radians (float)
  71729. */
  71730. radians(): number;
  71731. /**
  71732. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71733. * @param a defines first vector
  71734. * @param b defines second vector
  71735. * @returns a new Angle
  71736. */
  71737. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71738. /**
  71739. * Gets a new Angle object from the given float in radians
  71740. * @param radians defines the angle value in radians
  71741. * @returns a new Angle
  71742. */
  71743. static FromRadians(radians: number): Angle;
  71744. /**
  71745. * Gets a new Angle object from the given float in degrees
  71746. * @param degrees defines the angle value in degrees
  71747. * @returns a new Angle
  71748. */
  71749. static FromDegrees(degrees: number): Angle;
  71750. }
  71751. /**
  71752. * This represents an arc in a 2d space.
  71753. */
  71754. export class Arc2 {
  71755. /** Defines the start point of the arc */
  71756. startPoint: Vector2;
  71757. /** Defines the mid point of the arc */
  71758. midPoint: Vector2;
  71759. /** Defines the end point of the arc */
  71760. endPoint: Vector2;
  71761. /**
  71762. * Defines the center point of the arc.
  71763. */
  71764. centerPoint: Vector2;
  71765. /**
  71766. * Defines the radius of the arc.
  71767. */
  71768. radius: number;
  71769. /**
  71770. * Defines the angle of the arc (from mid point to end point).
  71771. */
  71772. angle: Angle;
  71773. /**
  71774. * Defines the start angle of the arc (from start point to middle point).
  71775. */
  71776. startAngle: Angle;
  71777. /**
  71778. * Defines the orientation of the arc (clock wise/counter clock wise).
  71779. */
  71780. orientation: Orientation;
  71781. /**
  71782. * Creates an Arc object from the three given points : start, middle and end.
  71783. * @param startPoint Defines the start point of the arc
  71784. * @param midPoint Defines the midlle point of the arc
  71785. * @param endPoint Defines the end point of the arc
  71786. */
  71787. constructor(
  71788. /** Defines the start point of the arc */
  71789. startPoint: Vector2,
  71790. /** Defines the mid point of the arc */
  71791. midPoint: Vector2,
  71792. /** Defines the end point of the arc */
  71793. endPoint: Vector2);
  71794. }
  71795. /**
  71796. * Represents a 2D path made up of multiple 2D points
  71797. */
  71798. export class Path2 {
  71799. private _points;
  71800. private _length;
  71801. /**
  71802. * If the path start and end point are the same
  71803. */
  71804. closed: boolean;
  71805. /**
  71806. * Creates a Path2 object from the starting 2D coordinates x and y.
  71807. * @param x the starting points x value
  71808. * @param y the starting points y value
  71809. */
  71810. constructor(x: number, y: number);
  71811. /**
  71812. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71813. * @param x the added points x value
  71814. * @param y the added points y value
  71815. * @returns the updated Path2.
  71816. */
  71817. addLineTo(x: number, y: number): Path2;
  71818. /**
  71819. * 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.
  71820. * @param midX middle point x value
  71821. * @param midY middle point y value
  71822. * @param endX end point x value
  71823. * @param endY end point y value
  71824. * @param numberOfSegments (default: 36)
  71825. * @returns the updated Path2.
  71826. */
  71827. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71828. /**
  71829. * Closes the Path2.
  71830. * @returns the Path2.
  71831. */
  71832. close(): Path2;
  71833. /**
  71834. * Gets the sum of the distance between each sequential point in the path
  71835. * @returns the Path2 total length (float).
  71836. */
  71837. length(): number;
  71838. /**
  71839. * Gets the points which construct the path
  71840. * @returns the Path2 internal array of points.
  71841. */
  71842. getPoints(): Vector2[];
  71843. /**
  71844. * Retreives the point at the distance aways from the starting point
  71845. * @param normalizedLengthPosition the length along the path to retreive the point from
  71846. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71847. */
  71848. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71849. /**
  71850. * Creates a new path starting from an x and y position
  71851. * @param x starting x value
  71852. * @param y starting y value
  71853. * @returns a new Path2 starting at the coordinates (x, y).
  71854. */
  71855. static StartingAt(x: number, y: number): Path2;
  71856. }
  71857. /**
  71858. * Represents a 3D path made up of multiple 3D points
  71859. */
  71860. export class Path3D {
  71861. /**
  71862. * an array of Vector3, the curve axis of the Path3D
  71863. */
  71864. path: Vector3[];
  71865. private _curve;
  71866. private _distances;
  71867. private _tangents;
  71868. private _normals;
  71869. private _binormals;
  71870. private _raw;
  71871. /**
  71872. * new Path3D(path, normal, raw)
  71873. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71874. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71875. * @param path an array of Vector3, the curve axis of the Path3D
  71876. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71877. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71878. */
  71879. constructor(
  71880. /**
  71881. * an array of Vector3, the curve axis of the Path3D
  71882. */
  71883. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71884. /**
  71885. * Returns the Path3D array of successive Vector3 designing its curve.
  71886. * @returns the Path3D array of successive Vector3 designing its curve.
  71887. */
  71888. getCurve(): Vector3[];
  71889. /**
  71890. * Returns an array populated with tangent vectors on each Path3D curve point.
  71891. * @returns an array populated with tangent vectors on each Path3D curve point.
  71892. */
  71893. getTangents(): Vector3[];
  71894. /**
  71895. * Returns an array populated with normal vectors on each Path3D curve point.
  71896. * @returns an array populated with normal vectors on each Path3D curve point.
  71897. */
  71898. getNormals(): Vector3[];
  71899. /**
  71900. * Returns an array populated with binormal vectors on each Path3D curve point.
  71901. * @returns an array populated with binormal vectors on each Path3D curve point.
  71902. */
  71903. getBinormals(): Vector3[];
  71904. /**
  71905. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71906. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71907. */
  71908. getDistances(): number[];
  71909. /**
  71910. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71911. * @param path path which all values are copied into the curves points
  71912. * @param firstNormal which should be projected onto the curve
  71913. * @returns the same object updated.
  71914. */
  71915. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71916. private _compute;
  71917. private _getFirstNonNullVector;
  71918. private _getLastNonNullVector;
  71919. private _normalVector;
  71920. }
  71921. /**
  71922. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71923. * A Curve3 is designed from a series of successive Vector3.
  71924. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71925. */
  71926. export class Curve3 {
  71927. private _points;
  71928. private _length;
  71929. /**
  71930. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71931. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71932. * @param v1 (Vector3) the control point
  71933. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71934. * @param nbPoints (integer) the wanted number of points in the curve
  71935. * @returns the created Curve3
  71936. */
  71937. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71938. /**
  71939. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71940. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71941. * @param v1 (Vector3) the first control point
  71942. * @param v2 (Vector3) the second control point
  71943. * @param v3 (Vector3) the end point of the Cubic Bezier
  71944. * @param nbPoints (integer) the wanted number of points in the curve
  71945. * @returns the created Curve3
  71946. */
  71947. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71948. /**
  71949. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71950. * @param p1 (Vector3) the origin point of the Hermite Spline
  71951. * @param t1 (Vector3) the tangent vector at the origin point
  71952. * @param p2 (Vector3) the end point of the Hermite Spline
  71953. * @param t2 (Vector3) the tangent vector at the end point
  71954. * @param nbPoints (integer) the wanted number of points in the curve
  71955. * @returns the created Curve3
  71956. */
  71957. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71958. /**
  71959. * Returns a Curve3 object along a CatmullRom Spline curve :
  71960. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71961. * @param nbPoints (integer) the wanted number of points between each curve control points
  71962. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71963. * @returns the created Curve3
  71964. */
  71965. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71966. /**
  71967. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71968. * A Curve3 is designed from a series of successive Vector3.
  71969. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71970. * @param points points which make up the curve
  71971. */
  71972. constructor(points: Vector3[]);
  71973. /**
  71974. * @returns the Curve3 stored array of successive Vector3
  71975. */
  71976. getPoints(): Vector3[];
  71977. /**
  71978. * @returns the computed length (float) of the curve.
  71979. */
  71980. length(): number;
  71981. /**
  71982. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71983. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71984. * curveA and curveB keep unchanged.
  71985. * @param curve the curve to continue from this curve
  71986. * @returns the newly constructed curve
  71987. */
  71988. continue(curve: DeepImmutable<Curve3>): Curve3;
  71989. private _computeLength;
  71990. }
  71991. }
  71992. declare module BABYLON {
  71993. /**
  71994. * This represents the main contract an easing function should follow.
  71995. * Easing functions are used throughout the animation system.
  71996. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71997. */
  71998. export interface IEasingFunction {
  71999. /**
  72000. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72001. * of the easing function.
  72002. * The link below provides some of the most common examples of easing functions.
  72003. * @see https://easings.net/
  72004. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72005. * @returns the corresponding value on the curve defined by the easing function
  72006. */
  72007. ease(gradient: number): number;
  72008. }
  72009. /**
  72010. * Base class used for every default easing function.
  72011. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72012. */
  72013. export class EasingFunction implements IEasingFunction {
  72014. /**
  72015. * Interpolation follows the mathematical formula associated with the easing function.
  72016. */
  72017. static readonly EASINGMODE_EASEIN: number;
  72018. /**
  72019. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72020. */
  72021. static readonly EASINGMODE_EASEOUT: number;
  72022. /**
  72023. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72024. */
  72025. static readonly EASINGMODE_EASEINOUT: number;
  72026. private _easingMode;
  72027. /**
  72028. * Sets the easing mode of the current function.
  72029. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72030. */
  72031. setEasingMode(easingMode: number): void;
  72032. /**
  72033. * Gets the current easing mode.
  72034. * @returns the easing mode
  72035. */
  72036. getEasingMode(): number;
  72037. /**
  72038. * @hidden
  72039. */
  72040. easeInCore(gradient: number): number;
  72041. /**
  72042. * Given an input gradient between 0 and 1, this returns the corresponding value
  72043. * of the easing function.
  72044. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72045. * @returns the corresponding value on the curve defined by the easing function
  72046. */
  72047. ease(gradient: number): number;
  72048. }
  72049. /**
  72050. * Easing function with a circle shape (see link below).
  72051. * @see https://easings.net/#easeInCirc
  72052. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72053. */
  72054. export class CircleEase extends EasingFunction implements IEasingFunction {
  72055. /** @hidden */
  72056. easeInCore(gradient: number): number;
  72057. }
  72058. /**
  72059. * Easing function with a ease back shape (see link below).
  72060. * @see https://easings.net/#easeInBack
  72061. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72062. */
  72063. export class BackEase extends EasingFunction implements IEasingFunction {
  72064. /** Defines the amplitude of the function */
  72065. amplitude: number;
  72066. /**
  72067. * Instantiates a back ease easing
  72068. * @see https://easings.net/#easeInBack
  72069. * @param amplitude Defines the amplitude of the function
  72070. */
  72071. constructor(
  72072. /** Defines the amplitude of the function */
  72073. amplitude?: number);
  72074. /** @hidden */
  72075. easeInCore(gradient: number): number;
  72076. }
  72077. /**
  72078. * Easing function with a bouncing shape (see link below).
  72079. * @see https://easings.net/#easeInBounce
  72080. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72081. */
  72082. export class BounceEase extends EasingFunction implements IEasingFunction {
  72083. /** Defines the number of bounces */
  72084. bounces: number;
  72085. /** Defines the amplitude of the bounce */
  72086. bounciness: number;
  72087. /**
  72088. * Instantiates a bounce easing
  72089. * @see https://easings.net/#easeInBounce
  72090. * @param bounces Defines the number of bounces
  72091. * @param bounciness Defines the amplitude of the bounce
  72092. */
  72093. constructor(
  72094. /** Defines the number of bounces */
  72095. bounces?: number,
  72096. /** Defines the amplitude of the bounce */
  72097. bounciness?: number);
  72098. /** @hidden */
  72099. easeInCore(gradient: number): number;
  72100. }
  72101. /**
  72102. * Easing function with a power of 3 shape (see link below).
  72103. * @see https://easings.net/#easeInCubic
  72104. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72105. */
  72106. export class CubicEase extends EasingFunction implements IEasingFunction {
  72107. /** @hidden */
  72108. easeInCore(gradient: number): number;
  72109. }
  72110. /**
  72111. * Easing function with an elastic shape (see link below).
  72112. * @see https://easings.net/#easeInElastic
  72113. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72114. */
  72115. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72116. /** Defines the number of oscillations*/
  72117. oscillations: number;
  72118. /** Defines the amplitude of the oscillations*/
  72119. springiness: number;
  72120. /**
  72121. * Instantiates an elastic easing function
  72122. * @see https://easings.net/#easeInElastic
  72123. * @param oscillations Defines the number of oscillations
  72124. * @param springiness Defines the amplitude of the oscillations
  72125. */
  72126. constructor(
  72127. /** Defines the number of oscillations*/
  72128. oscillations?: number,
  72129. /** Defines the amplitude of the oscillations*/
  72130. springiness?: number);
  72131. /** @hidden */
  72132. easeInCore(gradient: number): number;
  72133. }
  72134. /**
  72135. * Easing function with an exponential shape (see link below).
  72136. * @see https://easings.net/#easeInExpo
  72137. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72138. */
  72139. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72140. /** Defines the exponent of the function */
  72141. exponent: number;
  72142. /**
  72143. * Instantiates an exponential easing function
  72144. * @see https://easings.net/#easeInExpo
  72145. * @param exponent Defines the exponent of the function
  72146. */
  72147. constructor(
  72148. /** Defines the exponent of the function */
  72149. exponent?: number);
  72150. /** @hidden */
  72151. easeInCore(gradient: number): number;
  72152. }
  72153. /**
  72154. * Easing function with a power shape (see link below).
  72155. * @see https://easings.net/#easeInQuad
  72156. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72157. */
  72158. export class PowerEase extends EasingFunction implements IEasingFunction {
  72159. /** Defines the power of the function */
  72160. power: number;
  72161. /**
  72162. * Instantiates an power base easing function
  72163. * @see https://easings.net/#easeInQuad
  72164. * @param power Defines the power of the function
  72165. */
  72166. constructor(
  72167. /** Defines the power of the function */
  72168. power?: number);
  72169. /** @hidden */
  72170. easeInCore(gradient: number): number;
  72171. }
  72172. /**
  72173. * Easing function with a power of 2 shape (see link below).
  72174. * @see https://easings.net/#easeInQuad
  72175. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72176. */
  72177. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72178. /** @hidden */
  72179. easeInCore(gradient: number): number;
  72180. }
  72181. /**
  72182. * Easing function with a power of 4 shape (see link below).
  72183. * @see https://easings.net/#easeInQuart
  72184. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72185. */
  72186. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72187. /** @hidden */
  72188. easeInCore(gradient: number): number;
  72189. }
  72190. /**
  72191. * Easing function with a power of 5 shape (see link below).
  72192. * @see https://easings.net/#easeInQuint
  72193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72194. */
  72195. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72196. /** @hidden */
  72197. easeInCore(gradient: number): number;
  72198. }
  72199. /**
  72200. * Easing function with a sin shape (see link below).
  72201. * @see https://easings.net/#easeInSine
  72202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72203. */
  72204. export class SineEase extends EasingFunction implements IEasingFunction {
  72205. /** @hidden */
  72206. easeInCore(gradient: number): number;
  72207. }
  72208. /**
  72209. * Easing function with a bezier shape (see link below).
  72210. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72212. */
  72213. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72214. /** Defines the x component of the start tangent in the bezier curve */
  72215. x1: number;
  72216. /** Defines the y component of the start tangent in the bezier curve */
  72217. y1: number;
  72218. /** Defines the x component of the end tangent in the bezier curve */
  72219. x2: number;
  72220. /** Defines the y component of the end tangent in the bezier curve */
  72221. y2: number;
  72222. /**
  72223. * Instantiates a bezier function
  72224. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72225. * @param x1 Defines the x component of the start tangent in the bezier curve
  72226. * @param y1 Defines the y component of the start tangent in the bezier curve
  72227. * @param x2 Defines the x component of the end tangent in the bezier curve
  72228. * @param y2 Defines the y component of the end tangent in the bezier curve
  72229. */
  72230. constructor(
  72231. /** Defines the x component of the start tangent in the bezier curve */
  72232. x1?: number,
  72233. /** Defines the y component of the start tangent in the bezier curve */
  72234. y1?: number,
  72235. /** Defines the x component of the end tangent in the bezier curve */
  72236. x2?: number,
  72237. /** Defines the y component of the end tangent in the bezier curve */
  72238. y2?: number);
  72239. /** @hidden */
  72240. easeInCore(gradient: number): number;
  72241. }
  72242. }
  72243. declare module BABYLON {
  72244. /**
  72245. * Defines an interface which represents an animation key frame
  72246. */
  72247. export interface IAnimationKey {
  72248. /**
  72249. * Frame of the key frame
  72250. */
  72251. frame: number;
  72252. /**
  72253. * Value at the specifies key frame
  72254. */
  72255. value: any;
  72256. /**
  72257. * The input tangent for the cubic hermite spline
  72258. */
  72259. inTangent?: any;
  72260. /**
  72261. * The output tangent for the cubic hermite spline
  72262. */
  72263. outTangent?: any;
  72264. /**
  72265. * The animation interpolation type
  72266. */
  72267. interpolation?: AnimationKeyInterpolation;
  72268. }
  72269. /**
  72270. * Enum for the animation key frame interpolation type
  72271. */
  72272. export enum AnimationKeyInterpolation {
  72273. /**
  72274. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72275. */
  72276. STEP = 1
  72277. }
  72278. }
  72279. declare module BABYLON {
  72280. /**
  72281. * Represents the range of an animation
  72282. */
  72283. export class AnimationRange {
  72284. /**The name of the animation range**/
  72285. name: string;
  72286. /**The starting frame of the animation */
  72287. from: number;
  72288. /**The ending frame of the animation*/
  72289. to: number;
  72290. /**
  72291. * Initializes the range of an animation
  72292. * @param name The name of the animation range
  72293. * @param from The starting frame of the animation
  72294. * @param to The ending frame of the animation
  72295. */
  72296. constructor(
  72297. /**The name of the animation range**/
  72298. name: string,
  72299. /**The starting frame of the animation */
  72300. from: number,
  72301. /**The ending frame of the animation*/
  72302. to: number);
  72303. /**
  72304. * Makes a copy of the animation range
  72305. * @returns A copy of the animation range
  72306. */
  72307. clone(): AnimationRange;
  72308. }
  72309. }
  72310. declare module BABYLON {
  72311. /**
  72312. * Composed of a frame, and an action function
  72313. */
  72314. export class AnimationEvent {
  72315. /** The frame for which the event is triggered **/
  72316. frame: number;
  72317. /** The event to perform when triggered **/
  72318. action: (currentFrame: number) => void;
  72319. /** Specifies if the event should be triggered only once**/
  72320. onlyOnce?: boolean | undefined;
  72321. /**
  72322. * Specifies if the animation event is done
  72323. */
  72324. isDone: boolean;
  72325. /**
  72326. * Initializes the animation event
  72327. * @param frame The frame for which the event is triggered
  72328. * @param action The event to perform when triggered
  72329. * @param onlyOnce Specifies if the event should be triggered only once
  72330. */
  72331. constructor(
  72332. /** The frame for which the event is triggered **/
  72333. frame: number,
  72334. /** The event to perform when triggered **/
  72335. action: (currentFrame: number) => void,
  72336. /** Specifies if the event should be triggered only once**/
  72337. onlyOnce?: boolean | undefined);
  72338. /** @hidden */
  72339. _clone(): AnimationEvent;
  72340. }
  72341. }
  72342. declare module BABYLON {
  72343. /**
  72344. * Interface used to define a behavior
  72345. */
  72346. export interface Behavior<T> {
  72347. /** gets or sets behavior's name */
  72348. name: string;
  72349. /**
  72350. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72351. */
  72352. init(): void;
  72353. /**
  72354. * Called when the behavior is attached to a target
  72355. * @param target defines the target where the behavior is attached to
  72356. */
  72357. attach(target: T): void;
  72358. /**
  72359. * Called when the behavior is detached from its target
  72360. */
  72361. detach(): void;
  72362. }
  72363. /**
  72364. * Interface implemented by classes supporting behaviors
  72365. */
  72366. export interface IBehaviorAware<T> {
  72367. /**
  72368. * Attach a behavior
  72369. * @param behavior defines the behavior to attach
  72370. * @returns the current host
  72371. */
  72372. addBehavior(behavior: Behavior<T>): T;
  72373. /**
  72374. * Remove a behavior from the current object
  72375. * @param behavior defines the behavior to detach
  72376. * @returns the current host
  72377. */
  72378. removeBehavior(behavior: Behavior<T>): T;
  72379. /**
  72380. * Gets a behavior using its name to search
  72381. * @param name defines the name to search
  72382. * @returns the behavior or null if not found
  72383. */
  72384. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72385. }
  72386. }
  72387. declare module BABYLON {
  72388. /**
  72389. * Defines an array and its length.
  72390. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72391. */
  72392. export interface ISmartArrayLike<T> {
  72393. /**
  72394. * The data of the array.
  72395. */
  72396. data: Array<T>;
  72397. /**
  72398. * The active length of the array.
  72399. */
  72400. length: number;
  72401. }
  72402. /**
  72403. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72404. */
  72405. export class SmartArray<T> implements ISmartArrayLike<T> {
  72406. /**
  72407. * The full set of data from the array.
  72408. */
  72409. data: Array<T>;
  72410. /**
  72411. * The active length of the array.
  72412. */
  72413. length: number;
  72414. protected _id: number;
  72415. /**
  72416. * Instantiates a Smart Array.
  72417. * @param capacity defines the default capacity of the array.
  72418. */
  72419. constructor(capacity: number);
  72420. /**
  72421. * Pushes a value at the end of the active data.
  72422. * @param value defines the object to push in the array.
  72423. */
  72424. push(value: T): void;
  72425. /**
  72426. * Iterates over the active data and apply the lambda to them.
  72427. * @param func defines the action to apply on each value.
  72428. */
  72429. forEach(func: (content: T) => void): void;
  72430. /**
  72431. * Sorts the full sets of data.
  72432. * @param compareFn defines the comparison function to apply.
  72433. */
  72434. sort(compareFn: (a: T, b: T) => number): void;
  72435. /**
  72436. * Resets the active data to an empty array.
  72437. */
  72438. reset(): void;
  72439. /**
  72440. * Releases all the data from the array as well as the array.
  72441. */
  72442. dispose(): void;
  72443. /**
  72444. * Concats the active data with a given array.
  72445. * @param array defines the data to concatenate with.
  72446. */
  72447. concat(array: any): void;
  72448. /**
  72449. * Returns the position of a value in the active data.
  72450. * @param value defines the value to find the index for
  72451. * @returns the index if found in the active data otherwise -1
  72452. */
  72453. indexOf(value: T): number;
  72454. /**
  72455. * Returns whether an element is part of the active data.
  72456. * @param value defines the value to look for
  72457. * @returns true if found in the active data otherwise false
  72458. */
  72459. contains(value: T): boolean;
  72460. private static _GlobalId;
  72461. }
  72462. /**
  72463. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72464. * The data in this array can only be present once
  72465. */
  72466. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72467. private _duplicateId;
  72468. /**
  72469. * Pushes a value at the end of the active data.
  72470. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72471. * @param value defines the object to push in the array.
  72472. */
  72473. push(value: T): void;
  72474. /**
  72475. * Pushes a value at the end of the active data.
  72476. * If the data is already present, it won t be added again
  72477. * @param value defines the object to push in the array.
  72478. * @returns true if added false if it was already present
  72479. */
  72480. pushNoDuplicate(value: T): boolean;
  72481. /**
  72482. * Resets the active data to an empty array.
  72483. */
  72484. reset(): void;
  72485. /**
  72486. * Concats the active data with a given array.
  72487. * This ensures no dupplicate will be present in the result.
  72488. * @param array defines the data to concatenate with.
  72489. */
  72490. concatWithNoDuplicate(array: any): void;
  72491. }
  72492. }
  72493. declare module BABYLON {
  72494. /**
  72495. * @ignore
  72496. * This is a list of all the different input types that are available in the application.
  72497. * Fo instance: ArcRotateCameraGamepadInput...
  72498. */
  72499. export var CameraInputTypes: {};
  72500. /**
  72501. * This is the contract to implement in order to create a new input class.
  72502. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72503. */
  72504. export interface ICameraInput<TCamera extends Camera> {
  72505. /**
  72506. * Defines the camera the input is attached to.
  72507. */
  72508. camera: Nullable<TCamera>;
  72509. /**
  72510. * Gets the class name of the current intput.
  72511. * @returns the class name
  72512. */
  72513. getClassName(): string;
  72514. /**
  72515. * Get the friendly name associated with the input class.
  72516. * @returns the input friendly name
  72517. */
  72518. getSimpleName(): string;
  72519. /**
  72520. * Attach the input controls to a specific dom element to get the input from.
  72521. * @param element Defines the element the controls should be listened from
  72522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72523. */
  72524. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72525. /**
  72526. * Detach the current controls from the specified dom element.
  72527. * @param element Defines the element to stop listening the inputs from
  72528. */
  72529. detachControl(element: Nullable<HTMLElement>): void;
  72530. /**
  72531. * Update the current camera state depending on the inputs that have been used this frame.
  72532. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72533. */
  72534. checkInputs?: () => void;
  72535. }
  72536. /**
  72537. * Represents a map of input types to input instance or input index to input instance.
  72538. */
  72539. export interface CameraInputsMap<TCamera extends Camera> {
  72540. /**
  72541. * Accessor to the input by input type.
  72542. */
  72543. [name: string]: ICameraInput<TCamera>;
  72544. /**
  72545. * Accessor to the input by input index.
  72546. */
  72547. [idx: number]: ICameraInput<TCamera>;
  72548. }
  72549. /**
  72550. * This represents the input manager used within a camera.
  72551. * It helps dealing with all the different kind of input attached to a camera.
  72552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72553. */
  72554. export class CameraInputsManager<TCamera extends Camera> {
  72555. /**
  72556. * Defines the list of inputs attahed to the camera.
  72557. */
  72558. attached: CameraInputsMap<TCamera>;
  72559. /**
  72560. * Defines the dom element the camera is collecting inputs from.
  72561. * This is null if the controls have not been attached.
  72562. */
  72563. attachedElement: Nullable<HTMLElement>;
  72564. /**
  72565. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72566. */
  72567. noPreventDefault: boolean;
  72568. /**
  72569. * Defined the camera the input manager belongs to.
  72570. */
  72571. camera: TCamera;
  72572. /**
  72573. * Update the current camera state depending on the inputs that have been used this frame.
  72574. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72575. */
  72576. checkInputs: () => void;
  72577. /**
  72578. * Instantiate a new Camera Input Manager.
  72579. * @param camera Defines the camera the input manager blongs to
  72580. */
  72581. constructor(camera: TCamera);
  72582. /**
  72583. * Add an input method to a camera
  72584. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72585. * @param input camera input method
  72586. */
  72587. add(input: ICameraInput<TCamera>): void;
  72588. /**
  72589. * Remove a specific input method from a camera
  72590. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72591. * @param inputToRemove camera input method
  72592. */
  72593. remove(inputToRemove: ICameraInput<TCamera>): void;
  72594. /**
  72595. * Remove a specific input type from a camera
  72596. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72597. * @param inputType the type of the input to remove
  72598. */
  72599. removeByType(inputType: string): void;
  72600. private _addCheckInputs;
  72601. /**
  72602. * Attach the input controls to the currently attached dom element to listen the events from.
  72603. * @param input Defines the input to attach
  72604. */
  72605. attachInput(input: ICameraInput<TCamera>): void;
  72606. /**
  72607. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72608. * @param element Defines the dom element to collect the events from
  72609. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72610. */
  72611. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72612. /**
  72613. * Detach the current manager inputs controls from a specific dom element.
  72614. * @param element Defines the dom element to collect the events from
  72615. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72616. */
  72617. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72618. /**
  72619. * Rebuild the dynamic inputCheck function from the current list of
  72620. * defined inputs in the manager.
  72621. */
  72622. rebuildInputCheck(): void;
  72623. /**
  72624. * Remove all attached input methods from a camera
  72625. */
  72626. clear(): void;
  72627. /**
  72628. * Serialize the current input manager attached to a camera.
  72629. * This ensures than once parsed,
  72630. * the input associated to the camera will be identical to the current ones
  72631. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72632. */
  72633. serialize(serializedCamera: any): void;
  72634. /**
  72635. * Parses an input manager serialized JSON to restore the previous list of inputs
  72636. * and states associated to a camera.
  72637. * @param parsedCamera Defines the JSON to parse
  72638. */
  72639. parse(parsedCamera: any): void;
  72640. }
  72641. }
  72642. declare module BABYLON {
  72643. /**
  72644. * @hidden
  72645. */
  72646. export class IntersectionInfo {
  72647. bu: Nullable<number>;
  72648. bv: Nullable<number>;
  72649. distance: number;
  72650. faceId: number;
  72651. subMeshId: number;
  72652. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72653. }
  72654. }
  72655. declare module BABYLON {
  72656. /**
  72657. * Represens a plane by the equation ax + by + cz + d = 0
  72658. */
  72659. export class Plane {
  72660. private static _TmpMatrix;
  72661. /**
  72662. * Normal of the plane (a,b,c)
  72663. */
  72664. normal: Vector3;
  72665. /**
  72666. * d component of the plane
  72667. */
  72668. d: number;
  72669. /**
  72670. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72671. * @param a a component of the plane
  72672. * @param b b component of the plane
  72673. * @param c c component of the plane
  72674. * @param d d component of the plane
  72675. */
  72676. constructor(a: number, b: number, c: number, d: number);
  72677. /**
  72678. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72679. */
  72680. asArray(): number[];
  72681. /**
  72682. * @returns a new plane copied from the current Plane.
  72683. */
  72684. clone(): Plane;
  72685. /**
  72686. * @returns the string "Plane".
  72687. */
  72688. getClassName(): string;
  72689. /**
  72690. * @returns the Plane hash code.
  72691. */
  72692. getHashCode(): number;
  72693. /**
  72694. * Normalize the current Plane in place.
  72695. * @returns the updated Plane.
  72696. */
  72697. normalize(): Plane;
  72698. /**
  72699. * Applies a transformation the plane and returns the result
  72700. * @param transformation the transformation matrix to be applied to the plane
  72701. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72702. */
  72703. transform(transformation: DeepImmutable<Matrix>): Plane;
  72704. /**
  72705. * Calcualtte the dot product between the point and the plane normal
  72706. * @param point point to calculate the dot product with
  72707. * @returns the dot product (float) of the point coordinates and the plane normal.
  72708. */
  72709. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72710. /**
  72711. * Updates the current Plane from the plane defined by the three given points.
  72712. * @param point1 one of the points used to contruct the plane
  72713. * @param point2 one of the points used to contruct the plane
  72714. * @param point3 one of the points used to contruct the plane
  72715. * @returns the updated Plane.
  72716. */
  72717. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72718. /**
  72719. * Checks if the plane is facing a given direction
  72720. * @param direction the direction to check if the plane is facing
  72721. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72722. * @returns True is the vector "direction" is the same side than the plane normal.
  72723. */
  72724. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72725. /**
  72726. * Calculates the distance to a point
  72727. * @param point point to calculate distance to
  72728. * @returns the signed distance (float) from the given point to the Plane.
  72729. */
  72730. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  72731. /**
  72732. * Creates a plane from an array
  72733. * @param array the array to create a plane from
  72734. * @returns a new Plane from the given array.
  72735. */
  72736. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  72737. /**
  72738. * Creates a plane from three points
  72739. * @param point1 point used to create the plane
  72740. * @param point2 point used to create the plane
  72741. * @param point3 point used to create the plane
  72742. * @returns a new Plane defined by the three given points.
  72743. */
  72744. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72745. /**
  72746. * Creates a plane from an origin point and a normal
  72747. * @param origin origin of the plane to be constructed
  72748. * @param normal normal of the plane to be constructed
  72749. * @returns a new Plane the normal vector to this plane at the given origin point.
  72750. * Note : the vector "normal" is updated because normalized.
  72751. */
  72752. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  72753. /**
  72754. * Calculates the distance from a plane and a point
  72755. * @param origin origin of the plane to be constructed
  72756. * @param normal normal of the plane to be constructed
  72757. * @param point point to calculate distance to
  72758. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72759. */
  72760. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  72761. }
  72762. }
  72763. declare module BABYLON {
  72764. /**
  72765. * Class used to store bounding sphere information
  72766. */
  72767. export class BoundingSphere {
  72768. /**
  72769. * Gets the center of the bounding sphere in local space
  72770. */
  72771. readonly center: Vector3;
  72772. /**
  72773. * Radius of the bounding sphere in local space
  72774. */
  72775. radius: number;
  72776. /**
  72777. * Gets the center of the bounding sphere in world space
  72778. */
  72779. readonly centerWorld: Vector3;
  72780. /**
  72781. * Radius of the bounding sphere in world space
  72782. */
  72783. radiusWorld: number;
  72784. /**
  72785. * Gets the minimum vector in local space
  72786. */
  72787. readonly minimum: Vector3;
  72788. /**
  72789. * Gets the maximum vector in local space
  72790. */
  72791. readonly maximum: Vector3;
  72792. private _worldMatrix;
  72793. private static readonly TmpVector3;
  72794. /**
  72795. * Creates a new bounding sphere
  72796. * @param min defines the minimum vector (in local space)
  72797. * @param max defines the maximum vector (in local space)
  72798. * @param worldMatrix defines the new world matrix
  72799. */
  72800. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72801. /**
  72802. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  72803. * @param min defines the new minimum vector (in local space)
  72804. * @param max defines the new maximum vector (in local space)
  72805. * @param worldMatrix defines the new world matrix
  72806. */
  72807. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72808. /**
  72809. * Scale the current bounding sphere by applying a scale factor
  72810. * @param factor defines the scale factor to apply
  72811. * @returns the current bounding box
  72812. */
  72813. scale(factor: number): BoundingSphere;
  72814. /**
  72815. * Gets the world matrix of the bounding box
  72816. * @returns a matrix
  72817. */
  72818. getWorldMatrix(): DeepImmutable<Matrix>;
  72819. /** @hidden */
  72820. _update(worldMatrix: DeepImmutable<Matrix>): void;
  72821. /**
  72822. * Tests if the bounding sphere is intersecting the frustum planes
  72823. * @param frustumPlanes defines the frustum planes to test
  72824. * @returns true if there is an intersection
  72825. */
  72826. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72827. /**
  72828. * Tests if the bounding sphere center is in between the frustum planes.
  72829. * Used for optimistic fast inclusion.
  72830. * @param frustumPlanes defines the frustum planes to test
  72831. * @returns true if the sphere center is in between the frustum planes
  72832. */
  72833. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72834. /**
  72835. * Tests if a point is inside the bounding sphere
  72836. * @param point defines the point to test
  72837. * @returns true if the point is inside the bounding sphere
  72838. */
  72839. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72840. /**
  72841. * Checks if two sphere intersct
  72842. * @param sphere0 sphere 0
  72843. * @param sphere1 sphere 1
  72844. * @returns true if the speres intersect
  72845. */
  72846. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  72847. }
  72848. }
  72849. declare module BABYLON {
  72850. /**
  72851. * Class used to store bounding box information
  72852. */
  72853. export class BoundingBox implements ICullable {
  72854. /**
  72855. * Gets the 8 vectors representing the bounding box in local space
  72856. */
  72857. readonly vectors: Vector3[];
  72858. /**
  72859. * Gets the center of the bounding box in local space
  72860. */
  72861. readonly center: Vector3;
  72862. /**
  72863. * Gets the center of the bounding box in world space
  72864. */
  72865. readonly centerWorld: Vector3;
  72866. /**
  72867. * Gets the extend size in local space
  72868. */
  72869. readonly extendSize: Vector3;
  72870. /**
  72871. * Gets the extend size in world space
  72872. */
  72873. readonly extendSizeWorld: Vector3;
  72874. /**
  72875. * Gets the OBB (object bounding box) directions
  72876. */
  72877. readonly directions: Vector3[];
  72878. /**
  72879. * Gets the 8 vectors representing the bounding box in world space
  72880. */
  72881. readonly vectorsWorld: Vector3[];
  72882. /**
  72883. * Gets the minimum vector in world space
  72884. */
  72885. readonly minimumWorld: Vector3;
  72886. /**
  72887. * Gets the maximum vector in world space
  72888. */
  72889. readonly maximumWorld: Vector3;
  72890. /**
  72891. * Gets the minimum vector in local space
  72892. */
  72893. readonly minimum: Vector3;
  72894. /**
  72895. * Gets the maximum vector in local space
  72896. */
  72897. readonly maximum: Vector3;
  72898. private _worldMatrix;
  72899. private static readonly TmpVector3;
  72900. /**
  72901. * @hidden
  72902. */
  72903. _tag: number;
  72904. /**
  72905. * Creates a new bounding box
  72906. * @param min defines the minimum vector (in local space)
  72907. * @param max defines the maximum vector (in local space)
  72908. * @param worldMatrix defines the new world matrix
  72909. */
  72910. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72911. /**
  72912. * Recreates the entire bounding box from scratch as if we call the constructor in place
  72913. * @param min defines the new minimum vector (in local space)
  72914. * @param max defines the new maximum vector (in local space)
  72915. * @param worldMatrix defines the new world matrix
  72916. */
  72917. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72918. /**
  72919. * Scale the current bounding box by applying a scale factor
  72920. * @param factor defines the scale factor to apply
  72921. * @returns the current bounding box
  72922. */
  72923. scale(factor: number): BoundingBox;
  72924. /**
  72925. * Gets the world matrix of the bounding box
  72926. * @returns a matrix
  72927. */
  72928. getWorldMatrix(): DeepImmutable<Matrix>;
  72929. /** @hidden */
  72930. _update(world: DeepImmutable<Matrix>): void;
  72931. /**
  72932. * Tests if the bounding box is intersecting the frustum planes
  72933. * @param frustumPlanes defines the frustum planes to test
  72934. * @returns true if there is an intersection
  72935. */
  72936. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72937. /**
  72938. * Tests if the bounding box is entirely inside the frustum planes
  72939. * @param frustumPlanes defines the frustum planes to test
  72940. * @returns true if there is an inclusion
  72941. */
  72942. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72943. /**
  72944. * Tests if a point is inside the bounding box
  72945. * @param point defines the point to test
  72946. * @returns true if the point is inside the bounding box
  72947. */
  72948. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72949. /**
  72950. * Tests if the bounding box intersects with a bounding sphere
  72951. * @param sphere defines the sphere to test
  72952. * @returns true if there is an intersection
  72953. */
  72954. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  72955. /**
  72956. * Tests if the bounding box intersects with a box defined by a min and max vectors
  72957. * @param min defines the min vector to use
  72958. * @param max defines the max vector to use
  72959. * @returns true if there is an intersection
  72960. */
  72961. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  72962. /**
  72963. * Tests if two bounding boxes are intersections
  72964. * @param box0 defines the first box to test
  72965. * @param box1 defines the second box to test
  72966. * @returns true if there is an intersection
  72967. */
  72968. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  72969. /**
  72970. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  72971. * @param minPoint defines the minimum vector of the bounding box
  72972. * @param maxPoint defines the maximum vector of the bounding box
  72973. * @param sphereCenter defines the sphere center
  72974. * @param sphereRadius defines the sphere radius
  72975. * @returns true if there is an intersection
  72976. */
  72977. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  72978. /**
  72979. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  72980. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72981. * @param frustumPlanes defines the frustum planes to test
  72982. * @return true if there is an inclusion
  72983. */
  72984. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72985. /**
  72986. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  72987. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72988. * @param frustumPlanes defines the frustum planes to test
  72989. * @return true if there is an intersection
  72990. */
  72991. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72992. }
  72993. }
  72994. declare module BABYLON {
  72995. /** @hidden */
  72996. export class Collider {
  72997. /** Define if a collision was found */
  72998. collisionFound: boolean;
  72999. /**
  73000. * Define last intersection point in local space
  73001. */
  73002. intersectionPoint: Vector3;
  73003. /**
  73004. * Define last collided mesh
  73005. */
  73006. collidedMesh: Nullable<AbstractMesh>;
  73007. private _collisionPoint;
  73008. private _planeIntersectionPoint;
  73009. private _tempVector;
  73010. private _tempVector2;
  73011. private _tempVector3;
  73012. private _tempVector4;
  73013. private _edge;
  73014. private _baseToVertex;
  73015. private _destinationPoint;
  73016. private _slidePlaneNormal;
  73017. private _displacementVector;
  73018. /** @hidden */
  73019. _radius: Vector3;
  73020. /** @hidden */
  73021. _retry: number;
  73022. private _velocity;
  73023. private _basePoint;
  73024. private _epsilon;
  73025. /** @hidden */
  73026. _velocityWorldLength: number;
  73027. /** @hidden */
  73028. _basePointWorld: Vector3;
  73029. private _velocityWorld;
  73030. private _normalizedVelocity;
  73031. /** @hidden */
  73032. _initialVelocity: Vector3;
  73033. /** @hidden */
  73034. _initialPosition: Vector3;
  73035. private _nearestDistance;
  73036. private _collisionMask;
  73037. collisionMask: number;
  73038. /**
  73039. * Gets the plane normal used to compute the sliding response (in local space)
  73040. */
  73041. readonly slidePlaneNormal: Vector3;
  73042. /** @hidden */
  73043. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73044. /** @hidden */
  73045. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73046. /** @hidden */
  73047. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73048. /** @hidden */
  73049. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73050. /** @hidden */
  73051. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73052. /** @hidden */
  73053. _getResponse(pos: Vector3, vel: Vector3): void;
  73054. }
  73055. }
  73056. declare module BABYLON {
  73057. /**
  73058. * Interface for cullable objects
  73059. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73060. */
  73061. export interface ICullable {
  73062. /**
  73063. * Checks if the object or part of the object is in the frustum
  73064. * @param frustumPlanes Camera near/planes
  73065. * @returns true if the object is in frustum otherwise false
  73066. */
  73067. isInFrustum(frustumPlanes: Plane[]): boolean;
  73068. /**
  73069. * Checks if a cullable object (mesh...) is in the camera frustum
  73070. * Unlike isInFrustum this cheks the full bounding box
  73071. * @param frustumPlanes Camera near/planes
  73072. * @returns true if the object is in frustum otherwise false
  73073. */
  73074. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73075. }
  73076. /**
  73077. * Info for a bounding data of a mesh
  73078. */
  73079. export class BoundingInfo implements ICullable {
  73080. /**
  73081. * Bounding box for the mesh
  73082. */
  73083. readonly boundingBox: BoundingBox;
  73084. /**
  73085. * Bounding sphere for the mesh
  73086. */
  73087. readonly boundingSphere: BoundingSphere;
  73088. private _isLocked;
  73089. private static readonly TmpVector3;
  73090. /**
  73091. * Constructs bounding info
  73092. * @param minimum min vector of the bounding box/sphere
  73093. * @param maximum max vector of the bounding box/sphere
  73094. * @param worldMatrix defines the new world matrix
  73095. */
  73096. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73097. /**
  73098. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73099. * @param min defines the new minimum vector (in local space)
  73100. * @param max defines the new maximum vector (in local space)
  73101. * @param worldMatrix defines the new world matrix
  73102. */
  73103. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73104. /**
  73105. * min vector of the bounding box/sphere
  73106. */
  73107. readonly minimum: Vector3;
  73108. /**
  73109. * max vector of the bounding box/sphere
  73110. */
  73111. readonly maximum: Vector3;
  73112. /**
  73113. * If the info is locked and won't be updated to avoid perf overhead
  73114. */
  73115. isLocked: boolean;
  73116. /**
  73117. * Updates the bounding sphere and box
  73118. * @param world world matrix to be used to update
  73119. */
  73120. update(world: DeepImmutable<Matrix>): void;
  73121. /**
  73122. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73123. * @param center New center of the bounding info
  73124. * @param extend New extend of the bounding info
  73125. * @returns the current bounding info
  73126. */
  73127. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73128. /**
  73129. * Scale the current bounding info by applying a scale factor
  73130. * @param factor defines the scale factor to apply
  73131. * @returns the current bounding info
  73132. */
  73133. scale(factor: number): BoundingInfo;
  73134. /**
  73135. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73136. * @param frustumPlanes defines the frustum to test
  73137. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73138. * @returns true if the bounding info is in the frustum planes
  73139. */
  73140. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73141. /**
  73142. * Gets the world distance between the min and max points of the bounding box
  73143. */
  73144. readonly diagonalLength: number;
  73145. /**
  73146. * Checks if a cullable object (mesh...) is in the camera frustum
  73147. * Unlike isInFrustum this cheks the full bounding box
  73148. * @param frustumPlanes Camera near/planes
  73149. * @returns true if the object is in frustum otherwise false
  73150. */
  73151. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73152. /** @hidden */
  73153. _checkCollision(collider: Collider): boolean;
  73154. /**
  73155. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73156. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73157. * @param point the point to check intersection with
  73158. * @returns if the point intersects
  73159. */
  73160. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73161. /**
  73162. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73163. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73164. * @param boundingInfo the bounding info to check intersection with
  73165. * @param precise if the intersection should be done using OBB
  73166. * @returns if the bounding info intersects
  73167. */
  73168. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73169. }
  73170. }
  73171. declare module BABYLON {
  73172. /**
  73173. * Extracts minimum and maximum values from a list of indexed positions
  73174. * @param positions defines the positions to use
  73175. * @param indices defines the indices to the positions
  73176. * @param indexStart defines the start index
  73177. * @param indexCount defines the end index
  73178. * @param bias defines bias value to add to the result
  73179. * @return minimum and maximum values
  73180. */
  73181. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73182. minimum: Vector3;
  73183. maximum: Vector3;
  73184. };
  73185. /**
  73186. * Extracts minimum and maximum values from a list of positions
  73187. * @param positions defines the positions to use
  73188. * @param start defines the start index in the positions array
  73189. * @param count defines the number of positions to handle
  73190. * @param bias defines bias value to add to the result
  73191. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73192. * @return minimum and maximum values
  73193. */
  73194. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73195. minimum: Vector3;
  73196. maximum: Vector3;
  73197. };
  73198. }
  73199. declare module BABYLON {
  73200. /**
  73201. * Enum that determines the text-wrapping mode to use.
  73202. */
  73203. export enum InspectableType {
  73204. /**
  73205. * Checkbox for booleans
  73206. */
  73207. Checkbox = 0,
  73208. /**
  73209. * Sliders for numbers
  73210. */
  73211. Slider = 1,
  73212. /**
  73213. * Vector3
  73214. */
  73215. Vector3 = 2,
  73216. /**
  73217. * Quaternions
  73218. */
  73219. Quaternion = 3,
  73220. /**
  73221. * Color3
  73222. */
  73223. Color3 = 4,
  73224. /**
  73225. * String
  73226. */
  73227. String = 5
  73228. }
  73229. /**
  73230. * Interface used to define custom inspectable properties.
  73231. * This interface is used by the inspector to display custom property grids
  73232. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73233. */
  73234. export interface IInspectable {
  73235. /**
  73236. * Gets the label to display
  73237. */
  73238. label: string;
  73239. /**
  73240. * Gets the name of the property to edit
  73241. */
  73242. propertyName: string;
  73243. /**
  73244. * Gets the type of the editor to use
  73245. */
  73246. type: InspectableType;
  73247. /**
  73248. * Gets the minimum value of the property when using in "slider" mode
  73249. */
  73250. min?: number;
  73251. /**
  73252. * Gets the maximum value of the property when using in "slider" mode
  73253. */
  73254. max?: number;
  73255. /**
  73256. * Gets the setp to use when using in "slider" mode
  73257. */
  73258. step?: number;
  73259. }
  73260. }
  73261. declare module BABYLON {
  73262. /**
  73263. * Class used to provide helper for timing
  73264. */
  73265. export class TimingTools {
  73266. /**
  73267. * Polyfill for setImmediate
  73268. * @param action defines the action to execute after the current execution block
  73269. */
  73270. static SetImmediate(action: () => void): void;
  73271. }
  73272. }
  73273. declare module BABYLON {
  73274. /**
  73275. * Class used to enable instatition of objects by class name
  73276. */
  73277. export class InstantiationTools {
  73278. /**
  73279. * Use this object to register external classes like custom textures or material
  73280. * to allow the laoders to instantiate them
  73281. */
  73282. static RegisteredExternalClasses: {
  73283. [key: string]: Object;
  73284. };
  73285. /**
  73286. * Tries to instantiate a new object from a given class name
  73287. * @param className defines the class name to instantiate
  73288. * @returns the new object or null if the system was not able to do the instantiation
  73289. */
  73290. static Instantiate(className: string): any;
  73291. }
  73292. }
  73293. declare module BABYLON {
  73294. /**
  73295. * This represents the required contract to create a new type of texture loader.
  73296. */
  73297. export interface IInternalTextureLoader {
  73298. /**
  73299. * Defines wether the loader supports cascade loading the different faces.
  73300. */
  73301. supportCascades: boolean;
  73302. /**
  73303. * This returns if the loader support the current file information.
  73304. * @param extension defines the file extension of the file being loaded
  73305. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73306. * @param fallback defines the fallback internal texture if any
  73307. * @param isBase64 defines whether the texture is encoded as a base64
  73308. * @param isBuffer defines whether the texture data are stored as a buffer
  73309. * @returns true if the loader can load the specified file
  73310. */
  73311. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73312. /**
  73313. * Transform the url before loading if required.
  73314. * @param rootUrl the url of the texture
  73315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73316. * @returns the transformed texture
  73317. */
  73318. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73319. /**
  73320. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73321. * @param rootUrl the url of the texture
  73322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73323. * @returns the fallback texture
  73324. */
  73325. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73326. /**
  73327. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73328. * @param data contains the texture data
  73329. * @param texture defines the BabylonJS internal texture
  73330. * @param createPolynomials will be true if polynomials have been requested
  73331. * @param onLoad defines the callback to trigger once the texture is ready
  73332. * @param onError defines the callback to trigger in case of error
  73333. */
  73334. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73335. /**
  73336. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73337. * @param data contains the texture data
  73338. * @param texture defines the BabylonJS internal texture
  73339. * @param callback defines the method to call once ready to upload
  73340. */
  73341. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73342. }
  73343. }
  73344. declare module BABYLON {
  73345. interface Engine {
  73346. /**
  73347. * Creates a depth stencil cube texture.
  73348. * This is only available in WebGL 2.
  73349. * @param size The size of face edge in the cube texture.
  73350. * @param options The options defining the cube texture.
  73351. * @returns The cube texture
  73352. */
  73353. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  73354. /**
  73355. * Creates a cube texture
  73356. * @param rootUrl defines the url where the files to load is located
  73357. * @param scene defines the current scene
  73358. * @param files defines the list of files to load (1 per face)
  73359. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73360. * @param onLoad defines an optional callback raised when the texture is loaded
  73361. * @param onError defines an optional callback raised if there is an issue to load the texture
  73362. * @param format defines the format of the data
  73363. * @param forcedExtension defines the extension to use to pick the right loader
  73364. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73365. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73366. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73367. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  73368. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  73369. * @returns the cube texture as an InternalTexture
  73370. */
  73371. 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;
  73372. /**
  73373. * Creates a cube texture
  73374. * @param rootUrl defines the url where the files to load is located
  73375. * @param scene defines the current scene
  73376. * @param files defines the list of files to load (1 per face)
  73377. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73378. * @param onLoad defines an optional callback raised when the texture is loaded
  73379. * @param onError defines an optional callback raised if there is an issue to load the texture
  73380. * @param format defines the format of the data
  73381. * @param forcedExtension defines the extension to use to pick the right loader
  73382. * @returns the cube texture as an InternalTexture
  73383. */
  73384. 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;
  73385. /**
  73386. * Creates a cube texture
  73387. * @param rootUrl defines the url where the files to load is located
  73388. * @param scene defines the current scene
  73389. * @param files defines the list of files to load (1 per face)
  73390. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73391. * @param onLoad defines an optional callback raised when the texture is loaded
  73392. * @param onError defines an optional callback raised if there is an issue to load the texture
  73393. * @param format defines the format of the data
  73394. * @param forcedExtension defines the extension to use to pick the right loader
  73395. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73396. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73397. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73398. * @returns the cube texture as an InternalTexture
  73399. */
  73400. 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;
  73401. /** @hidden */
  73402. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73403. /** @hidden */
  73404. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73405. /** @hidden */
  73406. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73407. /** @hidden */
  73408. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73409. }
  73410. }
  73411. declare module BABYLON {
  73412. /**
  73413. * Class for creating a cube texture
  73414. */
  73415. export class CubeTexture extends BaseTexture {
  73416. private _delayedOnLoad;
  73417. /**
  73418. * The url of the texture
  73419. */
  73420. url: string;
  73421. /**
  73422. * Gets or sets the center of the bounding box associated with the cube texture.
  73423. * It must define where the camera used to render the texture was set
  73424. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73425. */
  73426. boundingBoxPosition: Vector3;
  73427. private _boundingBoxSize;
  73428. /**
  73429. * Gets or sets the size of the bounding box associated with the cube texture
  73430. * When defined, the cubemap will switch to local mode
  73431. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73432. * @example https://www.babylonjs-playground.com/#RNASML
  73433. */
  73434. /**
  73435. * Returns the bounding box size
  73436. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73437. */
  73438. boundingBoxSize: Vector3;
  73439. protected _rotationY: number;
  73440. /**
  73441. * Sets texture matrix rotation angle around Y axis in radians.
  73442. */
  73443. /**
  73444. * Gets texture matrix rotation angle around Y axis radians.
  73445. */
  73446. rotationY: number;
  73447. /**
  73448. * Are mip maps generated for this texture or not.
  73449. */
  73450. readonly noMipmap: boolean;
  73451. private _noMipmap;
  73452. private _files;
  73453. private _extensions;
  73454. private _textureMatrix;
  73455. private _format;
  73456. private _createPolynomials;
  73457. /** @hidden */
  73458. _prefiltered: boolean;
  73459. /**
  73460. * Creates a cube texture from an array of image urls
  73461. * @param files defines an array of image urls
  73462. * @param scene defines the hosting scene
  73463. * @param noMipmap specifies if mip maps are not used
  73464. * @returns a cube texture
  73465. */
  73466. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  73467. /**
  73468. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  73469. * @param url defines the url of the prefiltered texture
  73470. * @param scene defines the scene the texture is attached to
  73471. * @param forcedExtension defines the extension of the file if different from the url
  73472. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73473. * @return the prefiltered texture
  73474. */
  73475. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  73476. /**
  73477. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  73478. * as prefiltered data.
  73479. * @param rootUrl defines the url of the texture or the root name of the six images
  73480. * @param scene defines the scene the texture is attached to
  73481. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  73482. * @param noMipmap defines if mipmaps should be created or not
  73483. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  73484. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  73485. * @param onError defines a callback triggered in case of error during load
  73486. * @param format defines the internal format to use for the texture once loaded
  73487. * @param prefiltered defines whether or not the texture is created from prefiltered data
  73488. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  73489. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73490. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73491. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73492. * @return the cube texture
  73493. */
  73494. 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);
  73495. /**
  73496. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  73497. */
  73498. readonly isPrefiltered: boolean;
  73499. /**
  73500. * Get the current class name of the texture useful for serialization or dynamic coding.
  73501. * @returns "CubeTexture"
  73502. */
  73503. getClassName(): string;
  73504. /**
  73505. * Update the url (and optional buffer) of this texture if url was null during construction.
  73506. * @param url the url of the texture
  73507. * @param forcedExtension defines the extension to use
  73508. * @param onLoad callback called when the texture is loaded (defaults to null)
  73509. */
  73510. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  73511. /**
  73512. * Delays loading of the cube texture
  73513. * @param forcedExtension defines the extension to use
  73514. */
  73515. delayLoad(forcedExtension?: string): void;
  73516. /**
  73517. * Returns the reflection texture matrix
  73518. * @returns the reflection texture matrix
  73519. */
  73520. getReflectionTextureMatrix(): Matrix;
  73521. /**
  73522. * Sets the reflection texture matrix
  73523. * @param value Reflection texture matrix
  73524. */
  73525. setReflectionTextureMatrix(value: Matrix): void;
  73526. /**
  73527. * Parses text to create a cube texture
  73528. * @param parsedTexture define the serialized text to read from
  73529. * @param scene defines the hosting scene
  73530. * @param rootUrl defines the root url of the cube texture
  73531. * @returns a cube texture
  73532. */
  73533. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  73534. /**
  73535. * Makes a clone, or deep copy, of the cube texture
  73536. * @returns a new cube texture
  73537. */
  73538. clone(): CubeTexture;
  73539. }
  73540. }
  73541. declare module BABYLON {
  73542. /**
  73543. * Manages the defines for the Material
  73544. */
  73545. export class MaterialDefines {
  73546. /** @hidden */
  73547. protected _keys: string[];
  73548. private _isDirty;
  73549. /** @hidden */
  73550. _renderId: number;
  73551. /** @hidden */
  73552. _areLightsDirty: boolean;
  73553. /** @hidden */
  73554. _areLightsDisposed: boolean;
  73555. /** @hidden */
  73556. _areAttributesDirty: boolean;
  73557. /** @hidden */
  73558. _areTexturesDirty: boolean;
  73559. /** @hidden */
  73560. _areFresnelDirty: boolean;
  73561. /** @hidden */
  73562. _areMiscDirty: boolean;
  73563. /** @hidden */
  73564. _areImageProcessingDirty: boolean;
  73565. /** @hidden */
  73566. _normals: boolean;
  73567. /** @hidden */
  73568. _uvs: boolean;
  73569. /** @hidden */
  73570. _needNormals: boolean;
  73571. /** @hidden */
  73572. _needUVs: boolean;
  73573. [id: string]: any;
  73574. /**
  73575. * Specifies if the material needs to be re-calculated
  73576. */
  73577. readonly isDirty: boolean;
  73578. /**
  73579. * Marks the material to indicate that it has been re-calculated
  73580. */
  73581. markAsProcessed(): void;
  73582. /**
  73583. * Marks the material to indicate that it needs to be re-calculated
  73584. */
  73585. markAsUnprocessed(): void;
  73586. /**
  73587. * Marks the material to indicate all of its defines need to be re-calculated
  73588. */
  73589. markAllAsDirty(): void;
  73590. /**
  73591. * Marks the material to indicate that image processing needs to be re-calculated
  73592. */
  73593. markAsImageProcessingDirty(): void;
  73594. /**
  73595. * Marks the material to indicate the lights need to be re-calculated
  73596. * @param disposed Defines whether the light is dirty due to dispose or not
  73597. */
  73598. markAsLightDirty(disposed?: boolean): void;
  73599. /**
  73600. * Marks the attribute state as changed
  73601. */
  73602. markAsAttributesDirty(): void;
  73603. /**
  73604. * Marks the texture state as changed
  73605. */
  73606. markAsTexturesDirty(): void;
  73607. /**
  73608. * Marks the fresnel state as changed
  73609. */
  73610. markAsFresnelDirty(): void;
  73611. /**
  73612. * Marks the misc state as changed
  73613. */
  73614. markAsMiscDirty(): void;
  73615. /**
  73616. * Rebuilds the material defines
  73617. */
  73618. rebuild(): void;
  73619. /**
  73620. * Specifies if two material defines are equal
  73621. * @param other - A material define instance to compare to
  73622. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  73623. */
  73624. isEqual(other: MaterialDefines): boolean;
  73625. /**
  73626. * Clones this instance's defines to another instance
  73627. * @param other - material defines to clone values to
  73628. */
  73629. cloneTo(other: MaterialDefines): void;
  73630. /**
  73631. * Resets the material define values
  73632. */
  73633. reset(): void;
  73634. /**
  73635. * Converts the material define values to a string
  73636. * @returns - String of material define information
  73637. */
  73638. toString(): string;
  73639. }
  73640. }
  73641. declare module BABYLON {
  73642. /**
  73643. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  73644. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  73645. * 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;
  73646. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  73647. */
  73648. export class ColorCurves {
  73649. private _dirty;
  73650. private _tempColor;
  73651. private _globalCurve;
  73652. private _highlightsCurve;
  73653. private _midtonesCurve;
  73654. private _shadowsCurve;
  73655. private _positiveCurve;
  73656. private _negativeCurve;
  73657. private _globalHue;
  73658. private _globalDensity;
  73659. private _globalSaturation;
  73660. private _globalExposure;
  73661. /**
  73662. * Gets the global Hue value.
  73663. * 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).
  73664. */
  73665. /**
  73666. * Sets the global Hue value.
  73667. * 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).
  73668. */
  73669. globalHue: number;
  73670. /**
  73671. * Gets the global Density value.
  73672. * 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.
  73673. * Values less than zero provide a filter of opposite hue.
  73674. */
  73675. /**
  73676. * Sets the global Density value.
  73677. * 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.
  73678. * Values less than zero provide a filter of opposite hue.
  73679. */
  73680. globalDensity: number;
  73681. /**
  73682. * Gets the global Saturation value.
  73683. * 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.
  73684. */
  73685. /**
  73686. * Sets the global Saturation value.
  73687. * 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.
  73688. */
  73689. globalSaturation: number;
  73690. /**
  73691. * Gets the global Exposure value.
  73692. * 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.
  73693. */
  73694. /**
  73695. * Sets the global Exposure value.
  73696. * 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.
  73697. */
  73698. globalExposure: number;
  73699. private _highlightsHue;
  73700. private _highlightsDensity;
  73701. private _highlightsSaturation;
  73702. private _highlightsExposure;
  73703. /**
  73704. * Gets the highlights Hue value.
  73705. * 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).
  73706. */
  73707. /**
  73708. * Sets the highlights Hue value.
  73709. * 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).
  73710. */
  73711. highlightsHue: number;
  73712. /**
  73713. * Gets the highlights Density value.
  73714. * 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.
  73715. * Values less than zero provide a filter of opposite hue.
  73716. */
  73717. /**
  73718. * Sets the highlights Density value.
  73719. * 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.
  73720. * Values less than zero provide a filter of opposite hue.
  73721. */
  73722. highlightsDensity: number;
  73723. /**
  73724. * Gets the highlights Saturation value.
  73725. * 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.
  73726. */
  73727. /**
  73728. * Sets the highlights Saturation value.
  73729. * 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.
  73730. */
  73731. highlightsSaturation: number;
  73732. /**
  73733. * Gets the highlights Exposure value.
  73734. * 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.
  73735. */
  73736. /**
  73737. * Sets the highlights Exposure value.
  73738. * 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.
  73739. */
  73740. highlightsExposure: number;
  73741. private _midtonesHue;
  73742. private _midtonesDensity;
  73743. private _midtonesSaturation;
  73744. private _midtonesExposure;
  73745. /**
  73746. * Gets the midtones Hue value.
  73747. * 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).
  73748. */
  73749. /**
  73750. * Sets the midtones Hue value.
  73751. * 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).
  73752. */
  73753. midtonesHue: number;
  73754. /**
  73755. * Gets the midtones Density value.
  73756. * 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.
  73757. * Values less than zero provide a filter of opposite hue.
  73758. */
  73759. /**
  73760. * Sets the midtones Density value.
  73761. * 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.
  73762. * Values less than zero provide a filter of opposite hue.
  73763. */
  73764. midtonesDensity: number;
  73765. /**
  73766. * Gets the midtones Saturation value.
  73767. * 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.
  73768. */
  73769. /**
  73770. * Sets the midtones Saturation value.
  73771. * 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.
  73772. */
  73773. midtonesSaturation: number;
  73774. /**
  73775. * Gets the midtones Exposure value.
  73776. * 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.
  73777. */
  73778. /**
  73779. * Sets the midtones Exposure value.
  73780. * 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.
  73781. */
  73782. midtonesExposure: number;
  73783. private _shadowsHue;
  73784. private _shadowsDensity;
  73785. private _shadowsSaturation;
  73786. private _shadowsExposure;
  73787. /**
  73788. * Gets the shadows Hue value.
  73789. * 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).
  73790. */
  73791. /**
  73792. * Sets the shadows Hue value.
  73793. * 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).
  73794. */
  73795. shadowsHue: number;
  73796. /**
  73797. * Gets the shadows Density value.
  73798. * 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.
  73799. * Values less than zero provide a filter of opposite hue.
  73800. */
  73801. /**
  73802. * Sets the shadows Density value.
  73803. * 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.
  73804. * Values less than zero provide a filter of opposite hue.
  73805. */
  73806. shadowsDensity: number;
  73807. /**
  73808. * Gets the shadows Saturation value.
  73809. * 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.
  73810. */
  73811. /**
  73812. * Sets the shadows Saturation value.
  73813. * 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.
  73814. */
  73815. shadowsSaturation: number;
  73816. /**
  73817. * Gets the shadows Exposure value.
  73818. * 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.
  73819. */
  73820. /**
  73821. * Sets the shadows Exposure value.
  73822. * 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.
  73823. */
  73824. shadowsExposure: number;
  73825. /**
  73826. * Returns the class name
  73827. * @returns The class name
  73828. */
  73829. getClassName(): string;
  73830. /**
  73831. * Binds the color curves to the shader.
  73832. * @param colorCurves The color curve to bind
  73833. * @param effect The effect to bind to
  73834. * @param positiveUniform The positive uniform shader parameter
  73835. * @param neutralUniform The neutral uniform shader parameter
  73836. * @param negativeUniform The negative uniform shader parameter
  73837. */
  73838. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  73839. /**
  73840. * Prepare the list of uniforms associated with the ColorCurves effects.
  73841. * @param uniformsList The list of uniforms used in the effect
  73842. */
  73843. static PrepareUniforms(uniformsList: string[]): void;
  73844. /**
  73845. * Returns color grading data based on a hue, density, saturation and exposure value.
  73846. * @param filterHue The hue of the color filter.
  73847. * @param filterDensity The density of the color filter.
  73848. * @param saturation The saturation.
  73849. * @param exposure The exposure.
  73850. * @param result The result data container.
  73851. */
  73852. private getColorGradingDataToRef;
  73853. /**
  73854. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  73855. * @param value The input slider value in range [-100,100].
  73856. * @returns Adjusted value.
  73857. */
  73858. private static applyColorGradingSliderNonlinear;
  73859. /**
  73860. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  73861. * @param hue The hue (H) input.
  73862. * @param saturation The saturation (S) input.
  73863. * @param brightness The brightness (B) input.
  73864. * @result An RGBA color represented as Vector4.
  73865. */
  73866. private static fromHSBToRef;
  73867. /**
  73868. * Returns a value clamped between min and max
  73869. * @param value The value to clamp
  73870. * @param min The minimum of value
  73871. * @param max The maximum of value
  73872. * @returns The clamped value.
  73873. */
  73874. private static clamp;
  73875. /**
  73876. * Clones the current color curve instance.
  73877. * @return The cloned curves
  73878. */
  73879. clone(): ColorCurves;
  73880. /**
  73881. * Serializes the current color curve instance to a json representation.
  73882. * @return a JSON representation
  73883. */
  73884. serialize(): any;
  73885. /**
  73886. * Parses the color curve from a json representation.
  73887. * @param source the JSON source to parse
  73888. * @return The parsed curves
  73889. */
  73890. static Parse(source: any): ColorCurves;
  73891. }
  73892. }
  73893. declare module BABYLON {
  73894. /**
  73895. * Interface to follow in your material defines to integrate easily the
  73896. * Image proccessing functions.
  73897. * @hidden
  73898. */
  73899. export interface IImageProcessingConfigurationDefines {
  73900. IMAGEPROCESSING: boolean;
  73901. VIGNETTE: boolean;
  73902. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73903. VIGNETTEBLENDMODEOPAQUE: boolean;
  73904. TONEMAPPING: boolean;
  73905. TONEMAPPING_ACES: boolean;
  73906. CONTRAST: boolean;
  73907. EXPOSURE: boolean;
  73908. COLORCURVES: boolean;
  73909. COLORGRADING: boolean;
  73910. COLORGRADING3D: boolean;
  73911. SAMPLER3DGREENDEPTH: boolean;
  73912. SAMPLER3DBGRMAP: boolean;
  73913. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73914. }
  73915. /**
  73916. * @hidden
  73917. */
  73918. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  73919. IMAGEPROCESSING: boolean;
  73920. VIGNETTE: boolean;
  73921. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73922. VIGNETTEBLENDMODEOPAQUE: boolean;
  73923. TONEMAPPING: boolean;
  73924. TONEMAPPING_ACES: boolean;
  73925. CONTRAST: boolean;
  73926. COLORCURVES: boolean;
  73927. COLORGRADING: boolean;
  73928. COLORGRADING3D: boolean;
  73929. SAMPLER3DGREENDEPTH: boolean;
  73930. SAMPLER3DBGRMAP: boolean;
  73931. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73932. EXPOSURE: boolean;
  73933. constructor();
  73934. }
  73935. /**
  73936. * This groups together the common properties used for image processing either in direct forward pass
  73937. * or through post processing effect depending on the use of the image processing pipeline in your scene
  73938. * or not.
  73939. */
  73940. export class ImageProcessingConfiguration {
  73941. /**
  73942. * Default tone mapping applied in BabylonJS.
  73943. */
  73944. static readonly TONEMAPPING_STANDARD: number;
  73945. /**
  73946. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  73947. * to other engines rendering to increase portability.
  73948. */
  73949. static readonly TONEMAPPING_ACES: number;
  73950. /**
  73951. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73952. */
  73953. colorCurves: Nullable<ColorCurves>;
  73954. private _colorCurvesEnabled;
  73955. /**
  73956. * Gets wether the color curves effect is enabled.
  73957. */
  73958. /**
  73959. * Sets wether the color curves effect is enabled.
  73960. */
  73961. colorCurvesEnabled: boolean;
  73962. private _colorGradingTexture;
  73963. /**
  73964. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73965. */
  73966. /**
  73967. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73968. */
  73969. colorGradingTexture: Nullable<BaseTexture>;
  73970. private _colorGradingEnabled;
  73971. /**
  73972. * Gets wether the color grading effect is enabled.
  73973. */
  73974. /**
  73975. * Sets wether the color grading effect is enabled.
  73976. */
  73977. colorGradingEnabled: boolean;
  73978. private _colorGradingWithGreenDepth;
  73979. /**
  73980. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73981. */
  73982. /**
  73983. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73984. */
  73985. colorGradingWithGreenDepth: boolean;
  73986. private _colorGradingBGR;
  73987. /**
  73988. * Gets wether the color grading texture contains BGR values.
  73989. */
  73990. /**
  73991. * Sets wether the color grading texture contains BGR values.
  73992. */
  73993. colorGradingBGR: boolean;
  73994. /** @hidden */
  73995. _exposure: number;
  73996. /**
  73997. * Gets the Exposure used in the effect.
  73998. */
  73999. /**
  74000. * Sets the Exposure used in the effect.
  74001. */
  74002. exposure: number;
  74003. private _toneMappingEnabled;
  74004. /**
  74005. * Gets wether the tone mapping effect is enabled.
  74006. */
  74007. /**
  74008. * Sets wether the tone mapping effect is enabled.
  74009. */
  74010. toneMappingEnabled: boolean;
  74011. private _toneMappingType;
  74012. /**
  74013. * Gets the type of tone mapping effect.
  74014. */
  74015. /**
  74016. * Sets the type of tone mapping effect used in BabylonJS.
  74017. */
  74018. toneMappingType: number;
  74019. protected _contrast: number;
  74020. /**
  74021. * Gets the contrast used in the effect.
  74022. */
  74023. /**
  74024. * Sets the contrast used in the effect.
  74025. */
  74026. contrast: number;
  74027. /**
  74028. * Vignette stretch size.
  74029. */
  74030. vignetteStretch: number;
  74031. /**
  74032. * Vignette centre X Offset.
  74033. */
  74034. vignetteCentreX: number;
  74035. /**
  74036. * Vignette centre Y Offset.
  74037. */
  74038. vignetteCentreY: number;
  74039. /**
  74040. * Vignette weight or intensity of the vignette effect.
  74041. */
  74042. vignetteWeight: number;
  74043. /**
  74044. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74045. * if vignetteEnabled is set to true.
  74046. */
  74047. vignetteColor: Color4;
  74048. /**
  74049. * Camera field of view used by the Vignette effect.
  74050. */
  74051. vignetteCameraFov: number;
  74052. private _vignetteBlendMode;
  74053. /**
  74054. * Gets the vignette blend mode allowing different kind of effect.
  74055. */
  74056. /**
  74057. * Sets the vignette blend mode allowing different kind of effect.
  74058. */
  74059. vignetteBlendMode: number;
  74060. private _vignetteEnabled;
  74061. /**
  74062. * Gets wether the vignette effect is enabled.
  74063. */
  74064. /**
  74065. * Sets wether the vignette effect is enabled.
  74066. */
  74067. vignetteEnabled: boolean;
  74068. private _applyByPostProcess;
  74069. /**
  74070. * Gets wether the image processing is applied through a post process or not.
  74071. */
  74072. /**
  74073. * Sets wether the image processing is applied through a post process or not.
  74074. */
  74075. applyByPostProcess: boolean;
  74076. private _isEnabled;
  74077. /**
  74078. * Gets wether the image processing is enabled or not.
  74079. */
  74080. /**
  74081. * Sets wether the image processing is enabled or not.
  74082. */
  74083. isEnabled: boolean;
  74084. /**
  74085. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74086. */
  74087. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74088. /**
  74089. * Method called each time the image processing information changes requires to recompile the effect.
  74090. */
  74091. protected _updateParameters(): void;
  74092. /**
  74093. * Gets the current class name.
  74094. * @return "ImageProcessingConfiguration"
  74095. */
  74096. getClassName(): string;
  74097. /**
  74098. * Prepare the list of uniforms associated with the Image Processing effects.
  74099. * @param uniforms The list of uniforms used in the effect
  74100. * @param defines the list of defines currently in use
  74101. */
  74102. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74103. /**
  74104. * Prepare the list of samplers associated with the Image Processing effects.
  74105. * @param samplersList The list of uniforms used in the effect
  74106. * @param defines the list of defines currently in use
  74107. */
  74108. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74109. /**
  74110. * Prepare the list of defines associated to the shader.
  74111. * @param defines the list of defines to complete
  74112. * @param forPostProcess Define if we are currently in post process mode or not
  74113. */
  74114. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  74115. /**
  74116. * Returns true if all the image processing information are ready.
  74117. * @returns True if ready, otherwise, false
  74118. */
  74119. isReady(): boolean;
  74120. /**
  74121. * Binds the image processing to the shader.
  74122. * @param effect The effect to bind to
  74123. * @param aspectRatio Define the current aspect ratio of the effect
  74124. */
  74125. bind(effect: Effect, aspectRatio?: number): void;
  74126. /**
  74127. * Clones the current image processing instance.
  74128. * @return The cloned image processing
  74129. */
  74130. clone(): ImageProcessingConfiguration;
  74131. /**
  74132. * Serializes the current image processing instance to a json representation.
  74133. * @return a JSON representation
  74134. */
  74135. serialize(): any;
  74136. /**
  74137. * Parses the image processing from a json representation.
  74138. * @param source the JSON source to parse
  74139. * @return The parsed image processing
  74140. */
  74141. static Parse(source: any): ImageProcessingConfiguration;
  74142. private static _VIGNETTEMODE_MULTIPLY;
  74143. private static _VIGNETTEMODE_OPAQUE;
  74144. /**
  74145. * Used to apply the vignette as a mix with the pixel color.
  74146. */
  74147. static readonly VIGNETTEMODE_MULTIPLY: number;
  74148. /**
  74149. * Used to apply the vignette as a replacement of the pixel color.
  74150. */
  74151. static readonly VIGNETTEMODE_OPAQUE: number;
  74152. }
  74153. }
  74154. declare module BABYLON {
  74155. /** @hidden */
  74156. export var postprocessVertexShader: {
  74157. name: string;
  74158. shader: string;
  74159. };
  74160. }
  74161. declare module BABYLON {
  74162. /** Defines supported spaces */
  74163. export enum Space {
  74164. /** Local (object) space */
  74165. LOCAL = 0,
  74166. /** World space */
  74167. WORLD = 1,
  74168. /** Bone space */
  74169. BONE = 2
  74170. }
  74171. /** Defines the 3 main axes */
  74172. export class Axis {
  74173. /** X axis */
  74174. static X: Vector3;
  74175. /** Y axis */
  74176. static Y: Vector3;
  74177. /** Z axis */
  74178. static Z: Vector3;
  74179. }
  74180. }
  74181. declare module BABYLON {
  74182. /**
  74183. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  74184. * This is the base of the follow, arc rotate cameras and Free camera
  74185. * @see http://doc.babylonjs.com/features/cameras
  74186. */
  74187. export class TargetCamera extends Camera {
  74188. private static _RigCamTransformMatrix;
  74189. private static _TargetTransformMatrix;
  74190. private static _TargetFocalPoint;
  74191. /**
  74192. * Define the current direction the camera is moving to
  74193. */
  74194. cameraDirection: Vector3;
  74195. /**
  74196. * Define the current rotation the camera is rotating to
  74197. */
  74198. cameraRotation: Vector2;
  74199. /**
  74200. * When set, the up vector of the camera will be updated by the rotation of the camera
  74201. */
  74202. updateUpVectorFromRotation: boolean;
  74203. private _tmpQuaternion;
  74204. /**
  74205. * Define the current rotation of the camera
  74206. */
  74207. rotation: Vector3;
  74208. /**
  74209. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  74210. */
  74211. rotationQuaternion: Quaternion;
  74212. /**
  74213. * Define the current speed of the camera
  74214. */
  74215. speed: number;
  74216. /**
  74217. * Add cconstraint to the camera to prevent it to move freely in all directions and
  74218. * around all axis.
  74219. */
  74220. noRotationConstraint: boolean;
  74221. /**
  74222. * Define the current target of the camera as an object or a position.
  74223. */
  74224. lockedTarget: any;
  74225. /** @hidden */
  74226. _currentTarget: Vector3;
  74227. /** @hidden */
  74228. _initialFocalDistance: number;
  74229. /** @hidden */
  74230. _viewMatrix: Matrix;
  74231. /** @hidden */
  74232. _camMatrix: Matrix;
  74233. /** @hidden */
  74234. _cameraTransformMatrix: Matrix;
  74235. /** @hidden */
  74236. _cameraRotationMatrix: Matrix;
  74237. /** @hidden */
  74238. _referencePoint: Vector3;
  74239. /** @hidden */
  74240. _transformedReferencePoint: Vector3;
  74241. protected _globalCurrentTarget: Vector3;
  74242. protected _globalCurrentUpVector: Vector3;
  74243. /** @hidden */
  74244. _reset: () => void;
  74245. private _defaultUp;
  74246. /**
  74247. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  74248. * This is the base of the follow, arc rotate cameras and Free camera
  74249. * @see http://doc.babylonjs.com/features/cameras
  74250. * @param name Defines the name of the camera in the scene
  74251. * @param position Defines the start position of the camera in the scene
  74252. * @param scene Defines the scene the camera belongs to
  74253. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74254. */
  74255. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74256. /**
  74257. * Gets the position in front of the camera at a given distance.
  74258. * @param distance The distance from the camera we want the position to be
  74259. * @returns the position
  74260. */
  74261. getFrontPosition(distance: number): Vector3;
  74262. /** @hidden */
  74263. _getLockedTargetPosition(): Nullable<Vector3>;
  74264. private _storedPosition;
  74265. private _storedRotation;
  74266. private _storedRotationQuaternion;
  74267. /**
  74268. * Store current camera state of the camera (fov, position, rotation, etc..)
  74269. * @returns the camera
  74270. */
  74271. storeState(): Camera;
  74272. /**
  74273. * Restored camera state. You must call storeState() first
  74274. * @returns whether it was successful or not
  74275. * @hidden
  74276. */
  74277. _restoreStateValues(): boolean;
  74278. /** @hidden */
  74279. _initCache(): void;
  74280. /** @hidden */
  74281. _updateCache(ignoreParentClass?: boolean): void;
  74282. /** @hidden */
  74283. _isSynchronizedViewMatrix(): boolean;
  74284. /** @hidden */
  74285. _computeLocalCameraSpeed(): number;
  74286. /**
  74287. * Defines the target the camera should look at.
  74288. * @param target Defines the new target as a Vector or a mesh
  74289. */
  74290. setTarget(target: Vector3): void;
  74291. /**
  74292. * Return the current target position of the camera. This value is expressed in local space.
  74293. * @returns the target position
  74294. */
  74295. getTarget(): Vector3;
  74296. /** @hidden */
  74297. _decideIfNeedsToMove(): boolean;
  74298. /** @hidden */
  74299. _updatePosition(): void;
  74300. /** @hidden */
  74301. _checkInputs(): void;
  74302. protected _updateCameraRotationMatrix(): void;
  74303. /**
  74304. * 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)
  74305. * @returns the current camera
  74306. */
  74307. private _rotateUpVectorWithCameraRotationMatrix;
  74308. private _cachedRotationZ;
  74309. private _cachedQuaternionRotationZ;
  74310. /** @hidden */
  74311. _getViewMatrix(): Matrix;
  74312. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  74313. /**
  74314. * @hidden
  74315. */
  74316. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  74317. /**
  74318. * @hidden
  74319. */
  74320. _updateRigCameras(): void;
  74321. private _getRigCamPositionAndTarget;
  74322. /**
  74323. * Gets the current object class name.
  74324. * @return the class name
  74325. */
  74326. getClassName(): string;
  74327. }
  74328. }
  74329. declare module BABYLON {
  74330. /**
  74331. * Gather the list of keyboard event types as constants.
  74332. */
  74333. export class KeyboardEventTypes {
  74334. /**
  74335. * The keydown event is fired when a key becomes active (pressed).
  74336. */
  74337. static readonly KEYDOWN: number;
  74338. /**
  74339. * The keyup event is fired when a key has been released.
  74340. */
  74341. static readonly KEYUP: number;
  74342. }
  74343. /**
  74344. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74345. */
  74346. export class KeyboardInfo {
  74347. /**
  74348. * Defines the type of event (KeyboardEventTypes)
  74349. */
  74350. type: number;
  74351. /**
  74352. * Defines the related dom event
  74353. */
  74354. event: KeyboardEvent;
  74355. /**
  74356. * Instantiates a new keyboard info.
  74357. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74358. * @param type Defines the type of event (KeyboardEventTypes)
  74359. * @param event Defines the related dom event
  74360. */
  74361. constructor(
  74362. /**
  74363. * Defines the type of event (KeyboardEventTypes)
  74364. */
  74365. type: number,
  74366. /**
  74367. * Defines the related dom event
  74368. */
  74369. event: KeyboardEvent);
  74370. }
  74371. /**
  74372. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74373. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  74374. */
  74375. export class KeyboardInfoPre extends KeyboardInfo {
  74376. /**
  74377. * Defines the type of event (KeyboardEventTypes)
  74378. */
  74379. type: number;
  74380. /**
  74381. * Defines the related dom event
  74382. */
  74383. event: KeyboardEvent;
  74384. /**
  74385. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  74386. */
  74387. skipOnPointerObservable: boolean;
  74388. /**
  74389. * Instantiates a new keyboard pre info.
  74390. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74391. * @param type Defines the type of event (KeyboardEventTypes)
  74392. * @param event Defines the related dom event
  74393. */
  74394. constructor(
  74395. /**
  74396. * Defines the type of event (KeyboardEventTypes)
  74397. */
  74398. type: number,
  74399. /**
  74400. * Defines the related dom event
  74401. */
  74402. event: KeyboardEvent);
  74403. }
  74404. }
  74405. declare module BABYLON {
  74406. /**
  74407. * Manage the keyboard inputs to control the movement of a free camera.
  74408. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74409. */
  74410. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  74411. /**
  74412. * Defines the camera the input is attached to.
  74413. */
  74414. camera: FreeCamera;
  74415. /**
  74416. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74417. */
  74418. keysUp: number[];
  74419. /**
  74420. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74421. */
  74422. keysDown: number[];
  74423. /**
  74424. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74425. */
  74426. keysLeft: number[];
  74427. /**
  74428. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74429. */
  74430. keysRight: number[];
  74431. private _keys;
  74432. private _onCanvasBlurObserver;
  74433. private _onKeyboardObserver;
  74434. private _engine;
  74435. private _scene;
  74436. /**
  74437. * Attach the input controls to a specific dom element to get the input from.
  74438. * @param element Defines the element the controls should be listened from
  74439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74440. */
  74441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74442. /**
  74443. * Detach the current controls from the specified dom element.
  74444. * @param element Defines the element to stop listening the inputs from
  74445. */
  74446. detachControl(element: Nullable<HTMLElement>): void;
  74447. /**
  74448. * Update the current camera state depending on the inputs that have been used this frame.
  74449. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74450. */
  74451. checkInputs(): void;
  74452. /**
  74453. * Gets the class name of the current intput.
  74454. * @returns the class name
  74455. */
  74456. getClassName(): string;
  74457. /** @hidden */
  74458. _onLostFocus(): void;
  74459. /**
  74460. * Get the friendly name associated with the input class.
  74461. * @returns the input friendly name
  74462. */
  74463. getSimpleName(): string;
  74464. }
  74465. }
  74466. declare module BABYLON {
  74467. /**
  74468. * Interface describing all the common properties and methods a shadow light needs to implement.
  74469. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  74470. * as well as binding the different shadow properties to the effects.
  74471. */
  74472. export interface IShadowLight extends Light {
  74473. /**
  74474. * The light id in the scene (used in scene.findLighById for instance)
  74475. */
  74476. id: string;
  74477. /**
  74478. * The position the shdow will be casted from.
  74479. */
  74480. position: Vector3;
  74481. /**
  74482. * In 2d mode (needCube being false), the direction used to cast the shadow.
  74483. */
  74484. direction: Vector3;
  74485. /**
  74486. * The transformed position. Position of the light in world space taking parenting in account.
  74487. */
  74488. transformedPosition: Vector3;
  74489. /**
  74490. * The transformed direction. Direction of the light in world space taking parenting in account.
  74491. */
  74492. transformedDirection: Vector3;
  74493. /**
  74494. * The friendly name of the light in the scene.
  74495. */
  74496. name: string;
  74497. /**
  74498. * Defines the shadow projection clipping minimum z value.
  74499. */
  74500. shadowMinZ: number;
  74501. /**
  74502. * Defines the shadow projection clipping maximum z value.
  74503. */
  74504. shadowMaxZ: number;
  74505. /**
  74506. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74507. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74508. */
  74509. computeTransformedInformation(): boolean;
  74510. /**
  74511. * Gets the scene the light belongs to.
  74512. * @returns The scene
  74513. */
  74514. getScene(): Scene;
  74515. /**
  74516. * Callback defining a custom Projection Matrix Builder.
  74517. * This can be used to override the default projection matrix computation.
  74518. */
  74519. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74520. /**
  74521. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74522. * @param matrix The materix to updated with the projection information
  74523. * @param viewMatrix The transform matrix of the light
  74524. * @param renderList The list of mesh to render in the map
  74525. * @returns The current light
  74526. */
  74527. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74528. /**
  74529. * Gets the current depth scale used in ESM.
  74530. * @returns The scale
  74531. */
  74532. getDepthScale(): number;
  74533. /**
  74534. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74535. * @returns true if a cube texture needs to be use
  74536. */
  74537. needCube(): boolean;
  74538. /**
  74539. * Detects if the projection matrix requires to be recomputed this frame.
  74540. * @returns true if it requires to be recomputed otherwise, false.
  74541. */
  74542. needProjectionMatrixCompute(): boolean;
  74543. /**
  74544. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74545. */
  74546. forceProjectionMatrixCompute(): void;
  74547. /**
  74548. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74549. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74550. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74551. */
  74552. getShadowDirection(faceIndex?: number): Vector3;
  74553. /**
  74554. * Gets the minZ used for shadow according to both the scene and the light.
  74555. * @param activeCamera The camera we are returning the min for
  74556. * @returns the depth min z
  74557. */
  74558. getDepthMinZ(activeCamera: Camera): number;
  74559. /**
  74560. * Gets the maxZ used for shadow according to both the scene and the light.
  74561. * @param activeCamera The camera we are returning the max for
  74562. * @returns the depth max z
  74563. */
  74564. getDepthMaxZ(activeCamera: Camera): number;
  74565. }
  74566. /**
  74567. * Base implementation IShadowLight
  74568. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  74569. */
  74570. export abstract class ShadowLight extends Light implements IShadowLight {
  74571. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  74572. protected _position: Vector3;
  74573. protected _setPosition(value: Vector3): void;
  74574. /**
  74575. * Sets the position the shadow will be casted from. Also use as the light position for both
  74576. * point and spot lights.
  74577. */
  74578. /**
  74579. * Sets the position the shadow will be casted from. Also use as the light position for both
  74580. * point and spot lights.
  74581. */
  74582. position: Vector3;
  74583. protected _direction: Vector3;
  74584. protected _setDirection(value: Vector3): void;
  74585. /**
  74586. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  74587. * Also use as the light direction on spot and directional lights.
  74588. */
  74589. /**
  74590. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  74591. * Also use as the light direction on spot and directional lights.
  74592. */
  74593. direction: Vector3;
  74594. private _shadowMinZ;
  74595. /**
  74596. * Gets the shadow projection clipping minimum z value.
  74597. */
  74598. /**
  74599. * Sets the shadow projection clipping minimum z value.
  74600. */
  74601. shadowMinZ: number;
  74602. private _shadowMaxZ;
  74603. /**
  74604. * Sets the shadow projection clipping maximum z value.
  74605. */
  74606. /**
  74607. * Gets the shadow projection clipping maximum z value.
  74608. */
  74609. shadowMaxZ: number;
  74610. /**
  74611. * Callback defining a custom Projection Matrix Builder.
  74612. * This can be used to override the default projection matrix computation.
  74613. */
  74614. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74615. /**
  74616. * The transformed position. Position of the light in world space taking parenting in account.
  74617. */
  74618. transformedPosition: Vector3;
  74619. /**
  74620. * The transformed direction. Direction of the light in world space taking parenting in account.
  74621. */
  74622. transformedDirection: Vector3;
  74623. private _needProjectionMatrixCompute;
  74624. /**
  74625. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74626. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74627. */
  74628. computeTransformedInformation(): boolean;
  74629. /**
  74630. * Return the depth scale used for the shadow map.
  74631. * @returns the depth scale.
  74632. */
  74633. getDepthScale(): number;
  74634. /**
  74635. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74636. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74637. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74638. */
  74639. getShadowDirection(faceIndex?: number): Vector3;
  74640. /**
  74641. * Returns the ShadowLight absolute position in the World.
  74642. * @returns the position vector in world space
  74643. */
  74644. getAbsolutePosition(): Vector3;
  74645. /**
  74646. * Sets the ShadowLight direction toward the passed target.
  74647. * @param target The point to target in local space
  74648. * @returns the updated ShadowLight direction
  74649. */
  74650. setDirectionToTarget(target: Vector3): Vector3;
  74651. /**
  74652. * Returns the light rotation in euler definition.
  74653. * @returns the x y z rotation in local space.
  74654. */
  74655. getRotation(): Vector3;
  74656. /**
  74657. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74658. * @returns true if a cube texture needs to be use
  74659. */
  74660. needCube(): boolean;
  74661. /**
  74662. * Detects if the projection matrix requires to be recomputed this frame.
  74663. * @returns true if it requires to be recomputed otherwise, false.
  74664. */
  74665. needProjectionMatrixCompute(): boolean;
  74666. /**
  74667. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74668. */
  74669. forceProjectionMatrixCompute(): void;
  74670. /** @hidden */
  74671. _initCache(): void;
  74672. /** @hidden */
  74673. _isSynchronized(): boolean;
  74674. /**
  74675. * Computes the world matrix of the node
  74676. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  74677. * @returns the world matrix
  74678. */
  74679. computeWorldMatrix(force?: boolean): Matrix;
  74680. /**
  74681. * Gets the minZ used for shadow according to both the scene and the light.
  74682. * @param activeCamera The camera we are returning the min for
  74683. * @returns the depth min z
  74684. */
  74685. getDepthMinZ(activeCamera: Camera): number;
  74686. /**
  74687. * Gets the maxZ used for shadow according to both the scene and the light.
  74688. * @param activeCamera The camera we are returning the max for
  74689. * @returns the depth max z
  74690. */
  74691. getDepthMaxZ(activeCamera: Camera): number;
  74692. /**
  74693. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74694. * @param matrix The materix to updated with the projection information
  74695. * @param viewMatrix The transform matrix of the light
  74696. * @param renderList The list of mesh to render in the map
  74697. * @returns The current light
  74698. */
  74699. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74700. }
  74701. }
  74702. declare module BABYLON {
  74703. /**
  74704. * "Static Class" containing the most commonly used helper while dealing with material for
  74705. * rendering purpose.
  74706. *
  74707. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  74708. *
  74709. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  74710. */
  74711. export class MaterialHelper {
  74712. /**
  74713. * Bind the current view position to an effect.
  74714. * @param effect The effect to be bound
  74715. * @param scene The scene the eyes position is used from
  74716. */
  74717. static BindEyePosition(effect: Effect, scene: Scene): void;
  74718. /**
  74719. * Helps preparing the defines values about the UVs in used in the effect.
  74720. * UVs are shared as much as we can accross channels in the shaders.
  74721. * @param texture The texture we are preparing the UVs for
  74722. * @param defines The defines to update
  74723. * @param key The channel key "diffuse", "specular"... used in the shader
  74724. */
  74725. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  74726. /**
  74727. * Binds a texture matrix value to its corrsponding uniform
  74728. * @param texture The texture to bind the matrix for
  74729. * @param uniformBuffer The uniform buffer receivin the data
  74730. * @param key The channel key "diffuse", "specular"... used in the shader
  74731. */
  74732. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  74733. /**
  74734. * Gets the current status of the fog (should it be enabled?)
  74735. * @param mesh defines the mesh to evaluate for fog support
  74736. * @param scene defines the hosting scene
  74737. * @returns true if fog must be enabled
  74738. */
  74739. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  74740. /**
  74741. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  74742. * @param mesh defines the current mesh
  74743. * @param scene defines the current scene
  74744. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  74745. * @param pointsCloud defines if point cloud rendering has to be turned on
  74746. * @param fogEnabled defines if fog has to be turned on
  74747. * @param alphaTest defines if alpha testing has to be turned on
  74748. * @param defines defines the current list of defines
  74749. */
  74750. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  74751. /**
  74752. * Helper used to prepare the list of defines associated with frame values for shader compilation
  74753. * @param scene defines the current scene
  74754. * @param engine defines the current engine
  74755. * @param defines specifies the list of active defines
  74756. * @param useInstances defines if instances have to be turned on
  74757. * @param useClipPlane defines if clip plane have to be turned on
  74758. */
  74759. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  74760. /**
  74761. * Prepares the defines for bones
  74762. * @param mesh The mesh containing the geometry data we will draw
  74763. * @param defines The defines to update
  74764. */
  74765. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  74766. /**
  74767. * Prepares the defines for morph targets
  74768. * @param mesh The mesh containing the geometry data we will draw
  74769. * @param defines The defines to update
  74770. */
  74771. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  74772. /**
  74773. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  74774. * @param mesh The mesh containing the geometry data we will draw
  74775. * @param defines The defines to update
  74776. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  74777. * @param useBones Precise whether bones should be used or not (override mesh info)
  74778. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  74779. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  74780. * @returns false if defines are considered not dirty and have not been checked
  74781. */
  74782. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  74783. /**
  74784. * Prepares the defines related to multiview
  74785. * @param scene The scene we are intending to draw
  74786. * @param defines The defines to update
  74787. */
  74788. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  74789. /**
  74790. * Prepares the defines related to the light information passed in parameter
  74791. * @param scene The scene we are intending to draw
  74792. * @param mesh The mesh the effect is compiling for
  74793. * @param light The light the effect is compiling for
  74794. * @param lightIndex The index of the light
  74795. * @param defines The defines to update
  74796. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74797. * @param state Defines the current state regarding what is needed (normals, etc...)
  74798. */
  74799. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  74800. needNormals: boolean;
  74801. needRebuild: boolean;
  74802. shadowEnabled: boolean;
  74803. specularEnabled: boolean;
  74804. lightmapMode: boolean;
  74805. }): void;
  74806. /**
  74807. * Prepares the defines related to the light information passed in parameter
  74808. * @param scene The scene we are intending to draw
  74809. * @param mesh The mesh the effect is compiling for
  74810. * @param defines The defines to update
  74811. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74812. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  74813. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  74814. * @returns true if normals will be required for the rest of the effect
  74815. */
  74816. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  74817. /**
  74818. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  74819. * @param lightIndex defines the light index
  74820. * @param uniformsList The uniform list
  74821. * @param samplersList The sampler list
  74822. * @param projectedLightTexture defines if projected texture must be used
  74823. * @param uniformBuffersList defines an optional list of uniform buffers
  74824. */
  74825. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  74826. /**
  74827. * Prepares the uniforms and samplers list to be used in the effect
  74828. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  74829. * @param samplersList The sampler list
  74830. * @param defines The defines helping in the list generation
  74831. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  74832. */
  74833. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  74834. /**
  74835. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  74836. * @param defines The defines to update while falling back
  74837. * @param fallbacks The authorized effect fallbacks
  74838. * @param maxSimultaneousLights The maximum number of lights allowed
  74839. * @param rank the current rank of the Effect
  74840. * @returns The newly affected rank
  74841. */
  74842. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  74843. private static _TmpMorphInfluencers;
  74844. /**
  74845. * Prepares the list of attributes required for morph targets according to the effect defines.
  74846. * @param attribs The current list of supported attribs
  74847. * @param mesh The mesh to prepare the morph targets attributes for
  74848. * @param influencers The number of influencers
  74849. */
  74850. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  74851. /**
  74852. * Prepares the list of attributes required for morph targets according to the effect defines.
  74853. * @param attribs The current list of supported attribs
  74854. * @param mesh The mesh to prepare the morph targets attributes for
  74855. * @param defines The current Defines of the effect
  74856. */
  74857. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  74858. /**
  74859. * Prepares the list of attributes required for bones according to the effect defines.
  74860. * @param attribs The current list of supported attribs
  74861. * @param mesh The mesh to prepare the bones attributes for
  74862. * @param defines The current Defines of the effect
  74863. * @param fallbacks The current efffect fallback strategy
  74864. */
  74865. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  74866. /**
  74867. * Check and prepare the list of attributes required for instances according to the effect defines.
  74868. * @param attribs The current list of supported attribs
  74869. * @param defines The current MaterialDefines of the effect
  74870. */
  74871. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  74872. /**
  74873. * Add the list of attributes required for instances to the attribs array.
  74874. * @param attribs The current list of supported attribs
  74875. */
  74876. static PushAttributesForInstances(attribs: string[]): void;
  74877. /**
  74878. * Binds the light shadow information to the effect for the given mesh.
  74879. * @param light The light containing the generator
  74880. * @param scene The scene the lights belongs to
  74881. * @param mesh The mesh we are binding the information to render
  74882. * @param lightIndex The light index in the effect used to render the mesh
  74883. * @param effect The effect we are binding the data to
  74884. */
  74885. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74886. /**
  74887. * Binds the light information to the effect.
  74888. * @param light The light containing the generator
  74889. * @param effect The effect we are binding the data to
  74890. * @param lightIndex The light index in the effect used to render
  74891. */
  74892. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74893. /**
  74894. * Binds the lights information from the scene to the effect for the given mesh.
  74895. * @param light Light to bind
  74896. * @param lightIndex Light index
  74897. * @param scene The scene where the light belongs to
  74898. * @param mesh The mesh we are binding the information to render
  74899. * @param effect The effect we are binding the data to
  74900. * @param useSpecular Defines if specular is supported
  74901. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74902. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74903. */
  74904. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74905. /**
  74906. * Binds the lights information from the scene to the effect for the given mesh.
  74907. * @param scene The scene the lights belongs to
  74908. * @param mesh The mesh we are binding the information to render
  74909. * @param effect The effect we are binding the data to
  74910. * @param defines The generated defines for the effect
  74911. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74912. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74913. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74914. */
  74915. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74916. private static _tempFogColor;
  74917. /**
  74918. * Binds the fog information from the scene to the effect for the given mesh.
  74919. * @param scene The scene the lights belongs to
  74920. * @param mesh The mesh we are binding the information to render
  74921. * @param effect The effect we are binding the data to
  74922. * @param linearSpace Defines if the fog effect is applied in linear space
  74923. */
  74924. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74925. /**
  74926. * Binds the bones information from the mesh to the effect.
  74927. * @param mesh The mesh we are binding the information to render
  74928. * @param effect The effect we are binding the data to
  74929. */
  74930. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74931. /**
  74932. * Binds the morph targets information from the mesh to the effect.
  74933. * @param abstractMesh The mesh we are binding the information to render
  74934. * @param effect The effect we are binding the data to
  74935. */
  74936. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74937. /**
  74938. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74939. * @param defines The generated defines used in the effect
  74940. * @param effect The effect we are binding the data to
  74941. * @param scene The scene we are willing to render with logarithmic scale for
  74942. */
  74943. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74944. /**
  74945. * Binds the clip plane information from the scene to the effect.
  74946. * @param scene The scene the clip plane information are extracted from
  74947. * @param effect The effect we are binding the data to
  74948. */
  74949. static BindClipPlane(effect: Effect, scene: Scene): void;
  74950. }
  74951. }
  74952. declare module BABYLON {
  74953. /** @hidden */
  74954. export var packingFunctions: {
  74955. name: string;
  74956. shader: string;
  74957. };
  74958. }
  74959. declare module BABYLON {
  74960. /** @hidden */
  74961. export var shadowMapPixelShader: {
  74962. name: string;
  74963. shader: string;
  74964. };
  74965. }
  74966. declare module BABYLON {
  74967. /** @hidden */
  74968. export var bonesDeclaration: {
  74969. name: string;
  74970. shader: string;
  74971. };
  74972. }
  74973. declare module BABYLON {
  74974. /** @hidden */
  74975. export var morphTargetsVertexGlobalDeclaration: {
  74976. name: string;
  74977. shader: string;
  74978. };
  74979. }
  74980. declare module BABYLON {
  74981. /** @hidden */
  74982. export var morphTargetsVertexDeclaration: {
  74983. name: string;
  74984. shader: string;
  74985. };
  74986. }
  74987. declare module BABYLON {
  74988. /** @hidden */
  74989. export var instancesDeclaration: {
  74990. name: string;
  74991. shader: string;
  74992. };
  74993. }
  74994. declare module BABYLON {
  74995. /** @hidden */
  74996. export var helperFunctions: {
  74997. name: string;
  74998. shader: string;
  74999. };
  75000. }
  75001. declare module BABYLON {
  75002. /** @hidden */
  75003. export var morphTargetsVertex: {
  75004. name: string;
  75005. shader: string;
  75006. };
  75007. }
  75008. declare module BABYLON {
  75009. /** @hidden */
  75010. export var instancesVertex: {
  75011. name: string;
  75012. shader: string;
  75013. };
  75014. }
  75015. declare module BABYLON {
  75016. /** @hidden */
  75017. export var bonesVertex: {
  75018. name: string;
  75019. shader: string;
  75020. };
  75021. }
  75022. declare module BABYLON {
  75023. /** @hidden */
  75024. export var shadowMapVertexShader: {
  75025. name: string;
  75026. shader: string;
  75027. };
  75028. }
  75029. declare module BABYLON {
  75030. /** @hidden */
  75031. export var depthBoxBlurPixelShader: {
  75032. name: string;
  75033. shader: string;
  75034. };
  75035. }
  75036. declare module BABYLON {
  75037. /**
  75038. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75039. */
  75040. export interface ICustomShaderOptions {
  75041. /**
  75042. * Gets or sets the custom shader name to use
  75043. */
  75044. shaderName: string;
  75045. /**
  75046. * The list of attribute names used in the shader
  75047. */
  75048. attributes?: string[];
  75049. /**
  75050. * The list of unifrom names used in the shader
  75051. */
  75052. uniforms?: string[];
  75053. /**
  75054. * The list of sampler names used in the shader
  75055. */
  75056. samplers?: string[];
  75057. /**
  75058. * The list of defines used in the shader
  75059. */
  75060. defines?: string[];
  75061. }
  75062. /**
  75063. * Interface to implement to create a shadow generator compatible with BJS.
  75064. */
  75065. export interface IShadowGenerator {
  75066. /**
  75067. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75068. * @returns The render target texture if present otherwise, null
  75069. */
  75070. getShadowMap(): Nullable<RenderTargetTexture>;
  75071. /**
  75072. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75073. * @returns The render target texture if the shadow map is present otherwise, null
  75074. */
  75075. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75076. /**
  75077. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75078. * @param subMesh The submesh we want to render in the shadow map
  75079. * @param useInstances Defines wether will draw in the map using instances
  75080. * @returns true if ready otherwise, false
  75081. */
  75082. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75083. /**
  75084. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75085. * @param defines Defines of the material we want to update
  75086. * @param lightIndex Index of the light in the enabled light list of the material
  75087. */
  75088. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  75089. /**
  75090. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75091. * defined in the generator but impacting the effect).
  75092. * It implies the unifroms available on the materials are the standard BJS ones.
  75093. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75094. * @param effect The effect we are binfing the information for
  75095. */
  75096. bindShadowLight(lightIndex: string, effect: Effect): void;
  75097. /**
  75098. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75099. * (eq to shadow prjection matrix * light transform matrix)
  75100. * @returns The transform matrix used to create the shadow map
  75101. */
  75102. getTransformMatrix(): Matrix;
  75103. /**
  75104. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75105. * Cube and 2D textures for instance.
  75106. */
  75107. recreateShadowMap(): void;
  75108. /**
  75109. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75110. * @param onCompiled Callback triggered at the and of the effects compilation
  75111. * @param options Sets of optional options forcing the compilation with different modes
  75112. */
  75113. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75114. useInstances: boolean;
  75115. }>): void;
  75116. /**
  75117. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75118. * @param options Sets of optional options forcing the compilation with different modes
  75119. * @returns A promise that resolves when the compilation completes
  75120. */
  75121. forceCompilationAsync(options?: Partial<{
  75122. useInstances: boolean;
  75123. }>): Promise<void>;
  75124. /**
  75125. * Serializes the shadow generator setup to a json object.
  75126. * @returns The serialized JSON object
  75127. */
  75128. serialize(): any;
  75129. /**
  75130. * Disposes the Shadow map and related Textures and effects.
  75131. */
  75132. dispose(): void;
  75133. }
  75134. /**
  75135. * Default implementation IShadowGenerator.
  75136. * This is the main object responsible of generating shadows in the framework.
  75137. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  75138. */
  75139. export class ShadowGenerator implements IShadowGenerator {
  75140. /**
  75141. * Shadow generator mode None: no filtering applied.
  75142. */
  75143. static readonly FILTER_NONE: number;
  75144. /**
  75145. * Shadow generator mode ESM: Exponential Shadow Mapping.
  75146. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75147. */
  75148. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  75149. /**
  75150. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  75151. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  75152. */
  75153. static readonly FILTER_POISSONSAMPLING: number;
  75154. /**
  75155. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  75156. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75157. */
  75158. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  75159. /**
  75160. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  75161. * edge artifacts on steep falloff.
  75162. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75163. */
  75164. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  75165. /**
  75166. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  75167. * edge artifacts on steep falloff.
  75168. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75169. */
  75170. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  75171. /**
  75172. * Shadow generator mode PCF: Percentage Closer Filtering
  75173. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75174. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  75175. */
  75176. static readonly FILTER_PCF: number;
  75177. /**
  75178. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  75179. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75180. * Contact Hardening
  75181. */
  75182. static readonly FILTER_PCSS: number;
  75183. /**
  75184. * Reserved for PCF and PCSS
  75185. * Highest Quality.
  75186. *
  75187. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  75188. *
  75189. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  75190. */
  75191. static readonly QUALITY_HIGH: number;
  75192. /**
  75193. * Reserved for PCF and PCSS
  75194. * Good tradeoff for quality/perf cross devices
  75195. *
  75196. * Execute PCF on a 3*3 kernel.
  75197. *
  75198. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  75199. */
  75200. static readonly QUALITY_MEDIUM: number;
  75201. /**
  75202. * Reserved for PCF and PCSS
  75203. * The lowest quality but the fastest.
  75204. *
  75205. * Execute PCF on a 1*1 kernel.
  75206. *
  75207. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  75208. */
  75209. static readonly QUALITY_LOW: number;
  75210. /** Gets or sets the custom shader name to use */
  75211. customShaderOptions: ICustomShaderOptions;
  75212. /**
  75213. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  75214. */
  75215. onBeforeShadowMapRenderObservable: Observable<Effect>;
  75216. /**
  75217. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  75218. */
  75219. onAfterShadowMapRenderObservable: Observable<Effect>;
  75220. /**
  75221. * Observable triggered before a mesh is rendered in the shadow map.
  75222. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  75223. */
  75224. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  75225. /**
  75226. * Observable triggered after a mesh is rendered in the shadow map.
  75227. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  75228. */
  75229. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  75230. private _bias;
  75231. /**
  75232. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  75233. */
  75234. /**
  75235. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  75236. */
  75237. bias: number;
  75238. private _normalBias;
  75239. /**
  75240. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75241. */
  75242. /**
  75243. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75244. */
  75245. normalBias: number;
  75246. private _blurBoxOffset;
  75247. /**
  75248. * Gets the blur box offset: offset applied during the blur pass.
  75249. * Only useful if useKernelBlur = false
  75250. */
  75251. /**
  75252. * Sets the blur box offset: offset applied during the blur pass.
  75253. * Only useful if useKernelBlur = false
  75254. */
  75255. blurBoxOffset: number;
  75256. private _blurScale;
  75257. /**
  75258. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  75259. * 2 means half of the size.
  75260. */
  75261. /**
  75262. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  75263. * 2 means half of the size.
  75264. */
  75265. blurScale: number;
  75266. private _blurKernel;
  75267. /**
  75268. * Gets the blur kernel: kernel size of the blur pass.
  75269. * Only useful if useKernelBlur = true
  75270. */
  75271. /**
  75272. * Sets the blur kernel: kernel size of the blur pass.
  75273. * Only useful if useKernelBlur = true
  75274. */
  75275. blurKernel: number;
  75276. private _useKernelBlur;
  75277. /**
  75278. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  75279. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75280. */
  75281. /**
  75282. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  75283. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75284. */
  75285. useKernelBlur: boolean;
  75286. private _depthScale;
  75287. /**
  75288. * Gets the depth scale used in ESM mode.
  75289. */
  75290. /**
  75291. * Sets the depth scale used in ESM mode.
  75292. * This can override the scale stored on the light.
  75293. */
  75294. depthScale: number;
  75295. private _filter;
  75296. /**
  75297. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  75298. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75299. */
  75300. /**
  75301. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  75302. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75303. */
  75304. filter: number;
  75305. /**
  75306. * Gets if the current filter is set to Poisson Sampling.
  75307. */
  75308. /**
  75309. * Sets the current filter to Poisson Sampling.
  75310. */
  75311. usePoissonSampling: boolean;
  75312. /**
  75313. * Gets if the current filter is set to ESM.
  75314. */
  75315. /**
  75316. * Sets the current filter is to ESM.
  75317. */
  75318. useExponentialShadowMap: boolean;
  75319. /**
  75320. * Gets if the current filter is set to filtered ESM.
  75321. */
  75322. /**
  75323. * Gets if the current filter is set to filtered ESM.
  75324. */
  75325. useBlurExponentialShadowMap: boolean;
  75326. /**
  75327. * Gets if the current filter is set to "close ESM" (using the inverse of the
  75328. * exponential to prevent steep falloff artifacts).
  75329. */
  75330. /**
  75331. * Sets the current filter to "close ESM" (using the inverse of the
  75332. * exponential to prevent steep falloff artifacts).
  75333. */
  75334. useCloseExponentialShadowMap: boolean;
  75335. /**
  75336. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  75337. * exponential to prevent steep falloff artifacts).
  75338. */
  75339. /**
  75340. * Sets the current filter to filtered "close ESM" (using the inverse of the
  75341. * exponential to prevent steep falloff artifacts).
  75342. */
  75343. useBlurCloseExponentialShadowMap: boolean;
  75344. /**
  75345. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  75346. */
  75347. /**
  75348. * Sets the current filter to "PCF" (percentage closer filtering).
  75349. */
  75350. usePercentageCloserFiltering: boolean;
  75351. private _filteringQuality;
  75352. /**
  75353. * Gets the PCF or PCSS Quality.
  75354. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75355. */
  75356. /**
  75357. * Sets the PCF or PCSS Quality.
  75358. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75359. */
  75360. filteringQuality: number;
  75361. /**
  75362. * Gets if the current filter is set to "PCSS" (contact hardening).
  75363. */
  75364. /**
  75365. * Sets the current filter to "PCSS" (contact hardening).
  75366. */
  75367. useContactHardeningShadow: boolean;
  75368. private _contactHardeningLightSizeUVRatio;
  75369. /**
  75370. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75371. * Using a ratio helps keeping shape stability independently of the map size.
  75372. *
  75373. * It does not account for the light projection as it was having too much
  75374. * instability during the light setup or during light position changes.
  75375. *
  75376. * Only valid if useContactHardeningShadow is true.
  75377. */
  75378. /**
  75379. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75380. * Using a ratio helps keeping shape stability independently of the map size.
  75381. *
  75382. * It does not account for the light projection as it was having too much
  75383. * instability during the light setup or during light position changes.
  75384. *
  75385. * Only valid if useContactHardeningShadow is true.
  75386. */
  75387. contactHardeningLightSizeUVRatio: number;
  75388. private _darkness;
  75389. /** Gets or sets the actual darkness of a shadow */
  75390. darkness: number;
  75391. /**
  75392. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  75393. * 0 means strongest and 1 would means no shadow.
  75394. * @returns the darkness.
  75395. */
  75396. getDarkness(): number;
  75397. /**
  75398. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  75399. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  75400. * @returns the shadow generator allowing fluent coding.
  75401. */
  75402. setDarkness(darkness: number): ShadowGenerator;
  75403. private _transparencyShadow;
  75404. /** Gets or sets the ability to have transparent shadow */
  75405. transparencyShadow: boolean;
  75406. /**
  75407. * Sets the ability to have transparent shadow (boolean).
  75408. * @param transparent True if transparent else False
  75409. * @returns the shadow generator allowing fluent coding
  75410. */
  75411. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  75412. private _shadowMap;
  75413. private _shadowMap2;
  75414. /**
  75415. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75416. * @returns The render target texture if present otherwise, null
  75417. */
  75418. getShadowMap(): Nullable<RenderTargetTexture>;
  75419. /**
  75420. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75421. * @returns The render target texture if the shadow map is present otherwise, null
  75422. */
  75423. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75424. /**
  75425. * Gets the class name of that object
  75426. * @returns "ShadowGenerator"
  75427. */
  75428. getClassName(): string;
  75429. /**
  75430. * Helper function to add a mesh and its descendants to the list of shadow casters.
  75431. * @param mesh Mesh to add
  75432. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  75433. * @returns the Shadow Generator itself
  75434. */
  75435. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75436. /**
  75437. * Helper function to remove a mesh and its descendants from the list of shadow casters
  75438. * @param mesh Mesh to remove
  75439. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  75440. * @returns the Shadow Generator itself
  75441. */
  75442. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75443. /**
  75444. * Controls the extent to which the shadows fade out at the edge of the frustum
  75445. * Used only by directionals and spots
  75446. */
  75447. frustumEdgeFalloff: number;
  75448. private _light;
  75449. /**
  75450. * Returns the associated light object.
  75451. * @returns the light generating the shadow
  75452. */
  75453. getLight(): IShadowLight;
  75454. /**
  75455. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  75456. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  75457. * It might on the other hand introduce peter panning.
  75458. */
  75459. forceBackFacesOnly: boolean;
  75460. private _scene;
  75461. private _lightDirection;
  75462. private _effect;
  75463. private _viewMatrix;
  75464. private _projectionMatrix;
  75465. private _transformMatrix;
  75466. private _cachedPosition;
  75467. private _cachedDirection;
  75468. private _cachedDefines;
  75469. private _currentRenderID;
  75470. private _boxBlurPostprocess;
  75471. private _kernelBlurXPostprocess;
  75472. private _kernelBlurYPostprocess;
  75473. private _blurPostProcesses;
  75474. private _mapSize;
  75475. private _currentFaceIndex;
  75476. private _currentFaceIndexCache;
  75477. private _textureType;
  75478. private _defaultTextureMatrix;
  75479. /** @hidden */
  75480. static _SceneComponentInitialization: (scene: Scene) => void;
  75481. /**
  75482. * Creates a ShadowGenerator object.
  75483. * A ShadowGenerator is the required tool to use the shadows.
  75484. * Each light casting shadows needs to use its own ShadowGenerator.
  75485. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  75486. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  75487. * @param light The light object generating the shadows.
  75488. * @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.
  75489. */
  75490. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  75491. private _initializeGenerator;
  75492. private _initializeShadowMap;
  75493. private _initializeBlurRTTAndPostProcesses;
  75494. private _renderForShadowMap;
  75495. private _renderSubMeshForShadowMap;
  75496. private _applyFilterValues;
  75497. /**
  75498. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75499. * @param onCompiled Callback triggered at the and of the effects compilation
  75500. * @param options Sets of optional options forcing the compilation with different modes
  75501. */
  75502. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75503. useInstances: boolean;
  75504. }>): void;
  75505. /**
  75506. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75507. * @param options Sets of optional options forcing the compilation with different modes
  75508. * @returns A promise that resolves when the compilation completes
  75509. */
  75510. forceCompilationAsync(options?: Partial<{
  75511. useInstances: boolean;
  75512. }>): Promise<void>;
  75513. /**
  75514. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75515. * @param subMesh The submesh we want to render in the shadow map
  75516. * @param useInstances Defines wether will draw in the map using instances
  75517. * @returns true if ready otherwise, false
  75518. */
  75519. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75520. /**
  75521. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75522. * @param defines Defines of the material we want to update
  75523. * @param lightIndex Index of the light in the enabled light list of the material
  75524. */
  75525. prepareDefines(defines: any, lightIndex: number): void;
  75526. /**
  75527. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75528. * defined in the generator but impacting the effect).
  75529. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75530. * @param effect The effect we are binfing the information for
  75531. */
  75532. bindShadowLight(lightIndex: string, effect: Effect): void;
  75533. /**
  75534. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75535. * (eq to shadow prjection matrix * light transform matrix)
  75536. * @returns The transform matrix used to create the shadow map
  75537. */
  75538. getTransformMatrix(): Matrix;
  75539. /**
  75540. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75541. * Cube and 2D textures for instance.
  75542. */
  75543. recreateShadowMap(): void;
  75544. private _disposeBlurPostProcesses;
  75545. private _disposeRTTandPostProcesses;
  75546. /**
  75547. * Disposes the ShadowGenerator.
  75548. * Returns nothing.
  75549. */
  75550. dispose(): void;
  75551. /**
  75552. * Serializes the shadow generator setup to a json object.
  75553. * @returns The serialized JSON object
  75554. */
  75555. serialize(): any;
  75556. /**
  75557. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  75558. * @param parsedShadowGenerator The JSON object to parse
  75559. * @param scene The scene to create the shadow map for
  75560. * @returns The parsed shadow generator
  75561. */
  75562. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  75563. }
  75564. }
  75565. declare module BABYLON {
  75566. /**
  75567. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  75568. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  75569. * 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.
  75570. */
  75571. export abstract class Light extends Node {
  75572. /**
  75573. * Falloff Default: light is falling off following the material specification:
  75574. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  75575. */
  75576. static readonly FALLOFF_DEFAULT: number;
  75577. /**
  75578. * Falloff Physical: light is falling off following the inverse squared distance law.
  75579. */
  75580. static readonly FALLOFF_PHYSICAL: number;
  75581. /**
  75582. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  75583. * to enhance interoperability with other engines.
  75584. */
  75585. static readonly FALLOFF_GLTF: number;
  75586. /**
  75587. * Falloff Standard: light is falling off like in the standard material
  75588. * to enhance interoperability with other materials.
  75589. */
  75590. static readonly FALLOFF_STANDARD: number;
  75591. /**
  75592. * If every light affecting the material is in this lightmapMode,
  75593. * material.lightmapTexture adds or multiplies
  75594. * (depends on material.useLightmapAsShadowmap)
  75595. * after every other light calculations.
  75596. */
  75597. static readonly LIGHTMAP_DEFAULT: number;
  75598. /**
  75599. * material.lightmapTexture as only diffuse lighting from this light
  75600. * adds only specular lighting from this light
  75601. * adds dynamic shadows
  75602. */
  75603. static readonly LIGHTMAP_SPECULAR: number;
  75604. /**
  75605. * material.lightmapTexture as only lighting
  75606. * no light calculation from this light
  75607. * only adds dynamic shadows from this light
  75608. */
  75609. static readonly LIGHTMAP_SHADOWSONLY: number;
  75610. /**
  75611. * Each light type uses the default quantity according to its type:
  75612. * point/spot lights use luminous intensity
  75613. * directional lights use illuminance
  75614. */
  75615. static readonly INTENSITYMODE_AUTOMATIC: number;
  75616. /**
  75617. * lumen (lm)
  75618. */
  75619. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  75620. /**
  75621. * candela (lm/sr)
  75622. */
  75623. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  75624. /**
  75625. * lux (lm/m^2)
  75626. */
  75627. static readonly INTENSITYMODE_ILLUMINANCE: number;
  75628. /**
  75629. * nit (cd/m^2)
  75630. */
  75631. static readonly INTENSITYMODE_LUMINANCE: number;
  75632. /**
  75633. * Light type const id of the point light.
  75634. */
  75635. static readonly LIGHTTYPEID_POINTLIGHT: number;
  75636. /**
  75637. * Light type const id of the directional light.
  75638. */
  75639. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  75640. /**
  75641. * Light type const id of the spot light.
  75642. */
  75643. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  75644. /**
  75645. * Light type const id of the hemispheric light.
  75646. */
  75647. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  75648. /**
  75649. * Diffuse gives the basic color to an object.
  75650. */
  75651. diffuse: Color3;
  75652. /**
  75653. * Specular produces a highlight color on an object.
  75654. * Note: This is note affecting PBR materials.
  75655. */
  75656. specular: Color3;
  75657. /**
  75658. * Defines the falloff type for this light. This lets overrriding how punctual light are
  75659. * falling off base on range or angle.
  75660. * This can be set to any values in Light.FALLOFF_x.
  75661. *
  75662. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  75663. * other types of materials.
  75664. */
  75665. falloffType: number;
  75666. /**
  75667. * Strength of the light.
  75668. * Note: By default it is define in the framework own unit.
  75669. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  75670. */
  75671. intensity: number;
  75672. private _range;
  75673. protected _inverseSquaredRange: number;
  75674. /**
  75675. * Defines how far from the source the light is impacting in scene units.
  75676. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75677. */
  75678. /**
  75679. * Defines how far from the source the light is impacting in scene units.
  75680. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75681. */
  75682. range: number;
  75683. /**
  75684. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  75685. * of light.
  75686. */
  75687. private _photometricScale;
  75688. private _intensityMode;
  75689. /**
  75690. * Gets the photometric scale used to interpret the intensity.
  75691. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75692. */
  75693. /**
  75694. * Sets the photometric scale used to interpret the intensity.
  75695. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75696. */
  75697. intensityMode: number;
  75698. private _radius;
  75699. /**
  75700. * Gets the light radius used by PBR Materials to simulate soft area lights.
  75701. */
  75702. /**
  75703. * sets the light radius used by PBR Materials to simulate soft area lights.
  75704. */
  75705. radius: number;
  75706. private _renderPriority;
  75707. /**
  75708. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  75709. * exceeding the number allowed of the materials.
  75710. */
  75711. renderPriority: number;
  75712. private _shadowEnabled;
  75713. /**
  75714. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75715. * the current shadow generator.
  75716. */
  75717. /**
  75718. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75719. * the current shadow generator.
  75720. */
  75721. shadowEnabled: boolean;
  75722. private _includedOnlyMeshes;
  75723. /**
  75724. * Gets the only meshes impacted by this light.
  75725. */
  75726. /**
  75727. * Sets the only meshes impacted by this light.
  75728. */
  75729. includedOnlyMeshes: AbstractMesh[];
  75730. private _excludedMeshes;
  75731. /**
  75732. * Gets the meshes not impacted by this light.
  75733. */
  75734. /**
  75735. * Sets the meshes not impacted by this light.
  75736. */
  75737. excludedMeshes: AbstractMesh[];
  75738. private _excludeWithLayerMask;
  75739. /**
  75740. * Gets the layer id use to find what meshes are not impacted by the light.
  75741. * Inactive if 0
  75742. */
  75743. /**
  75744. * Sets the layer id use to find what meshes are not impacted by the light.
  75745. * Inactive if 0
  75746. */
  75747. excludeWithLayerMask: number;
  75748. private _includeOnlyWithLayerMask;
  75749. /**
  75750. * Gets the layer id use to find what meshes are impacted by the light.
  75751. * Inactive if 0
  75752. */
  75753. /**
  75754. * Sets the layer id use to find what meshes are impacted by the light.
  75755. * Inactive if 0
  75756. */
  75757. includeOnlyWithLayerMask: number;
  75758. private _lightmapMode;
  75759. /**
  75760. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75761. */
  75762. /**
  75763. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75764. */
  75765. lightmapMode: number;
  75766. /**
  75767. * Shadow generator associted to the light.
  75768. * @hidden Internal use only.
  75769. */
  75770. _shadowGenerator: Nullable<IShadowGenerator>;
  75771. /**
  75772. * @hidden Internal use only.
  75773. */
  75774. _excludedMeshesIds: string[];
  75775. /**
  75776. * @hidden Internal use only.
  75777. */
  75778. _includedOnlyMeshesIds: string[];
  75779. /**
  75780. * The current light unifom buffer.
  75781. * @hidden Internal use only.
  75782. */
  75783. _uniformBuffer: UniformBuffer;
  75784. /**
  75785. * Creates a Light object in the scene.
  75786. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75787. * @param name The firendly name of the light
  75788. * @param scene The scene the light belongs too
  75789. */
  75790. constructor(name: string, scene: Scene);
  75791. protected abstract _buildUniformLayout(): void;
  75792. /**
  75793. * Sets the passed Effect "effect" with the Light information.
  75794. * @param effect The effect to update
  75795. * @param lightIndex The index of the light in the effect to update
  75796. * @returns The light
  75797. */
  75798. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  75799. /**
  75800. * Sets the passed Effect "effect" with the Light information.
  75801. * @param effect The effect to update
  75802. * @param lightDataUniformName The uniform used to store light data (position or direction)
  75803. * @returns The light
  75804. */
  75805. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  75806. /**
  75807. * Returns the string "Light".
  75808. * @returns the class name
  75809. */
  75810. getClassName(): string;
  75811. /** @hidden */
  75812. readonly _isLight: boolean;
  75813. /**
  75814. * Converts the light information to a readable string for debug purpose.
  75815. * @param fullDetails Supports for multiple levels of logging within scene loading
  75816. * @returns the human readable light info
  75817. */
  75818. toString(fullDetails?: boolean): string;
  75819. /** @hidden */
  75820. protected _syncParentEnabledState(): void;
  75821. /**
  75822. * Set the enabled state of this node.
  75823. * @param value - the new enabled state
  75824. */
  75825. setEnabled(value: boolean): void;
  75826. /**
  75827. * Returns the Light associated shadow generator if any.
  75828. * @return the associated shadow generator.
  75829. */
  75830. getShadowGenerator(): Nullable<IShadowGenerator>;
  75831. /**
  75832. * Returns a Vector3, the absolute light position in the World.
  75833. * @returns the world space position of the light
  75834. */
  75835. getAbsolutePosition(): Vector3;
  75836. /**
  75837. * Specifies if the light will affect the passed mesh.
  75838. * @param mesh The mesh to test against the light
  75839. * @return true the mesh is affected otherwise, false.
  75840. */
  75841. canAffectMesh(mesh: AbstractMesh): boolean;
  75842. /**
  75843. * Sort function to order lights for rendering.
  75844. * @param a First Light object to compare to second.
  75845. * @param b Second Light object to compare first.
  75846. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  75847. */
  75848. static CompareLightsPriority(a: Light, b: Light): number;
  75849. /**
  75850. * Releases resources associated with this node.
  75851. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75852. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75853. */
  75854. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75855. /**
  75856. * Returns the light type ID (integer).
  75857. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75858. */
  75859. getTypeID(): number;
  75860. /**
  75861. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  75862. * @returns the scaled intensity in intensity mode unit
  75863. */
  75864. getScaledIntensity(): number;
  75865. /**
  75866. * Returns a new Light object, named "name", from the current one.
  75867. * @param name The name of the cloned light
  75868. * @returns the new created light
  75869. */
  75870. clone(name: string): Nullable<Light>;
  75871. /**
  75872. * Serializes the current light into a Serialization object.
  75873. * @returns the serialized object.
  75874. */
  75875. serialize(): any;
  75876. /**
  75877. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  75878. * This new light is named "name" and added to the passed scene.
  75879. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75880. * @param name The friendly name of the light
  75881. * @param scene The scene the new light will belong to
  75882. * @returns the constructor function
  75883. */
  75884. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75885. /**
  75886. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75887. * @param parsedLight The JSON representation of the light
  75888. * @param scene The scene to create the parsed light in
  75889. * @returns the created light after parsing
  75890. */
  75891. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75892. private _hookArrayForExcluded;
  75893. private _hookArrayForIncludedOnly;
  75894. private _resyncMeshes;
  75895. /**
  75896. * Forces the meshes to update their light related information in their rendering used effects
  75897. * @hidden Internal Use Only
  75898. */
  75899. _markMeshesAsLightDirty(): void;
  75900. /**
  75901. * Recomputes the cached photometric scale if needed.
  75902. */
  75903. private _computePhotometricScale;
  75904. /**
  75905. * Returns the Photometric Scale according to the light type and intensity mode.
  75906. */
  75907. private _getPhotometricScale;
  75908. /**
  75909. * Reorder the light in the scene according to their defined priority.
  75910. * @hidden Internal Use Only
  75911. */
  75912. _reorderLightsInScene(): void;
  75913. /**
  75914. * Prepares the list of defines specific to the light type.
  75915. * @param defines the list of defines
  75916. * @param lightIndex defines the index of the light for the effect
  75917. */
  75918. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75919. }
  75920. }
  75921. declare module BABYLON {
  75922. /**
  75923. * Interface used to define Action
  75924. */
  75925. export interface IAction {
  75926. /**
  75927. * Trigger for the action
  75928. */
  75929. trigger: number;
  75930. /** Options of the trigger */
  75931. triggerOptions: any;
  75932. /**
  75933. * Gets the trigger parameters
  75934. * @returns the trigger parameters
  75935. */
  75936. getTriggerParameter(): any;
  75937. /**
  75938. * Internal only - executes current action event
  75939. * @hidden
  75940. */
  75941. _executeCurrent(evt?: ActionEvent): void;
  75942. /**
  75943. * Serialize placeholder for child classes
  75944. * @param parent of child
  75945. * @returns the serialized object
  75946. */
  75947. serialize(parent: any): any;
  75948. /**
  75949. * Internal only
  75950. * @hidden
  75951. */
  75952. _prepare(): void;
  75953. /**
  75954. * Internal only - manager for action
  75955. * @hidden
  75956. */
  75957. _actionManager: AbstractActionManager;
  75958. /**
  75959. * Adds action to chain of actions, may be a DoNothingAction
  75960. * @param action defines the next action to execute
  75961. * @returns The action passed in
  75962. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75963. */
  75964. then(action: IAction): IAction;
  75965. }
  75966. /**
  75967. * The action to be carried out following a trigger
  75968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75969. */
  75970. export class Action implements IAction {
  75971. /** the trigger, with or without parameters, for the action */
  75972. triggerOptions: any;
  75973. /**
  75974. * Trigger for the action
  75975. */
  75976. trigger: number;
  75977. /**
  75978. * Internal only - manager for action
  75979. * @hidden
  75980. */
  75981. _actionManager: ActionManager;
  75982. private _nextActiveAction;
  75983. private _child;
  75984. private _condition?;
  75985. private _triggerParameter;
  75986. /**
  75987. * An event triggered prior to action being executed.
  75988. */
  75989. onBeforeExecuteObservable: Observable<Action>;
  75990. /**
  75991. * Creates a new Action
  75992. * @param triggerOptions the trigger, with or without parameters, for the action
  75993. * @param condition an optional determinant of action
  75994. */
  75995. constructor(
  75996. /** the trigger, with or without parameters, for the action */
  75997. triggerOptions: any, condition?: Condition);
  75998. /**
  75999. * Internal only
  76000. * @hidden
  76001. */
  76002. _prepare(): void;
  76003. /**
  76004. * Gets the trigger parameters
  76005. * @returns the trigger parameters
  76006. */
  76007. getTriggerParameter(): any;
  76008. /**
  76009. * Internal only - executes current action event
  76010. * @hidden
  76011. */
  76012. _executeCurrent(evt?: ActionEvent): void;
  76013. /**
  76014. * Execute placeholder for child classes
  76015. * @param evt optional action event
  76016. */
  76017. execute(evt?: ActionEvent): void;
  76018. /**
  76019. * Skips to next active action
  76020. */
  76021. skipToNextActiveAction(): void;
  76022. /**
  76023. * Adds action to chain of actions, may be a DoNothingAction
  76024. * @param action defines the next action to execute
  76025. * @returns The action passed in
  76026. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76027. */
  76028. then(action: Action): Action;
  76029. /**
  76030. * Internal only
  76031. * @hidden
  76032. */
  76033. _getProperty(propertyPath: string): string;
  76034. /**
  76035. * Internal only
  76036. * @hidden
  76037. */
  76038. _getEffectiveTarget(target: any, propertyPath: string): any;
  76039. /**
  76040. * Serialize placeholder for child classes
  76041. * @param parent of child
  76042. * @returns the serialized object
  76043. */
  76044. serialize(parent: any): any;
  76045. /**
  76046. * Internal only called by serialize
  76047. * @hidden
  76048. */
  76049. protected _serialize(serializedAction: any, parent?: any): any;
  76050. /**
  76051. * Internal only
  76052. * @hidden
  76053. */
  76054. static _SerializeValueAsString: (value: any) => string;
  76055. /**
  76056. * Internal only
  76057. * @hidden
  76058. */
  76059. static _GetTargetProperty: (target: Node | Scene) => {
  76060. name: string;
  76061. targetType: string;
  76062. value: string;
  76063. };
  76064. }
  76065. }
  76066. declare module BABYLON {
  76067. /**
  76068. * A Condition applied to an Action
  76069. */
  76070. export class Condition {
  76071. /**
  76072. * Internal only - manager for action
  76073. * @hidden
  76074. */
  76075. _actionManager: ActionManager;
  76076. /**
  76077. * Internal only
  76078. * @hidden
  76079. */
  76080. _evaluationId: number;
  76081. /**
  76082. * Internal only
  76083. * @hidden
  76084. */
  76085. _currentResult: boolean;
  76086. /**
  76087. * Creates a new Condition
  76088. * @param actionManager the manager of the action the condition is applied to
  76089. */
  76090. constructor(actionManager: ActionManager);
  76091. /**
  76092. * Check if the current condition is valid
  76093. * @returns a boolean
  76094. */
  76095. isValid(): boolean;
  76096. /**
  76097. * Internal only
  76098. * @hidden
  76099. */
  76100. _getProperty(propertyPath: string): string;
  76101. /**
  76102. * Internal only
  76103. * @hidden
  76104. */
  76105. _getEffectiveTarget(target: any, propertyPath: string): any;
  76106. /**
  76107. * Serialize placeholder for child classes
  76108. * @returns the serialized object
  76109. */
  76110. serialize(): any;
  76111. /**
  76112. * Internal only
  76113. * @hidden
  76114. */
  76115. protected _serialize(serializedCondition: any): any;
  76116. }
  76117. /**
  76118. * Defines specific conditional operators as extensions of Condition
  76119. */
  76120. export class ValueCondition extends Condition {
  76121. /** path to specify the property of the target the conditional operator uses */
  76122. propertyPath: string;
  76123. /** the value compared by the conditional operator against the current value of the property */
  76124. value: any;
  76125. /** the conditional operator, default ValueCondition.IsEqual */
  76126. operator: number;
  76127. /**
  76128. * Internal only
  76129. * @hidden
  76130. */
  76131. private static _IsEqual;
  76132. /**
  76133. * Internal only
  76134. * @hidden
  76135. */
  76136. private static _IsDifferent;
  76137. /**
  76138. * Internal only
  76139. * @hidden
  76140. */
  76141. private static _IsGreater;
  76142. /**
  76143. * Internal only
  76144. * @hidden
  76145. */
  76146. private static _IsLesser;
  76147. /**
  76148. * returns the number for IsEqual
  76149. */
  76150. static readonly IsEqual: number;
  76151. /**
  76152. * Returns the number for IsDifferent
  76153. */
  76154. static readonly IsDifferent: number;
  76155. /**
  76156. * Returns the number for IsGreater
  76157. */
  76158. static readonly IsGreater: number;
  76159. /**
  76160. * Returns the number for IsLesser
  76161. */
  76162. static readonly IsLesser: number;
  76163. /**
  76164. * Internal only The action manager for the condition
  76165. * @hidden
  76166. */
  76167. _actionManager: ActionManager;
  76168. /**
  76169. * Internal only
  76170. * @hidden
  76171. */
  76172. private _target;
  76173. /**
  76174. * Internal only
  76175. * @hidden
  76176. */
  76177. private _effectiveTarget;
  76178. /**
  76179. * Internal only
  76180. * @hidden
  76181. */
  76182. private _property;
  76183. /**
  76184. * Creates a new ValueCondition
  76185. * @param actionManager manager for the action the condition applies to
  76186. * @param target for the action
  76187. * @param propertyPath path to specify the property of the target the conditional operator uses
  76188. * @param value the value compared by the conditional operator against the current value of the property
  76189. * @param operator the conditional operator, default ValueCondition.IsEqual
  76190. */
  76191. constructor(actionManager: ActionManager, target: any,
  76192. /** path to specify the property of the target the conditional operator uses */
  76193. propertyPath: string,
  76194. /** the value compared by the conditional operator against the current value of the property */
  76195. value: any,
  76196. /** the conditional operator, default ValueCondition.IsEqual */
  76197. operator?: number);
  76198. /**
  76199. * Compares the given value with the property value for the specified conditional operator
  76200. * @returns the result of the comparison
  76201. */
  76202. isValid(): boolean;
  76203. /**
  76204. * Serialize the ValueCondition into a JSON compatible object
  76205. * @returns serialization object
  76206. */
  76207. serialize(): any;
  76208. /**
  76209. * Gets the name of the conditional operator for the ValueCondition
  76210. * @param operator the conditional operator
  76211. * @returns the name
  76212. */
  76213. static GetOperatorName(operator: number): string;
  76214. }
  76215. /**
  76216. * Defines a predicate condition as an extension of Condition
  76217. */
  76218. export class PredicateCondition extends Condition {
  76219. /** defines the predicate function used to validate the condition */
  76220. predicate: () => boolean;
  76221. /**
  76222. * Internal only - manager for action
  76223. * @hidden
  76224. */
  76225. _actionManager: ActionManager;
  76226. /**
  76227. * Creates a new PredicateCondition
  76228. * @param actionManager manager for the action the condition applies to
  76229. * @param predicate defines the predicate function used to validate the condition
  76230. */
  76231. constructor(actionManager: ActionManager,
  76232. /** defines the predicate function used to validate the condition */
  76233. predicate: () => boolean);
  76234. /**
  76235. * @returns the validity of the predicate condition
  76236. */
  76237. isValid(): boolean;
  76238. }
  76239. /**
  76240. * Defines a state condition as an extension of Condition
  76241. */
  76242. export class StateCondition extends Condition {
  76243. /** Value to compare with target state */
  76244. value: string;
  76245. /**
  76246. * Internal only - manager for action
  76247. * @hidden
  76248. */
  76249. _actionManager: ActionManager;
  76250. /**
  76251. * Internal only
  76252. * @hidden
  76253. */
  76254. private _target;
  76255. /**
  76256. * Creates a new StateCondition
  76257. * @param actionManager manager for the action the condition applies to
  76258. * @param target of the condition
  76259. * @param value to compare with target state
  76260. */
  76261. constructor(actionManager: ActionManager, target: any,
  76262. /** Value to compare with target state */
  76263. value: string);
  76264. /**
  76265. * Gets a boolean indicating if the current condition is met
  76266. * @returns the validity of the state
  76267. */
  76268. isValid(): boolean;
  76269. /**
  76270. * Serialize the StateCondition into a JSON compatible object
  76271. * @returns serialization object
  76272. */
  76273. serialize(): any;
  76274. }
  76275. }
  76276. declare module BABYLON {
  76277. /**
  76278. * This defines an action responsible to toggle a boolean once triggered.
  76279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76280. */
  76281. export class SwitchBooleanAction extends Action {
  76282. /**
  76283. * The path to the boolean property in the target object
  76284. */
  76285. propertyPath: string;
  76286. private _target;
  76287. private _effectiveTarget;
  76288. private _property;
  76289. /**
  76290. * Instantiate the action
  76291. * @param triggerOptions defines the trigger options
  76292. * @param target defines the object containing the boolean
  76293. * @param propertyPath defines the path to the boolean property in the target object
  76294. * @param condition defines the trigger related conditions
  76295. */
  76296. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76297. /** @hidden */
  76298. _prepare(): void;
  76299. /**
  76300. * Execute the action toggle the boolean value.
  76301. */
  76302. execute(): void;
  76303. /**
  76304. * Serializes the actions and its related information.
  76305. * @param parent defines the object to serialize in
  76306. * @returns the serialized object
  76307. */
  76308. serialize(parent: any): any;
  76309. }
  76310. /**
  76311. * This defines an action responsible to set a the state field of the target
  76312. * to a desired value once triggered.
  76313. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76314. */
  76315. export class SetStateAction extends Action {
  76316. /**
  76317. * The value to store in the state field.
  76318. */
  76319. value: string;
  76320. private _target;
  76321. /**
  76322. * Instantiate the action
  76323. * @param triggerOptions defines the trigger options
  76324. * @param target defines the object containing the state property
  76325. * @param value defines the value to store in the state field
  76326. * @param condition defines the trigger related conditions
  76327. */
  76328. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76329. /**
  76330. * Execute the action and store the value on the target state property.
  76331. */
  76332. execute(): void;
  76333. /**
  76334. * Serializes the actions and its related information.
  76335. * @param parent defines the object to serialize in
  76336. * @returns the serialized object
  76337. */
  76338. serialize(parent: any): any;
  76339. }
  76340. /**
  76341. * This defines an action responsible to set a property of the target
  76342. * to a desired value once triggered.
  76343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76344. */
  76345. export class SetValueAction extends Action {
  76346. /**
  76347. * The path of the property to set in the target.
  76348. */
  76349. propertyPath: string;
  76350. /**
  76351. * The value to set in the property
  76352. */
  76353. value: any;
  76354. private _target;
  76355. private _effectiveTarget;
  76356. private _property;
  76357. /**
  76358. * Instantiate the action
  76359. * @param triggerOptions defines the trigger options
  76360. * @param target defines the object containing the property
  76361. * @param propertyPath defines the path of the property to set in the target
  76362. * @param value defines the value to set in the property
  76363. * @param condition defines the trigger related conditions
  76364. */
  76365. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76366. /** @hidden */
  76367. _prepare(): void;
  76368. /**
  76369. * Execute the action and set the targetted property to the desired value.
  76370. */
  76371. execute(): void;
  76372. /**
  76373. * Serializes the actions and its related information.
  76374. * @param parent defines the object to serialize in
  76375. * @returns the serialized object
  76376. */
  76377. serialize(parent: any): any;
  76378. }
  76379. /**
  76380. * This defines an action responsible to increment the target value
  76381. * to a desired value once triggered.
  76382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76383. */
  76384. export class IncrementValueAction extends Action {
  76385. /**
  76386. * The path of the property to increment in the target.
  76387. */
  76388. propertyPath: string;
  76389. /**
  76390. * The value we should increment the property by.
  76391. */
  76392. value: any;
  76393. private _target;
  76394. private _effectiveTarget;
  76395. private _property;
  76396. /**
  76397. * Instantiate the action
  76398. * @param triggerOptions defines the trigger options
  76399. * @param target defines the object containing the property
  76400. * @param propertyPath defines the path of the property to increment in the target
  76401. * @param value defines the value value we should increment the property by
  76402. * @param condition defines the trigger related conditions
  76403. */
  76404. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76405. /** @hidden */
  76406. _prepare(): void;
  76407. /**
  76408. * Execute the action and increment the target of the value amount.
  76409. */
  76410. execute(): void;
  76411. /**
  76412. * Serializes the actions and its related information.
  76413. * @param parent defines the object to serialize in
  76414. * @returns the serialized object
  76415. */
  76416. serialize(parent: any): any;
  76417. }
  76418. /**
  76419. * This defines an action responsible to start an animation once triggered.
  76420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76421. */
  76422. export class PlayAnimationAction extends Action {
  76423. /**
  76424. * Where the animation should start (animation frame)
  76425. */
  76426. from: number;
  76427. /**
  76428. * Where the animation should stop (animation frame)
  76429. */
  76430. to: number;
  76431. /**
  76432. * Define if the animation should loop or stop after the first play.
  76433. */
  76434. loop?: boolean;
  76435. private _target;
  76436. /**
  76437. * Instantiate the action
  76438. * @param triggerOptions defines the trigger options
  76439. * @param target defines the target animation or animation name
  76440. * @param from defines from where the animation should start (animation frame)
  76441. * @param end defines where the animation should stop (animation frame)
  76442. * @param loop defines if the animation should loop or stop after the first play
  76443. * @param condition defines the trigger related conditions
  76444. */
  76445. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  76446. /** @hidden */
  76447. _prepare(): void;
  76448. /**
  76449. * Execute the action and play the animation.
  76450. */
  76451. execute(): void;
  76452. /**
  76453. * Serializes the actions and its related information.
  76454. * @param parent defines the object to serialize in
  76455. * @returns the serialized object
  76456. */
  76457. serialize(parent: any): any;
  76458. }
  76459. /**
  76460. * This defines an action responsible to stop an animation once triggered.
  76461. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76462. */
  76463. export class StopAnimationAction extends Action {
  76464. private _target;
  76465. /**
  76466. * Instantiate the action
  76467. * @param triggerOptions defines the trigger options
  76468. * @param target defines the target animation or animation name
  76469. * @param condition defines the trigger related conditions
  76470. */
  76471. constructor(triggerOptions: any, target: any, condition?: Condition);
  76472. /** @hidden */
  76473. _prepare(): void;
  76474. /**
  76475. * Execute the action and stop the animation.
  76476. */
  76477. execute(): void;
  76478. /**
  76479. * Serializes the actions and its related information.
  76480. * @param parent defines the object to serialize in
  76481. * @returns the serialized object
  76482. */
  76483. serialize(parent: any): any;
  76484. }
  76485. /**
  76486. * This defines an action responsible that does nothing once triggered.
  76487. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76488. */
  76489. export class DoNothingAction extends Action {
  76490. /**
  76491. * Instantiate the action
  76492. * @param triggerOptions defines the trigger options
  76493. * @param condition defines the trigger related conditions
  76494. */
  76495. constructor(triggerOptions?: any, condition?: Condition);
  76496. /**
  76497. * Execute the action and do nothing.
  76498. */
  76499. execute(): void;
  76500. /**
  76501. * Serializes the actions and its related information.
  76502. * @param parent defines the object to serialize in
  76503. * @returns the serialized object
  76504. */
  76505. serialize(parent: any): any;
  76506. }
  76507. /**
  76508. * This defines an action responsible to trigger several actions once triggered.
  76509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76510. */
  76511. export class CombineAction extends Action {
  76512. /**
  76513. * The list of aggregated animations to run.
  76514. */
  76515. children: Action[];
  76516. /**
  76517. * Instantiate the action
  76518. * @param triggerOptions defines the trigger options
  76519. * @param children defines the list of aggregated animations to run
  76520. * @param condition defines the trigger related conditions
  76521. */
  76522. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76523. /** @hidden */
  76524. _prepare(): void;
  76525. /**
  76526. * Execute the action and executes all the aggregated actions.
  76527. */
  76528. execute(evt: ActionEvent): void;
  76529. /**
  76530. * Serializes the actions and its related information.
  76531. * @param parent defines the object to serialize in
  76532. * @returns the serialized object
  76533. */
  76534. serialize(parent: any): any;
  76535. }
  76536. /**
  76537. * This defines an action responsible to run code (external event) once triggered.
  76538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76539. */
  76540. export class ExecuteCodeAction extends Action {
  76541. /**
  76542. * The callback function to run.
  76543. */
  76544. func: (evt: ActionEvent) => void;
  76545. /**
  76546. * Instantiate the action
  76547. * @param triggerOptions defines the trigger options
  76548. * @param func defines the callback function to run
  76549. * @param condition defines the trigger related conditions
  76550. */
  76551. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76552. /**
  76553. * Execute the action and run the attached code.
  76554. */
  76555. execute(evt: ActionEvent): void;
  76556. }
  76557. /**
  76558. * This defines an action responsible to set the parent property of the target once triggered.
  76559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76560. */
  76561. export class SetParentAction extends Action {
  76562. private _parent;
  76563. private _target;
  76564. /**
  76565. * Instantiate the action
  76566. * @param triggerOptions defines the trigger options
  76567. * @param target defines the target containing the parent property
  76568. * @param parent defines from where the animation should start (animation frame)
  76569. * @param condition defines the trigger related conditions
  76570. */
  76571. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76572. /** @hidden */
  76573. _prepare(): void;
  76574. /**
  76575. * Execute the action and set the parent property.
  76576. */
  76577. execute(): void;
  76578. /**
  76579. * Serializes the actions and its related information.
  76580. * @param parent defines the object to serialize in
  76581. * @returns the serialized object
  76582. */
  76583. serialize(parent: any): any;
  76584. }
  76585. }
  76586. declare module BABYLON {
  76587. /**
  76588. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76589. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76591. */
  76592. export class ActionManager extends AbstractActionManager {
  76593. /**
  76594. * Nothing
  76595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76596. */
  76597. static readonly NothingTrigger: number;
  76598. /**
  76599. * On pick
  76600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76601. */
  76602. static readonly OnPickTrigger: number;
  76603. /**
  76604. * On left pick
  76605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76606. */
  76607. static readonly OnLeftPickTrigger: number;
  76608. /**
  76609. * On right pick
  76610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76611. */
  76612. static readonly OnRightPickTrigger: number;
  76613. /**
  76614. * On center pick
  76615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76616. */
  76617. static readonly OnCenterPickTrigger: number;
  76618. /**
  76619. * On pick down
  76620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76621. */
  76622. static readonly OnPickDownTrigger: number;
  76623. /**
  76624. * On double pick
  76625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76626. */
  76627. static readonly OnDoublePickTrigger: number;
  76628. /**
  76629. * On pick up
  76630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76631. */
  76632. static readonly OnPickUpTrigger: number;
  76633. /**
  76634. * On pick out.
  76635. * This trigger will only be raised if you also declared a OnPickDown
  76636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76637. */
  76638. static readonly OnPickOutTrigger: number;
  76639. /**
  76640. * On long press
  76641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76642. */
  76643. static readonly OnLongPressTrigger: number;
  76644. /**
  76645. * On pointer over
  76646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76647. */
  76648. static readonly OnPointerOverTrigger: number;
  76649. /**
  76650. * On pointer out
  76651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76652. */
  76653. static readonly OnPointerOutTrigger: number;
  76654. /**
  76655. * On every frame
  76656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76657. */
  76658. static readonly OnEveryFrameTrigger: number;
  76659. /**
  76660. * On intersection enter
  76661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76662. */
  76663. static readonly OnIntersectionEnterTrigger: number;
  76664. /**
  76665. * On intersection exit
  76666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76667. */
  76668. static readonly OnIntersectionExitTrigger: number;
  76669. /**
  76670. * On key down
  76671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76672. */
  76673. static readonly OnKeyDownTrigger: number;
  76674. /**
  76675. * On key up
  76676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76677. */
  76678. static readonly OnKeyUpTrigger: number;
  76679. private _scene;
  76680. /**
  76681. * Creates a new action manager
  76682. * @param scene defines the hosting scene
  76683. */
  76684. constructor(scene: Scene);
  76685. /**
  76686. * Releases all associated resources
  76687. */
  76688. dispose(): void;
  76689. /**
  76690. * Gets hosting scene
  76691. * @returns the hosting scene
  76692. */
  76693. getScene(): Scene;
  76694. /**
  76695. * Does this action manager handles actions of any of the given triggers
  76696. * @param triggers defines the triggers to be tested
  76697. * @return a boolean indicating whether one (or more) of the triggers is handled
  76698. */
  76699. hasSpecificTriggers(triggers: number[]): boolean;
  76700. /**
  76701. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76702. * speed.
  76703. * @param triggerA defines the trigger to be tested
  76704. * @param triggerB defines the trigger to be tested
  76705. * @return a boolean indicating whether one (or more) of the triggers is handled
  76706. */
  76707. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76708. /**
  76709. * Does this action manager handles actions of a given trigger
  76710. * @param trigger defines the trigger to be tested
  76711. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76712. * @return whether the trigger is handled
  76713. */
  76714. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76715. /**
  76716. * Does this action manager has pointer triggers
  76717. */
  76718. readonly hasPointerTriggers: boolean;
  76719. /**
  76720. * Does this action manager has pick triggers
  76721. */
  76722. readonly hasPickTriggers: boolean;
  76723. /**
  76724. * Registers an action to this action manager
  76725. * @param action defines the action to be registered
  76726. * @return the action amended (prepared) after registration
  76727. */
  76728. registerAction(action: IAction): Nullable<IAction>;
  76729. /**
  76730. * Unregisters an action to this action manager
  76731. * @param action defines the action to be unregistered
  76732. * @return a boolean indicating whether the action has been unregistered
  76733. */
  76734. unregisterAction(action: IAction): Boolean;
  76735. /**
  76736. * Process a specific trigger
  76737. * @param trigger defines the trigger to process
  76738. * @param evt defines the event details to be processed
  76739. */
  76740. processTrigger(trigger: number, evt?: IActionEvent): void;
  76741. /** @hidden */
  76742. _getEffectiveTarget(target: any, propertyPath: string): any;
  76743. /** @hidden */
  76744. _getProperty(propertyPath: string): string;
  76745. /**
  76746. * Serialize this manager to a JSON object
  76747. * @param name defines the property name to store this manager
  76748. * @returns a JSON representation of this manager
  76749. */
  76750. serialize(name: string): any;
  76751. /**
  76752. * Creates a new ActionManager from a JSON data
  76753. * @param parsedActions defines the JSON data to read from
  76754. * @param object defines the hosting mesh
  76755. * @param scene defines the hosting scene
  76756. */
  76757. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  76758. /**
  76759. * Get a trigger name by index
  76760. * @param trigger defines the trigger index
  76761. * @returns a trigger name
  76762. */
  76763. static GetTriggerName(trigger: number): string;
  76764. }
  76765. }
  76766. declare module BABYLON {
  76767. /**
  76768. * Class representing a ray with position and direction
  76769. */
  76770. export class Ray {
  76771. /** origin point */
  76772. origin: Vector3;
  76773. /** direction */
  76774. direction: Vector3;
  76775. /** length of the ray */
  76776. length: number;
  76777. private static readonly TmpVector3;
  76778. private _tmpRay;
  76779. /**
  76780. * Creates a new ray
  76781. * @param origin origin point
  76782. * @param direction direction
  76783. * @param length length of the ray
  76784. */
  76785. constructor(
  76786. /** origin point */
  76787. origin: Vector3,
  76788. /** direction */
  76789. direction: Vector3,
  76790. /** length of the ray */
  76791. length?: number);
  76792. /**
  76793. * Checks if the ray intersects a box
  76794. * @param minimum bound of the box
  76795. * @param maximum bound of the box
  76796. * @param intersectionTreshold extra extend to be added to the box in all direction
  76797. * @returns if the box was hit
  76798. */
  76799. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  76800. /**
  76801. * Checks if the ray intersects a box
  76802. * @param box the bounding box to check
  76803. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  76804. * @returns if the box was hit
  76805. */
  76806. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  76807. /**
  76808. * If the ray hits a sphere
  76809. * @param sphere the bounding sphere to check
  76810. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  76811. * @returns true if it hits the sphere
  76812. */
  76813. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  76814. /**
  76815. * If the ray hits a triange
  76816. * @param vertex0 triangle vertex
  76817. * @param vertex1 triangle vertex
  76818. * @param vertex2 triangle vertex
  76819. * @returns intersection information if hit
  76820. */
  76821. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  76822. /**
  76823. * Checks if ray intersects a plane
  76824. * @param plane the plane to check
  76825. * @returns the distance away it was hit
  76826. */
  76827. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  76828. /**
  76829. * Calculate the intercept of a ray on a given axis
  76830. * @param axis to check 'x' | 'y' | 'z'
  76831. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  76832. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  76833. */
  76834. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  76835. /**
  76836. * Checks if ray intersects a mesh
  76837. * @param mesh the mesh to check
  76838. * @param fastCheck if only the bounding box should checked
  76839. * @returns picking info of the intersecton
  76840. */
  76841. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  76842. /**
  76843. * Checks if ray intersects a mesh
  76844. * @param meshes the meshes to check
  76845. * @param fastCheck if only the bounding box should checked
  76846. * @param results array to store result in
  76847. * @returns Array of picking infos
  76848. */
  76849. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  76850. private _comparePickingInfo;
  76851. private static smallnum;
  76852. private static rayl;
  76853. /**
  76854. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  76855. * @param sega the first point of the segment to test the intersection against
  76856. * @param segb the second point of the segment to test the intersection against
  76857. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  76858. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  76859. */
  76860. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  76861. /**
  76862. * Update the ray from viewport position
  76863. * @param x position
  76864. * @param y y position
  76865. * @param viewportWidth viewport width
  76866. * @param viewportHeight viewport height
  76867. * @param world world matrix
  76868. * @param view view matrix
  76869. * @param projection projection matrix
  76870. * @returns this ray updated
  76871. */
  76872. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76873. /**
  76874. * Creates a ray with origin and direction of 0,0,0
  76875. * @returns the new ray
  76876. */
  76877. static Zero(): Ray;
  76878. /**
  76879. * Creates a new ray from screen space and viewport
  76880. * @param x position
  76881. * @param y y position
  76882. * @param viewportWidth viewport width
  76883. * @param viewportHeight viewport height
  76884. * @param world world matrix
  76885. * @param view view matrix
  76886. * @param projection projection matrix
  76887. * @returns new ray
  76888. */
  76889. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76890. /**
  76891. * 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
  76892. * transformed to the given world matrix.
  76893. * @param origin The origin point
  76894. * @param end The end point
  76895. * @param world a matrix to transform the ray to. Default is the identity matrix.
  76896. * @returns the new ray
  76897. */
  76898. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  76899. /**
  76900. * Transforms a ray by a matrix
  76901. * @param ray ray to transform
  76902. * @param matrix matrix to apply
  76903. * @returns the resulting new ray
  76904. */
  76905. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  76906. /**
  76907. * Transforms a ray by a matrix
  76908. * @param ray ray to transform
  76909. * @param matrix matrix to apply
  76910. * @param result ray to store result in
  76911. */
  76912. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  76913. /**
  76914. * Unproject a ray from screen space to object space
  76915. * @param sourceX defines the screen space x coordinate to use
  76916. * @param sourceY defines the screen space y coordinate to use
  76917. * @param viewportWidth defines the current width of the viewport
  76918. * @param viewportHeight defines the current height of the viewport
  76919. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76920. * @param view defines the view matrix to use
  76921. * @param projection defines the projection matrix to use
  76922. */
  76923. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  76924. }
  76925. /**
  76926. * Type used to define predicate used to select faces when a mesh intersection is detected
  76927. */
  76928. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  76929. interface Scene {
  76930. /** @hidden */
  76931. _tempPickingRay: Nullable<Ray>;
  76932. /** @hidden */
  76933. _cachedRayForTransform: Ray;
  76934. /** @hidden */
  76935. _pickWithRayInverseMatrix: Matrix;
  76936. /** @hidden */
  76937. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  76938. /** @hidden */
  76939. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  76940. }
  76941. }
  76942. declare module BABYLON {
  76943. /**
  76944. * Groups all the scene component constants in one place to ease maintenance.
  76945. * @hidden
  76946. */
  76947. export class SceneComponentConstants {
  76948. static readonly NAME_EFFECTLAYER: string;
  76949. static readonly NAME_LAYER: string;
  76950. static readonly NAME_LENSFLARESYSTEM: string;
  76951. static readonly NAME_BOUNDINGBOXRENDERER: string;
  76952. static readonly NAME_PARTICLESYSTEM: string;
  76953. static readonly NAME_GAMEPAD: string;
  76954. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  76955. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  76956. static readonly NAME_DEPTHRENDERER: string;
  76957. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  76958. static readonly NAME_SPRITE: string;
  76959. static readonly NAME_OUTLINERENDERER: string;
  76960. static readonly NAME_PROCEDURALTEXTURE: string;
  76961. static readonly NAME_SHADOWGENERATOR: string;
  76962. static readonly NAME_OCTREE: string;
  76963. static readonly NAME_PHYSICSENGINE: string;
  76964. static readonly NAME_AUDIO: string;
  76965. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  76966. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76967. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  76968. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76969. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  76970. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  76971. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  76972. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  76973. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  76974. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  76975. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  76976. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  76977. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  76978. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  76979. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  76980. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  76981. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  76982. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  76983. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  76984. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  76985. static readonly STEP_AFTERRENDER_AUDIO: number;
  76986. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  76987. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  76988. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  76989. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  76990. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  76991. static readonly STEP_POINTERMOVE_SPRITE: number;
  76992. static readonly STEP_POINTERDOWN_SPRITE: number;
  76993. static readonly STEP_POINTERUP_SPRITE: number;
  76994. }
  76995. /**
  76996. * This represents a scene component.
  76997. *
  76998. * This is used to decouple the dependency the scene is having on the different workloads like
  76999. * layers, post processes...
  77000. */
  77001. export interface ISceneComponent {
  77002. /**
  77003. * The name of the component. Each component must have a unique name.
  77004. */
  77005. name: string;
  77006. /**
  77007. * The scene the component belongs to.
  77008. */
  77009. scene: Scene;
  77010. /**
  77011. * Register the component to one instance of a scene.
  77012. */
  77013. register(): void;
  77014. /**
  77015. * Rebuilds the elements related to this component in case of
  77016. * context lost for instance.
  77017. */
  77018. rebuild(): void;
  77019. /**
  77020. * Disposes the component and the associated ressources.
  77021. */
  77022. dispose(): void;
  77023. }
  77024. /**
  77025. * This represents a SERIALIZABLE scene component.
  77026. *
  77027. * This extends Scene Component to add Serialization methods on top.
  77028. */
  77029. export interface ISceneSerializableComponent extends ISceneComponent {
  77030. /**
  77031. * Adds all the elements from the container to the scene
  77032. * @param container the container holding the elements
  77033. */
  77034. addFromContainer(container: AbstractScene): void;
  77035. /**
  77036. * Removes all the elements in the container from the scene
  77037. * @param container contains the elements to remove
  77038. * @param dispose if the removed element should be disposed (default: false)
  77039. */
  77040. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77041. /**
  77042. * Serializes the component data to the specified json object
  77043. * @param serializationObject The object to serialize to
  77044. */
  77045. serialize(serializationObject: any): void;
  77046. }
  77047. /**
  77048. * Strong typing of a Mesh related stage step action
  77049. */
  77050. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77051. /**
  77052. * Strong typing of a Evaluate Sub Mesh related stage step action
  77053. */
  77054. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77055. /**
  77056. * Strong typing of a Active Mesh related stage step action
  77057. */
  77058. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77059. /**
  77060. * Strong typing of a Camera related stage step action
  77061. */
  77062. export type CameraStageAction = (camera: Camera) => void;
  77063. /**
  77064. * Strong typing of a Camera Frame buffer related stage step action
  77065. */
  77066. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77067. /**
  77068. * Strong typing of a Render Target related stage step action
  77069. */
  77070. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77071. /**
  77072. * Strong typing of a RenderingGroup related stage step action
  77073. */
  77074. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  77075. /**
  77076. * Strong typing of a Mesh Render related stage step action
  77077. */
  77078. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  77079. /**
  77080. * Strong typing of a simple stage step action
  77081. */
  77082. export type SimpleStageAction = () => void;
  77083. /**
  77084. * Strong typing of a render target action.
  77085. */
  77086. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  77087. /**
  77088. * Strong typing of a pointer move action.
  77089. */
  77090. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  77091. /**
  77092. * Strong typing of a pointer up/down action.
  77093. */
  77094. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  77095. /**
  77096. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  77097. * @hidden
  77098. */
  77099. export class Stage<T extends Function> extends Array<{
  77100. index: number;
  77101. component: ISceneComponent;
  77102. action: T;
  77103. }> {
  77104. /**
  77105. * Hide ctor from the rest of the world.
  77106. * @param items The items to add.
  77107. */
  77108. private constructor();
  77109. /**
  77110. * Creates a new Stage.
  77111. * @returns A new instance of a Stage
  77112. */
  77113. static Create<T extends Function>(): Stage<T>;
  77114. /**
  77115. * Registers a step in an ordered way in the targeted stage.
  77116. * @param index Defines the position to register the step in
  77117. * @param component Defines the component attached to the step
  77118. * @param action Defines the action to launch during the step
  77119. */
  77120. registerStep(index: number, component: ISceneComponent, action: T): void;
  77121. /**
  77122. * Clears all the steps from the stage.
  77123. */
  77124. clear(): void;
  77125. }
  77126. }
  77127. declare module BABYLON {
  77128. interface Scene {
  77129. /** @hidden */
  77130. _pointerOverSprite: Nullable<Sprite>;
  77131. /** @hidden */
  77132. _pickedDownSprite: Nullable<Sprite>;
  77133. /** @hidden */
  77134. _tempSpritePickingRay: Nullable<Ray>;
  77135. /**
  77136. * All of the sprite managers added to this scene
  77137. * @see http://doc.babylonjs.com/babylon101/sprites
  77138. */
  77139. spriteManagers: Array<ISpriteManager>;
  77140. /**
  77141. * An event triggered when sprites rendering is about to start
  77142. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77143. */
  77144. onBeforeSpritesRenderingObservable: Observable<Scene>;
  77145. /**
  77146. * An event triggered when sprites rendering is done
  77147. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77148. */
  77149. onAfterSpritesRenderingObservable: Observable<Scene>;
  77150. /** @hidden */
  77151. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77152. /** Launch a ray to try to pick a sprite in the scene
  77153. * @param x position on screen
  77154. * @param y position on screen
  77155. * @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
  77156. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77157. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77158. * @returns a PickingInfo
  77159. */
  77160. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77161. /** Use the given ray to pick a sprite in the scene
  77162. * @param ray The ray (in world space) to use to pick meshes
  77163. * @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
  77164. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77165. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77166. * @returns a PickingInfo
  77167. */
  77168. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77169. /** @hidden */
  77170. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77171. /** Launch a ray to try to pick sprites in the scene
  77172. * @param x position on screen
  77173. * @param y position on screen
  77174. * @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
  77175. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77176. * @returns a PickingInfo array
  77177. */
  77178. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77179. /** Use the given ray to pick sprites in the scene
  77180. * @param ray The ray (in world space) to use to pick meshes
  77181. * @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
  77182. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77183. * @returns a PickingInfo array
  77184. */
  77185. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77186. /**
  77187. * Force the sprite under the pointer
  77188. * @param sprite defines the sprite to use
  77189. */
  77190. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  77191. /**
  77192. * Gets the sprite under the pointer
  77193. * @returns a Sprite or null if no sprite is under the pointer
  77194. */
  77195. getPointerOverSprite(): Nullable<Sprite>;
  77196. }
  77197. /**
  77198. * Defines the sprite scene component responsible to manage sprites
  77199. * in a given scene.
  77200. */
  77201. export class SpriteSceneComponent implements ISceneComponent {
  77202. /**
  77203. * The component name helpfull to identify the component in the list of scene components.
  77204. */
  77205. readonly name: string;
  77206. /**
  77207. * The scene the component belongs to.
  77208. */
  77209. scene: Scene;
  77210. /** @hidden */
  77211. private _spritePredicate;
  77212. /**
  77213. * Creates a new instance of the component for the given scene
  77214. * @param scene Defines the scene to register the component in
  77215. */
  77216. constructor(scene: Scene);
  77217. /**
  77218. * Registers the component in a given scene
  77219. */
  77220. register(): void;
  77221. /**
  77222. * Rebuilds the elements related to this component in case of
  77223. * context lost for instance.
  77224. */
  77225. rebuild(): void;
  77226. /**
  77227. * Disposes the component and the associated ressources.
  77228. */
  77229. dispose(): void;
  77230. private _pickSpriteButKeepRay;
  77231. private _pointerMove;
  77232. private _pointerDown;
  77233. private _pointerUp;
  77234. }
  77235. }
  77236. declare module BABYLON {
  77237. /** @hidden */
  77238. export var fogFragmentDeclaration: {
  77239. name: string;
  77240. shader: string;
  77241. };
  77242. }
  77243. declare module BABYLON {
  77244. /** @hidden */
  77245. export var fogFragment: {
  77246. name: string;
  77247. shader: string;
  77248. };
  77249. }
  77250. declare module BABYLON {
  77251. /** @hidden */
  77252. export var spritesPixelShader: {
  77253. name: string;
  77254. shader: string;
  77255. };
  77256. }
  77257. declare module BABYLON {
  77258. /** @hidden */
  77259. export var fogVertexDeclaration: {
  77260. name: string;
  77261. shader: string;
  77262. };
  77263. }
  77264. declare module BABYLON {
  77265. /** @hidden */
  77266. export var spritesVertexShader: {
  77267. name: string;
  77268. shader: string;
  77269. };
  77270. }
  77271. declare module BABYLON {
  77272. /**
  77273. * Defines the minimum interface to fullfil in order to be a sprite manager.
  77274. */
  77275. export interface ISpriteManager extends IDisposable {
  77276. /**
  77277. * Restricts the camera to viewing objects with the same layerMask.
  77278. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  77279. */
  77280. layerMask: number;
  77281. /**
  77282. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  77283. */
  77284. isPickable: boolean;
  77285. /**
  77286. * Specifies the rendering group id for this mesh (0 by default)
  77287. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  77288. */
  77289. renderingGroupId: number;
  77290. /**
  77291. * Defines the list of sprites managed by the manager.
  77292. */
  77293. sprites: Array<Sprite>;
  77294. /**
  77295. * Tests the intersection of a sprite with a specific ray.
  77296. * @param ray The ray we are sending to test the collision
  77297. * @param camera The camera space we are sending rays in
  77298. * @param predicate A predicate allowing excluding sprites from the list of object to test
  77299. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  77300. * @returns picking info or null.
  77301. */
  77302. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77303. /**
  77304. * Intersects the sprites with a ray
  77305. * @param ray defines the ray to intersect with
  77306. * @param camera defines the current active camera
  77307. * @param predicate defines a predicate used to select candidate sprites
  77308. * @returns null if no hit or a PickingInfo array
  77309. */
  77310. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77311. /**
  77312. * Renders the list of sprites on screen.
  77313. */
  77314. render(): void;
  77315. }
  77316. /**
  77317. * Class used to manage multiple sprites on the same spritesheet
  77318. * @see http://doc.babylonjs.com/babylon101/sprites
  77319. */
  77320. export class SpriteManager implements ISpriteManager {
  77321. /** defines the manager's name */
  77322. name: string;
  77323. /** Gets the list of sprites */
  77324. sprites: Sprite[];
  77325. /** Gets or sets the rendering group id (0 by default) */
  77326. renderingGroupId: number;
  77327. /** Gets or sets camera layer mask */
  77328. layerMask: number;
  77329. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  77330. fogEnabled: boolean;
  77331. /** Gets or sets a boolean indicating if the sprites are pickable */
  77332. isPickable: boolean;
  77333. /** Defines the default width of a cell in the spritesheet */
  77334. cellWidth: number;
  77335. /** Defines the default height of a cell in the spritesheet */
  77336. cellHeight: number;
  77337. /** Associative array from JSON sprite data file */
  77338. private _cellData;
  77339. /** Array of sprite names from JSON sprite data file */
  77340. private _spriteMap;
  77341. /** True when packed cell data from JSON file is ready*/
  77342. private _packedAndReady;
  77343. /**
  77344. * An event triggered when the manager is disposed.
  77345. */
  77346. onDisposeObservable: Observable<SpriteManager>;
  77347. private _onDisposeObserver;
  77348. /**
  77349. * Callback called when the manager is disposed
  77350. */
  77351. onDispose: () => void;
  77352. private _capacity;
  77353. private _fromPacked;
  77354. private _spriteTexture;
  77355. private _epsilon;
  77356. private _scene;
  77357. private _vertexData;
  77358. private _buffer;
  77359. private _vertexBuffers;
  77360. private _indexBuffer;
  77361. private _effectBase;
  77362. private _effectFog;
  77363. /**
  77364. * Gets or sets the spritesheet texture
  77365. */
  77366. texture: Texture;
  77367. /**
  77368. * Creates a new sprite manager
  77369. * @param name defines the manager's name
  77370. * @param imgUrl defines the sprite sheet url
  77371. * @param capacity defines the maximum allowed number of sprites
  77372. * @param cellSize defines the size of a sprite cell
  77373. * @param scene defines the hosting scene
  77374. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77375. * @param samplingMode defines the smapling mode to use with spritesheet
  77376. * @param fromPacked set to false; do not alter
  77377. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  77378. */
  77379. constructor(
  77380. /** defines the manager's name */
  77381. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  77382. private _makePacked;
  77383. private _appendSpriteVertex;
  77384. /**
  77385. * Intersects the sprites with a ray
  77386. * @param ray defines the ray to intersect with
  77387. * @param camera defines the current active camera
  77388. * @param predicate defines a predicate used to select candidate sprites
  77389. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  77390. * @returns null if no hit or a PickingInfo
  77391. */
  77392. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77393. /**
  77394. * Intersects the sprites with a ray
  77395. * @param ray defines the ray to intersect with
  77396. * @param camera defines the current active camera
  77397. * @param predicate defines a predicate used to select candidate sprites
  77398. * @returns null if no hit or a PickingInfo array
  77399. */
  77400. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77401. /**
  77402. * Render all child sprites
  77403. */
  77404. render(): void;
  77405. /**
  77406. * Release associated resources
  77407. */
  77408. dispose(): void;
  77409. }
  77410. }
  77411. declare module BABYLON {
  77412. /**
  77413. * Class used to represent a sprite
  77414. * @see http://doc.babylonjs.com/babylon101/sprites
  77415. */
  77416. export class Sprite {
  77417. /** defines the name */
  77418. name: string;
  77419. /** Gets or sets the current world position */
  77420. position: Vector3;
  77421. /** Gets or sets the main color */
  77422. color: Color4;
  77423. /** Gets or sets the width */
  77424. width: number;
  77425. /** Gets or sets the height */
  77426. height: number;
  77427. /** Gets or sets rotation angle */
  77428. angle: number;
  77429. /** Gets or sets the cell index in the sprite sheet */
  77430. cellIndex: number;
  77431. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  77432. cellRef: string;
  77433. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  77434. invertU: number;
  77435. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  77436. invertV: number;
  77437. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  77438. disposeWhenFinishedAnimating: boolean;
  77439. /** Gets the list of attached animations */
  77440. animations: Animation[];
  77441. /** Gets or sets a boolean indicating if the sprite can be picked */
  77442. isPickable: boolean;
  77443. /**
  77444. * Gets or sets the associated action manager
  77445. */
  77446. actionManager: Nullable<ActionManager>;
  77447. private _animationStarted;
  77448. private _loopAnimation;
  77449. private _fromIndex;
  77450. private _toIndex;
  77451. private _delay;
  77452. private _direction;
  77453. private _manager;
  77454. private _time;
  77455. private _onAnimationEnd;
  77456. /**
  77457. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  77458. */
  77459. isVisible: boolean;
  77460. /**
  77461. * Gets or sets the sprite size
  77462. */
  77463. size: number;
  77464. /**
  77465. * Creates a new Sprite
  77466. * @param name defines the name
  77467. * @param manager defines the manager
  77468. */
  77469. constructor(
  77470. /** defines the name */
  77471. name: string, manager: ISpriteManager);
  77472. /**
  77473. * Starts an animation
  77474. * @param from defines the initial key
  77475. * @param to defines the end key
  77476. * @param loop defines if the animation must loop
  77477. * @param delay defines the start delay (in ms)
  77478. * @param onAnimationEnd defines a callback to call when animation ends
  77479. */
  77480. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  77481. /** Stops current animation (if any) */
  77482. stopAnimation(): void;
  77483. /** @hidden */
  77484. _animate(deltaTime: number): void;
  77485. /** Release associated resources */
  77486. dispose(): void;
  77487. }
  77488. }
  77489. declare module BABYLON {
  77490. /**
  77491. * Information about the result of picking within a scene
  77492. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  77493. */
  77494. export class PickingInfo {
  77495. /** @hidden */
  77496. _pickingUnavailable: boolean;
  77497. /**
  77498. * If the pick collided with an object
  77499. */
  77500. hit: boolean;
  77501. /**
  77502. * Distance away where the pick collided
  77503. */
  77504. distance: number;
  77505. /**
  77506. * The location of pick collision
  77507. */
  77508. pickedPoint: Nullable<Vector3>;
  77509. /**
  77510. * The mesh corresponding the the pick collision
  77511. */
  77512. pickedMesh: Nullable<AbstractMesh>;
  77513. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  77514. bu: number;
  77515. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  77516. bv: number;
  77517. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  77518. faceId: number;
  77519. /** Id of the the submesh that was picked */
  77520. subMeshId: number;
  77521. /** If a sprite was picked, this will be the sprite the pick collided with */
  77522. pickedSprite: Nullable<Sprite>;
  77523. /**
  77524. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  77525. */
  77526. originMesh: Nullable<AbstractMesh>;
  77527. /**
  77528. * The ray that was used to perform the picking.
  77529. */
  77530. ray: Nullable<Ray>;
  77531. /**
  77532. * Gets the normal correspodning to the face the pick collided with
  77533. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  77534. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  77535. * @returns The normal correspodning to the face the pick collided with
  77536. */
  77537. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  77538. /**
  77539. * Gets the texture coordinates of where the pick occured
  77540. * @returns the vector containing the coordnates of the texture
  77541. */
  77542. getTextureCoordinates(): Nullable<Vector2>;
  77543. }
  77544. }
  77545. declare module BABYLON {
  77546. /**
  77547. * Gather the list of pointer event types as constants.
  77548. */
  77549. export class PointerEventTypes {
  77550. /**
  77551. * 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.
  77552. */
  77553. static readonly POINTERDOWN: number;
  77554. /**
  77555. * The pointerup event is fired when a pointer is no longer active.
  77556. */
  77557. static readonly POINTERUP: number;
  77558. /**
  77559. * The pointermove event is fired when a pointer changes coordinates.
  77560. */
  77561. static readonly POINTERMOVE: number;
  77562. /**
  77563. * The pointerwheel event is fired when a mouse wheel has been rotated.
  77564. */
  77565. static readonly POINTERWHEEL: number;
  77566. /**
  77567. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  77568. */
  77569. static readonly POINTERPICK: number;
  77570. /**
  77571. * The pointertap event is fired when a the object has been touched and released without drag.
  77572. */
  77573. static readonly POINTERTAP: number;
  77574. /**
  77575. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  77576. */
  77577. static readonly POINTERDOUBLETAP: number;
  77578. }
  77579. /**
  77580. * Base class of pointer info types.
  77581. */
  77582. export class PointerInfoBase {
  77583. /**
  77584. * Defines the type of event (PointerEventTypes)
  77585. */
  77586. type: number;
  77587. /**
  77588. * Defines the related dom event
  77589. */
  77590. event: PointerEvent | MouseWheelEvent;
  77591. /**
  77592. * Instantiates the base class of pointers info.
  77593. * @param type Defines the type of event (PointerEventTypes)
  77594. * @param event Defines the related dom event
  77595. */
  77596. constructor(
  77597. /**
  77598. * Defines the type of event (PointerEventTypes)
  77599. */
  77600. type: number,
  77601. /**
  77602. * Defines the related dom event
  77603. */
  77604. event: PointerEvent | MouseWheelEvent);
  77605. }
  77606. /**
  77607. * This class is used to store pointer related info for the onPrePointerObservable event.
  77608. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  77609. */
  77610. export class PointerInfoPre extends PointerInfoBase {
  77611. /**
  77612. * Ray from a pointer if availible (eg. 6dof controller)
  77613. */
  77614. ray: Nullable<Ray>;
  77615. /**
  77616. * Defines the local position of the pointer on the canvas.
  77617. */
  77618. localPosition: Vector2;
  77619. /**
  77620. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  77621. */
  77622. skipOnPointerObservable: boolean;
  77623. /**
  77624. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  77625. * @param type Defines the type of event (PointerEventTypes)
  77626. * @param event Defines the related dom event
  77627. * @param localX Defines the local x coordinates of the pointer when the event occured
  77628. * @param localY Defines the local y coordinates of the pointer when the event occured
  77629. */
  77630. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  77631. }
  77632. /**
  77633. * This type contains all the data related to a pointer event in Babylon.js.
  77634. * 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.
  77635. */
  77636. export class PointerInfo extends PointerInfoBase {
  77637. /**
  77638. * Defines the picking info associated to the info (if any)\
  77639. */
  77640. pickInfo: Nullable<PickingInfo>;
  77641. /**
  77642. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  77643. * @param type Defines the type of event (PointerEventTypes)
  77644. * @param event Defines the related dom event
  77645. * @param pickInfo Defines the picking info associated to the info (if any)\
  77646. */
  77647. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  77648. /**
  77649. * Defines the picking info associated to the info (if any)\
  77650. */
  77651. pickInfo: Nullable<PickingInfo>);
  77652. }
  77653. /**
  77654. * Data relating to a touch event on the screen.
  77655. */
  77656. export interface PointerTouch {
  77657. /**
  77658. * X coordinate of touch.
  77659. */
  77660. x: number;
  77661. /**
  77662. * Y coordinate of touch.
  77663. */
  77664. y: number;
  77665. /**
  77666. * Id of touch. Unique for each finger.
  77667. */
  77668. pointerId: number;
  77669. /**
  77670. * Event type passed from DOM.
  77671. */
  77672. type: any;
  77673. }
  77674. }
  77675. declare module BABYLON {
  77676. /**
  77677. * Manage the mouse inputs to control the movement of a free camera.
  77678. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77679. */
  77680. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  77681. /**
  77682. * Define if touch is enabled in the mouse input
  77683. */
  77684. touchEnabled: boolean;
  77685. /**
  77686. * Defines the camera the input is attached to.
  77687. */
  77688. camera: FreeCamera;
  77689. /**
  77690. * Defines the buttons associated with the input to handle camera move.
  77691. */
  77692. buttons: number[];
  77693. /**
  77694. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  77695. */
  77696. angularSensibility: number;
  77697. private _pointerInput;
  77698. private _onMouseMove;
  77699. private _observer;
  77700. private previousPosition;
  77701. /**
  77702. * Observable for when a pointer move event occurs containing the move offset
  77703. */
  77704. onPointerMovedObservable: Observable<{
  77705. offsetX: number;
  77706. offsetY: number;
  77707. }>;
  77708. /**
  77709. * @hidden
  77710. * If the camera should be rotated automatically based on pointer movement
  77711. */
  77712. _allowCameraRotation: boolean;
  77713. /**
  77714. * Manage the mouse inputs to control the movement of a free camera.
  77715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77716. * @param touchEnabled Defines if touch is enabled or not
  77717. */
  77718. constructor(
  77719. /**
  77720. * Define if touch is enabled in the mouse input
  77721. */
  77722. touchEnabled?: boolean);
  77723. /**
  77724. * Attach the input controls to a specific dom element to get the input from.
  77725. * @param element Defines the element the controls should be listened from
  77726. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77727. */
  77728. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77729. /**
  77730. * Called on JS contextmenu event.
  77731. * Override this method to provide functionality.
  77732. */
  77733. protected onContextMenu(evt: PointerEvent): void;
  77734. /**
  77735. * Detach the current controls from the specified dom element.
  77736. * @param element Defines the element to stop listening the inputs from
  77737. */
  77738. detachControl(element: Nullable<HTMLElement>): void;
  77739. /**
  77740. * Gets the class name of the current intput.
  77741. * @returns the class name
  77742. */
  77743. getClassName(): string;
  77744. /**
  77745. * Get the friendly name associated with the input class.
  77746. * @returns the input friendly name
  77747. */
  77748. getSimpleName(): string;
  77749. }
  77750. }
  77751. declare module BABYLON {
  77752. /**
  77753. * Manage the touch inputs to control the movement of a free camera.
  77754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77755. */
  77756. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  77757. /**
  77758. * Defines the camera the input is attached to.
  77759. */
  77760. camera: FreeCamera;
  77761. /**
  77762. * Defines the touch sensibility for rotation.
  77763. * The higher the faster.
  77764. */
  77765. touchAngularSensibility: number;
  77766. /**
  77767. * Defines the touch sensibility for move.
  77768. * The higher the faster.
  77769. */
  77770. touchMoveSensibility: number;
  77771. private _offsetX;
  77772. private _offsetY;
  77773. private _pointerPressed;
  77774. private _pointerInput;
  77775. private _observer;
  77776. private _onLostFocus;
  77777. /**
  77778. * Attach the input controls to a specific dom element to get the input from.
  77779. * @param element Defines the element the controls should be listened from
  77780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77781. */
  77782. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77783. /**
  77784. * Detach the current controls from the specified dom element.
  77785. * @param element Defines the element to stop listening the inputs from
  77786. */
  77787. detachControl(element: Nullable<HTMLElement>): void;
  77788. /**
  77789. * Update the current camera state depending on the inputs that have been used this frame.
  77790. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77791. */
  77792. checkInputs(): void;
  77793. /**
  77794. * Gets the class name of the current intput.
  77795. * @returns the class name
  77796. */
  77797. getClassName(): string;
  77798. /**
  77799. * Get the friendly name associated with the input class.
  77800. * @returns the input friendly name
  77801. */
  77802. getSimpleName(): string;
  77803. }
  77804. }
  77805. declare module BABYLON {
  77806. /**
  77807. * Default Inputs manager for the FreeCamera.
  77808. * It groups all the default supported inputs for ease of use.
  77809. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77810. */
  77811. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  77812. /**
  77813. * @hidden
  77814. */
  77815. _mouseInput: Nullable<FreeCameraMouseInput>;
  77816. /**
  77817. * Instantiates a new FreeCameraInputsManager.
  77818. * @param camera Defines the camera the inputs belong to
  77819. */
  77820. constructor(camera: FreeCamera);
  77821. /**
  77822. * Add keyboard input support to the input manager.
  77823. * @returns the current input manager
  77824. */
  77825. addKeyboard(): FreeCameraInputsManager;
  77826. /**
  77827. * Add mouse input support to the input manager.
  77828. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  77829. * @returns the current input manager
  77830. */
  77831. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  77832. /**
  77833. * Removes the mouse input support from the manager
  77834. * @returns the current input manager
  77835. */
  77836. removeMouse(): FreeCameraInputsManager;
  77837. /**
  77838. * Add touch input support to the input manager.
  77839. * @returns the current input manager
  77840. */
  77841. addTouch(): FreeCameraInputsManager;
  77842. /**
  77843. * Remove all attached input methods from a camera
  77844. */
  77845. clear(): void;
  77846. }
  77847. }
  77848. declare module BABYLON {
  77849. /**
  77850. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77851. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  77852. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77853. */
  77854. export class FreeCamera extends TargetCamera {
  77855. /**
  77856. * Define the collision ellipsoid of the camera.
  77857. * This is helpful to simulate a camera body like the player body around the camera
  77858. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  77859. */
  77860. ellipsoid: Vector3;
  77861. /**
  77862. * Define an offset for the position of the ellipsoid around the camera.
  77863. * This can be helpful to determine the center of the body near the gravity center of the body
  77864. * instead of its head.
  77865. */
  77866. ellipsoidOffset: Vector3;
  77867. /**
  77868. * Enable or disable collisions of the camera with the rest of the scene objects.
  77869. */
  77870. checkCollisions: boolean;
  77871. /**
  77872. * Enable or disable gravity on the camera.
  77873. */
  77874. applyGravity: boolean;
  77875. /**
  77876. * Define the input manager associated to the camera.
  77877. */
  77878. inputs: FreeCameraInputsManager;
  77879. /**
  77880. * Gets the input sensibility for a mouse input. (default is 2000.0)
  77881. * Higher values reduce sensitivity.
  77882. */
  77883. /**
  77884. * Sets the input sensibility for a mouse input. (default is 2000.0)
  77885. * Higher values reduce sensitivity.
  77886. */
  77887. angularSensibility: number;
  77888. /**
  77889. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77890. */
  77891. keysUp: number[];
  77892. /**
  77893. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77894. */
  77895. keysDown: number[];
  77896. /**
  77897. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77898. */
  77899. keysLeft: number[];
  77900. /**
  77901. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77902. */
  77903. keysRight: number[];
  77904. /**
  77905. * Event raised when the camera collide with a mesh in the scene.
  77906. */
  77907. onCollide: (collidedMesh: AbstractMesh) => void;
  77908. private _collider;
  77909. private _needMoveForGravity;
  77910. private _oldPosition;
  77911. private _diffPosition;
  77912. private _newPosition;
  77913. /** @hidden */
  77914. _localDirection: Vector3;
  77915. /** @hidden */
  77916. _transformedDirection: Vector3;
  77917. /**
  77918. * Instantiates a Free Camera.
  77919. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77920. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  77921. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77922. * @param name Define the name of the camera in the scene
  77923. * @param position Define the start position of the camera in the scene
  77924. * @param scene Define the scene the camera belongs to
  77925. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77926. */
  77927. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77928. /**
  77929. * Attached controls to the current camera.
  77930. * @param element Defines the element the controls should be listened from
  77931. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77932. */
  77933. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77934. /**
  77935. * Detach the current controls from the camera.
  77936. * The camera will stop reacting to inputs.
  77937. * @param element Defines the element to stop listening the inputs from
  77938. */
  77939. detachControl(element: HTMLElement): void;
  77940. private _collisionMask;
  77941. /**
  77942. * Define a collision mask to limit the list of object the camera can collide with
  77943. */
  77944. collisionMask: number;
  77945. /** @hidden */
  77946. _collideWithWorld(displacement: Vector3): void;
  77947. private _onCollisionPositionChange;
  77948. /** @hidden */
  77949. _checkInputs(): void;
  77950. /** @hidden */
  77951. _decideIfNeedsToMove(): boolean;
  77952. /** @hidden */
  77953. _updatePosition(): void;
  77954. /**
  77955. * Destroy the camera and release the current resources hold by it.
  77956. */
  77957. dispose(): void;
  77958. /**
  77959. * Gets the current object class name.
  77960. * @return the class name
  77961. */
  77962. getClassName(): string;
  77963. }
  77964. }
  77965. declare module BABYLON {
  77966. /**
  77967. * Represents a gamepad control stick position
  77968. */
  77969. export class StickValues {
  77970. /**
  77971. * The x component of the control stick
  77972. */
  77973. x: number;
  77974. /**
  77975. * The y component of the control stick
  77976. */
  77977. y: number;
  77978. /**
  77979. * Initializes the gamepad x and y control stick values
  77980. * @param x The x component of the gamepad control stick value
  77981. * @param y The y component of the gamepad control stick value
  77982. */
  77983. constructor(
  77984. /**
  77985. * The x component of the control stick
  77986. */
  77987. x: number,
  77988. /**
  77989. * The y component of the control stick
  77990. */
  77991. y: number);
  77992. }
  77993. /**
  77994. * An interface which manages callbacks for gamepad button changes
  77995. */
  77996. export interface GamepadButtonChanges {
  77997. /**
  77998. * Called when a gamepad has been changed
  77999. */
  78000. changed: boolean;
  78001. /**
  78002. * Called when a gamepad press event has been triggered
  78003. */
  78004. pressChanged: boolean;
  78005. /**
  78006. * Called when a touch event has been triggered
  78007. */
  78008. touchChanged: boolean;
  78009. /**
  78010. * Called when a value has changed
  78011. */
  78012. valueChanged: boolean;
  78013. }
  78014. /**
  78015. * Represents a gamepad
  78016. */
  78017. export class Gamepad {
  78018. /**
  78019. * The id of the gamepad
  78020. */
  78021. id: string;
  78022. /**
  78023. * The index of the gamepad
  78024. */
  78025. index: number;
  78026. /**
  78027. * The browser gamepad
  78028. */
  78029. browserGamepad: any;
  78030. /**
  78031. * Specifies what type of gamepad this represents
  78032. */
  78033. type: number;
  78034. private _leftStick;
  78035. private _rightStick;
  78036. /** @hidden */
  78037. _isConnected: boolean;
  78038. private _leftStickAxisX;
  78039. private _leftStickAxisY;
  78040. private _rightStickAxisX;
  78041. private _rightStickAxisY;
  78042. /**
  78043. * Triggered when the left control stick has been changed
  78044. */
  78045. private _onleftstickchanged;
  78046. /**
  78047. * Triggered when the right control stick has been changed
  78048. */
  78049. private _onrightstickchanged;
  78050. /**
  78051. * Represents a gamepad controller
  78052. */
  78053. static GAMEPAD: number;
  78054. /**
  78055. * Represents a generic controller
  78056. */
  78057. static GENERIC: number;
  78058. /**
  78059. * Represents an XBox controller
  78060. */
  78061. static XBOX: number;
  78062. /**
  78063. * Represents a pose-enabled controller
  78064. */
  78065. static POSE_ENABLED: number;
  78066. /**
  78067. * Represents an Dual Shock controller
  78068. */
  78069. static DUALSHOCK: number;
  78070. /**
  78071. * Specifies whether the left control stick should be Y-inverted
  78072. */
  78073. protected _invertLeftStickY: boolean;
  78074. /**
  78075. * Specifies if the gamepad has been connected
  78076. */
  78077. readonly isConnected: boolean;
  78078. /**
  78079. * Initializes the gamepad
  78080. * @param id The id of the gamepad
  78081. * @param index The index of the gamepad
  78082. * @param browserGamepad The browser gamepad
  78083. * @param leftStickX The x component of the left joystick
  78084. * @param leftStickY The y component of the left joystick
  78085. * @param rightStickX The x component of the right joystick
  78086. * @param rightStickY The y component of the right joystick
  78087. */
  78088. constructor(
  78089. /**
  78090. * The id of the gamepad
  78091. */
  78092. id: string,
  78093. /**
  78094. * The index of the gamepad
  78095. */
  78096. index: number,
  78097. /**
  78098. * The browser gamepad
  78099. */
  78100. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  78101. /**
  78102. * Callback triggered when the left joystick has changed
  78103. * @param callback
  78104. */
  78105. onleftstickchanged(callback: (values: StickValues) => void): void;
  78106. /**
  78107. * Callback triggered when the right joystick has changed
  78108. * @param callback
  78109. */
  78110. onrightstickchanged(callback: (values: StickValues) => void): void;
  78111. /**
  78112. * Gets the left joystick
  78113. */
  78114. /**
  78115. * Sets the left joystick values
  78116. */
  78117. leftStick: StickValues;
  78118. /**
  78119. * Gets the right joystick
  78120. */
  78121. /**
  78122. * Sets the right joystick value
  78123. */
  78124. rightStick: StickValues;
  78125. /**
  78126. * Updates the gamepad joystick positions
  78127. */
  78128. update(): void;
  78129. /**
  78130. * Disposes the gamepad
  78131. */
  78132. dispose(): void;
  78133. }
  78134. /**
  78135. * Represents a generic gamepad
  78136. */
  78137. export class GenericPad extends Gamepad {
  78138. private _buttons;
  78139. private _onbuttondown;
  78140. private _onbuttonup;
  78141. /**
  78142. * Observable triggered when a button has been pressed
  78143. */
  78144. onButtonDownObservable: Observable<number>;
  78145. /**
  78146. * Observable triggered when a button has been released
  78147. */
  78148. onButtonUpObservable: Observable<number>;
  78149. /**
  78150. * Callback triggered when a button has been pressed
  78151. * @param callback Called when a button has been pressed
  78152. */
  78153. onbuttondown(callback: (buttonPressed: number) => void): void;
  78154. /**
  78155. * Callback triggered when a button has been released
  78156. * @param callback Called when a button has been released
  78157. */
  78158. onbuttonup(callback: (buttonReleased: number) => void): void;
  78159. /**
  78160. * Initializes the generic gamepad
  78161. * @param id The id of the generic gamepad
  78162. * @param index The index of the generic gamepad
  78163. * @param browserGamepad The browser gamepad
  78164. */
  78165. constructor(id: string, index: number, browserGamepad: any);
  78166. private _setButtonValue;
  78167. /**
  78168. * Updates the generic gamepad
  78169. */
  78170. update(): void;
  78171. /**
  78172. * Disposes the generic gamepad
  78173. */
  78174. dispose(): void;
  78175. }
  78176. }
  78177. declare module BABYLON {
  78178. interface Engine {
  78179. /**
  78180. * Creates a raw texture
  78181. * @param data defines the data to store in the texture
  78182. * @param width defines the width of the texture
  78183. * @param height defines the height of the texture
  78184. * @param format defines the format of the data
  78185. * @param generateMipMaps defines if the engine should generate the mip levels
  78186. * @param invertY defines if data must be stored with Y axis inverted
  78187. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78188. * @param compression defines the compression used (null by default)
  78189. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78190. * @returns the raw texture inside an InternalTexture
  78191. */
  78192. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78193. /**
  78194. * Update a raw texture
  78195. * @param texture defines the texture to update
  78196. * @param data defines the data to store in the texture
  78197. * @param format defines the format of the data
  78198. * @param invertY defines if data must be stored with Y axis inverted
  78199. */
  78200. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78201. /**
  78202. * Update a raw texture
  78203. * @param texture defines the texture to update
  78204. * @param data defines the data to store in the texture
  78205. * @param format defines the format of the data
  78206. * @param invertY defines if data must be stored with Y axis inverted
  78207. * @param compression defines the compression used (null by default)
  78208. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78209. */
  78210. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78211. /**
  78212. * Creates a new raw cube texture
  78213. * @param data defines the array of data to use to create each face
  78214. * @param size defines the size of the textures
  78215. * @param format defines the format of the data
  78216. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78217. * @param generateMipMaps defines if the engine should generate the mip levels
  78218. * @param invertY defines if data must be stored with Y axis inverted
  78219. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78220. * @param compression defines the compression used (null by default)
  78221. * @returns the cube texture as an InternalTexture
  78222. */
  78223. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78224. /**
  78225. * Update a raw cube texture
  78226. * @param texture defines the texture to udpdate
  78227. * @param data defines the data to store
  78228. * @param format defines the data format
  78229. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78230. * @param invertY defines if data must be stored with Y axis inverted
  78231. */
  78232. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78233. /**
  78234. * Update a raw cube texture
  78235. * @param texture defines the texture to udpdate
  78236. * @param data defines the data to store
  78237. * @param format defines the data format
  78238. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78239. * @param invertY defines if data must be stored with Y axis inverted
  78240. * @param compression defines the compression used (null by default)
  78241. */
  78242. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78243. /**
  78244. * Update a raw cube texture
  78245. * @param texture defines the texture to udpdate
  78246. * @param data defines the data to store
  78247. * @param format defines the data format
  78248. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78249. * @param invertY defines if data must be stored with Y axis inverted
  78250. * @param compression defines the compression used (null by default)
  78251. * @param level defines which level of the texture to update
  78252. */
  78253. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78254. /**
  78255. * Creates a new raw cube texture from a specified url
  78256. * @param url defines the url where the data is located
  78257. * @param scene defines the current scene
  78258. * @param size defines the size of the textures
  78259. * @param format defines the format of the data
  78260. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78261. * @param noMipmap defines if the engine should avoid generating the mip levels
  78262. * @param callback defines a callback used to extract texture data from loaded data
  78263. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78264. * @param onLoad defines a callback called when texture is loaded
  78265. * @param onError defines a callback called if there is an error
  78266. * @returns the cube texture as an InternalTexture
  78267. */
  78268. 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;
  78269. /**
  78270. * Creates a new raw cube texture from a specified url
  78271. * @param url defines the url where the data is located
  78272. * @param scene defines the current scene
  78273. * @param size defines the size of the textures
  78274. * @param format defines the format of the data
  78275. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78276. * @param noMipmap defines if the engine should avoid generating the mip levels
  78277. * @param callback defines a callback used to extract texture data from loaded data
  78278. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78279. * @param onLoad defines a callback called when texture is loaded
  78280. * @param onError defines a callback called if there is an error
  78281. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78282. * @param invertY defines if data must be stored with Y axis inverted
  78283. * @returns the cube texture as an InternalTexture
  78284. */
  78285. 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;
  78286. /**
  78287. * Creates a new raw 3D texture
  78288. * @param data defines the data used to create the texture
  78289. * @param width defines the width of the texture
  78290. * @param height defines the height of the texture
  78291. * @param depth defines the depth of the texture
  78292. * @param format defines the format of the texture
  78293. * @param generateMipMaps defines if the engine must generate mip levels
  78294. * @param invertY defines if data must be stored with Y axis inverted
  78295. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78296. * @param compression defines the compressed used (can be null)
  78297. * @param textureType defines the compressed used (can be null)
  78298. * @returns a new raw 3D texture (stored in an InternalTexture)
  78299. */
  78300. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78301. /**
  78302. * Update a raw 3D texture
  78303. * @param texture defines the texture to update
  78304. * @param data defines the data to store
  78305. * @param format defines the data format
  78306. * @param invertY defines if data must be stored with Y axis inverted
  78307. */
  78308. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78309. /**
  78310. * Update a raw 3D texture
  78311. * @param texture defines the texture to update
  78312. * @param data defines the data to store
  78313. * @param format defines the data format
  78314. * @param invertY defines if data must be stored with Y axis inverted
  78315. * @param compression defines the used compression (can be null)
  78316. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78317. */
  78318. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78319. }
  78320. }
  78321. declare module BABYLON {
  78322. /**
  78323. * Raw texture can help creating a texture directly from an array of data.
  78324. * This can be super useful if you either get the data from an uncompressed source or
  78325. * if you wish to create your texture pixel by pixel.
  78326. */
  78327. export class RawTexture extends Texture {
  78328. /**
  78329. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78330. */
  78331. format: number;
  78332. private _engine;
  78333. /**
  78334. * Instantiates a new RawTexture.
  78335. * Raw texture can help creating a texture directly from an array of data.
  78336. * This can be super useful if you either get the data from an uncompressed source or
  78337. * if you wish to create your texture pixel by pixel.
  78338. * @param data define the array of data to use to create the texture
  78339. * @param width define the width of the texture
  78340. * @param height define the height of the texture
  78341. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78342. * @param scene define the scene the texture belongs to
  78343. * @param generateMipMaps define whether mip maps should be generated or not
  78344. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78345. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78346. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78347. */
  78348. constructor(data: ArrayBufferView, width: number, height: number,
  78349. /**
  78350. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78351. */
  78352. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78353. /**
  78354. * Updates the texture underlying data.
  78355. * @param data Define the new data of the texture
  78356. */
  78357. update(data: ArrayBufferView): void;
  78358. /**
  78359. * Creates a luminance texture from some data.
  78360. * @param data Define the texture data
  78361. * @param width Define the width of the texture
  78362. * @param height Define the height of the texture
  78363. * @param scene Define the scene the texture belongs to
  78364. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78365. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78366. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78367. * @returns the luminance texture
  78368. */
  78369. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78370. /**
  78371. * Creates a luminance alpha texture from some data.
  78372. * @param data Define the texture data
  78373. * @param width Define the width of the texture
  78374. * @param height Define the height of the texture
  78375. * @param scene Define the scene the texture belongs to
  78376. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78377. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78378. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78379. * @returns the luminance alpha texture
  78380. */
  78381. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78382. /**
  78383. * Creates an alpha texture from some data.
  78384. * @param data Define the texture data
  78385. * @param width Define the width of the texture
  78386. * @param height Define the height of the texture
  78387. * @param scene Define the scene the texture belongs to
  78388. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78389. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78390. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78391. * @returns the alpha texture
  78392. */
  78393. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78394. /**
  78395. * Creates a RGB texture from some data.
  78396. * @param data Define the texture data
  78397. * @param width Define the width of the texture
  78398. * @param height Define the height of the texture
  78399. * @param scene Define the scene the texture belongs to
  78400. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78401. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78402. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78403. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78404. * @returns the RGB alpha texture
  78405. */
  78406. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78407. /**
  78408. * Creates a RGBA texture from some data.
  78409. * @param data Define the texture data
  78410. * @param width Define the width of the texture
  78411. * @param height Define the height of the texture
  78412. * @param scene Define the scene the texture belongs to
  78413. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78414. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78415. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78416. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78417. * @returns the RGBA texture
  78418. */
  78419. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78420. /**
  78421. * Creates a R texture from some data.
  78422. * @param data Define the texture data
  78423. * @param width Define the width of the texture
  78424. * @param height Define the height of the texture
  78425. * @param scene Define the scene the texture belongs to
  78426. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78427. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78428. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78429. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78430. * @returns the R texture
  78431. */
  78432. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78433. }
  78434. }
  78435. declare module BABYLON {
  78436. /**
  78437. * Interface for the size containing width and height
  78438. */
  78439. export interface ISize {
  78440. /**
  78441. * Width
  78442. */
  78443. width: number;
  78444. /**
  78445. * Heighht
  78446. */
  78447. height: number;
  78448. }
  78449. /**
  78450. * Size containing widht and height
  78451. */
  78452. export class Size implements ISize {
  78453. /**
  78454. * Width
  78455. */
  78456. width: number;
  78457. /**
  78458. * Height
  78459. */
  78460. height: number;
  78461. /**
  78462. * Creates a Size object from the given width and height (floats).
  78463. * @param width width of the new size
  78464. * @param height height of the new size
  78465. */
  78466. constructor(width: number, height: number);
  78467. /**
  78468. * Returns a string with the Size width and height
  78469. * @returns a string with the Size width and height
  78470. */
  78471. toString(): string;
  78472. /**
  78473. * "Size"
  78474. * @returns the string "Size"
  78475. */
  78476. getClassName(): string;
  78477. /**
  78478. * Returns the Size hash code.
  78479. * @returns a hash code for a unique width and height
  78480. */
  78481. getHashCode(): number;
  78482. /**
  78483. * Updates the current size from the given one.
  78484. * @param src the given size
  78485. */
  78486. copyFrom(src: Size): void;
  78487. /**
  78488. * Updates in place the current Size from the given floats.
  78489. * @param width width of the new size
  78490. * @param height height of the new size
  78491. * @returns the updated Size.
  78492. */
  78493. copyFromFloats(width: number, height: number): Size;
  78494. /**
  78495. * Updates in place the current Size from the given floats.
  78496. * @param width width to set
  78497. * @param height height to set
  78498. * @returns the updated Size.
  78499. */
  78500. set(width: number, height: number): Size;
  78501. /**
  78502. * Multiplies the width and height by numbers
  78503. * @param w factor to multiple the width by
  78504. * @param h factor to multiple the height by
  78505. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  78506. */
  78507. multiplyByFloats(w: number, h: number): Size;
  78508. /**
  78509. * Clones the size
  78510. * @returns a new Size copied from the given one.
  78511. */
  78512. clone(): Size;
  78513. /**
  78514. * True if the current Size and the given one width and height are strictly equal.
  78515. * @param other the other size to compare against
  78516. * @returns True if the current Size and the given one width and height are strictly equal.
  78517. */
  78518. equals(other: Size): boolean;
  78519. /**
  78520. * The surface of the Size : width * height (float).
  78521. */
  78522. readonly surface: number;
  78523. /**
  78524. * Create a new size of zero
  78525. * @returns a new Size set to (0.0, 0.0)
  78526. */
  78527. static Zero(): Size;
  78528. /**
  78529. * Sums the width and height of two sizes
  78530. * @param otherSize size to add to this size
  78531. * @returns a new Size set as the addition result of the current Size and the given one.
  78532. */
  78533. add(otherSize: Size): Size;
  78534. /**
  78535. * Subtracts the width and height of two
  78536. * @param otherSize size to subtract to this size
  78537. * @returns a new Size set as the subtraction result of the given one from the current Size.
  78538. */
  78539. subtract(otherSize: Size): Size;
  78540. /**
  78541. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  78542. * @param start starting size to lerp between
  78543. * @param end end size to lerp between
  78544. * @param amount amount to lerp between the start and end values
  78545. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  78546. */
  78547. static Lerp(start: Size, end: Size, amount: number): Size;
  78548. }
  78549. }
  78550. declare module BABYLON {
  78551. /**
  78552. * Defines a runtime animation
  78553. */
  78554. export class RuntimeAnimation {
  78555. private _events;
  78556. /**
  78557. * The current frame of the runtime animation
  78558. */
  78559. private _currentFrame;
  78560. /**
  78561. * The animation used by the runtime animation
  78562. */
  78563. private _animation;
  78564. /**
  78565. * The target of the runtime animation
  78566. */
  78567. private _target;
  78568. /**
  78569. * The initiating animatable
  78570. */
  78571. private _host;
  78572. /**
  78573. * The original value of the runtime animation
  78574. */
  78575. private _originalValue;
  78576. /**
  78577. * The original blend value of the runtime animation
  78578. */
  78579. private _originalBlendValue;
  78580. /**
  78581. * The offsets cache of the runtime animation
  78582. */
  78583. private _offsetsCache;
  78584. /**
  78585. * The high limits cache of the runtime animation
  78586. */
  78587. private _highLimitsCache;
  78588. /**
  78589. * Specifies if the runtime animation has been stopped
  78590. */
  78591. private _stopped;
  78592. /**
  78593. * The blending factor of the runtime animation
  78594. */
  78595. private _blendingFactor;
  78596. /**
  78597. * The BabylonJS scene
  78598. */
  78599. private _scene;
  78600. /**
  78601. * The current value of the runtime animation
  78602. */
  78603. private _currentValue;
  78604. /** @hidden */
  78605. _animationState: _IAnimationState;
  78606. /**
  78607. * The active target of the runtime animation
  78608. */
  78609. private _activeTargets;
  78610. private _currentActiveTarget;
  78611. private _directTarget;
  78612. /**
  78613. * The target path of the runtime animation
  78614. */
  78615. private _targetPath;
  78616. /**
  78617. * The weight of the runtime animation
  78618. */
  78619. private _weight;
  78620. /**
  78621. * The ratio offset of the runtime animation
  78622. */
  78623. private _ratioOffset;
  78624. /**
  78625. * The previous delay of the runtime animation
  78626. */
  78627. private _previousDelay;
  78628. /**
  78629. * The previous ratio of the runtime animation
  78630. */
  78631. private _previousRatio;
  78632. private _enableBlending;
  78633. private _keys;
  78634. private _minFrame;
  78635. private _maxFrame;
  78636. private _minValue;
  78637. private _maxValue;
  78638. private _targetIsArray;
  78639. /**
  78640. * Gets the current frame of the runtime animation
  78641. */
  78642. readonly currentFrame: number;
  78643. /**
  78644. * Gets the weight of the runtime animation
  78645. */
  78646. readonly weight: number;
  78647. /**
  78648. * Gets the current value of the runtime animation
  78649. */
  78650. readonly currentValue: any;
  78651. /**
  78652. * Gets the target path of the runtime animation
  78653. */
  78654. readonly targetPath: string;
  78655. /**
  78656. * Gets the actual target of the runtime animation
  78657. */
  78658. readonly target: any;
  78659. /** @hidden */
  78660. _onLoop: () => void;
  78661. /**
  78662. * Create a new RuntimeAnimation object
  78663. * @param target defines the target of the animation
  78664. * @param animation defines the source animation object
  78665. * @param scene defines the hosting scene
  78666. * @param host defines the initiating Animatable
  78667. */
  78668. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78669. private _preparePath;
  78670. /**
  78671. * Gets the animation from the runtime animation
  78672. */
  78673. readonly animation: Animation;
  78674. /**
  78675. * Resets the runtime animation to the beginning
  78676. * @param restoreOriginal defines whether to restore the target property to the original value
  78677. */
  78678. reset(restoreOriginal?: boolean): void;
  78679. /**
  78680. * Specifies if the runtime animation is stopped
  78681. * @returns Boolean specifying if the runtime animation is stopped
  78682. */
  78683. isStopped(): boolean;
  78684. /**
  78685. * Disposes of the runtime animation
  78686. */
  78687. dispose(): void;
  78688. /**
  78689. * Apply the interpolated value to the target
  78690. * @param currentValue defines the value computed by the animation
  78691. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78692. */
  78693. setValue(currentValue: any, weight: number): void;
  78694. private _getOriginalValues;
  78695. private _setValue;
  78696. /**
  78697. * Gets the loop pmode of the runtime animation
  78698. * @returns Loop Mode
  78699. */
  78700. private _getCorrectLoopMode;
  78701. /**
  78702. * Move the current animation to a given frame
  78703. * @param frame defines the frame to move to
  78704. */
  78705. goToFrame(frame: number): void;
  78706. /**
  78707. * @hidden Internal use only
  78708. */
  78709. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78710. /**
  78711. * Execute the current animation
  78712. * @param delay defines the delay to add to the current frame
  78713. * @param from defines the lower bound of the animation range
  78714. * @param to defines the upper bound of the animation range
  78715. * @param loop defines if the current animation must loop
  78716. * @param speedRatio defines the current speed ratio
  78717. * @param weight defines the weight of the animation (default is -1 so no weight)
  78718. * @param onLoop optional callback called when animation loops
  78719. * @returns a boolean indicating if the animation is running
  78720. */
  78721. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78722. }
  78723. }
  78724. declare module BABYLON {
  78725. /**
  78726. * Class used to store an actual running animation
  78727. */
  78728. export class Animatable {
  78729. /** defines the target object */
  78730. target: any;
  78731. /** defines the starting frame number (default is 0) */
  78732. fromFrame: number;
  78733. /** defines the ending frame number (default is 100) */
  78734. toFrame: number;
  78735. /** defines if the animation must loop (default is false) */
  78736. loopAnimation: boolean;
  78737. /** defines a callback to call when animation ends if it is not looping */
  78738. onAnimationEnd?: (() => void) | null | undefined;
  78739. /** defines a callback to call when animation loops */
  78740. onAnimationLoop?: (() => void) | null | undefined;
  78741. private _localDelayOffset;
  78742. private _pausedDelay;
  78743. private _runtimeAnimations;
  78744. private _paused;
  78745. private _scene;
  78746. private _speedRatio;
  78747. private _weight;
  78748. private _syncRoot;
  78749. /**
  78750. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78751. * This will only apply for non looping animation (default is true)
  78752. */
  78753. disposeOnEnd: boolean;
  78754. /**
  78755. * Gets a boolean indicating if the animation has started
  78756. */
  78757. animationStarted: boolean;
  78758. /**
  78759. * Observer raised when the animation ends
  78760. */
  78761. onAnimationEndObservable: Observable<Animatable>;
  78762. /**
  78763. * Observer raised when the animation loops
  78764. */
  78765. onAnimationLoopObservable: Observable<Animatable>;
  78766. /**
  78767. * Gets the root Animatable used to synchronize and normalize animations
  78768. */
  78769. readonly syncRoot: Nullable<Animatable>;
  78770. /**
  78771. * Gets the current frame of the first RuntimeAnimation
  78772. * Used to synchronize Animatables
  78773. */
  78774. readonly masterFrame: number;
  78775. /**
  78776. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78777. */
  78778. weight: number;
  78779. /**
  78780. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78781. */
  78782. speedRatio: number;
  78783. /**
  78784. * Creates a new Animatable
  78785. * @param scene defines the hosting scene
  78786. * @param target defines the target object
  78787. * @param fromFrame defines the starting frame number (default is 0)
  78788. * @param toFrame defines the ending frame number (default is 100)
  78789. * @param loopAnimation defines if the animation must loop (default is false)
  78790. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78791. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78792. * @param animations defines a group of animation to add to the new Animatable
  78793. * @param onAnimationLoop defines a callback to call when animation loops
  78794. */
  78795. constructor(scene: Scene,
  78796. /** defines the target object */
  78797. target: any,
  78798. /** defines the starting frame number (default is 0) */
  78799. fromFrame?: number,
  78800. /** defines the ending frame number (default is 100) */
  78801. toFrame?: number,
  78802. /** defines if the animation must loop (default is false) */
  78803. loopAnimation?: boolean, speedRatio?: number,
  78804. /** defines a callback to call when animation ends if it is not looping */
  78805. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78806. /** defines a callback to call when animation loops */
  78807. onAnimationLoop?: (() => void) | null | undefined);
  78808. /**
  78809. * Synchronize and normalize current Animatable with a source Animatable
  78810. * This is useful when using animation weights and when animations are not of the same length
  78811. * @param root defines the root Animatable to synchronize with
  78812. * @returns the current Animatable
  78813. */
  78814. syncWith(root: Animatable): Animatable;
  78815. /**
  78816. * Gets the list of runtime animations
  78817. * @returns an array of RuntimeAnimation
  78818. */
  78819. getAnimations(): RuntimeAnimation[];
  78820. /**
  78821. * Adds more animations to the current animatable
  78822. * @param target defines the target of the animations
  78823. * @param animations defines the new animations to add
  78824. */
  78825. appendAnimations(target: any, animations: Animation[]): void;
  78826. /**
  78827. * Gets the source animation for a specific property
  78828. * @param property defines the propertyu to look for
  78829. * @returns null or the source animation for the given property
  78830. */
  78831. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78832. /**
  78833. * Gets the runtime animation for a specific property
  78834. * @param property defines the propertyu to look for
  78835. * @returns null or the runtime animation for the given property
  78836. */
  78837. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78838. /**
  78839. * Resets the animatable to its original state
  78840. */
  78841. reset(): void;
  78842. /**
  78843. * Allows the animatable to blend with current running animations
  78844. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78845. * @param blendingSpeed defines the blending speed to use
  78846. */
  78847. enableBlending(blendingSpeed: number): void;
  78848. /**
  78849. * Disable animation blending
  78850. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78851. */
  78852. disableBlending(): void;
  78853. /**
  78854. * Jump directly to a given frame
  78855. * @param frame defines the frame to jump to
  78856. */
  78857. goToFrame(frame: number): void;
  78858. /**
  78859. * Pause the animation
  78860. */
  78861. pause(): void;
  78862. /**
  78863. * Restart the animation
  78864. */
  78865. restart(): void;
  78866. private _raiseOnAnimationEnd;
  78867. /**
  78868. * Stop and delete the current animation
  78869. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78870. * @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)
  78871. */
  78872. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78873. /**
  78874. * Wait asynchronously for the animation to end
  78875. * @returns a promise which will be fullfilled when the animation ends
  78876. */
  78877. waitAsync(): Promise<Animatable>;
  78878. /** @hidden */
  78879. _animate(delay: number): boolean;
  78880. }
  78881. interface Scene {
  78882. /** @hidden */
  78883. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78884. /** @hidden */
  78885. _processLateAnimationBindingsForMatrices(holder: {
  78886. totalWeight: number;
  78887. animations: RuntimeAnimation[];
  78888. originalValue: Matrix;
  78889. }): any;
  78890. /** @hidden */
  78891. _processLateAnimationBindingsForQuaternions(holder: {
  78892. totalWeight: number;
  78893. animations: RuntimeAnimation[];
  78894. originalValue: Quaternion;
  78895. }, refQuaternion: Quaternion): Quaternion;
  78896. /** @hidden */
  78897. _processLateAnimationBindings(): void;
  78898. /**
  78899. * Will start the animation sequence of a given target
  78900. * @param target defines the target
  78901. * @param from defines from which frame should animation start
  78902. * @param to defines until which frame should animation run.
  78903. * @param weight defines the weight to apply to the animation (1.0 by default)
  78904. * @param loop defines if the animation loops
  78905. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78906. * @param onAnimationEnd defines the function to be executed when the animation ends
  78907. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78908. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78909. * @param onAnimationLoop defines the callback to call when an animation loops
  78910. * @returns the animatable object created for this animation
  78911. */
  78912. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78913. /**
  78914. * Will start the animation sequence of a given target
  78915. * @param target defines the target
  78916. * @param from defines from which frame should animation start
  78917. * @param to defines until which frame should animation run.
  78918. * @param loop defines if the animation loops
  78919. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78920. * @param onAnimationEnd defines the function to be executed when the animation ends
  78921. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78922. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78923. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78924. * @param onAnimationLoop defines the callback to call when an animation loops
  78925. * @returns the animatable object created for this animation
  78926. */
  78927. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78928. /**
  78929. * Will start the animation sequence of a given target and its hierarchy
  78930. * @param target defines the target
  78931. * @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.
  78932. * @param from defines from which frame should animation start
  78933. * @param to defines until which frame should animation run.
  78934. * @param loop defines if the animation loops
  78935. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78936. * @param onAnimationEnd defines the function to be executed when the animation ends
  78937. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78938. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78939. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78940. * @param onAnimationLoop defines the callback to call when an animation loops
  78941. * @returns the list of created animatables
  78942. */
  78943. 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[];
  78944. /**
  78945. * Begin a new animation on a given node
  78946. * @param target defines the target where the animation will take place
  78947. * @param animations defines the list of animations to start
  78948. * @param from defines the initial value
  78949. * @param to defines the final value
  78950. * @param loop defines if you want animation to loop (off by default)
  78951. * @param speedRatio defines the speed ratio to apply to all animations
  78952. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78953. * @param onAnimationLoop defines the callback to call when an animation loops
  78954. * @returns the list of created animatables
  78955. */
  78956. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78957. /**
  78958. * Begin a new animation on a given node and its hierarchy
  78959. * @param target defines the root node where the animation will take place
  78960. * @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.
  78961. * @param animations defines the list of animations to start
  78962. * @param from defines the initial value
  78963. * @param to defines the final value
  78964. * @param loop defines if you want animation to loop (off by default)
  78965. * @param speedRatio defines the speed ratio to apply to all animations
  78966. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78967. * @param onAnimationLoop defines the callback to call when an animation loops
  78968. * @returns the list of animatables created for all nodes
  78969. */
  78970. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78971. /**
  78972. * Gets the animatable associated with a specific target
  78973. * @param target defines the target of the animatable
  78974. * @returns the required animatable if found
  78975. */
  78976. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78977. /**
  78978. * Gets all animatables associated with a given target
  78979. * @param target defines the target to look animatables for
  78980. * @returns an array of Animatables
  78981. */
  78982. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78983. /**
  78984. * Stops and removes all animations that have been applied to the scene
  78985. */
  78986. stopAllAnimations(): void;
  78987. }
  78988. interface Bone {
  78989. /**
  78990. * Copy an animation range from another bone
  78991. * @param source defines the source bone
  78992. * @param rangeName defines the range name to copy
  78993. * @param frameOffset defines the frame offset
  78994. * @param rescaleAsRequired defines if rescaling must be applied if required
  78995. * @param skelDimensionsRatio defines the scaling ratio
  78996. * @returns true if operation was successful
  78997. */
  78998. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78999. }
  79000. }
  79001. declare module BABYLON {
  79002. /**
  79003. * Class used to override all child animations of a given target
  79004. */
  79005. export class AnimationPropertiesOverride {
  79006. /**
  79007. * Gets or sets a value indicating if animation blending must be used
  79008. */
  79009. enableBlending: boolean;
  79010. /**
  79011. * Gets or sets the blending speed to use when enableBlending is true
  79012. */
  79013. blendingSpeed: number;
  79014. /**
  79015. * Gets or sets the default loop mode to use
  79016. */
  79017. loopMode: number;
  79018. }
  79019. }
  79020. declare module BABYLON {
  79021. /**
  79022. * Class used to handle skinning animations
  79023. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79024. */
  79025. export class Skeleton implements IAnimatable {
  79026. /** defines the skeleton name */
  79027. name: string;
  79028. /** defines the skeleton Id */
  79029. id: string;
  79030. /**
  79031. * Defines the list of child bones
  79032. */
  79033. bones: Bone[];
  79034. /**
  79035. * Defines an estimate of the dimension of the skeleton at rest
  79036. */
  79037. dimensionsAtRest: Vector3;
  79038. /**
  79039. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79040. */
  79041. needInitialSkinMatrix: boolean;
  79042. /**
  79043. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79044. */
  79045. overrideMesh: Nullable<AbstractMesh>;
  79046. /**
  79047. * Gets the list of animations attached to this skeleton
  79048. */
  79049. animations: Array<Animation>;
  79050. private _scene;
  79051. private _isDirty;
  79052. private _transformMatrices;
  79053. private _transformMatrixTexture;
  79054. private _meshesWithPoseMatrix;
  79055. private _animatables;
  79056. private _identity;
  79057. private _synchronizedWithMesh;
  79058. private _ranges;
  79059. private _lastAbsoluteTransformsUpdateId;
  79060. private _canUseTextureForBones;
  79061. private _uniqueId;
  79062. /** @hidden */
  79063. _numBonesWithLinkedTransformNode: number;
  79064. /** @hidden */
  79065. _hasWaitingData: Nullable<boolean>;
  79066. /**
  79067. * Specifies if the skeleton should be serialized
  79068. */
  79069. doNotSerialize: boolean;
  79070. private _useTextureToStoreBoneMatrices;
  79071. /**
  79072. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79073. * Please note that this option is not available if the hardware does not support it
  79074. */
  79075. useTextureToStoreBoneMatrices: boolean;
  79076. private _animationPropertiesOverride;
  79077. /**
  79078. * Gets or sets the animation properties override
  79079. */
  79080. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79081. /**
  79082. * List of inspectable custom properties (used by the Inspector)
  79083. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79084. */
  79085. inspectableCustomProperties: IInspectable[];
  79086. /**
  79087. * An observable triggered before computing the skeleton's matrices
  79088. */
  79089. onBeforeComputeObservable: Observable<Skeleton>;
  79090. /**
  79091. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79092. */
  79093. readonly isUsingTextureForMatrices: boolean;
  79094. /**
  79095. * Gets the unique ID of this skeleton
  79096. */
  79097. readonly uniqueId: number;
  79098. /**
  79099. * Creates a new skeleton
  79100. * @param name defines the skeleton name
  79101. * @param id defines the skeleton Id
  79102. * @param scene defines the hosting scene
  79103. */
  79104. constructor(
  79105. /** defines the skeleton name */
  79106. name: string,
  79107. /** defines the skeleton Id */
  79108. id: string, scene: Scene);
  79109. /**
  79110. * Gets the current object class name.
  79111. * @return the class name
  79112. */
  79113. getClassName(): string;
  79114. /**
  79115. * Returns an array containing the root bones
  79116. * @returns an array containing the root bones
  79117. */
  79118. getChildren(): Array<Bone>;
  79119. /**
  79120. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79121. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79122. * @returns a Float32Array containing matrices data
  79123. */
  79124. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79125. /**
  79126. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79127. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79128. * @returns a raw texture containing the data
  79129. */
  79130. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  79131. /**
  79132. * Gets the current hosting scene
  79133. * @returns a scene object
  79134. */
  79135. getScene(): Scene;
  79136. /**
  79137. * Gets a string representing the current skeleton data
  79138. * @param fullDetails defines a boolean indicating if we want a verbose version
  79139. * @returns a string representing the current skeleton data
  79140. */
  79141. toString(fullDetails?: boolean): string;
  79142. /**
  79143. * Get bone's index searching by name
  79144. * @param name defines bone's name to search for
  79145. * @return the indice of the bone. Returns -1 if not found
  79146. */
  79147. getBoneIndexByName(name: string): number;
  79148. /**
  79149. * Creater a new animation range
  79150. * @param name defines the name of the range
  79151. * @param from defines the start key
  79152. * @param to defines the end key
  79153. */
  79154. createAnimationRange(name: string, from: number, to: number): void;
  79155. /**
  79156. * Delete a specific animation range
  79157. * @param name defines the name of the range
  79158. * @param deleteFrames defines if frames must be removed as well
  79159. */
  79160. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79161. /**
  79162. * Gets a specific animation range
  79163. * @param name defines the name of the range to look for
  79164. * @returns the requested animation range or null if not found
  79165. */
  79166. getAnimationRange(name: string): Nullable<AnimationRange>;
  79167. /**
  79168. * Gets the list of all animation ranges defined on this skeleton
  79169. * @returns an array
  79170. */
  79171. getAnimationRanges(): Nullable<AnimationRange>[];
  79172. /**
  79173. * Copy animation range from a source skeleton.
  79174. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79175. * @param source defines the source skeleton
  79176. * @param name defines the name of the range to copy
  79177. * @param rescaleAsRequired defines if rescaling must be applied if required
  79178. * @returns true if operation was successful
  79179. */
  79180. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79181. /**
  79182. * Forces the skeleton to go to rest pose
  79183. */
  79184. returnToRest(): void;
  79185. private _getHighestAnimationFrame;
  79186. /**
  79187. * Begin a specific animation range
  79188. * @param name defines the name of the range to start
  79189. * @param loop defines if looping must be turned on (false by default)
  79190. * @param speedRatio defines the speed ratio to apply (1 by default)
  79191. * @param onAnimationEnd defines a callback which will be called when animation will end
  79192. * @returns a new animatable
  79193. */
  79194. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79195. /** @hidden */
  79196. _markAsDirty(): void;
  79197. /** @hidden */
  79198. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79199. /** @hidden */
  79200. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79201. private _computeTransformMatrices;
  79202. /**
  79203. * Build all resources required to render a skeleton
  79204. */
  79205. prepare(): void;
  79206. /**
  79207. * Gets the list of animatables currently running for this skeleton
  79208. * @returns an array of animatables
  79209. */
  79210. getAnimatables(): IAnimatable[];
  79211. /**
  79212. * Clone the current skeleton
  79213. * @param name defines the name of the new skeleton
  79214. * @param id defines the id of the new skeleton
  79215. * @returns the new skeleton
  79216. */
  79217. clone(name: string, id: string): Skeleton;
  79218. /**
  79219. * Enable animation blending for this skeleton
  79220. * @param blendingSpeed defines the blending speed to apply
  79221. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79222. */
  79223. enableBlending(blendingSpeed?: number): void;
  79224. /**
  79225. * Releases all resources associated with the current skeleton
  79226. */
  79227. dispose(): void;
  79228. /**
  79229. * Serialize the skeleton in a JSON object
  79230. * @returns a JSON object
  79231. */
  79232. serialize(): any;
  79233. /**
  79234. * Creates a new skeleton from serialized data
  79235. * @param parsedSkeleton defines the serialized data
  79236. * @param scene defines the hosting scene
  79237. * @returns a new skeleton
  79238. */
  79239. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79240. /**
  79241. * Compute all node absolute transforms
  79242. * @param forceUpdate defines if computation must be done even if cache is up to date
  79243. */
  79244. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79245. /**
  79246. * Gets the root pose matrix
  79247. * @returns a matrix
  79248. */
  79249. getPoseMatrix(): Nullable<Matrix>;
  79250. /**
  79251. * Sorts bones per internal index
  79252. */
  79253. sortBones(): void;
  79254. private _sortBones;
  79255. }
  79256. }
  79257. declare module BABYLON {
  79258. /**
  79259. * Class used to store bone information
  79260. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79261. */
  79262. export class Bone extends Node {
  79263. /**
  79264. * defines the bone name
  79265. */
  79266. name: string;
  79267. private static _tmpVecs;
  79268. private static _tmpQuat;
  79269. private static _tmpMats;
  79270. /**
  79271. * Gets the list of child bones
  79272. */
  79273. children: Bone[];
  79274. /** Gets the animations associated with this bone */
  79275. animations: Animation[];
  79276. /**
  79277. * Gets or sets bone length
  79278. */
  79279. length: number;
  79280. /**
  79281. * @hidden Internal only
  79282. * Set this value to map this bone to a different index in the transform matrices
  79283. * Set this value to -1 to exclude the bone from the transform matrices
  79284. */
  79285. _index: Nullable<number>;
  79286. private _skeleton;
  79287. private _localMatrix;
  79288. private _restPose;
  79289. private _baseMatrix;
  79290. private _absoluteTransform;
  79291. private _invertedAbsoluteTransform;
  79292. private _parent;
  79293. private _scalingDeterminant;
  79294. private _worldTransform;
  79295. private _localScaling;
  79296. private _localRotation;
  79297. private _localPosition;
  79298. private _needToDecompose;
  79299. private _needToCompose;
  79300. /** @hidden */
  79301. _linkedTransformNode: Nullable<TransformNode>;
  79302. /** @hidden */
  79303. _waitingTransformNodeId: Nullable<string>;
  79304. /** @hidden */
  79305. /** @hidden */
  79306. _matrix: Matrix;
  79307. /**
  79308. * Create a new bone
  79309. * @param name defines the bone name
  79310. * @param skeleton defines the parent skeleton
  79311. * @param parentBone defines the parent (can be null if the bone is the root)
  79312. * @param localMatrix defines the local matrix
  79313. * @param restPose defines the rest pose matrix
  79314. * @param baseMatrix defines the base matrix
  79315. * @param index defines index of the bone in the hiearchy
  79316. */
  79317. constructor(
  79318. /**
  79319. * defines the bone name
  79320. */
  79321. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79322. /**
  79323. * Gets the current object class name.
  79324. * @return the class name
  79325. */
  79326. getClassName(): string;
  79327. /**
  79328. * Gets the parent skeleton
  79329. * @returns a skeleton
  79330. */
  79331. getSkeleton(): Skeleton;
  79332. /**
  79333. * Gets parent bone
  79334. * @returns a bone or null if the bone is the root of the bone hierarchy
  79335. */
  79336. getParent(): Nullable<Bone>;
  79337. /**
  79338. * Returns an array containing the root bones
  79339. * @returns an array containing the root bones
  79340. */
  79341. getChildren(): Array<Bone>;
  79342. /**
  79343. * Sets the parent bone
  79344. * @param parent defines the parent (can be null if the bone is the root)
  79345. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79346. */
  79347. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79348. /**
  79349. * Gets the local matrix
  79350. * @returns a matrix
  79351. */
  79352. getLocalMatrix(): Matrix;
  79353. /**
  79354. * Gets the base matrix (initial matrix which remains unchanged)
  79355. * @returns a matrix
  79356. */
  79357. getBaseMatrix(): Matrix;
  79358. /**
  79359. * Gets the rest pose matrix
  79360. * @returns a matrix
  79361. */
  79362. getRestPose(): Matrix;
  79363. /**
  79364. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79365. */
  79366. getWorldMatrix(): Matrix;
  79367. /**
  79368. * Sets the local matrix to rest pose matrix
  79369. */
  79370. returnToRest(): void;
  79371. /**
  79372. * Gets the inverse of the absolute transform matrix.
  79373. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79374. * @returns a matrix
  79375. */
  79376. getInvertedAbsoluteTransform(): Matrix;
  79377. /**
  79378. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79379. * @returns a matrix
  79380. */
  79381. getAbsoluteTransform(): Matrix;
  79382. /**
  79383. * Links with the given transform node.
  79384. * The local matrix of this bone is copied from the transform node every frame.
  79385. * @param transformNode defines the transform node to link to
  79386. */
  79387. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79388. /**
  79389. * Gets the node used to drive the bone's transformation
  79390. * @returns a transform node or null
  79391. */
  79392. getTransformNode(): Nullable<TransformNode>;
  79393. /** Gets or sets current position (in local space) */
  79394. position: Vector3;
  79395. /** Gets or sets current rotation (in local space) */
  79396. rotation: Vector3;
  79397. /** Gets or sets current rotation quaternion (in local space) */
  79398. rotationQuaternion: Quaternion;
  79399. /** Gets or sets current scaling (in local space) */
  79400. scaling: Vector3;
  79401. /**
  79402. * Gets the animation properties override
  79403. */
  79404. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79405. private _decompose;
  79406. private _compose;
  79407. /**
  79408. * Update the base and local matrices
  79409. * @param matrix defines the new base or local matrix
  79410. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79411. * @param updateLocalMatrix defines if the local matrix should be updated
  79412. */
  79413. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  79414. /** @hidden */
  79415. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  79416. /**
  79417. * Flag the bone as dirty (Forcing it to update everything)
  79418. */
  79419. markAsDirty(): void;
  79420. /** @hidden */
  79421. _markAsDirtyAndCompose(): void;
  79422. private _markAsDirtyAndDecompose;
  79423. /**
  79424. * Translate the bone in local or world space
  79425. * @param vec The amount to translate the bone
  79426. * @param space The space that the translation is in
  79427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79428. */
  79429. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79430. /**
  79431. * Set the postion of the bone in local or world space
  79432. * @param position The position to set the bone
  79433. * @param space The space that the position is in
  79434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79435. */
  79436. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79437. /**
  79438. * Set the absolute position of the bone (world space)
  79439. * @param position The position to set the bone
  79440. * @param mesh The mesh that this bone is attached to
  79441. */
  79442. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  79443. /**
  79444. * Scale the bone on the x, y and z axes (in local space)
  79445. * @param x The amount to scale the bone on the x axis
  79446. * @param y The amount to scale the bone on the y axis
  79447. * @param z The amount to scale the bone on the z axis
  79448. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  79449. */
  79450. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  79451. /**
  79452. * Set the bone scaling in local space
  79453. * @param scale defines the scaling vector
  79454. */
  79455. setScale(scale: Vector3): void;
  79456. /**
  79457. * Gets the current scaling in local space
  79458. * @returns the current scaling vector
  79459. */
  79460. getScale(): Vector3;
  79461. /**
  79462. * Gets the current scaling in local space and stores it in a target vector
  79463. * @param result defines the target vector
  79464. */
  79465. getScaleToRef(result: Vector3): void;
  79466. /**
  79467. * Set the yaw, pitch, and roll of the bone in local or world space
  79468. * @param yaw The rotation of the bone on the y axis
  79469. * @param pitch The rotation of the bone on the x axis
  79470. * @param roll The rotation of the bone on the z axis
  79471. * @param space The space that the axes of rotation are in
  79472. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79473. */
  79474. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  79475. /**
  79476. * Add a rotation to the bone on an axis in local or world space
  79477. * @param axis The axis to rotate the bone on
  79478. * @param amount The amount to rotate the bone
  79479. * @param space The space that the axis is in
  79480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79481. */
  79482. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  79483. /**
  79484. * Set the rotation of the bone to a particular axis angle in local or world space
  79485. * @param axis The axis to rotate the bone on
  79486. * @param angle The angle that the bone should be rotated to
  79487. * @param space The space that the axis is in
  79488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79489. */
  79490. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  79491. /**
  79492. * Set the euler rotation of the bone in local of world space
  79493. * @param rotation The euler rotation that the bone should be set to
  79494. * @param space The space that the rotation is in
  79495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79496. */
  79497. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79498. /**
  79499. * Set the quaternion rotation of the bone in local of world space
  79500. * @param quat The quaternion rotation that the bone should be set to
  79501. * @param space The space that the rotation is in
  79502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79503. */
  79504. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  79505. /**
  79506. * Set the rotation matrix of the bone in local of world space
  79507. * @param rotMat The rotation matrix that the bone should be set to
  79508. * @param space The space that the rotation is in
  79509. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79510. */
  79511. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  79512. private _rotateWithMatrix;
  79513. private _getNegativeRotationToRef;
  79514. /**
  79515. * Get the position of the bone in local or world space
  79516. * @param space The space that the returned position is in
  79517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79518. * @returns The position of the bone
  79519. */
  79520. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79521. /**
  79522. * Copy the position of the bone to a vector3 in local or world space
  79523. * @param space The space that the returned position is in
  79524. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79525. * @param result The vector3 to copy the position to
  79526. */
  79527. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  79528. /**
  79529. * Get the absolute position of the bone (world space)
  79530. * @param mesh The mesh that this bone is attached to
  79531. * @returns The absolute position of the bone
  79532. */
  79533. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  79534. /**
  79535. * Copy the absolute position of the bone (world space) to the result param
  79536. * @param mesh The mesh that this bone is attached to
  79537. * @param result The vector3 to copy the absolute position to
  79538. */
  79539. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  79540. /**
  79541. * Compute the absolute transforms of this bone and its children
  79542. */
  79543. computeAbsoluteTransforms(): void;
  79544. /**
  79545. * Get the world direction from an axis that is in the local space of the bone
  79546. * @param localAxis The local direction that is used to compute the world direction
  79547. * @param mesh The mesh that this bone is attached to
  79548. * @returns The world direction
  79549. */
  79550. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79551. /**
  79552. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  79553. * @param localAxis The local direction that is used to compute the world direction
  79554. * @param mesh The mesh that this bone is attached to
  79555. * @param result The vector3 that the world direction will be copied to
  79556. */
  79557. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79558. /**
  79559. * Get the euler rotation of the bone in local or world space
  79560. * @param space The space that the rotation should be in
  79561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79562. * @returns The euler rotation
  79563. */
  79564. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79565. /**
  79566. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  79567. * @param space The space that the rotation should be in
  79568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79569. * @param result The vector3 that the rotation should be copied to
  79570. */
  79571. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79572. /**
  79573. * Get the quaternion rotation of the bone in either local or world space
  79574. * @param space The space that the rotation should be in
  79575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79576. * @returns The quaternion rotation
  79577. */
  79578. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  79579. /**
  79580. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  79581. * @param space The space that the rotation should be in
  79582. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79583. * @param result The quaternion that the rotation should be copied to
  79584. */
  79585. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  79586. /**
  79587. * Get the rotation matrix of the bone in local or world space
  79588. * @param space The space that the rotation should be in
  79589. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79590. * @returns The rotation matrix
  79591. */
  79592. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  79593. /**
  79594. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  79595. * @param space The space that the rotation should be in
  79596. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79597. * @param result The quaternion that the rotation should be copied to
  79598. */
  79599. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  79600. /**
  79601. * Get the world position of a point that is in the local space of the bone
  79602. * @param position The local position
  79603. * @param mesh The mesh that this bone is attached to
  79604. * @returns The world position
  79605. */
  79606. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79607. /**
  79608. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  79609. * @param position The local position
  79610. * @param mesh The mesh that this bone is attached to
  79611. * @param result The vector3 that the world position should be copied to
  79612. */
  79613. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79614. /**
  79615. * Get the local position of a point that is in world space
  79616. * @param position The world position
  79617. * @param mesh The mesh that this bone is attached to
  79618. * @returns The local position
  79619. */
  79620. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79621. /**
  79622. * Get the local position of a point that is in world space and copy it to the result param
  79623. * @param position The world position
  79624. * @param mesh The mesh that this bone is attached to
  79625. * @param result The vector3 that the local position should be copied to
  79626. */
  79627. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79628. }
  79629. }
  79630. declare module BABYLON {
  79631. /**
  79632. * 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.
  79633. * @see https://doc.babylonjs.com/how_to/transformnode
  79634. */
  79635. export class TransformNode extends Node {
  79636. /**
  79637. * Object will not rotate to face the camera
  79638. */
  79639. static BILLBOARDMODE_NONE: number;
  79640. /**
  79641. * Object will rotate to face the camera but only on the x axis
  79642. */
  79643. static BILLBOARDMODE_X: number;
  79644. /**
  79645. * Object will rotate to face the camera but only on the y axis
  79646. */
  79647. static BILLBOARDMODE_Y: number;
  79648. /**
  79649. * Object will rotate to face the camera but only on the z axis
  79650. */
  79651. static BILLBOARDMODE_Z: number;
  79652. /**
  79653. * Object will rotate to face the camera
  79654. */
  79655. static BILLBOARDMODE_ALL: number;
  79656. /**
  79657. * Object will rotate to face the camera's position instead of orientation
  79658. */
  79659. static BILLBOARDMODE_USE_POSITION: number;
  79660. private _forward;
  79661. private _forwardInverted;
  79662. private _up;
  79663. private _right;
  79664. private _rightInverted;
  79665. private _position;
  79666. private _rotation;
  79667. private _rotationQuaternion;
  79668. protected _scaling: Vector3;
  79669. protected _isDirty: boolean;
  79670. private _transformToBoneReferal;
  79671. private _isAbsoluteSynced;
  79672. private _billboardMode;
  79673. /**
  79674. * Gets or sets the billboard mode. Default is 0.
  79675. *
  79676. * | Value | Type | Description |
  79677. * | --- | --- | --- |
  79678. * | 0 | BILLBOARDMODE_NONE | |
  79679. * | 1 | BILLBOARDMODE_X | |
  79680. * | 2 | BILLBOARDMODE_Y | |
  79681. * | 4 | BILLBOARDMODE_Z | |
  79682. * | 7 | BILLBOARDMODE_ALL | |
  79683. *
  79684. */
  79685. billboardMode: number;
  79686. private _preserveParentRotationForBillboard;
  79687. /**
  79688. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  79689. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  79690. */
  79691. preserveParentRotationForBillboard: boolean;
  79692. /**
  79693. * 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
  79694. */
  79695. scalingDeterminant: number;
  79696. private _infiniteDistance;
  79697. /**
  79698. * Gets or sets the distance of the object to max, often used by skybox
  79699. */
  79700. infiniteDistance: boolean;
  79701. /**
  79702. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  79703. * By default the system will update normals to compensate
  79704. */
  79705. ignoreNonUniformScaling: boolean;
  79706. /**
  79707. * 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
  79708. */
  79709. reIntegrateRotationIntoRotationQuaternion: boolean;
  79710. /** @hidden */
  79711. _poseMatrix: Nullable<Matrix>;
  79712. /** @hidden */
  79713. _localMatrix: Matrix;
  79714. private _usePivotMatrix;
  79715. private _absolutePosition;
  79716. private _absoluteScaling;
  79717. private _absoluteRotationQuaternion;
  79718. private _pivotMatrix;
  79719. private _pivotMatrixInverse;
  79720. protected _postMultiplyPivotMatrix: boolean;
  79721. protected _isWorldMatrixFrozen: boolean;
  79722. /** @hidden */
  79723. _indexInSceneTransformNodesArray: number;
  79724. /**
  79725. * An event triggered after the world matrix is updated
  79726. */
  79727. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  79728. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  79729. /**
  79730. * Gets a string identifying the name of the class
  79731. * @returns "TransformNode" string
  79732. */
  79733. getClassName(): string;
  79734. /**
  79735. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  79736. */
  79737. position: Vector3;
  79738. /**
  79739. * 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)).
  79740. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  79741. */
  79742. rotation: Vector3;
  79743. /**
  79744. * 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)).
  79745. */
  79746. scaling: Vector3;
  79747. /**
  79748. * 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).
  79749. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  79750. */
  79751. rotationQuaternion: Nullable<Quaternion>;
  79752. /**
  79753. * The forward direction of that transform in world space.
  79754. */
  79755. readonly forward: Vector3;
  79756. /**
  79757. * The up direction of that transform in world space.
  79758. */
  79759. readonly up: Vector3;
  79760. /**
  79761. * The right direction of that transform in world space.
  79762. */
  79763. readonly right: Vector3;
  79764. /**
  79765. * Copies the parameter passed Matrix into the mesh Pose matrix.
  79766. * @param matrix the matrix to copy the pose from
  79767. * @returns this TransformNode.
  79768. */
  79769. updatePoseMatrix(matrix: Matrix): TransformNode;
  79770. /**
  79771. * Returns the mesh Pose matrix.
  79772. * @returns the pose matrix
  79773. */
  79774. getPoseMatrix(): Matrix;
  79775. /** @hidden */
  79776. _isSynchronized(): boolean;
  79777. /** @hidden */
  79778. _initCache(): void;
  79779. /**
  79780. * Flag the transform node as dirty (Forcing it to update everything)
  79781. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  79782. * @returns this transform node
  79783. */
  79784. markAsDirty(property: string): TransformNode;
  79785. /**
  79786. * Returns the current mesh absolute position.
  79787. * Returns a Vector3.
  79788. */
  79789. readonly absolutePosition: Vector3;
  79790. /**
  79791. * Returns the current mesh absolute scaling.
  79792. * Returns a Vector3.
  79793. */
  79794. readonly absoluteScaling: Vector3;
  79795. /**
  79796. * Returns the current mesh absolute rotation.
  79797. * Returns a Quaternion.
  79798. */
  79799. readonly absoluteRotationQuaternion: Quaternion;
  79800. /**
  79801. * Sets a new matrix to apply before all other transformation
  79802. * @param matrix defines the transform matrix
  79803. * @returns the current TransformNode
  79804. */
  79805. setPreTransformMatrix(matrix: Matrix): TransformNode;
  79806. /**
  79807. * Sets a new pivot matrix to the current node
  79808. * @param matrix defines the new pivot matrix to use
  79809. * @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
  79810. * @returns the current TransformNode
  79811. */
  79812. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  79813. /**
  79814. * Returns the mesh pivot matrix.
  79815. * Default : Identity.
  79816. * @returns the matrix
  79817. */
  79818. getPivotMatrix(): Matrix;
  79819. /**
  79820. * Instantiate (when possible) or clone that node with its hierarchy
  79821. * @param newParent defines the new parent to use for the instance (or clone)
  79822. * @returns an instance (or a clone) of the current node with its hiearchy
  79823. */
  79824. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  79825. /**
  79826. * Prevents the World matrix to be computed any longer
  79827. * @param newWorldMatrix defines an optional matrix to use as world matrix
  79828. * @returns the TransformNode.
  79829. */
  79830. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  79831. /**
  79832. * Allows back the World matrix computation.
  79833. * @returns the TransformNode.
  79834. */
  79835. unfreezeWorldMatrix(): this;
  79836. /**
  79837. * True if the World matrix has been frozen.
  79838. */
  79839. readonly isWorldMatrixFrozen: boolean;
  79840. /**
  79841. * Retuns the mesh absolute position in the World.
  79842. * @returns a Vector3.
  79843. */
  79844. getAbsolutePosition(): Vector3;
  79845. /**
  79846. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  79847. * @param absolutePosition the absolute position to set
  79848. * @returns the TransformNode.
  79849. */
  79850. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79851. /**
  79852. * Sets the mesh position in its local space.
  79853. * @param vector3 the position to set in localspace
  79854. * @returns the TransformNode.
  79855. */
  79856. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  79857. /**
  79858. * Returns the mesh position in the local space from the current World matrix values.
  79859. * @returns a new Vector3.
  79860. */
  79861. getPositionExpressedInLocalSpace(): Vector3;
  79862. /**
  79863. * Translates the mesh along the passed Vector3 in its local space.
  79864. * @param vector3 the distance to translate in localspace
  79865. * @returns the TransformNode.
  79866. */
  79867. locallyTranslate(vector3: Vector3): TransformNode;
  79868. private static _lookAtVectorCache;
  79869. /**
  79870. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  79871. * @param targetPoint the position (must be in same space as current mesh) to look at
  79872. * @param yawCor optional yaw (y-axis) correction in radians
  79873. * @param pitchCor optional pitch (x-axis) correction in radians
  79874. * @param rollCor optional roll (z-axis) correction in radians
  79875. * @param space the choosen space of the target
  79876. * @returns the TransformNode.
  79877. */
  79878. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  79879. /**
  79880. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79881. * This Vector3 is expressed in the World space.
  79882. * @param localAxis axis to rotate
  79883. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79884. */
  79885. getDirection(localAxis: Vector3): Vector3;
  79886. /**
  79887. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  79888. * localAxis is expressed in the mesh local space.
  79889. * result is computed in the Wordl space from the mesh World matrix.
  79890. * @param localAxis axis to rotate
  79891. * @param result the resulting transformnode
  79892. * @returns this TransformNode.
  79893. */
  79894. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  79895. /**
  79896. * Sets this transform node rotation to the given local axis.
  79897. * @param localAxis the axis in local space
  79898. * @param yawCor optional yaw (y-axis) correction in radians
  79899. * @param pitchCor optional pitch (x-axis) correction in radians
  79900. * @param rollCor optional roll (z-axis) correction in radians
  79901. * @returns this TransformNode
  79902. */
  79903. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  79904. /**
  79905. * Sets a new pivot point to the current node
  79906. * @param point defines the new pivot point to use
  79907. * @param space defines if the point is in world or local space (local by default)
  79908. * @returns the current TransformNode
  79909. */
  79910. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  79911. /**
  79912. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  79913. * @returns the pivot point
  79914. */
  79915. getPivotPoint(): Vector3;
  79916. /**
  79917. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  79918. * @param result the vector3 to store the result
  79919. * @returns this TransformNode.
  79920. */
  79921. getPivotPointToRef(result: Vector3): TransformNode;
  79922. /**
  79923. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  79924. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  79925. */
  79926. getAbsolutePivotPoint(): Vector3;
  79927. /**
  79928. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  79929. * @param result vector3 to store the result
  79930. * @returns this TransformNode.
  79931. */
  79932. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  79933. /**
  79934. * Defines the passed node as the parent of the current node.
  79935. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  79936. * @see https://doc.babylonjs.com/how_to/parenting
  79937. * @param node the node ot set as the parent
  79938. * @returns this TransformNode.
  79939. */
  79940. setParent(node: Nullable<Node>): TransformNode;
  79941. private _nonUniformScaling;
  79942. /**
  79943. * True if the scaling property of this object is non uniform eg. (1,2,1)
  79944. */
  79945. readonly nonUniformScaling: boolean;
  79946. /** @hidden */
  79947. _updateNonUniformScalingState(value: boolean): boolean;
  79948. /**
  79949. * Attach the current TransformNode to another TransformNode associated with a bone
  79950. * @param bone Bone affecting the TransformNode
  79951. * @param affectedTransformNode TransformNode associated with the bone
  79952. * @returns this object
  79953. */
  79954. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  79955. /**
  79956. * Detach the transform node if its associated with a bone
  79957. * @returns this object
  79958. */
  79959. detachFromBone(): TransformNode;
  79960. private static _rotationAxisCache;
  79961. /**
  79962. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  79963. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79964. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79965. * The passed axis is also normalized.
  79966. * @param axis the axis to rotate around
  79967. * @param amount the amount to rotate in radians
  79968. * @param space Space to rotate in (Default: local)
  79969. * @returns the TransformNode.
  79970. */
  79971. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79972. /**
  79973. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  79974. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79975. * The passed axis is also normalized. .
  79976. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  79977. * @param point the point to rotate around
  79978. * @param axis the axis to rotate around
  79979. * @param amount the amount to rotate in radians
  79980. * @returns the TransformNode
  79981. */
  79982. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  79983. /**
  79984. * Translates the mesh along the axis vector for the passed distance in the given space.
  79985. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79986. * @param axis the axis to translate in
  79987. * @param distance the distance to translate
  79988. * @param space Space to rotate in (Default: local)
  79989. * @returns the TransformNode.
  79990. */
  79991. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79992. /**
  79993. * Adds a rotation step to the mesh current rotation.
  79994. * x, y, z are Euler angles expressed in radians.
  79995. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  79996. * This means this rotation is made in the mesh local space only.
  79997. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  79998. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  79999. * ```javascript
  80000. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80001. * ```
  80002. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80003. * 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.
  80004. * @param x Rotation to add
  80005. * @param y Rotation to add
  80006. * @param z Rotation to add
  80007. * @returns the TransformNode.
  80008. */
  80009. addRotation(x: number, y: number, z: number): TransformNode;
  80010. /**
  80011. * @hidden
  80012. */
  80013. protected _getEffectiveParent(): Nullable<Node>;
  80014. /**
  80015. * Computes the world matrix of the node
  80016. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80017. * @returns the world matrix
  80018. */
  80019. computeWorldMatrix(force?: boolean): Matrix;
  80020. protected _afterComputeWorldMatrix(): void;
  80021. /**
  80022. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80023. * @param func callback function to add
  80024. *
  80025. * @returns the TransformNode.
  80026. */
  80027. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80028. /**
  80029. * Removes a registered callback function.
  80030. * @param func callback function to remove
  80031. * @returns the TransformNode.
  80032. */
  80033. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80034. /**
  80035. * Gets the position of the current mesh in camera space
  80036. * @param camera defines the camera to use
  80037. * @returns a position
  80038. */
  80039. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80040. /**
  80041. * Returns the distance from the mesh to the active camera
  80042. * @param camera defines the camera to use
  80043. * @returns the distance
  80044. */
  80045. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80046. /**
  80047. * Clone the current transform node
  80048. * @param name Name of the new clone
  80049. * @param newParent New parent for the clone
  80050. * @param doNotCloneChildren Do not clone children hierarchy
  80051. * @returns the new transform node
  80052. */
  80053. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80054. /**
  80055. * Serializes the objects information.
  80056. * @param currentSerializationObject defines the object to serialize in
  80057. * @returns the serialized object
  80058. */
  80059. serialize(currentSerializationObject?: any): any;
  80060. /**
  80061. * Returns a new TransformNode object parsed from the source provided.
  80062. * @param parsedTransformNode is the source.
  80063. * @param scene the scne the object belongs to
  80064. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80065. * @returns a new TransformNode object parsed from the source provided.
  80066. */
  80067. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80068. /**
  80069. * Get all child-transformNodes of this node
  80070. * @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
  80071. * @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
  80072. * @returns an array of TransformNode
  80073. */
  80074. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  80075. /**
  80076. * Releases resources associated with this transform node.
  80077. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80078. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80079. */
  80080. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80081. /**
  80082. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80083. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  80084. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  80085. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  80086. * @returns the current mesh
  80087. */
  80088. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  80089. private _syncAbsoluteScalingAndRotation;
  80090. }
  80091. }
  80092. declare module BABYLON {
  80093. /**
  80094. * Defines the types of pose enabled controllers that are supported
  80095. */
  80096. export enum PoseEnabledControllerType {
  80097. /**
  80098. * HTC Vive
  80099. */
  80100. VIVE = 0,
  80101. /**
  80102. * Oculus Rift
  80103. */
  80104. OCULUS = 1,
  80105. /**
  80106. * Windows mixed reality
  80107. */
  80108. WINDOWS = 2,
  80109. /**
  80110. * Samsung gear VR
  80111. */
  80112. GEAR_VR = 3,
  80113. /**
  80114. * Google Daydream
  80115. */
  80116. DAYDREAM = 4,
  80117. /**
  80118. * Generic
  80119. */
  80120. GENERIC = 5
  80121. }
  80122. /**
  80123. * Defines the MutableGamepadButton interface for the state of a gamepad button
  80124. */
  80125. export interface MutableGamepadButton {
  80126. /**
  80127. * Value of the button/trigger
  80128. */
  80129. value: number;
  80130. /**
  80131. * If the button/trigger is currently touched
  80132. */
  80133. touched: boolean;
  80134. /**
  80135. * If the button/trigger is currently pressed
  80136. */
  80137. pressed: boolean;
  80138. }
  80139. /**
  80140. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80141. * @hidden
  80142. */
  80143. export interface ExtendedGamepadButton extends GamepadButton {
  80144. /**
  80145. * If the button/trigger is currently pressed
  80146. */
  80147. readonly pressed: boolean;
  80148. /**
  80149. * If the button/trigger is currently touched
  80150. */
  80151. readonly touched: boolean;
  80152. /**
  80153. * Value of the button/trigger
  80154. */
  80155. readonly value: number;
  80156. }
  80157. /** @hidden */
  80158. export interface _GamePadFactory {
  80159. /**
  80160. * Returns wether or not the current gamepad can be created for this type of controller.
  80161. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80162. * @returns true if it can be created, otherwise false
  80163. */
  80164. canCreate(gamepadInfo: any): boolean;
  80165. /**
  80166. * Creates a new instance of the Gamepad.
  80167. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80168. * @returns the new gamepad instance
  80169. */
  80170. create(gamepadInfo: any): Gamepad;
  80171. }
  80172. /**
  80173. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80174. */
  80175. export class PoseEnabledControllerHelper {
  80176. /** @hidden */
  80177. static _ControllerFactories: _GamePadFactory[];
  80178. /** @hidden */
  80179. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80180. /**
  80181. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80182. * @param vrGamepad the gamepad to initialized
  80183. * @returns a vr controller of the type the gamepad identified as
  80184. */
  80185. static InitiateController(vrGamepad: any): Gamepad;
  80186. }
  80187. /**
  80188. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80189. */
  80190. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80191. /**
  80192. * If the controller is used in a webXR session
  80193. */
  80194. isXR: boolean;
  80195. private _deviceRoomPosition;
  80196. private _deviceRoomRotationQuaternion;
  80197. /**
  80198. * The device position in babylon space
  80199. */
  80200. devicePosition: Vector3;
  80201. /**
  80202. * The device rotation in babylon space
  80203. */
  80204. deviceRotationQuaternion: Quaternion;
  80205. /**
  80206. * The scale factor of the device in babylon space
  80207. */
  80208. deviceScaleFactor: number;
  80209. /**
  80210. * (Likely devicePosition should be used instead) The device position in its room space
  80211. */
  80212. position: Vector3;
  80213. /**
  80214. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80215. */
  80216. rotationQuaternion: Quaternion;
  80217. /**
  80218. * The type of controller (Eg. Windows mixed reality)
  80219. */
  80220. controllerType: PoseEnabledControllerType;
  80221. protected _calculatedPosition: Vector3;
  80222. private _calculatedRotation;
  80223. /**
  80224. * The raw pose from the device
  80225. */
  80226. rawPose: DevicePose;
  80227. private _trackPosition;
  80228. private _maxRotationDistFromHeadset;
  80229. private _draggedRoomRotation;
  80230. /**
  80231. * @hidden
  80232. */
  80233. _disableTrackPosition(fixedPosition: Vector3): void;
  80234. /**
  80235. * Internal, the mesh attached to the controller
  80236. * @hidden
  80237. */
  80238. _mesh: Nullable<AbstractMesh>;
  80239. private _poseControlledCamera;
  80240. private _leftHandSystemQuaternion;
  80241. /**
  80242. * Internal, matrix used to convert room space to babylon space
  80243. * @hidden
  80244. */
  80245. _deviceToWorld: Matrix;
  80246. /**
  80247. * Node to be used when casting a ray from the controller
  80248. * @hidden
  80249. */
  80250. _pointingPoseNode: Nullable<TransformNode>;
  80251. /**
  80252. * Name of the child mesh that can be used to cast a ray from the controller
  80253. */
  80254. static readonly POINTING_POSE: string;
  80255. /**
  80256. * Creates a new PoseEnabledController from a gamepad
  80257. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80258. */
  80259. constructor(browserGamepad: any);
  80260. private _workingMatrix;
  80261. /**
  80262. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80263. */
  80264. update(): void;
  80265. /**
  80266. * Updates only the pose device and mesh without doing any button event checking
  80267. */
  80268. protected _updatePoseAndMesh(): void;
  80269. /**
  80270. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80271. * @param poseData raw pose fromthe device
  80272. */
  80273. updateFromDevice(poseData: DevicePose): void;
  80274. /**
  80275. * @hidden
  80276. */
  80277. _meshAttachedObservable: Observable<AbstractMesh>;
  80278. /**
  80279. * Attaches a mesh to the controller
  80280. * @param mesh the mesh to be attached
  80281. */
  80282. attachToMesh(mesh: AbstractMesh): void;
  80283. /**
  80284. * Attaches the controllers mesh to a camera
  80285. * @param camera the camera the mesh should be attached to
  80286. */
  80287. attachToPoseControlledCamera(camera: TargetCamera): void;
  80288. /**
  80289. * Disposes of the controller
  80290. */
  80291. dispose(): void;
  80292. /**
  80293. * The mesh that is attached to the controller
  80294. */
  80295. readonly mesh: Nullable<AbstractMesh>;
  80296. /**
  80297. * Gets the ray of the controller in the direction the controller is pointing
  80298. * @param length the length the resulting ray should be
  80299. * @returns a ray in the direction the controller is pointing
  80300. */
  80301. getForwardRay(length?: number): Ray;
  80302. }
  80303. }
  80304. declare module BABYLON {
  80305. /**
  80306. * Defines the WebVRController object that represents controllers tracked in 3D space
  80307. */
  80308. export abstract class WebVRController extends PoseEnabledController {
  80309. /**
  80310. * Internal, the default controller model for the controller
  80311. */
  80312. protected _defaultModel: Nullable<AbstractMesh>;
  80313. /**
  80314. * Fired when the trigger state has changed
  80315. */
  80316. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80317. /**
  80318. * Fired when the main button state has changed
  80319. */
  80320. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80321. /**
  80322. * Fired when the secondary button state has changed
  80323. */
  80324. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80325. /**
  80326. * Fired when the pad state has changed
  80327. */
  80328. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80329. /**
  80330. * Fired when controllers stick values have changed
  80331. */
  80332. onPadValuesChangedObservable: Observable<StickValues>;
  80333. /**
  80334. * Array of button availible on the controller
  80335. */
  80336. protected _buttons: Array<MutableGamepadButton>;
  80337. private _onButtonStateChange;
  80338. /**
  80339. * Fired when a controller button's state has changed
  80340. * @param callback the callback containing the button that was modified
  80341. */
  80342. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80343. /**
  80344. * X and Y axis corresponding to the controllers joystick
  80345. */
  80346. pad: StickValues;
  80347. /**
  80348. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80349. */
  80350. hand: string;
  80351. /**
  80352. * The default controller model for the controller
  80353. */
  80354. readonly defaultModel: Nullable<AbstractMesh>;
  80355. /**
  80356. * Creates a new WebVRController from a gamepad
  80357. * @param vrGamepad the gamepad that the WebVRController should be created from
  80358. */
  80359. constructor(vrGamepad: any);
  80360. /**
  80361. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80362. */
  80363. update(): void;
  80364. /**
  80365. * Function to be called when a button is modified
  80366. */
  80367. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80368. /**
  80369. * Loads a mesh and attaches it to the controller
  80370. * @param scene the scene the mesh should be added to
  80371. * @param meshLoaded callback for when the mesh has been loaded
  80372. */
  80373. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80374. private _setButtonValue;
  80375. private _changes;
  80376. private _checkChanges;
  80377. /**
  80378. * Disposes of th webVRCOntroller
  80379. */
  80380. dispose(): void;
  80381. }
  80382. }
  80383. declare module BABYLON {
  80384. /**
  80385. * The HemisphericLight simulates the ambient environment light,
  80386. * so the passed direction is the light reflection direction, not the incoming direction.
  80387. */
  80388. export class HemisphericLight extends Light {
  80389. /**
  80390. * The groundColor is the light in the opposite direction to the one specified during creation.
  80391. * 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.
  80392. */
  80393. groundColor: Color3;
  80394. /**
  80395. * The light reflection direction, not the incoming direction.
  80396. */
  80397. direction: Vector3;
  80398. /**
  80399. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80400. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80401. * The HemisphericLight can't cast shadows.
  80402. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80403. * @param name The friendly name of the light
  80404. * @param direction The direction of the light reflection
  80405. * @param scene The scene the light belongs to
  80406. */
  80407. constructor(name: string, direction: Vector3, scene: Scene);
  80408. protected _buildUniformLayout(): void;
  80409. /**
  80410. * Returns the string "HemisphericLight".
  80411. * @return The class name
  80412. */
  80413. getClassName(): string;
  80414. /**
  80415. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80416. * Returns the updated direction.
  80417. * @param target The target the direction should point to
  80418. * @return The computed direction
  80419. */
  80420. setDirectionToTarget(target: Vector3): Vector3;
  80421. /**
  80422. * Returns the shadow generator associated to the light.
  80423. * @returns Always null for hemispheric lights because it does not support shadows.
  80424. */
  80425. getShadowGenerator(): Nullable<IShadowGenerator>;
  80426. /**
  80427. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80428. * @param effect The effect to update
  80429. * @param lightIndex The index of the light in the effect to update
  80430. * @returns The hemispheric light
  80431. */
  80432. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80433. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  80434. /**
  80435. * Computes the world matrix of the node
  80436. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80437. * @param useWasUpdatedFlag defines a reserved property
  80438. * @returns the world matrix
  80439. */
  80440. computeWorldMatrix(): Matrix;
  80441. /**
  80442. * Returns the integer 3.
  80443. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80444. */
  80445. getTypeID(): number;
  80446. /**
  80447. * Prepares the list of defines specific to the light type.
  80448. * @param defines the list of defines
  80449. * @param lightIndex defines the index of the light for the effect
  80450. */
  80451. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80452. }
  80453. }
  80454. declare module BABYLON {
  80455. /** @hidden */
  80456. export var vrMultiviewToSingleviewPixelShader: {
  80457. name: string;
  80458. shader: string;
  80459. };
  80460. }
  80461. declare module BABYLON {
  80462. /**
  80463. * Renders to multiple views with a single draw call
  80464. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80465. */
  80466. export class MultiviewRenderTarget extends RenderTargetTexture {
  80467. /**
  80468. * Creates a multiview render target
  80469. * @param scene scene used with the render target
  80470. * @param size the size of the render target (used for each view)
  80471. */
  80472. constructor(scene: Scene, size?: number | {
  80473. width: number;
  80474. height: number;
  80475. } | {
  80476. ratio: number;
  80477. });
  80478. /**
  80479. * @hidden
  80480. * @param faceIndex the face index, if its a cube texture
  80481. */
  80482. _bindFrameBuffer(faceIndex?: number): void;
  80483. /**
  80484. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80485. * @returns the view count
  80486. */
  80487. getViewCount(): number;
  80488. }
  80489. }
  80490. declare module BABYLON {
  80491. /**
  80492. * Represents a camera frustum
  80493. */
  80494. export class Frustum {
  80495. /**
  80496. * Gets the planes representing the frustum
  80497. * @param transform matrix to be applied to the returned planes
  80498. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  80499. */
  80500. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  80501. /**
  80502. * Gets the near frustum plane transformed by the transform matrix
  80503. * @param transform transformation matrix to be applied to the resulting frustum plane
  80504. * @param frustumPlane the resuling frustum plane
  80505. */
  80506. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80507. /**
  80508. * Gets the far frustum plane transformed by the transform matrix
  80509. * @param transform transformation matrix to be applied to the resulting frustum plane
  80510. * @param frustumPlane the resuling frustum plane
  80511. */
  80512. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80513. /**
  80514. * Gets the left frustum plane transformed by the transform matrix
  80515. * @param transform transformation matrix to be applied to the resulting frustum plane
  80516. * @param frustumPlane the resuling frustum plane
  80517. */
  80518. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80519. /**
  80520. * Gets the right frustum plane transformed by the transform matrix
  80521. * @param transform transformation matrix to be applied to the resulting frustum plane
  80522. * @param frustumPlane the resuling frustum plane
  80523. */
  80524. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80525. /**
  80526. * Gets the top frustum plane transformed by the transform matrix
  80527. * @param transform transformation matrix to be applied to the resulting frustum plane
  80528. * @param frustumPlane the resuling frustum plane
  80529. */
  80530. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80531. /**
  80532. * Gets the bottom frustum plane transformed by the transform matrix
  80533. * @param transform transformation matrix to be applied to the resulting frustum plane
  80534. * @param frustumPlane the resuling frustum plane
  80535. */
  80536. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80537. /**
  80538. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  80539. * @param transform transformation matrix to be applied to the resulting frustum planes
  80540. * @param frustumPlanes the resuling frustum planes
  80541. */
  80542. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  80543. }
  80544. }
  80545. declare module BABYLON {
  80546. interface Engine {
  80547. /**
  80548. * Creates a new multiview render target
  80549. * @param width defines the width of the texture
  80550. * @param height defines the height of the texture
  80551. * @returns the created multiview texture
  80552. */
  80553. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80554. /**
  80555. * Binds a multiview framebuffer to be drawn to
  80556. * @param multiviewTexture texture to bind
  80557. */
  80558. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80559. }
  80560. interface Camera {
  80561. /**
  80562. * @hidden
  80563. * 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)
  80564. */
  80565. _useMultiviewToSingleView: boolean;
  80566. /**
  80567. * @hidden
  80568. * 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)
  80569. */
  80570. _multiviewTexture: Nullable<RenderTargetTexture>;
  80571. /**
  80572. * @hidden
  80573. * ensures the multiview texture of the camera exists and has the specified width/height
  80574. * @param width height to set on the multiview texture
  80575. * @param height width to set on the multiview texture
  80576. */
  80577. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80578. }
  80579. interface Scene {
  80580. /** @hidden */
  80581. _transformMatrixR: Matrix;
  80582. /** @hidden */
  80583. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80584. /** @hidden */
  80585. _createMultiviewUbo(): void;
  80586. /** @hidden */
  80587. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80588. /** @hidden */
  80589. _renderMultiviewToSingleView(camera: Camera): void;
  80590. }
  80591. }
  80592. declare module BABYLON {
  80593. /**
  80594. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80595. * This will not be used for webXR as it supports displaying texture arrays directly
  80596. */
  80597. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80598. /**
  80599. * Initializes a VRMultiviewToSingleview
  80600. * @param name name of the post process
  80601. * @param camera camera to be applied to
  80602. * @param scaleFactor scaling factor to the size of the output texture
  80603. */
  80604. constructor(name: string, camera: Camera, scaleFactor: number);
  80605. }
  80606. }
  80607. declare module BABYLON {
  80608. interface Engine {
  80609. /** @hidden */
  80610. _vrDisplay: any;
  80611. /** @hidden */
  80612. _vrSupported: boolean;
  80613. /** @hidden */
  80614. _oldSize: Size;
  80615. /** @hidden */
  80616. _oldHardwareScaleFactor: number;
  80617. /** @hidden */
  80618. _vrExclusivePointerMode: boolean;
  80619. /** @hidden */
  80620. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80621. /** @hidden */
  80622. _onVRDisplayPointerRestricted: () => void;
  80623. /** @hidden */
  80624. _onVRDisplayPointerUnrestricted: () => void;
  80625. /** @hidden */
  80626. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80627. /** @hidden */
  80628. _onVrDisplayDisconnect: Nullable<() => void>;
  80629. /** @hidden */
  80630. _onVrDisplayPresentChange: Nullable<() => void>;
  80631. /**
  80632. * Observable signaled when VR display mode changes
  80633. */
  80634. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80635. /**
  80636. * Observable signaled when VR request present is complete
  80637. */
  80638. onVRRequestPresentComplete: Observable<boolean>;
  80639. /**
  80640. * Observable signaled when VR request present starts
  80641. */
  80642. onVRRequestPresentStart: Observable<Engine>;
  80643. /**
  80644. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80645. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80646. */
  80647. isInVRExclusivePointerMode: boolean;
  80648. /**
  80649. * Gets a boolean indicating if a webVR device was detected
  80650. * @returns true if a webVR device was detected
  80651. */
  80652. isVRDevicePresent(): boolean;
  80653. /**
  80654. * Gets the current webVR device
  80655. * @returns the current webVR device (or null)
  80656. */
  80657. getVRDevice(): any;
  80658. /**
  80659. * Initializes a webVR display and starts listening to display change events
  80660. * The onVRDisplayChangedObservable will be notified upon these changes
  80661. * @returns A promise containing a VRDisplay and if vr is supported
  80662. */
  80663. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80664. /** @hidden */
  80665. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80666. /**
  80667. * Call this function to switch to webVR mode
  80668. * Will do nothing if webVR is not supported or if there is no webVR device
  80669. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80670. */
  80671. enableVR(): void;
  80672. /** @hidden */
  80673. _onVRFullScreenTriggered(): void;
  80674. }
  80675. }
  80676. declare module BABYLON {
  80677. /**
  80678. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80679. * IMPORTANT!! The data is right-hand data.
  80680. * @export
  80681. * @interface DevicePose
  80682. */
  80683. export interface DevicePose {
  80684. /**
  80685. * The position of the device, values in array are [x,y,z].
  80686. */
  80687. readonly position: Nullable<Float32Array>;
  80688. /**
  80689. * The linearVelocity of the device, values in array are [x,y,z].
  80690. */
  80691. readonly linearVelocity: Nullable<Float32Array>;
  80692. /**
  80693. * The linearAcceleration of the device, values in array are [x,y,z].
  80694. */
  80695. readonly linearAcceleration: Nullable<Float32Array>;
  80696. /**
  80697. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80698. */
  80699. readonly orientation: Nullable<Float32Array>;
  80700. /**
  80701. * The angularVelocity of the device, values in array are [x,y,z].
  80702. */
  80703. readonly angularVelocity: Nullable<Float32Array>;
  80704. /**
  80705. * The angularAcceleration of the device, values in array are [x,y,z].
  80706. */
  80707. readonly angularAcceleration: Nullable<Float32Array>;
  80708. }
  80709. /**
  80710. * Interface representing a pose controlled object in Babylon.
  80711. * A pose controlled object has both regular pose values as well as pose values
  80712. * from an external device such as a VR head mounted display
  80713. */
  80714. export interface PoseControlled {
  80715. /**
  80716. * The position of the object in babylon space.
  80717. */
  80718. position: Vector3;
  80719. /**
  80720. * The rotation quaternion of the object in babylon space.
  80721. */
  80722. rotationQuaternion: Quaternion;
  80723. /**
  80724. * The position of the device in babylon space.
  80725. */
  80726. devicePosition?: Vector3;
  80727. /**
  80728. * The rotation quaternion of the device in babylon space.
  80729. */
  80730. deviceRotationQuaternion: Quaternion;
  80731. /**
  80732. * The raw pose coming from the device.
  80733. */
  80734. rawPose: Nullable<DevicePose>;
  80735. /**
  80736. * The scale of the device to be used when translating from device space to babylon space.
  80737. */
  80738. deviceScaleFactor: number;
  80739. /**
  80740. * Updates the poseControlled values based on the input device pose.
  80741. * @param poseData the pose data to update the object with
  80742. */
  80743. updateFromDevice(poseData: DevicePose): void;
  80744. }
  80745. /**
  80746. * Set of options to customize the webVRCamera
  80747. */
  80748. export interface WebVROptions {
  80749. /**
  80750. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80751. */
  80752. trackPosition?: boolean;
  80753. /**
  80754. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80755. */
  80756. positionScale?: number;
  80757. /**
  80758. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80759. */
  80760. displayName?: string;
  80761. /**
  80762. * Should the native controller meshes be initialized. (default: true)
  80763. */
  80764. controllerMeshes?: boolean;
  80765. /**
  80766. * Creating a default HemiLight only on controllers. (default: true)
  80767. */
  80768. defaultLightingOnControllers?: boolean;
  80769. /**
  80770. * If you don't want to use the default VR button of the helper. (default: false)
  80771. */
  80772. useCustomVRButton?: boolean;
  80773. /**
  80774. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80775. */
  80776. customVRButton?: HTMLButtonElement;
  80777. /**
  80778. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80779. */
  80780. rayLength?: number;
  80781. /**
  80782. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80783. */
  80784. defaultHeight?: number;
  80785. /**
  80786. * If multiview should be used if availible (default: false)
  80787. */
  80788. useMultiview?: boolean;
  80789. }
  80790. /**
  80791. * This represents a WebVR camera.
  80792. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80793. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80794. */
  80795. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80796. private webVROptions;
  80797. /**
  80798. * @hidden
  80799. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80800. */
  80801. _vrDevice: any;
  80802. /**
  80803. * The rawPose of the vrDevice.
  80804. */
  80805. rawPose: Nullable<DevicePose>;
  80806. private _onVREnabled;
  80807. private _specsVersion;
  80808. private _attached;
  80809. private _frameData;
  80810. protected _descendants: Array<Node>;
  80811. private _deviceRoomPosition;
  80812. /** @hidden */
  80813. _deviceRoomRotationQuaternion: Quaternion;
  80814. private _standingMatrix;
  80815. /**
  80816. * Represents device position in babylon space.
  80817. */
  80818. devicePosition: Vector3;
  80819. /**
  80820. * Represents device rotation in babylon space.
  80821. */
  80822. deviceRotationQuaternion: Quaternion;
  80823. /**
  80824. * The scale of the device to be used when translating from device space to babylon space.
  80825. */
  80826. deviceScaleFactor: number;
  80827. private _deviceToWorld;
  80828. private _worldToDevice;
  80829. /**
  80830. * References to the webVR controllers for the vrDevice.
  80831. */
  80832. controllers: Array<WebVRController>;
  80833. /**
  80834. * Emits an event when a controller is attached.
  80835. */
  80836. onControllersAttachedObservable: Observable<WebVRController[]>;
  80837. /**
  80838. * Emits an event when a controller's mesh has been loaded;
  80839. */
  80840. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80841. /**
  80842. * Emits an event when the HMD's pose has been updated.
  80843. */
  80844. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80845. private _poseSet;
  80846. /**
  80847. * If the rig cameras be used as parent instead of this camera.
  80848. */
  80849. rigParenting: boolean;
  80850. private _lightOnControllers;
  80851. private _defaultHeight?;
  80852. /**
  80853. * Instantiates a WebVRFreeCamera.
  80854. * @param name The name of the WebVRFreeCamera
  80855. * @param position The starting anchor position for the camera
  80856. * @param scene The scene the camera belongs to
  80857. * @param webVROptions a set of customizable options for the webVRCamera
  80858. */
  80859. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80860. /**
  80861. * Gets the device distance from the ground in meters.
  80862. * @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.
  80863. */
  80864. deviceDistanceToRoomGround(): number;
  80865. /**
  80866. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80867. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80868. */
  80869. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80870. /**
  80871. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80872. * @returns A promise with a boolean set to if the standing matrix is supported.
  80873. */
  80874. useStandingMatrixAsync(): Promise<boolean>;
  80875. /**
  80876. * Disposes the camera
  80877. */
  80878. dispose(): void;
  80879. /**
  80880. * Gets a vrController by name.
  80881. * @param name The name of the controller to retreive
  80882. * @returns the controller matching the name specified or null if not found
  80883. */
  80884. getControllerByName(name: string): Nullable<WebVRController>;
  80885. private _leftController;
  80886. /**
  80887. * The controller corresponding to the users left hand.
  80888. */
  80889. readonly leftController: Nullable<WebVRController>;
  80890. private _rightController;
  80891. /**
  80892. * The controller corresponding to the users right hand.
  80893. */
  80894. readonly rightController: Nullable<WebVRController>;
  80895. /**
  80896. * Casts a ray forward from the vrCamera's gaze.
  80897. * @param length Length of the ray (default: 100)
  80898. * @returns the ray corresponding to the gaze
  80899. */
  80900. getForwardRay(length?: number): Ray;
  80901. /**
  80902. * @hidden
  80903. * Updates the camera based on device's frame data
  80904. */
  80905. _checkInputs(): void;
  80906. /**
  80907. * Updates the poseControlled values based on the input device pose.
  80908. * @param poseData Pose coming from the device
  80909. */
  80910. updateFromDevice(poseData: DevicePose): void;
  80911. private _htmlElementAttached;
  80912. private _detachIfAttached;
  80913. /**
  80914. * WebVR's attach control will start broadcasting frames to the device.
  80915. * Note that in certain browsers (chrome for example) this function must be called
  80916. * within a user-interaction callback. Example:
  80917. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80918. *
  80919. * @param element html element to attach the vrDevice to
  80920. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80921. */
  80922. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80923. /**
  80924. * Detaches the camera from the html element and disables VR
  80925. *
  80926. * @param element html element to detach from
  80927. */
  80928. detachControl(element: HTMLElement): void;
  80929. /**
  80930. * @returns the name of this class
  80931. */
  80932. getClassName(): string;
  80933. /**
  80934. * Calls resetPose on the vrDisplay
  80935. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80936. */
  80937. resetToCurrentRotation(): void;
  80938. /**
  80939. * @hidden
  80940. * Updates the rig cameras (left and right eye)
  80941. */
  80942. _updateRigCameras(): void;
  80943. private _workingVector;
  80944. private _oneVector;
  80945. private _workingMatrix;
  80946. private updateCacheCalled;
  80947. private _correctPositionIfNotTrackPosition;
  80948. /**
  80949. * @hidden
  80950. * Updates the cached values of the camera
  80951. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80952. */
  80953. _updateCache(ignoreParentClass?: boolean): void;
  80954. /**
  80955. * @hidden
  80956. * Get current device position in babylon world
  80957. */
  80958. _computeDevicePosition(): void;
  80959. /**
  80960. * Updates the current device position and rotation in the babylon world
  80961. */
  80962. update(): void;
  80963. /**
  80964. * @hidden
  80965. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80966. * @returns an identity matrix
  80967. */
  80968. _getViewMatrix(): Matrix;
  80969. private _tmpMatrix;
  80970. /**
  80971. * This function is called by the two RIG cameras.
  80972. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80973. * @hidden
  80974. */
  80975. _getWebVRViewMatrix(): Matrix;
  80976. /** @hidden */
  80977. _getWebVRProjectionMatrix(): Matrix;
  80978. private _onGamepadConnectedObserver;
  80979. private _onGamepadDisconnectedObserver;
  80980. private _updateCacheWhenTrackingDisabledObserver;
  80981. /**
  80982. * Initializes the controllers and their meshes
  80983. */
  80984. initControllers(): void;
  80985. }
  80986. }
  80987. declare module BABYLON {
  80988. /**
  80989. * Size options for a post process
  80990. */
  80991. export type PostProcessOptions = {
  80992. width: number;
  80993. height: number;
  80994. };
  80995. /**
  80996. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80997. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80998. */
  80999. export class PostProcess {
  81000. /** Name of the PostProcess. */
  81001. name: string;
  81002. /**
  81003. * Gets or sets the unique id of the post process
  81004. */
  81005. uniqueId: number;
  81006. /**
  81007. * Width of the texture to apply the post process on
  81008. */
  81009. width: number;
  81010. /**
  81011. * Height of the texture to apply the post process on
  81012. */
  81013. height: number;
  81014. /**
  81015. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81016. * @hidden
  81017. */
  81018. _outputTexture: Nullable<InternalTexture>;
  81019. /**
  81020. * Sampling mode used by the shader
  81021. * See https://doc.babylonjs.com/classes/3.1/texture
  81022. */
  81023. renderTargetSamplingMode: number;
  81024. /**
  81025. * Clear color to use when screen clearing
  81026. */
  81027. clearColor: Color4;
  81028. /**
  81029. * If the buffer needs to be cleared before applying the post process. (default: true)
  81030. * Should be set to false if shader will overwrite all previous pixels.
  81031. */
  81032. autoClear: boolean;
  81033. /**
  81034. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81035. */
  81036. alphaMode: number;
  81037. /**
  81038. * Sets the setAlphaBlendConstants of the babylon engine
  81039. */
  81040. alphaConstants: Color4;
  81041. /**
  81042. * Animations to be used for the post processing
  81043. */
  81044. animations: Animation[];
  81045. /**
  81046. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81047. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81048. */
  81049. enablePixelPerfectMode: boolean;
  81050. /**
  81051. * Force the postprocess to be applied without taking in account viewport
  81052. */
  81053. forceFullscreenViewport: boolean;
  81054. /**
  81055. * List of inspectable custom properties (used by the Inspector)
  81056. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81057. */
  81058. inspectableCustomProperties: IInspectable[];
  81059. /**
  81060. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81061. *
  81062. * | Value | Type | Description |
  81063. * | ----- | ----------------------------------- | ----------- |
  81064. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81065. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81066. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81067. *
  81068. */
  81069. scaleMode: number;
  81070. /**
  81071. * Force textures to be a power of two (default: false)
  81072. */
  81073. alwaysForcePOT: boolean;
  81074. private _samples;
  81075. /**
  81076. * Number of sample textures (default: 1)
  81077. */
  81078. samples: number;
  81079. /**
  81080. * Modify the scale of the post process to be the same as the viewport (default: false)
  81081. */
  81082. adaptScaleToCurrentViewport: boolean;
  81083. private _camera;
  81084. private _scene;
  81085. private _engine;
  81086. private _options;
  81087. private _reusable;
  81088. private _textureType;
  81089. /**
  81090. * Smart array of input and output textures for the post process.
  81091. * @hidden
  81092. */
  81093. _textures: SmartArray<InternalTexture>;
  81094. /**
  81095. * The index in _textures that corresponds to the output texture.
  81096. * @hidden
  81097. */
  81098. _currentRenderTextureInd: number;
  81099. private _effect;
  81100. private _samplers;
  81101. private _fragmentUrl;
  81102. private _vertexUrl;
  81103. private _parameters;
  81104. private _scaleRatio;
  81105. protected _indexParameters: any;
  81106. private _shareOutputWithPostProcess;
  81107. private _texelSize;
  81108. private _forcedOutputTexture;
  81109. /**
  81110. * Returns the fragment url or shader name used in the post process.
  81111. * @returns the fragment url or name in the shader store.
  81112. */
  81113. getEffectName(): string;
  81114. /**
  81115. * An event triggered when the postprocess is activated.
  81116. */
  81117. onActivateObservable: Observable<Camera>;
  81118. private _onActivateObserver;
  81119. /**
  81120. * A function that is added to the onActivateObservable
  81121. */
  81122. onActivate: Nullable<(camera: Camera) => void>;
  81123. /**
  81124. * An event triggered when the postprocess changes its size.
  81125. */
  81126. onSizeChangedObservable: Observable<PostProcess>;
  81127. private _onSizeChangedObserver;
  81128. /**
  81129. * A function that is added to the onSizeChangedObservable
  81130. */
  81131. onSizeChanged: (postProcess: PostProcess) => void;
  81132. /**
  81133. * An event triggered when the postprocess applies its effect.
  81134. */
  81135. onApplyObservable: Observable<Effect>;
  81136. private _onApplyObserver;
  81137. /**
  81138. * A function that is added to the onApplyObservable
  81139. */
  81140. onApply: (effect: Effect) => void;
  81141. /**
  81142. * An event triggered before rendering the postprocess
  81143. */
  81144. onBeforeRenderObservable: Observable<Effect>;
  81145. private _onBeforeRenderObserver;
  81146. /**
  81147. * A function that is added to the onBeforeRenderObservable
  81148. */
  81149. onBeforeRender: (effect: Effect) => void;
  81150. /**
  81151. * An event triggered after rendering the postprocess
  81152. */
  81153. onAfterRenderObservable: Observable<Effect>;
  81154. private _onAfterRenderObserver;
  81155. /**
  81156. * A function that is added to the onAfterRenderObservable
  81157. */
  81158. onAfterRender: (efect: Effect) => void;
  81159. /**
  81160. * 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
  81161. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81162. */
  81163. inputTexture: InternalTexture;
  81164. /**
  81165. * Gets the camera which post process is applied to.
  81166. * @returns The camera the post process is applied to.
  81167. */
  81168. getCamera(): Camera;
  81169. /**
  81170. * Gets the texel size of the postprocess.
  81171. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81172. */
  81173. readonly texelSize: Vector2;
  81174. /**
  81175. * Creates a new instance PostProcess
  81176. * @param name The name of the PostProcess.
  81177. * @param fragmentUrl The url of the fragment shader to be used.
  81178. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81179. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81180. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81181. * @param camera The camera to apply the render pass to.
  81182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81183. * @param engine The engine which the post process will be applied. (default: current engine)
  81184. * @param reusable If the post process can be reused on the same frame. (default: false)
  81185. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81186. * @param textureType Type of textures used when performing the post process. (default: 0)
  81187. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81188. * @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
  81189. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81190. */
  81191. constructor(
  81192. /** Name of the PostProcess. */
  81193. 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);
  81194. /**
  81195. * Gets a string idenfifying the name of the class
  81196. * @returns "PostProcess" string
  81197. */
  81198. getClassName(): string;
  81199. /**
  81200. * Gets the engine which this post process belongs to.
  81201. * @returns The engine the post process was enabled with.
  81202. */
  81203. getEngine(): Engine;
  81204. /**
  81205. * The effect that is created when initializing the post process.
  81206. * @returns The created effect corresponding the the postprocess.
  81207. */
  81208. getEffect(): Effect;
  81209. /**
  81210. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81211. * @param postProcess The post process to share the output with.
  81212. * @returns This post process.
  81213. */
  81214. shareOutputWith(postProcess: PostProcess): PostProcess;
  81215. /**
  81216. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81217. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81218. */
  81219. useOwnOutput(): void;
  81220. /**
  81221. * Updates the effect with the current post process compile time values and recompiles the shader.
  81222. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81223. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81224. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81225. * @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
  81226. * @param onCompiled Called when the shader has been compiled.
  81227. * @param onError Called if there is an error when compiling a shader.
  81228. */
  81229. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81230. /**
  81231. * The post process is reusable if it can be used multiple times within one frame.
  81232. * @returns If the post process is reusable
  81233. */
  81234. isReusable(): boolean;
  81235. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81236. markTextureDirty(): void;
  81237. /**
  81238. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81239. * 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.
  81240. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81241. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81242. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81243. * @returns The target texture that was bound to be written to.
  81244. */
  81245. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81246. /**
  81247. * If the post process is supported.
  81248. */
  81249. readonly isSupported: boolean;
  81250. /**
  81251. * The aspect ratio of the output texture.
  81252. */
  81253. readonly aspectRatio: number;
  81254. /**
  81255. * Get a value indicating if the post-process is ready to be used
  81256. * @returns true if the post-process is ready (shader is compiled)
  81257. */
  81258. isReady(): boolean;
  81259. /**
  81260. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81261. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81262. */
  81263. apply(): Nullable<Effect>;
  81264. private _disposeTextures;
  81265. /**
  81266. * Disposes the post process.
  81267. * @param camera The camera to dispose the post process on.
  81268. */
  81269. dispose(camera?: Camera): void;
  81270. }
  81271. }
  81272. declare module BABYLON {
  81273. /** @hidden */
  81274. export var kernelBlurVaryingDeclaration: {
  81275. name: string;
  81276. shader: string;
  81277. };
  81278. }
  81279. declare module BABYLON {
  81280. /** @hidden */
  81281. export var kernelBlurFragment: {
  81282. name: string;
  81283. shader: string;
  81284. };
  81285. }
  81286. declare module BABYLON {
  81287. /** @hidden */
  81288. export var kernelBlurFragment2: {
  81289. name: string;
  81290. shader: string;
  81291. };
  81292. }
  81293. declare module BABYLON {
  81294. /** @hidden */
  81295. export var kernelBlurPixelShader: {
  81296. name: string;
  81297. shader: string;
  81298. };
  81299. }
  81300. declare module BABYLON {
  81301. /** @hidden */
  81302. export var kernelBlurVertex: {
  81303. name: string;
  81304. shader: string;
  81305. };
  81306. }
  81307. declare module BABYLON {
  81308. /** @hidden */
  81309. export var kernelBlurVertexShader: {
  81310. name: string;
  81311. shader: string;
  81312. };
  81313. }
  81314. declare module BABYLON {
  81315. /**
  81316. * The Blur Post Process which blurs an image based on a kernel and direction.
  81317. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81318. */
  81319. export class BlurPostProcess extends PostProcess {
  81320. /** The direction in which to blur the image. */
  81321. direction: Vector2;
  81322. private blockCompilation;
  81323. protected _kernel: number;
  81324. protected _idealKernel: number;
  81325. protected _packedFloat: boolean;
  81326. private _staticDefines;
  81327. /**
  81328. * Sets the length in pixels of the blur sample region
  81329. */
  81330. /**
  81331. * Gets the length in pixels of the blur sample region
  81332. */
  81333. kernel: number;
  81334. /**
  81335. * Sets wether or not the blur needs to unpack/repack floats
  81336. */
  81337. /**
  81338. * Gets wether or not the blur is unpacking/repacking floats
  81339. */
  81340. packedFloat: boolean;
  81341. /**
  81342. * Creates a new instance BlurPostProcess
  81343. * @param name The name of the effect.
  81344. * @param direction The direction in which to blur the image.
  81345. * @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.
  81346. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81347. * @param camera The camera to apply the render pass to.
  81348. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81349. * @param engine The engine which the post process will be applied. (default: current engine)
  81350. * @param reusable If the post process can be reused on the same frame. (default: false)
  81351. * @param textureType Type of textures used when performing the post process. (default: 0)
  81352. * @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)
  81353. */
  81354. constructor(name: string,
  81355. /** The direction in which to blur the image. */
  81356. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81357. /**
  81358. * Updates the effect with the current post process compile time values and recompiles the shader.
  81359. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81360. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81361. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81362. * @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
  81363. * @param onCompiled Called when the shader has been compiled.
  81364. * @param onError Called if there is an error when compiling a shader.
  81365. */
  81366. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81367. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81368. /**
  81369. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81370. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81371. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81372. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81373. * The gaps between physical kernels are compensated for in the weighting of the samples
  81374. * @param idealKernel Ideal blur kernel.
  81375. * @return Nearest best kernel.
  81376. */
  81377. protected _nearestBestKernel(idealKernel: number): number;
  81378. /**
  81379. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81380. * @param x The point on the Gaussian distribution to sample.
  81381. * @return the value of the Gaussian function at x.
  81382. */
  81383. protected _gaussianWeight(x: number): number;
  81384. /**
  81385. * Generates a string that can be used as a floating point number in GLSL.
  81386. * @param x Value to print.
  81387. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81388. * @return GLSL float string.
  81389. */
  81390. protected _glslFloat(x: number, decimalFigures?: number): string;
  81391. }
  81392. }
  81393. declare module BABYLON {
  81394. /**
  81395. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81396. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81397. * You can then easily use it as a reflectionTexture on a flat surface.
  81398. * In case the surface is not a plane, please consider relying on reflection probes.
  81399. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81400. */
  81401. export class MirrorTexture extends RenderTargetTexture {
  81402. private scene;
  81403. /**
  81404. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81405. * 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.
  81406. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81407. */
  81408. mirrorPlane: Plane;
  81409. /**
  81410. * Define the blur ratio used to blur the reflection if needed.
  81411. */
  81412. blurRatio: number;
  81413. /**
  81414. * Define the adaptive blur kernel used to blur the reflection if needed.
  81415. * This will autocompute the closest best match for the `blurKernel`
  81416. */
  81417. adaptiveBlurKernel: number;
  81418. /**
  81419. * Define the blur kernel used to blur the reflection if needed.
  81420. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81421. */
  81422. blurKernel: number;
  81423. /**
  81424. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81425. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81426. */
  81427. blurKernelX: number;
  81428. /**
  81429. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81430. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81431. */
  81432. blurKernelY: number;
  81433. private _autoComputeBlurKernel;
  81434. protected _onRatioRescale(): void;
  81435. private _updateGammaSpace;
  81436. private _imageProcessingConfigChangeObserver;
  81437. private _transformMatrix;
  81438. private _mirrorMatrix;
  81439. private _savedViewMatrix;
  81440. private _blurX;
  81441. private _blurY;
  81442. private _adaptiveBlurKernel;
  81443. private _blurKernelX;
  81444. private _blurKernelY;
  81445. private _blurRatio;
  81446. /**
  81447. * Instantiates a Mirror Texture.
  81448. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81449. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81450. * You can then easily use it as a reflectionTexture on a flat surface.
  81451. * In case the surface is not a plane, please consider relying on reflection probes.
  81452. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81453. * @param name
  81454. * @param size
  81455. * @param scene
  81456. * @param generateMipMaps
  81457. * @param type
  81458. * @param samplingMode
  81459. * @param generateDepthBuffer
  81460. */
  81461. constructor(name: string, size: number | {
  81462. width: number;
  81463. height: number;
  81464. } | {
  81465. ratio: number;
  81466. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81467. private _preparePostProcesses;
  81468. /**
  81469. * Clone the mirror texture.
  81470. * @returns the cloned texture
  81471. */
  81472. clone(): MirrorTexture;
  81473. /**
  81474. * Serialize the texture to a JSON representation you could use in Parse later on
  81475. * @returns the serialized JSON representation
  81476. */
  81477. serialize(): any;
  81478. /**
  81479. * Dispose the texture and release its associated resources.
  81480. */
  81481. dispose(): void;
  81482. }
  81483. }
  81484. declare module BABYLON {
  81485. /**
  81486. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81487. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81488. */
  81489. export class Texture extends BaseTexture {
  81490. /**
  81491. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  81492. */
  81493. static SerializeBuffers: boolean;
  81494. /** @hidden */
  81495. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81496. /** @hidden */
  81497. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81498. /** @hidden */
  81499. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81500. /** nearest is mag = nearest and min = nearest and mip = linear */
  81501. static readonly NEAREST_SAMPLINGMODE: number;
  81502. /** nearest is mag = nearest and min = nearest and mip = linear */
  81503. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81504. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81505. static readonly BILINEAR_SAMPLINGMODE: number;
  81506. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81507. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81508. /** Trilinear is mag = linear and min = linear and mip = linear */
  81509. static readonly TRILINEAR_SAMPLINGMODE: number;
  81510. /** Trilinear is mag = linear and min = linear and mip = linear */
  81511. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81512. /** mag = nearest and min = nearest and mip = nearest */
  81513. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81514. /** mag = nearest and min = linear and mip = nearest */
  81515. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81516. /** mag = nearest and min = linear and mip = linear */
  81517. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81518. /** mag = nearest and min = linear and mip = none */
  81519. static readonly NEAREST_LINEAR: number;
  81520. /** mag = nearest and min = nearest and mip = none */
  81521. static readonly NEAREST_NEAREST: number;
  81522. /** mag = linear and min = nearest and mip = nearest */
  81523. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81524. /** mag = linear and min = nearest and mip = linear */
  81525. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81526. /** mag = linear and min = linear and mip = none */
  81527. static readonly LINEAR_LINEAR: number;
  81528. /** mag = linear and min = nearest and mip = none */
  81529. static readonly LINEAR_NEAREST: number;
  81530. /** Explicit coordinates mode */
  81531. static readonly EXPLICIT_MODE: number;
  81532. /** Spherical coordinates mode */
  81533. static readonly SPHERICAL_MODE: number;
  81534. /** Planar coordinates mode */
  81535. static readonly PLANAR_MODE: number;
  81536. /** Cubic coordinates mode */
  81537. static readonly CUBIC_MODE: number;
  81538. /** Projection coordinates mode */
  81539. static readonly PROJECTION_MODE: number;
  81540. /** Inverse Cubic coordinates mode */
  81541. static readonly SKYBOX_MODE: number;
  81542. /** Inverse Cubic coordinates mode */
  81543. static readonly INVCUBIC_MODE: number;
  81544. /** Equirectangular coordinates mode */
  81545. static readonly EQUIRECTANGULAR_MODE: number;
  81546. /** Equirectangular Fixed coordinates mode */
  81547. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81548. /** Equirectangular Fixed Mirrored coordinates mode */
  81549. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81550. /** Texture is not repeating outside of 0..1 UVs */
  81551. static readonly CLAMP_ADDRESSMODE: number;
  81552. /** Texture is repeating outside of 0..1 UVs */
  81553. static readonly WRAP_ADDRESSMODE: number;
  81554. /** Texture is repeating and mirrored */
  81555. static readonly MIRROR_ADDRESSMODE: number;
  81556. /**
  81557. * 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
  81558. */
  81559. static UseSerializedUrlIfAny: boolean;
  81560. /**
  81561. * Define the url of the texture.
  81562. */
  81563. url: Nullable<string>;
  81564. /**
  81565. * Define an offset on the texture to offset the u coordinates of the UVs
  81566. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81567. */
  81568. uOffset: number;
  81569. /**
  81570. * Define an offset on the texture to offset the v coordinates of the UVs
  81571. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81572. */
  81573. vOffset: number;
  81574. /**
  81575. * Define an offset on the texture to scale the u coordinates of the UVs
  81576. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81577. */
  81578. uScale: number;
  81579. /**
  81580. * Define an offset on the texture to scale the v coordinates of the UVs
  81581. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81582. */
  81583. vScale: number;
  81584. /**
  81585. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81586. * @see http://doc.babylonjs.com/how_to/more_materials
  81587. */
  81588. uAng: number;
  81589. /**
  81590. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81591. * @see http://doc.babylonjs.com/how_to/more_materials
  81592. */
  81593. vAng: number;
  81594. /**
  81595. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81596. * @see http://doc.babylonjs.com/how_to/more_materials
  81597. */
  81598. wAng: number;
  81599. /**
  81600. * Defines the center of rotation (U)
  81601. */
  81602. uRotationCenter: number;
  81603. /**
  81604. * Defines the center of rotation (V)
  81605. */
  81606. vRotationCenter: number;
  81607. /**
  81608. * Defines the center of rotation (W)
  81609. */
  81610. wRotationCenter: number;
  81611. /**
  81612. * Are mip maps generated for this texture or not.
  81613. */
  81614. readonly noMipmap: boolean;
  81615. /**
  81616. * List of inspectable custom properties (used by the Inspector)
  81617. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81618. */
  81619. inspectableCustomProperties: Nullable<IInspectable[]>;
  81620. private _noMipmap;
  81621. /** @hidden */
  81622. _invertY: boolean;
  81623. private _rowGenerationMatrix;
  81624. private _cachedTextureMatrix;
  81625. private _projectionModeMatrix;
  81626. private _t0;
  81627. private _t1;
  81628. private _t2;
  81629. private _cachedUOffset;
  81630. private _cachedVOffset;
  81631. private _cachedUScale;
  81632. private _cachedVScale;
  81633. private _cachedUAng;
  81634. private _cachedVAng;
  81635. private _cachedWAng;
  81636. private _cachedProjectionMatrixId;
  81637. private _cachedCoordinatesMode;
  81638. /** @hidden */
  81639. protected _initialSamplingMode: number;
  81640. /** @hidden */
  81641. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  81642. private _deleteBuffer;
  81643. protected _format: Nullable<number>;
  81644. private _delayedOnLoad;
  81645. private _delayedOnError;
  81646. /**
  81647. * Observable triggered once the texture has been loaded.
  81648. */
  81649. onLoadObservable: Observable<Texture>;
  81650. protected _isBlocking: boolean;
  81651. /**
  81652. * Is the texture preventing material to render while loading.
  81653. * If false, a default texture will be used instead of the loading one during the preparation step.
  81654. */
  81655. isBlocking: boolean;
  81656. /**
  81657. * Get the current sampling mode associated with the texture.
  81658. */
  81659. readonly samplingMode: number;
  81660. /**
  81661. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81662. */
  81663. readonly invertY: boolean;
  81664. /**
  81665. * Instantiates a new texture.
  81666. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81667. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81668. * @param url define the url of the picture to load as a texture
  81669. * @param scene define the scene or engine the texture will belong to
  81670. * @param noMipmap define if the texture will require mip maps or not
  81671. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81672. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81673. * @param onLoad define a callback triggered when the texture has been loaded
  81674. * @param onError define a callback triggered when an error occurred during the loading session
  81675. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81676. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81677. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81678. */
  81679. 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);
  81680. /**
  81681. * Update the url (and optional buffer) of this texture if url was null during construction.
  81682. * @param url the url of the texture
  81683. * @param buffer the buffer of the texture (defaults to null)
  81684. * @param onLoad callback called when the texture is loaded (defaults to null)
  81685. */
  81686. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81687. /**
  81688. * Finish the loading sequence of a texture flagged as delayed load.
  81689. * @hidden
  81690. */
  81691. delayLoad(): void;
  81692. private _prepareRowForTextureGeneration;
  81693. /**
  81694. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81695. * @returns the transform matrix of the texture.
  81696. */
  81697. getTextureMatrix(): Matrix;
  81698. /**
  81699. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81700. * @returns The reflection texture transform
  81701. */
  81702. getReflectionTextureMatrix(): Matrix;
  81703. /**
  81704. * Clones the texture.
  81705. * @returns the cloned texture
  81706. */
  81707. clone(): Texture;
  81708. /**
  81709. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81710. * @returns The JSON representation of the texture
  81711. */
  81712. serialize(): any;
  81713. /**
  81714. * Get the current class name of the texture useful for serialization or dynamic coding.
  81715. * @returns "Texture"
  81716. */
  81717. getClassName(): string;
  81718. /**
  81719. * Dispose the texture and release its associated resources.
  81720. */
  81721. dispose(): void;
  81722. /**
  81723. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81724. * @param parsedTexture Define the JSON representation of the texture
  81725. * @param scene Define the scene the parsed texture should be instantiated in
  81726. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81727. * @returns The parsed texture if successful
  81728. */
  81729. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81730. /**
  81731. * Creates a texture from its base 64 representation.
  81732. * @param data Define the base64 payload without the data: prefix
  81733. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81734. * @param scene Define the scene the texture should belong to
  81735. * @param noMipmap Forces the texture to not create mip map information if true
  81736. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81737. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81738. * @param onLoad define a callback triggered when the texture has been loaded
  81739. * @param onError define a callback triggered when an error occurred during the loading session
  81740. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81741. * @returns the created texture
  81742. */
  81743. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81744. /**
  81745. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81746. * @param data Define the base64 payload without the data: prefix
  81747. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81748. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81749. * @param scene Define the scene the texture should belong to
  81750. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81751. * @param noMipmap Forces the texture to not create mip map information if true
  81752. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81753. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81754. * @param onLoad define a callback triggered when the texture has been loaded
  81755. * @param onError define a callback triggered when an error occurred during the loading session
  81756. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81757. * @returns the created texture
  81758. */
  81759. 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;
  81760. }
  81761. }
  81762. declare module BABYLON {
  81763. /**
  81764. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81765. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81766. */
  81767. export class PostProcessManager {
  81768. private _scene;
  81769. private _indexBuffer;
  81770. private _vertexBuffers;
  81771. /**
  81772. * Creates a new instance PostProcess
  81773. * @param scene The scene that the post process is associated with.
  81774. */
  81775. constructor(scene: Scene);
  81776. private _prepareBuffers;
  81777. private _buildIndexBuffer;
  81778. /**
  81779. * Rebuilds the vertex buffers of the manager.
  81780. * @hidden
  81781. */
  81782. _rebuild(): void;
  81783. /**
  81784. * Prepares a frame to be run through a post process.
  81785. * @param sourceTexture The input texture to the post procesess. (default: null)
  81786. * @param postProcesses An array of post processes to be run. (default: null)
  81787. * @returns True if the post processes were able to be run.
  81788. * @hidden
  81789. */
  81790. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81791. /**
  81792. * Manually render a set of post processes to a texture.
  81793. * @param postProcesses An array of post processes to be run.
  81794. * @param targetTexture The target texture to render to.
  81795. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81796. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81797. * @param lodLevel defines which lod of the texture to render to
  81798. */
  81799. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81800. /**
  81801. * Finalize the result of the output of the postprocesses.
  81802. * @param doNotPresent If true the result will not be displayed to the screen.
  81803. * @param targetTexture The target texture to render to.
  81804. * @param faceIndex The index of the face to bind the target texture to.
  81805. * @param postProcesses The array of post processes to render.
  81806. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81807. * @hidden
  81808. */
  81809. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81810. /**
  81811. * Disposes of the post process manager.
  81812. */
  81813. dispose(): void;
  81814. }
  81815. }
  81816. declare module BABYLON {
  81817. /** Interface used by value gradients (color, factor, ...) */
  81818. export interface IValueGradient {
  81819. /**
  81820. * Gets or sets the gradient value (between 0 and 1)
  81821. */
  81822. gradient: number;
  81823. }
  81824. /** Class used to store color4 gradient */
  81825. export class ColorGradient implements IValueGradient {
  81826. /**
  81827. * Gets or sets the gradient value (between 0 and 1)
  81828. */
  81829. gradient: number;
  81830. /**
  81831. * Gets or sets first associated color
  81832. */
  81833. color1: Color4;
  81834. /**
  81835. * Gets or sets second associated color
  81836. */
  81837. color2?: Color4;
  81838. /**
  81839. * Will get a color picked randomly between color1 and color2.
  81840. * If color2 is undefined then color1 will be used
  81841. * @param result defines the target Color4 to store the result in
  81842. */
  81843. getColorToRef(result: Color4): void;
  81844. }
  81845. /** Class used to store color 3 gradient */
  81846. export class Color3Gradient implements IValueGradient {
  81847. /**
  81848. * Gets or sets the gradient value (between 0 and 1)
  81849. */
  81850. gradient: number;
  81851. /**
  81852. * Gets or sets the associated color
  81853. */
  81854. color: Color3;
  81855. }
  81856. /** Class used to store factor gradient */
  81857. export class FactorGradient implements IValueGradient {
  81858. /**
  81859. * Gets or sets the gradient value (between 0 and 1)
  81860. */
  81861. gradient: number;
  81862. /**
  81863. * Gets or sets first associated factor
  81864. */
  81865. factor1: number;
  81866. /**
  81867. * Gets or sets second associated factor
  81868. */
  81869. factor2?: number;
  81870. /**
  81871. * Will get a number picked randomly between factor1 and factor2.
  81872. * If factor2 is undefined then factor1 will be used
  81873. * @returns the picked number
  81874. */
  81875. getFactor(): number;
  81876. }
  81877. /**
  81878. * Helper used to simplify some generic gradient tasks
  81879. */
  81880. export class GradientHelper {
  81881. /**
  81882. * Gets the current gradient from an array of IValueGradient
  81883. * @param ratio defines the current ratio to get
  81884. * @param gradients defines the array of IValueGradient
  81885. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  81886. */
  81887. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  81888. }
  81889. }
  81890. declare module BABYLON {
  81891. /**
  81892. * A class extending Texture allowing drawing on a texture
  81893. * @see http://doc.babylonjs.com/how_to/dynamictexture
  81894. */
  81895. export class DynamicTexture extends Texture {
  81896. private _generateMipMaps;
  81897. private _canvas;
  81898. private _context;
  81899. private _engine;
  81900. /**
  81901. * Creates a DynamicTexture
  81902. * @param name defines the name of the texture
  81903. * @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
  81904. * @param scene defines the scene where you want the texture
  81905. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  81906. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81907. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  81908. */
  81909. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  81910. /**
  81911. * Get the current class name of the texture useful for serialization or dynamic coding.
  81912. * @returns "DynamicTexture"
  81913. */
  81914. getClassName(): string;
  81915. /**
  81916. * Gets the current state of canRescale
  81917. */
  81918. readonly canRescale: boolean;
  81919. private _recreate;
  81920. /**
  81921. * Scales the texture
  81922. * @param ratio the scale factor to apply to both width and height
  81923. */
  81924. scale(ratio: number): void;
  81925. /**
  81926. * Resizes the texture
  81927. * @param width the new width
  81928. * @param height the new height
  81929. */
  81930. scaleTo(width: number, height: number): void;
  81931. /**
  81932. * Gets the context of the canvas used by the texture
  81933. * @returns the canvas context of the dynamic texture
  81934. */
  81935. getContext(): CanvasRenderingContext2D;
  81936. /**
  81937. * Clears the texture
  81938. */
  81939. clear(): void;
  81940. /**
  81941. * Updates the texture
  81942. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81943. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  81944. */
  81945. update(invertY?: boolean, premulAlpha?: boolean): void;
  81946. /**
  81947. * Draws text onto the texture
  81948. * @param text defines the text to be drawn
  81949. * @param x defines the placement of the text from the left
  81950. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  81951. * @param font defines the font to be used with font-style, font-size, font-name
  81952. * @param color defines the color used for the text
  81953. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  81954. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81955. * @param update defines whether texture is immediately update (default is true)
  81956. */
  81957. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  81958. /**
  81959. * Clones the texture
  81960. * @returns the clone of the texture.
  81961. */
  81962. clone(): DynamicTexture;
  81963. /**
  81964. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  81965. * @returns a serialized dynamic texture object
  81966. */
  81967. serialize(): any;
  81968. /** @hidden */
  81969. _rebuild(): void;
  81970. }
  81971. }
  81972. declare module BABYLON {
  81973. interface AbstractScene {
  81974. /**
  81975. * The list of procedural textures added to the scene
  81976. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81977. */
  81978. proceduralTextures: Array<ProceduralTexture>;
  81979. }
  81980. /**
  81981. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81982. * in a given scene.
  81983. */
  81984. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81985. /**
  81986. * The component name helpfull to identify the component in the list of scene components.
  81987. */
  81988. readonly name: string;
  81989. /**
  81990. * The scene the component belongs to.
  81991. */
  81992. scene: Scene;
  81993. /**
  81994. * Creates a new instance of the component for the given scene
  81995. * @param scene Defines the scene to register the component in
  81996. */
  81997. constructor(scene: Scene);
  81998. /**
  81999. * Registers the component in a given scene
  82000. */
  82001. register(): void;
  82002. /**
  82003. * Rebuilds the elements related to this component in case of
  82004. * context lost for instance.
  82005. */
  82006. rebuild(): void;
  82007. /**
  82008. * Disposes the component and the associated ressources.
  82009. */
  82010. dispose(): void;
  82011. private _beforeClear;
  82012. }
  82013. }
  82014. declare module BABYLON {
  82015. interface Engine {
  82016. /**
  82017. * Creates a new render target cube texture
  82018. * @param size defines the size of the texture
  82019. * @param options defines the options used to create the texture
  82020. * @returns a new render target cube texture stored in an InternalTexture
  82021. */
  82022. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  82023. }
  82024. }
  82025. declare module BABYLON {
  82026. /** @hidden */
  82027. export var proceduralVertexShader: {
  82028. name: string;
  82029. shader: string;
  82030. };
  82031. }
  82032. declare module BABYLON {
  82033. /**
  82034. * 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.
  82035. * This is the base class of any Procedural texture and contains most of the shareable code.
  82036. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82037. */
  82038. export class ProceduralTexture extends Texture {
  82039. isCube: boolean;
  82040. /**
  82041. * Define if the texture is enabled or not (disabled texture will not render)
  82042. */
  82043. isEnabled: boolean;
  82044. /**
  82045. * Define if the texture must be cleared before rendering (default is true)
  82046. */
  82047. autoClear: boolean;
  82048. /**
  82049. * Callback called when the texture is generated
  82050. */
  82051. onGenerated: () => void;
  82052. /**
  82053. * Event raised when the texture is generated
  82054. */
  82055. onGeneratedObservable: Observable<ProceduralTexture>;
  82056. /** @hidden */
  82057. _generateMipMaps: boolean;
  82058. /** @hidden **/
  82059. _effect: Effect;
  82060. /** @hidden */
  82061. _textures: {
  82062. [key: string]: Texture;
  82063. };
  82064. private _size;
  82065. private _currentRefreshId;
  82066. private _refreshRate;
  82067. private _vertexBuffers;
  82068. private _indexBuffer;
  82069. private _uniforms;
  82070. private _samplers;
  82071. private _fragment;
  82072. private _floats;
  82073. private _ints;
  82074. private _floatsArrays;
  82075. private _colors3;
  82076. private _colors4;
  82077. private _vectors2;
  82078. private _vectors3;
  82079. private _matrices;
  82080. private _fallbackTexture;
  82081. private _fallbackTextureUsed;
  82082. private _engine;
  82083. private _cachedDefines;
  82084. private _contentUpdateId;
  82085. private _contentData;
  82086. /**
  82087. * Instantiates a new procedural texture.
  82088. * 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.
  82089. * This is the base class of any Procedural texture and contains most of the shareable code.
  82090. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82091. * @param name Define the name of the texture
  82092. * @param size Define the size of the texture to create
  82093. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  82094. * @param scene Define the scene the texture belongs to
  82095. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  82096. * @param generateMipMaps Define if the texture should creates mip maps or not
  82097. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  82098. */
  82099. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  82100. /**
  82101. * The effect that is created when initializing the post process.
  82102. * @returns The created effect corresponding the the postprocess.
  82103. */
  82104. getEffect(): Effect;
  82105. /**
  82106. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  82107. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  82108. */
  82109. getContent(): Nullable<ArrayBufferView>;
  82110. private _createIndexBuffer;
  82111. /** @hidden */
  82112. _rebuild(): void;
  82113. /**
  82114. * Resets the texture in order to recreate its associated resources.
  82115. * This can be called in case of context loss
  82116. */
  82117. reset(): void;
  82118. protected _getDefines(): string;
  82119. /**
  82120. * Is the texture ready to be used ? (rendered at least once)
  82121. * @returns true if ready, otherwise, false.
  82122. */
  82123. isReady(): boolean;
  82124. /**
  82125. * Resets the refresh counter of the texture and start bak from scratch.
  82126. * Could be useful to regenerate the texture if it is setup to render only once.
  82127. */
  82128. resetRefreshCounter(): void;
  82129. /**
  82130. * Set the fragment shader to use in order to render the texture.
  82131. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  82132. */
  82133. setFragment(fragment: any): void;
  82134. /**
  82135. * Define the refresh rate of the texture or the rendering frequency.
  82136. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  82137. */
  82138. refreshRate: number;
  82139. /** @hidden */
  82140. _shouldRender(): boolean;
  82141. /**
  82142. * Get the size the texture is rendering at.
  82143. * @returns the size (texture is always squared)
  82144. */
  82145. getRenderSize(): number;
  82146. /**
  82147. * Resize the texture to new value.
  82148. * @param size Define the new size the texture should have
  82149. * @param generateMipMaps Define whether the new texture should create mip maps
  82150. */
  82151. resize(size: number, generateMipMaps: boolean): void;
  82152. private _checkUniform;
  82153. /**
  82154. * Set a texture in the shader program used to render.
  82155. * @param name Define the name of the uniform samplers as defined in the shader
  82156. * @param texture Define the texture to bind to this sampler
  82157. * @return the texture itself allowing "fluent" like uniform updates
  82158. */
  82159. setTexture(name: string, texture: Texture): ProceduralTexture;
  82160. /**
  82161. * Set a float in the shader.
  82162. * @param name Define the name of the uniform as defined in the shader
  82163. * @param value Define the value to give to the uniform
  82164. * @return the texture itself allowing "fluent" like uniform updates
  82165. */
  82166. setFloat(name: string, value: number): ProceduralTexture;
  82167. /**
  82168. * Set a int in the shader.
  82169. * @param name Define the name of the uniform as defined in the shader
  82170. * @param value Define the value to give to the uniform
  82171. * @return the texture itself allowing "fluent" like uniform updates
  82172. */
  82173. setInt(name: string, value: number): ProceduralTexture;
  82174. /**
  82175. * Set an array of floats in the shader.
  82176. * @param name Define the name of the uniform as defined in the shader
  82177. * @param value Define the value to give to the uniform
  82178. * @return the texture itself allowing "fluent" like uniform updates
  82179. */
  82180. setFloats(name: string, value: number[]): ProceduralTexture;
  82181. /**
  82182. * Set a vec3 in the shader from a Color3.
  82183. * @param name Define the name of the uniform as defined in the shader
  82184. * @param value Define the value to give to the uniform
  82185. * @return the texture itself allowing "fluent" like uniform updates
  82186. */
  82187. setColor3(name: string, value: Color3): ProceduralTexture;
  82188. /**
  82189. * Set a vec4 in the shader from a Color4.
  82190. * @param name Define the name of the uniform as defined in the shader
  82191. * @param value Define the value to give to the uniform
  82192. * @return the texture itself allowing "fluent" like uniform updates
  82193. */
  82194. setColor4(name: string, value: Color4): ProceduralTexture;
  82195. /**
  82196. * Set a vec2 in the shader from a Vector2.
  82197. * @param name Define the name of the uniform as defined in the shader
  82198. * @param value Define the value to give to the uniform
  82199. * @return the texture itself allowing "fluent" like uniform updates
  82200. */
  82201. setVector2(name: string, value: Vector2): ProceduralTexture;
  82202. /**
  82203. * Set a vec3 in the shader from a Vector3.
  82204. * @param name Define the name of the uniform as defined in the shader
  82205. * @param value Define the value to give to the uniform
  82206. * @return the texture itself allowing "fluent" like uniform updates
  82207. */
  82208. setVector3(name: string, value: Vector3): ProceduralTexture;
  82209. /**
  82210. * Set a mat4 in the shader from a MAtrix.
  82211. * @param name Define the name of the uniform as defined in the shader
  82212. * @param value Define the value to give to the uniform
  82213. * @return the texture itself allowing "fluent" like uniform updates
  82214. */
  82215. setMatrix(name: string, value: Matrix): ProceduralTexture;
  82216. /**
  82217. * Render the texture to its associated render target.
  82218. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  82219. */
  82220. render(useCameraPostProcess?: boolean): void;
  82221. /**
  82222. * Clone the texture.
  82223. * @returns the cloned texture
  82224. */
  82225. clone(): ProceduralTexture;
  82226. /**
  82227. * Dispose the texture and release its asoociated resources.
  82228. */
  82229. dispose(): void;
  82230. }
  82231. }
  82232. declare module BABYLON {
  82233. /**
  82234. * This represents the base class for particle system in Babylon.
  82235. * 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.
  82236. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82237. * @example https://doc.babylonjs.com/babylon101/particles
  82238. */
  82239. export class BaseParticleSystem {
  82240. /**
  82241. * Source color is added to the destination color without alpha affecting the result
  82242. */
  82243. static BLENDMODE_ONEONE: number;
  82244. /**
  82245. * Blend current color and particle color using particle’s alpha
  82246. */
  82247. static BLENDMODE_STANDARD: number;
  82248. /**
  82249. * Add current color and particle color multiplied by particle’s alpha
  82250. */
  82251. static BLENDMODE_ADD: number;
  82252. /**
  82253. * Multiply current color with particle color
  82254. */
  82255. static BLENDMODE_MULTIPLY: number;
  82256. /**
  82257. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  82258. */
  82259. static BLENDMODE_MULTIPLYADD: number;
  82260. /**
  82261. * List of animations used by the particle system.
  82262. */
  82263. animations: Animation[];
  82264. /**
  82265. * The id of the Particle system.
  82266. */
  82267. id: string;
  82268. /**
  82269. * The friendly name of the Particle system.
  82270. */
  82271. name: string;
  82272. /**
  82273. * The rendering group used by the Particle system to chose when to render.
  82274. */
  82275. renderingGroupId: number;
  82276. /**
  82277. * The emitter represents the Mesh or position we are attaching the particle system to.
  82278. */
  82279. emitter: Nullable<AbstractMesh | Vector3>;
  82280. /**
  82281. * The maximum number of particles to emit per frame
  82282. */
  82283. emitRate: number;
  82284. /**
  82285. * If you want to launch only a few particles at once, that can be done, as well.
  82286. */
  82287. manualEmitCount: number;
  82288. /**
  82289. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82290. */
  82291. updateSpeed: number;
  82292. /**
  82293. * The amount of time the particle system is running (depends of the overall update speed).
  82294. */
  82295. targetStopDuration: number;
  82296. /**
  82297. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82298. */
  82299. disposeOnStop: boolean;
  82300. /**
  82301. * Minimum power of emitting particles.
  82302. */
  82303. minEmitPower: number;
  82304. /**
  82305. * Maximum power of emitting particles.
  82306. */
  82307. maxEmitPower: number;
  82308. /**
  82309. * Minimum life time of emitting particles.
  82310. */
  82311. minLifeTime: number;
  82312. /**
  82313. * Maximum life time of emitting particles.
  82314. */
  82315. maxLifeTime: number;
  82316. /**
  82317. * Minimum Size of emitting particles.
  82318. */
  82319. minSize: number;
  82320. /**
  82321. * Maximum Size of emitting particles.
  82322. */
  82323. maxSize: number;
  82324. /**
  82325. * Minimum scale of emitting particles on X axis.
  82326. */
  82327. minScaleX: number;
  82328. /**
  82329. * Maximum scale of emitting particles on X axis.
  82330. */
  82331. maxScaleX: number;
  82332. /**
  82333. * Minimum scale of emitting particles on Y axis.
  82334. */
  82335. minScaleY: number;
  82336. /**
  82337. * Maximum scale of emitting particles on Y axis.
  82338. */
  82339. maxScaleY: number;
  82340. /**
  82341. * Gets or sets the minimal initial rotation in radians.
  82342. */
  82343. minInitialRotation: number;
  82344. /**
  82345. * Gets or sets the maximal initial rotation in radians.
  82346. */
  82347. maxInitialRotation: number;
  82348. /**
  82349. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82350. */
  82351. minAngularSpeed: number;
  82352. /**
  82353. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82354. */
  82355. maxAngularSpeed: number;
  82356. /**
  82357. * The texture used to render each particle. (this can be a spritesheet)
  82358. */
  82359. particleTexture: Nullable<Texture>;
  82360. /**
  82361. * The layer mask we are rendering the particles through.
  82362. */
  82363. layerMask: number;
  82364. /**
  82365. * This can help using your own shader to render the particle system.
  82366. * The according effect will be created
  82367. */
  82368. customShader: any;
  82369. /**
  82370. * By default particle system starts as soon as they are created. This prevents the
  82371. * automatic start to happen and let you decide when to start emitting particles.
  82372. */
  82373. preventAutoStart: boolean;
  82374. private _noiseTexture;
  82375. /**
  82376. * Gets or sets a texture used to add random noise to particle positions
  82377. */
  82378. noiseTexture: Nullable<ProceduralTexture>;
  82379. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82380. noiseStrength: Vector3;
  82381. /**
  82382. * Callback triggered when the particle animation is ending.
  82383. */
  82384. onAnimationEnd: Nullable<() => void>;
  82385. /**
  82386. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82387. */
  82388. blendMode: number;
  82389. /**
  82390. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82391. * to override the particles.
  82392. */
  82393. forceDepthWrite: boolean;
  82394. /** 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 */
  82395. preWarmCycles: number;
  82396. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82397. preWarmStepOffset: number;
  82398. /**
  82399. * 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)
  82400. */
  82401. spriteCellChangeSpeed: number;
  82402. /**
  82403. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82404. */
  82405. startSpriteCellID: number;
  82406. /**
  82407. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82408. */
  82409. endSpriteCellID: number;
  82410. /**
  82411. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82412. */
  82413. spriteCellWidth: number;
  82414. /**
  82415. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82416. */
  82417. spriteCellHeight: number;
  82418. /**
  82419. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82420. */
  82421. spriteRandomStartCell: boolean;
  82422. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82423. translationPivot: Vector2;
  82424. /** @hidden */
  82425. protected _isAnimationSheetEnabled: boolean;
  82426. /**
  82427. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82428. */
  82429. beginAnimationOnStart: boolean;
  82430. /**
  82431. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82432. */
  82433. beginAnimationFrom: number;
  82434. /**
  82435. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82436. */
  82437. beginAnimationTo: number;
  82438. /**
  82439. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82440. */
  82441. beginAnimationLoop: boolean;
  82442. /**
  82443. * Gets or sets a world offset applied to all particles
  82444. */
  82445. worldOffset: Vector3;
  82446. /**
  82447. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82448. */
  82449. isAnimationSheetEnabled: boolean;
  82450. /**
  82451. * Get hosting scene
  82452. * @returns the scene
  82453. */
  82454. getScene(): Scene;
  82455. /**
  82456. * You can use gravity if you want to give an orientation to your particles.
  82457. */
  82458. gravity: Vector3;
  82459. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82460. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82461. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82462. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82463. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82464. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82465. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82466. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82467. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82468. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82469. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82470. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82471. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82472. /**
  82473. * Defines the delay in milliseconds before starting the system (0 by default)
  82474. */
  82475. startDelay: number;
  82476. /**
  82477. * Gets the current list of drag gradients.
  82478. * You must use addDragGradient and removeDragGradient to udpate this list
  82479. * @returns the list of drag gradients
  82480. */
  82481. getDragGradients(): Nullable<Array<FactorGradient>>;
  82482. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82483. limitVelocityDamping: number;
  82484. /**
  82485. * Gets the current list of limit velocity gradients.
  82486. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82487. * @returns the list of limit velocity gradients
  82488. */
  82489. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82490. /**
  82491. * Gets the current list of color gradients.
  82492. * You must use addColorGradient and removeColorGradient to udpate this list
  82493. * @returns the list of color gradients
  82494. */
  82495. getColorGradients(): Nullable<Array<ColorGradient>>;
  82496. /**
  82497. * Gets the current list of size gradients.
  82498. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82499. * @returns the list of size gradients
  82500. */
  82501. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82502. /**
  82503. * Gets the current list of color remap gradients.
  82504. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82505. * @returns the list of color remap gradients
  82506. */
  82507. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82508. /**
  82509. * Gets the current list of alpha remap gradients.
  82510. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82511. * @returns the list of alpha remap gradients
  82512. */
  82513. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82514. /**
  82515. * Gets the current list of life time gradients.
  82516. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82517. * @returns the list of life time gradients
  82518. */
  82519. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82520. /**
  82521. * Gets the current list of angular speed gradients.
  82522. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82523. * @returns the list of angular speed gradients
  82524. */
  82525. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82526. /**
  82527. * Gets the current list of velocity gradients.
  82528. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82529. * @returns the list of velocity gradients
  82530. */
  82531. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82532. /**
  82533. * Gets the current list of start size gradients.
  82534. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82535. * @returns the list of start size gradients
  82536. */
  82537. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82538. /**
  82539. * Gets the current list of emit rate gradients.
  82540. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82541. * @returns the list of emit rate gradients
  82542. */
  82543. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82544. /**
  82545. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82546. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82547. */
  82548. direction1: Vector3;
  82549. /**
  82550. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82551. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82552. */
  82553. direction2: Vector3;
  82554. /**
  82555. * 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.
  82556. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82557. */
  82558. minEmitBox: Vector3;
  82559. /**
  82560. * 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.
  82561. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82562. */
  82563. maxEmitBox: Vector3;
  82564. /**
  82565. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82566. */
  82567. color1: Color4;
  82568. /**
  82569. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82570. */
  82571. color2: Color4;
  82572. /**
  82573. * Color the particle will have at the end of its lifetime
  82574. */
  82575. colorDead: Color4;
  82576. /**
  82577. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82578. */
  82579. textureMask: Color4;
  82580. /**
  82581. * The particle emitter type defines the emitter used by the particle system.
  82582. * It can be for example box, sphere, or cone...
  82583. */
  82584. particleEmitterType: IParticleEmitterType;
  82585. /** @hidden */
  82586. _isSubEmitter: boolean;
  82587. /**
  82588. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82589. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82590. */
  82591. billboardMode: number;
  82592. protected _isBillboardBased: boolean;
  82593. /**
  82594. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82595. */
  82596. isBillboardBased: boolean;
  82597. /**
  82598. * The scene the particle system belongs to.
  82599. */
  82600. protected _scene: Scene;
  82601. /**
  82602. * Local cache of defines for image processing.
  82603. */
  82604. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82605. /**
  82606. * Default configuration related to image processing available in the standard Material.
  82607. */
  82608. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82609. /**
  82610. * Gets the image processing configuration used either in this material.
  82611. */
  82612. /**
  82613. * Sets the Default image processing configuration used either in the this material.
  82614. *
  82615. * If sets to null, the scene one is in use.
  82616. */
  82617. imageProcessingConfiguration: ImageProcessingConfiguration;
  82618. /**
  82619. * Attaches a new image processing configuration to the Standard Material.
  82620. * @param configuration
  82621. */
  82622. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82623. /** @hidden */
  82624. protected _reset(): void;
  82625. /** @hidden */
  82626. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82627. /**
  82628. * Instantiates a particle system.
  82629. * 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.
  82630. * @param name The name of the particle system
  82631. */
  82632. constructor(name: string);
  82633. /**
  82634. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82635. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82636. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82637. * @returns the emitter
  82638. */
  82639. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82640. /**
  82641. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82642. * @param radius The radius of the hemisphere to emit from
  82643. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82644. * @returns the emitter
  82645. */
  82646. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82647. /**
  82648. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82649. * @param radius The radius of the sphere to emit from
  82650. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82651. * @returns the emitter
  82652. */
  82653. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82654. /**
  82655. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82656. * @param radius The radius of the sphere to emit from
  82657. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82658. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82659. * @returns the emitter
  82660. */
  82661. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82662. /**
  82663. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82664. * @param radius The radius of the emission cylinder
  82665. * @param height The height of the emission cylinder
  82666. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82667. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82668. * @returns the emitter
  82669. */
  82670. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82671. /**
  82672. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82673. * @param radius The radius of the cylinder to emit from
  82674. * @param height The height of the emission cylinder
  82675. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82676. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82677. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82678. * @returns the emitter
  82679. */
  82680. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82681. /**
  82682. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82683. * @param radius The radius of the cone to emit from
  82684. * @param angle The base angle of the cone
  82685. * @returns the emitter
  82686. */
  82687. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82688. /**
  82689. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82690. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82691. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82692. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82693. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82694. * @returns the emitter
  82695. */
  82696. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82697. }
  82698. }
  82699. declare module BABYLON {
  82700. /**
  82701. * Type of sub emitter
  82702. */
  82703. export enum SubEmitterType {
  82704. /**
  82705. * Attached to the particle over it's lifetime
  82706. */
  82707. ATTACHED = 0,
  82708. /**
  82709. * Created when the particle dies
  82710. */
  82711. END = 1
  82712. }
  82713. /**
  82714. * Sub emitter class used to emit particles from an existing particle
  82715. */
  82716. export class SubEmitter {
  82717. /**
  82718. * the particle system to be used by the sub emitter
  82719. */
  82720. particleSystem: ParticleSystem;
  82721. /**
  82722. * Type of the submitter (Default: END)
  82723. */
  82724. type: SubEmitterType;
  82725. /**
  82726. * 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)
  82727. * Note: This only is supported when using an emitter of type Mesh
  82728. */
  82729. inheritDirection: boolean;
  82730. /**
  82731. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82732. */
  82733. inheritedVelocityAmount: number;
  82734. /**
  82735. * Creates a sub emitter
  82736. * @param particleSystem the particle system to be used by the sub emitter
  82737. */
  82738. constructor(
  82739. /**
  82740. * the particle system to be used by the sub emitter
  82741. */
  82742. particleSystem: ParticleSystem);
  82743. /**
  82744. * Clones the sub emitter
  82745. * @returns the cloned sub emitter
  82746. */
  82747. clone(): SubEmitter;
  82748. /**
  82749. * Serialize current object to a JSON object
  82750. * @returns the serialized object
  82751. */
  82752. serialize(): any;
  82753. /** @hidden */
  82754. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82755. /**
  82756. * Creates a new SubEmitter from a serialized JSON version
  82757. * @param serializationObject defines the JSON object to read from
  82758. * @param scene defines the hosting scene
  82759. * @param rootUrl defines the rootUrl for data loading
  82760. * @returns a new SubEmitter
  82761. */
  82762. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82763. /** Release associated resources */
  82764. dispose(): void;
  82765. }
  82766. }
  82767. declare module BABYLON {
  82768. /** @hidden */
  82769. export var clipPlaneFragmentDeclaration: {
  82770. name: string;
  82771. shader: string;
  82772. };
  82773. }
  82774. declare module BABYLON {
  82775. /** @hidden */
  82776. export var imageProcessingDeclaration: {
  82777. name: string;
  82778. shader: string;
  82779. };
  82780. }
  82781. declare module BABYLON {
  82782. /** @hidden */
  82783. export var imageProcessingFunctions: {
  82784. name: string;
  82785. shader: string;
  82786. };
  82787. }
  82788. declare module BABYLON {
  82789. /** @hidden */
  82790. export var clipPlaneFragment: {
  82791. name: string;
  82792. shader: string;
  82793. };
  82794. }
  82795. declare module BABYLON {
  82796. /** @hidden */
  82797. export var particlesPixelShader: {
  82798. name: string;
  82799. shader: string;
  82800. };
  82801. }
  82802. declare module BABYLON {
  82803. /** @hidden */
  82804. export var clipPlaneVertexDeclaration: {
  82805. name: string;
  82806. shader: string;
  82807. };
  82808. }
  82809. declare module BABYLON {
  82810. /** @hidden */
  82811. export var clipPlaneVertex: {
  82812. name: string;
  82813. shader: string;
  82814. };
  82815. }
  82816. declare module BABYLON {
  82817. /** @hidden */
  82818. export var particlesVertexShader: {
  82819. name: string;
  82820. shader: string;
  82821. };
  82822. }
  82823. declare module BABYLON {
  82824. /**
  82825. * This represents a particle system in Babylon.
  82826. * 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.
  82827. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82828. * @example https://doc.babylonjs.com/babylon101/particles
  82829. */
  82830. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82831. /**
  82832. * Billboard mode will only apply to Y axis
  82833. */
  82834. static readonly BILLBOARDMODE_Y: number;
  82835. /**
  82836. * Billboard mode will apply to all axes
  82837. */
  82838. static readonly BILLBOARDMODE_ALL: number;
  82839. /**
  82840. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82841. */
  82842. static readonly BILLBOARDMODE_STRETCHED: number;
  82843. /**
  82844. * This function can be defined to provide custom update for active particles.
  82845. * This function will be called instead of regular update (age, position, color, etc.).
  82846. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82847. */
  82848. updateFunction: (particles: Particle[]) => void;
  82849. private _emitterWorldMatrix;
  82850. /**
  82851. * This function can be defined to specify initial direction for every new particle.
  82852. * It by default use the emitterType defined function
  82853. */
  82854. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82855. /**
  82856. * This function can be defined to specify initial position for every new particle.
  82857. * It by default use the emitterType defined function
  82858. */
  82859. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82860. /**
  82861. * @hidden
  82862. */
  82863. _inheritedVelocityOffset: Vector3;
  82864. /**
  82865. * An event triggered when the system is disposed
  82866. */
  82867. onDisposeObservable: Observable<ParticleSystem>;
  82868. private _onDisposeObserver;
  82869. /**
  82870. * Sets a callback that will be triggered when the system is disposed
  82871. */
  82872. onDispose: () => void;
  82873. private _particles;
  82874. private _epsilon;
  82875. private _capacity;
  82876. private _stockParticles;
  82877. private _newPartsExcess;
  82878. private _vertexData;
  82879. private _vertexBuffer;
  82880. private _vertexBuffers;
  82881. private _spriteBuffer;
  82882. private _indexBuffer;
  82883. private _effect;
  82884. private _customEffect;
  82885. private _cachedDefines;
  82886. private _scaledColorStep;
  82887. private _colorDiff;
  82888. private _scaledDirection;
  82889. private _scaledGravity;
  82890. private _currentRenderId;
  82891. private _alive;
  82892. private _useInstancing;
  82893. private _started;
  82894. private _stopped;
  82895. private _actualFrame;
  82896. private _scaledUpdateSpeed;
  82897. private _vertexBufferSize;
  82898. /** @hidden */
  82899. _currentEmitRateGradient: Nullable<FactorGradient>;
  82900. /** @hidden */
  82901. _currentEmitRate1: number;
  82902. /** @hidden */
  82903. _currentEmitRate2: number;
  82904. /** @hidden */
  82905. _currentStartSizeGradient: Nullable<FactorGradient>;
  82906. /** @hidden */
  82907. _currentStartSize1: number;
  82908. /** @hidden */
  82909. _currentStartSize2: number;
  82910. private readonly _rawTextureWidth;
  82911. private _rampGradientsTexture;
  82912. private _useRampGradients;
  82913. /** Gets or sets a boolean indicating that ramp gradients must be used
  82914. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82915. */
  82916. useRampGradients: boolean;
  82917. /**
  82918. * 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.
  82919. * 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: [])
  82920. */
  82921. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82922. private _subEmitters;
  82923. /**
  82924. * @hidden
  82925. * If the particle systems emitter should be disposed when the particle system is disposed
  82926. */
  82927. _disposeEmitterOnDispose: boolean;
  82928. /**
  82929. * The current active Sub-systems, this property is used by the root particle system only.
  82930. */
  82931. activeSubSystems: Array<ParticleSystem>;
  82932. private _rootParticleSystem;
  82933. /**
  82934. * Gets the current list of active particles
  82935. */
  82936. readonly particles: Particle[];
  82937. /**
  82938. * Returns the string "ParticleSystem"
  82939. * @returns a string containing the class name
  82940. */
  82941. getClassName(): string;
  82942. /**
  82943. * Instantiates a particle system.
  82944. * 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.
  82945. * @param name The name of the particle system
  82946. * @param capacity The max number of particles alive at the same time
  82947. * @param scene The scene the particle system belongs to
  82948. * @param customEffect a custom effect used to change the way particles are rendered by default
  82949. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82950. * @param epsilon Offset used to render the particles
  82951. */
  82952. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82953. private _addFactorGradient;
  82954. private _removeFactorGradient;
  82955. /**
  82956. * Adds a new life time gradient
  82957. * @param gradient defines the gradient to use (between 0 and 1)
  82958. * @param factor defines the life time factor to affect to the specified gradient
  82959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82960. * @returns the current particle system
  82961. */
  82962. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82963. /**
  82964. * Remove a specific life time gradient
  82965. * @param gradient defines the gradient to remove
  82966. * @returns the current particle system
  82967. */
  82968. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82969. /**
  82970. * Adds a new size gradient
  82971. * @param gradient defines the gradient to use (between 0 and 1)
  82972. * @param factor defines the size factor to affect to the specified gradient
  82973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82974. * @returns the current particle system
  82975. */
  82976. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82977. /**
  82978. * Remove a specific size gradient
  82979. * @param gradient defines the gradient to remove
  82980. * @returns the current particle system
  82981. */
  82982. removeSizeGradient(gradient: number): IParticleSystem;
  82983. /**
  82984. * Adds a new color remap gradient
  82985. * @param gradient defines the gradient to use (between 0 and 1)
  82986. * @param min defines the color remap minimal range
  82987. * @param max defines the color remap maximal range
  82988. * @returns the current particle system
  82989. */
  82990. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82991. /**
  82992. * Remove a specific color remap gradient
  82993. * @param gradient defines the gradient to remove
  82994. * @returns the current particle system
  82995. */
  82996. removeColorRemapGradient(gradient: number): IParticleSystem;
  82997. /**
  82998. * Adds a new alpha remap gradient
  82999. * @param gradient defines the gradient to use (between 0 and 1)
  83000. * @param min defines the alpha remap minimal range
  83001. * @param max defines the alpha remap maximal range
  83002. * @returns the current particle system
  83003. */
  83004. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83005. /**
  83006. * Remove a specific alpha remap gradient
  83007. * @param gradient defines the gradient to remove
  83008. * @returns the current particle system
  83009. */
  83010. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  83011. /**
  83012. * Adds a new angular speed gradient
  83013. * @param gradient defines the gradient to use (between 0 and 1)
  83014. * @param factor defines the angular speed to affect to the specified gradient
  83015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83016. * @returns the current particle system
  83017. */
  83018. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83019. /**
  83020. * Remove a specific angular speed gradient
  83021. * @param gradient defines the gradient to remove
  83022. * @returns the current particle system
  83023. */
  83024. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83025. /**
  83026. * Adds a new velocity gradient
  83027. * @param gradient defines the gradient to use (between 0 and 1)
  83028. * @param factor defines the velocity to affect to the specified gradient
  83029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83030. * @returns the current particle system
  83031. */
  83032. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83033. /**
  83034. * Remove a specific velocity gradient
  83035. * @param gradient defines the gradient to remove
  83036. * @returns the current particle system
  83037. */
  83038. removeVelocityGradient(gradient: number): IParticleSystem;
  83039. /**
  83040. * Adds a new limit velocity gradient
  83041. * @param gradient defines the gradient to use (between 0 and 1)
  83042. * @param factor defines the limit velocity value to affect to the specified gradient
  83043. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83044. * @returns the current particle system
  83045. */
  83046. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83047. /**
  83048. * Remove a specific limit velocity gradient
  83049. * @param gradient defines the gradient to remove
  83050. * @returns the current particle system
  83051. */
  83052. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83053. /**
  83054. * Adds a new drag gradient
  83055. * @param gradient defines the gradient to use (between 0 and 1)
  83056. * @param factor defines the drag value to affect to the specified gradient
  83057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83058. * @returns the current particle system
  83059. */
  83060. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83061. /**
  83062. * Remove a specific drag gradient
  83063. * @param gradient defines the gradient to remove
  83064. * @returns the current particle system
  83065. */
  83066. removeDragGradient(gradient: number): IParticleSystem;
  83067. /**
  83068. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83069. * @param gradient defines the gradient to use (between 0 and 1)
  83070. * @param factor defines the emit rate value to affect to the specified gradient
  83071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83072. * @returns the current particle system
  83073. */
  83074. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83075. /**
  83076. * Remove a specific emit rate gradient
  83077. * @param gradient defines the gradient to remove
  83078. * @returns the current particle system
  83079. */
  83080. removeEmitRateGradient(gradient: number): IParticleSystem;
  83081. /**
  83082. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83083. * @param gradient defines the gradient to use (between 0 and 1)
  83084. * @param factor defines the start size value to affect to the specified gradient
  83085. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83086. * @returns the current particle system
  83087. */
  83088. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83089. /**
  83090. * Remove a specific start size gradient
  83091. * @param gradient defines the gradient to remove
  83092. * @returns the current particle system
  83093. */
  83094. removeStartSizeGradient(gradient: number): IParticleSystem;
  83095. private _createRampGradientTexture;
  83096. /**
  83097. * Gets the current list of ramp gradients.
  83098. * You must use addRampGradient and removeRampGradient to udpate this list
  83099. * @returns the list of ramp gradients
  83100. */
  83101. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83102. /**
  83103. * Adds a new ramp gradient used to remap particle colors
  83104. * @param gradient defines the gradient to use (between 0 and 1)
  83105. * @param color defines the color to affect to the specified gradient
  83106. * @returns the current particle system
  83107. */
  83108. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  83109. /**
  83110. * Remove a specific ramp gradient
  83111. * @param gradient defines the gradient to remove
  83112. * @returns the current particle system
  83113. */
  83114. removeRampGradient(gradient: number): ParticleSystem;
  83115. /**
  83116. * Adds a new color gradient
  83117. * @param gradient defines the gradient to use (between 0 and 1)
  83118. * @param color1 defines the color to affect to the specified gradient
  83119. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83120. * @returns this particle system
  83121. */
  83122. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83123. /**
  83124. * Remove a specific color gradient
  83125. * @param gradient defines the gradient to remove
  83126. * @returns this particle system
  83127. */
  83128. removeColorGradient(gradient: number): IParticleSystem;
  83129. private _fetchR;
  83130. protected _reset(): void;
  83131. private _resetEffect;
  83132. private _createVertexBuffers;
  83133. private _createIndexBuffer;
  83134. /**
  83135. * Gets the maximum number of particles active at the same time.
  83136. * @returns The max number of active particles.
  83137. */
  83138. getCapacity(): number;
  83139. /**
  83140. * Gets whether there are still active particles in the system.
  83141. * @returns True if it is alive, otherwise false.
  83142. */
  83143. isAlive(): boolean;
  83144. /**
  83145. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83146. * @returns True if it has been started, otherwise false.
  83147. */
  83148. isStarted(): boolean;
  83149. private _prepareSubEmitterInternalArray;
  83150. /**
  83151. * Starts the particle system and begins to emit
  83152. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  83153. */
  83154. start(delay?: number): void;
  83155. /**
  83156. * Stops the particle system.
  83157. * @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.
  83158. */
  83159. stop(stopSubEmitters?: boolean): void;
  83160. /**
  83161. * Remove all active particles
  83162. */
  83163. reset(): void;
  83164. /**
  83165. * @hidden (for internal use only)
  83166. */
  83167. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  83168. /**
  83169. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  83170. * Its lifetime will start back at 0.
  83171. */
  83172. recycleParticle: (particle: Particle) => void;
  83173. private _stopSubEmitters;
  83174. private _createParticle;
  83175. private _removeFromRoot;
  83176. private _emitFromParticle;
  83177. private _update;
  83178. /** @hidden */
  83179. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  83180. /** @hidden */
  83181. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  83182. /** @hidden */
  83183. private _getEffect;
  83184. /**
  83185. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  83186. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  83187. */
  83188. animate(preWarmOnly?: boolean): void;
  83189. private _appendParticleVertices;
  83190. /**
  83191. * Rebuilds the particle system.
  83192. */
  83193. rebuild(): void;
  83194. /**
  83195. * Is this system ready to be used/rendered
  83196. * @return true if the system is ready
  83197. */
  83198. isReady(): boolean;
  83199. private _render;
  83200. /**
  83201. * Renders the particle system in its current state.
  83202. * @returns the current number of particles
  83203. */
  83204. render(): number;
  83205. /**
  83206. * Disposes the particle system and free the associated resources
  83207. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83208. */
  83209. dispose(disposeTexture?: boolean): void;
  83210. /**
  83211. * Clones the particle system.
  83212. * @param name The name of the cloned object
  83213. * @param newEmitter The new emitter to use
  83214. * @returns the cloned particle system
  83215. */
  83216. clone(name: string, newEmitter: any): ParticleSystem;
  83217. /**
  83218. * Serializes the particle system to a JSON object.
  83219. * @returns the JSON object
  83220. */
  83221. serialize(): any;
  83222. /** @hidden */
  83223. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  83224. /** @hidden */
  83225. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  83226. /**
  83227. * Parses a JSON object to create a particle system.
  83228. * @param parsedParticleSystem The JSON object to parse
  83229. * @param scene The scene to create the particle system in
  83230. * @param rootUrl The root url to use to load external dependencies like texture
  83231. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  83232. * @returns the Parsed particle system
  83233. */
  83234. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  83235. }
  83236. }
  83237. declare module BABYLON {
  83238. /**
  83239. * A particle represents one of the element emitted by a particle system.
  83240. * This is mainly define by its coordinates, direction, velocity and age.
  83241. */
  83242. export class Particle {
  83243. /**
  83244. * The particle system the particle belongs to.
  83245. */
  83246. particleSystem: ParticleSystem;
  83247. private static _Count;
  83248. /**
  83249. * Unique ID of the particle
  83250. */
  83251. id: number;
  83252. /**
  83253. * The world position of the particle in the scene.
  83254. */
  83255. position: Vector3;
  83256. /**
  83257. * The world direction of the particle in the scene.
  83258. */
  83259. direction: Vector3;
  83260. /**
  83261. * The color of the particle.
  83262. */
  83263. color: Color4;
  83264. /**
  83265. * The color change of the particle per step.
  83266. */
  83267. colorStep: Color4;
  83268. /**
  83269. * Defines how long will the life of the particle be.
  83270. */
  83271. lifeTime: number;
  83272. /**
  83273. * The current age of the particle.
  83274. */
  83275. age: number;
  83276. /**
  83277. * The current size of the particle.
  83278. */
  83279. size: number;
  83280. /**
  83281. * The current scale of the particle.
  83282. */
  83283. scale: Vector2;
  83284. /**
  83285. * The current angle of the particle.
  83286. */
  83287. angle: number;
  83288. /**
  83289. * Defines how fast is the angle changing.
  83290. */
  83291. angularSpeed: number;
  83292. /**
  83293. * Defines the cell index used by the particle to be rendered from a sprite.
  83294. */
  83295. cellIndex: number;
  83296. /**
  83297. * The information required to support color remapping
  83298. */
  83299. remapData: Vector4;
  83300. /** @hidden */
  83301. _randomCellOffset?: number;
  83302. /** @hidden */
  83303. _initialDirection: Nullable<Vector3>;
  83304. /** @hidden */
  83305. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  83306. /** @hidden */
  83307. _initialStartSpriteCellID: number;
  83308. /** @hidden */
  83309. _initialEndSpriteCellID: number;
  83310. /** @hidden */
  83311. _currentColorGradient: Nullable<ColorGradient>;
  83312. /** @hidden */
  83313. _currentColor1: Color4;
  83314. /** @hidden */
  83315. _currentColor2: Color4;
  83316. /** @hidden */
  83317. _currentSizeGradient: Nullable<FactorGradient>;
  83318. /** @hidden */
  83319. _currentSize1: number;
  83320. /** @hidden */
  83321. _currentSize2: number;
  83322. /** @hidden */
  83323. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83324. /** @hidden */
  83325. _currentAngularSpeed1: number;
  83326. /** @hidden */
  83327. _currentAngularSpeed2: number;
  83328. /** @hidden */
  83329. _currentVelocityGradient: Nullable<FactorGradient>;
  83330. /** @hidden */
  83331. _currentVelocity1: number;
  83332. /** @hidden */
  83333. _currentVelocity2: number;
  83334. /** @hidden */
  83335. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83336. /** @hidden */
  83337. _currentLimitVelocity1: number;
  83338. /** @hidden */
  83339. _currentLimitVelocity2: number;
  83340. /** @hidden */
  83341. _currentDragGradient: Nullable<FactorGradient>;
  83342. /** @hidden */
  83343. _currentDrag1: number;
  83344. /** @hidden */
  83345. _currentDrag2: number;
  83346. /** @hidden */
  83347. _randomNoiseCoordinates1: Vector3;
  83348. /** @hidden */
  83349. _randomNoiseCoordinates2: Vector3;
  83350. /**
  83351. * Creates a new instance Particle
  83352. * @param particleSystem the particle system the particle belongs to
  83353. */
  83354. constructor(
  83355. /**
  83356. * The particle system the particle belongs to.
  83357. */
  83358. particleSystem: ParticleSystem);
  83359. private updateCellInfoFromSystem;
  83360. /**
  83361. * Defines how the sprite cell index is updated for the particle
  83362. */
  83363. updateCellIndex(): void;
  83364. /** @hidden */
  83365. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83366. /** @hidden */
  83367. _inheritParticleInfoToSubEmitters(): void;
  83368. /** @hidden */
  83369. _reset(): void;
  83370. /**
  83371. * Copy the properties of particle to another one.
  83372. * @param other the particle to copy the information to.
  83373. */
  83374. copyTo(other: Particle): void;
  83375. }
  83376. }
  83377. declare module BABYLON {
  83378. /**
  83379. * Particle emitter represents a volume emitting particles.
  83380. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83381. */
  83382. export interface IParticleEmitterType {
  83383. /**
  83384. * Called by the particle System when the direction is computed for the created particle.
  83385. * @param worldMatrix is the world matrix of the particle system
  83386. * @param directionToUpdate is the direction vector to update with the result
  83387. * @param particle is the particle we are computed the direction for
  83388. */
  83389. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83390. /**
  83391. * Called by the particle System when the position is computed for the created particle.
  83392. * @param worldMatrix is the world matrix of the particle system
  83393. * @param positionToUpdate is the position vector to update with the result
  83394. * @param particle is the particle we are computed the position for
  83395. */
  83396. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83397. /**
  83398. * Clones the current emitter and returns a copy of it
  83399. * @returns the new emitter
  83400. */
  83401. clone(): IParticleEmitterType;
  83402. /**
  83403. * Called by the GPUParticleSystem to setup the update shader
  83404. * @param effect defines the update shader
  83405. */
  83406. applyToShader(effect: Effect): void;
  83407. /**
  83408. * Returns a string to use to update the GPU particles update shader
  83409. * @returns the effect defines string
  83410. */
  83411. getEffectDefines(): string;
  83412. /**
  83413. * Returns a string representing the class name
  83414. * @returns a string containing the class name
  83415. */
  83416. getClassName(): string;
  83417. /**
  83418. * Serializes the particle system to a JSON object.
  83419. * @returns the JSON object
  83420. */
  83421. serialize(): any;
  83422. /**
  83423. * Parse properties from a JSON object
  83424. * @param serializationObject defines the JSON object
  83425. */
  83426. parse(serializationObject: any): void;
  83427. }
  83428. }
  83429. declare module BABYLON {
  83430. /**
  83431. * Particle emitter emitting particles from the inside of a box.
  83432. * It emits the particles randomly between 2 given directions.
  83433. */
  83434. export class BoxParticleEmitter implements IParticleEmitterType {
  83435. /**
  83436. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83437. */
  83438. direction1: Vector3;
  83439. /**
  83440. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83441. */
  83442. direction2: Vector3;
  83443. /**
  83444. * 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.
  83445. */
  83446. minEmitBox: Vector3;
  83447. /**
  83448. * 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.
  83449. */
  83450. maxEmitBox: Vector3;
  83451. /**
  83452. * Creates a new instance BoxParticleEmitter
  83453. */
  83454. constructor();
  83455. /**
  83456. * Called by the particle System when the direction is computed for the created particle.
  83457. * @param worldMatrix is the world matrix of the particle system
  83458. * @param directionToUpdate is the direction vector to update with the result
  83459. * @param particle is the particle we are computed the direction for
  83460. */
  83461. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83462. /**
  83463. * Called by the particle System when the position is computed for the created particle.
  83464. * @param worldMatrix is the world matrix of the particle system
  83465. * @param positionToUpdate is the position vector to update with the result
  83466. * @param particle is the particle we are computed the position for
  83467. */
  83468. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83469. /**
  83470. * Clones the current emitter and returns a copy of it
  83471. * @returns the new emitter
  83472. */
  83473. clone(): BoxParticleEmitter;
  83474. /**
  83475. * Called by the GPUParticleSystem to setup the update shader
  83476. * @param effect defines the update shader
  83477. */
  83478. applyToShader(effect: Effect): void;
  83479. /**
  83480. * Returns a string to use to update the GPU particles update shader
  83481. * @returns a string containng the defines string
  83482. */
  83483. getEffectDefines(): string;
  83484. /**
  83485. * Returns the string "BoxParticleEmitter"
  83486. * @returns a string containing the class name
  83487. */
  83488. getClassName(): string;
  83489. /**
  83490. * Serializes the particle system to a JSON object.
  83491. * @returns the JSON object
  83492. */
  83493. serialize(): any;
  83494. /**
  83495. * Parse properties from a JSON object
  83496. * @param serializationObject defines the JSON object
  83497. */
  83498. parse(serializationObject: any): void;
  83499. }
  83500. }
  83501. declare module BABYLON {
  83502. /**
  83503. * Particle emitter emitting particles from the inside of a cone.
  83504. * It emits the particles alongside the cone volume from the base to the particle.
  83505. * The emission direction might be randomized.
  83506. */
  83507. export class ConeParticleEmitter implements IParticleEmitterType {
  83508. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83509. directionRandomizer: number;
  83510. private _radius;
  83511. private _angle;
  83512. private _height;
  83513. /**
  83514. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83515. */
  83516. radiusRange: number;
  83517. /**
  83518. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83519. */
  83520. heightRange: number;
  83521. /**
  83522. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83523. */
  83524. emitFromSpawnPointOnly: boolean;
  83525. /**
  83526. * Gets or sets the radius of the emission cone
  83527. */
  83528. radius: number;
  83529. /**
  83530. * Gets or sets the angle of the emission cone
  83531. */
  83532. angle: number;
  83533. private _buildHeight;
  83534. /**
  83535. * Creates a new instance ConeParticleEmitter
  83536. * @param radius the radius of the emission cone (1 by default)
  83537. * @param angle the cone base angle (PI by default)
  83538. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83539. */
  83540. constructor(radius?: number, angle?: number,
  83541. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83542. directionRandomizer?: number);
  83543. /**
  83544. * Called by the particle System when the direction is computed for the created particle.
  83545. * @param worldMatrix is the world matrix of the particle system
  83546. * @param directionToUpdate is the direction vector to update with the result
  83547. * @param particle is the particle we are computed the direction for
  83548. */
  83549. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83550. /**
  83551. * Called by the particle System when the position is computed for the created particle.
  83552. * @param worldMatrix is the world matrix of the particle system
  83553. * @param positionToUpdate is the position vector to update with the result
  83554. * @param particle is the particle we are computed the position for
  83555. */
  83556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83557. /**
  83558. * Clones the current emitter and returns a copy of it
  83559. * @returns the new emitter
  83560. */
  83561. clone(): ConeParticleEmitter;
  83562. /**
  83563. * Called by the GPUParticleSystem to setup the update shader
  83564. * @param effect defines the update shader
  83565. */
  83566. applyToShader(effect: Effect): void;
  83567. /**
  83568. * Returns a string to use to update the GPU particles update shader
  83569. * @returns a string containng the defines string
  83570. */
  83571. getEffectDefines(): string;
  83572. /**
  83573. * Returns the string "ConeParticleEmitter"
  83574. * @returns a string containing the class name
  83575. */
  83576. getClassName(): string;
  83577. /**
  83578. * Serializes the particle system to a JSON object.
  83579. * @returns the JSON object
  83580. */
  83581. serialize(): any;
  83582. /**
  83583. * Parse properties from a JSON object
  83584. * @param serializationObject defines the JSON object
  83585. */
  83586. parse(serializationObject: any): void;
  83587. }
  83588. }
  83589. declare module BABYLON {
  83590. /**
  83591. * Particle emitter emitting particles from the inside of a cylinder.
  83592. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83593. */
  83594. export class CylinderParticleEmitter implements IParticleEmitterType {
  83595. /**
  83596. * The radius of the emission cylinder.
  83597. */
  83598. radius: number;
  83599. /**
  83600. * The height of the emission cylinder.
  83601. */
  83602. height: number;
  83603. /**
  83604. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83605. */
  83606. radiusRange: number;
  83607. /**
  83608. * How much to randomize the particle direction [0-1].
  83609. */
  83610. directionRandomizer: number;
  83611. /**
  83612. * Creates a new instance CylinderParticleEmitter
  83613. * @param radius the radius of the emission cylinder (1 by default)
  83614. * @param height the height of the emission cylinder (1 by default)
  83615. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83616. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83617. */
  83618. constructor(
  83619. /**
  83620. * The radius of the emission cylinder.
  83621. */
  83622. radius?: number,
  83623. /**
  83624. * The height of the emission cylinder.
  83625. */
  83626. height?: number,
  83627. /**
  83628. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83629. */
  83630. radiusRange?: number,
  83631. /**
  83632. * How much to randomize the particle direction [0-1].
  83633. */
  83634. directionRandomizer?: number);
  83635. /**
  83636. * Called by the particle System when the direction is computed for the created particle.
  83637. * @param worldMatrix is the world matrix of the particle system
  83638. * @param directionToUpdate is the direction vector to update with the result
  83639. * @param particle is the particle we are computed the direction for
  83640. */
  83641. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83642. /**
  83643. * Called by the particle System when the position is computed for the created particle.
  83644. * @param worldMatrix is the world matrix of the particle system
  83645. * @param positionToUpdate is the position vector to update with the result
  83646. * @param particle is the particle we are computed the position for
  83647. */
  83648. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83649. /**
  83650. * Clones the current emitter and returns a copy of it
  83651. * @returns the new emitter
  83652. */
  83653. clone(): CylinderParticleEmitter;
  83654. /**
  83655. * Called by the GPUParticleSystem to setup the update shader
  83656. * @param effect defines the update shader
  83657. */
  83658. applyToShader(effect: Effect): void;
  83659. /**
  83660. * Returns a string to use to update the GPU particles update shader
  83661. * @returns a string containng the defines string
  83662. */
  83663. getEffectDefines(): string;
  83664. /**
  83665. * Returns the string "CylinderParticleEmitter"
  83666. * @returns a string containing the class name
  83667. */
  83668. getClassName(): string;
  83669. /**
  83670. * Serializes the particle system to a JSON object.
  83671. * @returns the JSON object
  83672. */
  83673. serialize(): any;
  83674. /**
  83675. * Parse properties from a JSON object
  83676. * @param serializationObject defines the JSON object
  83677. */
  83678. parse(serializationObject: any): void;
  83679. }
  83680. /**
  83681. * Particle emitter emitting particles from the inside of a cylinder.
  83682. * It emits the particles randomly between two vectors.
  83683. */
  83684. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83685. /**
  83686. * The min limit of the emission direction.
  83687. */
  83688. direction1: Vector3;
  83689. /**
  83690. * The max limit of the emission direction.
  83691. */
  83692. direction2: Vector3;
  83693. /**
  83694. * Creates a new instance CylinderDirectedParticleEmitter
  83695. * @param radius the radius of the emission cylinder (1 by default)
  83696. * @param height the height of the emission cylinder (1 by default)
  83697. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83698. * @param direction1 the min limit of the emission direction (up vector by default)
  83699. * @param direction2 the max limit of the emission direction (up vector by default)
  83700. */
  83701. constructor(radius?: number, height?: number, radiusRange?: number,
  83702. /**
  83703. * The min limit of the emission direction.
  83704. */
  83705. direction1?: Vector3,
  83706. /**
  83707. * The max limit of the emission direction.
  83708. */
  83709. direction2?: Vector3);
  83710. /**
  83711. * Called by the particle System when the direction is computed for the created particle.
  83712. * @param worldMatrix is the world matrix of the particle system
  83713. * @param directionToUpdate is the direction vector to update with the result
  83714. * @param particle is the particle we are computed the direction for
  83715. */
  83716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83717. /**
  83718. * Clones the current emitter and returns a copy of it
  83719. * @returns the new emitter
  83720. */
  83721. clone(): CylinderDirectedParticleEmitter;
  83722. /**
  83723. * Called by the GPUParticleSystem to setup the update shader
  83724. * @param effect defines the update shader
  83725. */
  83726. applyToShader(effect: Effect): void;
  83727. /**
  83728. * Returns a string to use to update the GPU particles update shader
  83729. * @returns a string containng the defines string
  83730. */
  83731. getEffectDefines(): string;
  83732. /**
  83733. * Returns the string "CylinderDirectedParticleEmitter"
  83734. * @returns a string containing the class name
  83735. */
  83736. getClassName(): string;
  83737. /**
  83738. * Serializes the particle system to a JSON object.
  83739. * @returns the JSON object
  83740. */
  83741. serialize(): any;
  83742. /**
  83743. * Parse properties from a JSON object
  83744. * @param serializationObject defines the JSON object
  83745. */
  83746. parse(serializationObject: any): void;
  83747. }
  83748. }
  83749. declare module BABYLON {
  83750. /**
  83751. * Particle emitter emitting particles from the inside of a hemisphere.
  83752. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83753. */
  83754. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83755. /**
  83756. * The radius of the emission hemisphere.
  83757. */
  83758. radius: number;
  83759. /**
  83760. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83761. */
  83762. radiusRange: number;
  83763. /**
  83764. * How much to randomize the particle direction [0-1].
  83765. */
  83766. directionRandomizer: number;
  83767. /**
  83768. * Creates a new instance HemisphericParticleEmitter
  83769. * @param radius the radius of the emission hemisphere (1 by default)
  83770. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83771. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83772. */
  83773. constructor(
  83774. /**
  83775. * The radius of the emission hemisphere.
  83776. */
  83777. radius?: number,
  83778. /**
  83779. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83780. */
  83781. radiusRange?: number,
  83782. /**
  83783. * How much to randomize the particle direction [0-1].
  83784. */
  83785. directionRandomizer?: number);
  83786. /**
  83787. * Called by the particle System when the direction is computed for the created particle.
  83788. * @param worldMatrix is the world matrix of the particle system
  83789. * @param directionToUpdate is the direction vector to update with the result
  83790. * @param particle is the particle we are computed the direction for
  83791. */
  83792. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83793. /**
  83794. * Called by the particle System when the position is computed for the created particle.
  83795. * @param worldMatrix is the world matrix of the particle system
  83796. * @param positionToUpdate is the position vector to update with the result
  83797. * @param particle is the particle we are computed the position for
  83798. */
  83799. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83800. /**
  83801. * Clones the current emitter and returns a copy of it
  83802. * @returns the new emitter
  83803. */
  83804. clone(): HemisphericParticleEmitter;
  83805. /**
  83806. * Called by the GPUParticleSystem to setup the update shader
  83807. * @param effect defines the update shader
  83808. */
  83809. applyToShader(effect: Effect): void;
  83810. /**
  83811. * Returns a string to use to update the GPU particles update shader
  83812. * @returns a string containng the defines string
  83813. */
  83814. getEffectDefines(): string;
  83815. /**
  83816. * Returns the string "HemisphericParticleEmitter"
  83817. * @returns a string containing the class name
  83818. */
  83819. getClassName(): string;
  83820. /**
  83821. * Serializes the particle system to a JSON object.
  83822. * @returns the JSON object
  83823. */
  83824. serialize(): any;
  83825. /**
  83826. * Parse properties from a JSON object
  83827. * @param serializationObject defines the JSON object
  83828. */
  83829. parse(serializationObject: any): void;
  83830. }
  83831. }
  83832. declare module BABYLON {
  83833. /**
  83834. * Particle emitter emitting particles from a point.
  83835. * It emits the particles randomly between 2 given directions.
  83836. */
  83837. export class PointParticleEmitter implements IParticleEmitterType {
  83838. /**
  83839. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83840. */
  83841. direction1: Vector3;
  83842. /**
  83843. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83844. */
  83845. direction2: Vector3;
  83846. /**
  83847. * Creates a new instance PointParticleEmitter
  83848. */
  83849. constructor();
  83850. /**
  83851. * Called by the particle System when the direction is computed for the created particle.
  83852. * @param worldMatrix is the world matrix of the particle system
  83853. * @param directionToUpdate is the direction vector to update with the result
  83854. * @param particle is the particle we are computed the direction for
  83855. */
  83856. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83857. /**
  83858. * Called by the particle System when the position is computed for the created particle.
  83859. * @param worldMatrix is the world matrix of the particle system
  83860. * @param positionToUpdate is the position vector to update with the result
  83861. * @param particle is the particle we are computed the position for
  83862. */
  83863. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83864. /**
  83865. * Clones the current emitter and returns a copy of it
  83866. * @returns the new emitter
  83867. */
  83868. clone(): PointParticleEmitter;
  83869. /**
  83870. * Called by the GPUParticleSystem to setup the update shader
  83871. * @param effect defines the update shader
  83872. */
  83873. applyToShader(effect: Effect): void;
  83874. /**
  83875. * Returns a string to use to update the GPU particles update shader
  83876. * @returns a string containng the defines string
  83877. */
  83878. getEffectDefines(): string;
  83879. /**
  83880. * Returns the string "PointParticleEmitter"
  83881. * @returns a string containing the class name
  83882. */
  83883. getClassName(): string;
  83884. /**
  83885. * Serializes the particle system to a JSON object.
  83886. * @returns the JSON object
  83887. */
  83888. serialize(): any;
  83889. /**
  83890. * Parse properties from a JSON object
  83891. * @param serializationObject defines the JSON object
  83892. */
  83893. parse(serializationObject: any): void;
  83894. }
  83895. }
  83896. declare module BABYLON {
  83897. /**
  83898. * Particle emitter emitting particles from the inside of a sphere.
  83899. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83900. */
  83901. export class SphereParticleEmitter implements IParticleEmitterType {
  83902. /**
  83903. * The radius of the emission sphere.
  83904. */
  83905. radius: number;
  83906. /**
  83907. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83908. */
  83909. radiusRange: number;
  83910. /**
  83911. * How much to randomize the particle direction [0-1].
  83912. */
  83913. directionRandomizer: number;
  83914. /**
  83915. * Creates a new instance SphereParticleEmitter
  83916. * @param radius the radius of the emission sphere (1 by default)
  83917. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83918. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83919. */
  83920. constructor(
  83921. /**
  83922. * The radius of the emission sphere.
  83923. */
  83924. radius?: number,
  83925. /**
  83926. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83927. */
  83928. radiusRange?: number,
  83929. /**
  83930. * How much to randomize the particle direction [0-1].
  83931. */
  83932. directionRandomizer?: number);
  83933. /**
  83934. * Called by the particle System when the direction is computed for the created particle.
  83935. * @param worldMatrix is the world matrix of the particle system
  83936. * @param directionToUpdate is the direction vector to update with the result
  83937. * @param particle is the particle we are computed the direction for
  83938. */
  83939. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83940. /**
  83941. * Called by the particle System when the position is computed for the created particle.
  83942. * @param worldMatrix is the world matrix of the particle system
  83943. * @param positionToUpdate is the position vector to update with the result
  83944. * @param particle is the particle we are computed the position for
  83945. */
  83946. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83947. /**
  83948. * Clones the current emitter and returns a copy of it
  83949. * @returns the new emitter
  83950. */
  83951. clone(): SphereParticleEmitter;
  83952. /**
  83953. * Called by the GPUParticleSystem to setup the update shader
  83954. * @param effect defines the update shader
  83955. */
  83956. applyToShader(effect: Effect): void;
  83957. /**
  83958. * Returns a string to use to update the GPU particles update shader
  83959. * @returns a string containng the defines string
  83960. */
  83961. getEffectDefines(): string;
  83962. /**
  83963. * Returns the string "SphereParticleEmitter"
  83964. * @returns a string containing the class name
  83965. */
  83966. getClassName(): string;
  83967. /**
  83968. * Serializes the particle system to a JSON object.
  83969. * @returns the JSON object
  83970. */
  83971. serialize(): any;
  83972. /**
  83973. * Parse properties from a JSON object
  83974. * @param serializationObject defines the JSON object
  83975. */
  83976. parse(serializationObject: any): void;
  83977. }
  83978. /**
  83979. * Particle emitter emitting particles from the inside of a sphere.
  83980. * It emits the particles randomly between two vectors.
  83981. */
  83982. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83983. /**
  83984. * The min limit of the emission direction.
  83985. */
  83986. direction1: Vector3;
  83987. /**
  83988. * The max limit of the emission direction.
  83989. */
  83990. direction2: Vector3;
  83991. /**
  83992. * Creates a new instance SphereDirectedParticleEmitter
  83993. * @param radius the radius of the emission sphere (1 by default)
  83994. * @param direction1 the min limit of the emission direction (up vector by default)
  83995. * @param direction2 the max limit of the emission direction (up vector by default)
  83996. */
  83997. constructor(radius?: number,
  83998. /**
  83999. * The min limit of the emission direction.
  84000. */
  84001. direction1?: Vector3,
  84002. /**
  84003. * The max limit of the emission direction.
  84004. */
  84005. direction2?: Vector3);
  84006. /**
  84007. * Called by the particle System when the direction is computed for the created particle.
  84008. * @param worldMatrix is the world matrix of the particle system
  84009. * @param directionToUpdate is the direction vector to update with the result
  84010. * @param particle is the particle we are computed the direction for
  84011. */
  84012. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84013. /**
  84014. * Clones the current emitter and returns a copy of it
  84015. * @returns the new emitter
  84016. */
  84017. clone(): SphereDirectedParticleEmitter;
  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 a string containng the defines string
  84026. */
  84027. getEffectDefines(): string;
  84028. /**
  84029. * Returns the string "SphereDirectedParticleEmitter"
  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. * Interface representing a particle system in Babylon.js.
  84048. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  84049. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  84050. */
  84051. export interface IParticleSystem {
  84052. /**
  84053. * List of animations used by the particle system.
  84054. */
  84055. animations: Animation[];
  84056. /**
  84057. * The id of the Particle system.
  84058. */
  84059. id: string;
  84060. /**
  84061. * The name of the Particle system.
  84062. */
  84063. name: string;
  84064. /**
  84065. * The emitter represents the Mesh or position we are attaching the particle system to.
  84066. */
  84067. emitter: Nullable<AbstractMesh | Vector3>;
  84068. /**
  84069. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84070. */
  84071. isBillboardBased: boolean;
  84072. /**
  84073. * The rendering group used by the Particle system to chose when to render.
  84074. */
  84075. renderingGroupId: number;
  84076. /**
  84077. * The layer mask we are rendering the particles through.
  84078. */
  84079. layerMask: number;
  84080. /**
  84081. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84082. */
  84083. updateSpeed: number;
  84084. /**
  84085. * The amount of time the particle system is running (depends of the overall update speed).
  84086. */
  84087. targetStopDuration: number;
  84088. /**
  84089. * The texture used to render each particle. (this can be a spritesheet)
  84090. */
  84091. particleTexture: Nullable<Texture>;
  84092. /**
  84093. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  84094. */
  84095. blendMode: number;
  84096. /**
  84097. * Minimum life time of emitting particles.
  84098. */
  84099. minLifeTime: number;
  84100. /**
  84101. * Maximum life time of emitting particles.
  84102. */
  84103. maxLifeTime: number;
  84104. /**
  84105. * Minimum Size of emitting particles.
  84106. */
  84107. minSize: number;
  84108. /**
  84109. * Maximum Size of emitting particles.
  84110. */
  84111. maxSize: number;
  84112. /**
  84113. * Minimum scale of emitting particles on X axis.
  84114. */
  84115. minScaleX: number;
  84116. /**
  84117. * Maximum scale of emitting particles on X axis.
  84118. */
  84119. maxScaleX: number;
  84120. /**
  84121. * Minimum scale of emitting particles on Y axis.
  84122. */
  84123. minScaleY: number;
  84124. /**
  84125. * Maximum scale of emitting particles on Y axis.
  84126. */
  84127. maxScaleY: number;
  84128. /**
  84129. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84130. */
  84131. color1: Color4;
  84132. /**
  84133. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84134. */
  84135. color2: Color4;
  84136. /**
  84137. * Color the particle will have at the end of its lifetime.
  84138. */
  84139. colorDead: Color4;
  84140. /**
  84141. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  84142. */
  84143. emitRate: number;
  84144. /**
  84145. * You can use gravity if you want to give an orientation to your particles.
  84146. */
  84147. gravity: Vector3;
  84148. /**
  84149. * Minimum power of emitting particles.
  84150. */
  84151. minEmitPower: number;
  84152. /**
  84153. * Maximum power of emitting particles.
  84154. */
  84155. maxEmitPower: number;
  84156. /**
  84157. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84158. */
  84159. minAngularSpeed: number;
  84160. /**
  84161. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84162. */
  84163. maxAngularSpeed: number;
  84164. /**
  84165. * Gets or sets the minimal initial rotation in radians.
  84166. */
  84167. minInitialRotation: number;
  84168. /**
  84169. * Gets or sets the maximal initial rotation in radians.
  84170. */
  84171. maxInitialRotation: number;
  84172. /**
  84173. * The particle emitter type defines the emitter used by the particle system.
  84174. * It can be for example box, sphere, or cone...
  84175. */
  84176. particleEmitterType: Nullable<IParticleEmitterType>;
  84177. /**
  84178. * Defines the delay in milliseconds before starting the system (0 by default)
  84179. */
  84180. startDelay: number;
  84181. /**
  84182. * 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
  84183. */
  84184. preWarmCycles: number;
  84185. /**
  84186. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  84187. */
  84188. preWarmStepOffset: number;
  84189. /**
  84190. * 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)
  84191. */
  84192. spriteCellChangeSpeed: number;
  84193. /**
  84194. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84195. */
  84196. startSpriteCellID: number;
  84197. /**
  84198. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84199. */
  84200. endSpriteCellID: number;
  84201. /**
  84202. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84203. */
  84204. spriteCellWidth: number;
  84205. /**
  84206. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84207. */
  84208. spriteCellHeight: number;
  84209. /**
  84210. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84211. */
  84212. spriteRandomStartCell: boolean;
  84213. /**
  84214. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  84215. */
  84216. isAnimationSheetEnabled: boolean;
  84217. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84218. translationPivot: Vector2;
  84219. /**
  84220. * Gets or sets a texture used to add random noise to particle positions
  84221. */
  84222. noiseTexture: Nullable<BaseTexture>;
  84223. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84224. noiseStrength: Vector3;
  84225. /**
  84226. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84227. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84228. */
  84229. billboardMode: number;
  84230. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84231. limitVelocityDamping: number;
  84232. /**
  84233. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84234. */
  84235. beginAnimationOnStart: boolean;
  84236. /**
  84237. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84238. */
  84239. beginAnimationFrom: number;
  84240. /**
  84241. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84242. */
  84243. beginAnimationTo: number;
  84244. /**
  84245. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84246. */
  84247. beginAnimationLoop: boolean;
  84248. /**
  84249. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84250. */
  84251. disposeOnStop: boolean;
  84252. /**
  84253. * Gets the maximum number of particles active at the same time.
  84254. * @returns The max number of active particles.
  84255. */
  84256. getCapacity(): number;
  84257. /**
  84258. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84259. * @returns True if it has been started, otherwise false.
  84260. */
  84261. isStarted(): boolean;
  84262. /**
  84263. * Animates the particle system for this frame.
  84264. */
  84265. animate(): void;
  84266. /**
  84267. * Renders the particle system in its current state.
  84268. * @returns the current number of particles
  84269. */
  84270. render(): number;
  84271. /**
  84272. * Dispose the particle system and frees its associated resources.
  84273. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84274. */
  84275. dispose(disposeTexture?: boolean): void;
  84276. /**
  84277. * Clones the particle system.
  84278. * @param name The name of the cloned object
  84279. * @param newEmitter The new emitter to use
  84280. * @returns the cloned particle system
  84281. */
  84282. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  84283. /**
  84284. * Serializes the particle system to a JSON object.
  84285. * @returns the JSON object
  84286. */
  84287. serialize(): any;
  84288. /**
  84289. * Rebuild the particle system
  84290. */
  84291. rebuild(): void;
  84292. /**
  84293. * Starts the particle system and begins to emit
  84294. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  84295. */
  84296. start(delay?: number): void;
  84297. /**
  84298. * Stops the particle system.
  84299. */
  84300. stop(): void;
  84301. /**
  84302. * Remove all active particles
  84303. */
  84304. reset(): void;
  84305. /**
  84306. * Is this system ready to be used/rendered
  84307. * @return true if the system is ready
  84308. */
  84309. isReady(): boolean;
  84310. /**
  84311. * Adds a new color gradient
  84312. * @param gradient defines the gradient to use (between 0 and 1)
  84313. * @param color1 defines the color to affect to the specified gradient
  84314. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84315. * @returns the current particle system
  84316. */
  84317. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84318. /**
  84319. * Remove a specific color gradient
  84320. * @param gradient defines the gradient to remove
  84321. * @returns the current particle system
  84322. */
  84323. removeColorGradient(gradient: number): IParticleSystem;
  84324. /**
  84325. * Adds a new size gradient
  84326. * @param gradient defines the gradient to use (between 0 and 1)
  84327. * @param factor defines the size factor to affect to the specified gradient
  84328. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84329. * @returns the current particle system
  84330. */
  84331. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84332. /**
  84333. * Remove a specific size gradient
  84334. * @param gradient defines the gradient to remove
  84335. * @returns the current particle system
  84336. */
  84337. removeSizeGradient(gradient: number): IParticleSystem;
  84338. /**
  84339. * Gets the current list of color gradients.
  84340. * You must use addColorGradient and removeColorGradient to udpate this list
  84341. * @returns the list of color gradients
  84342. */
  84343. getColorGradients(): Nullable<Array<ColorGradient>>;
  84344. /**
  84345. * Gets the current list of size gradients.
  84346. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84347. * @returns the list of size gradients
  84348. */
  84349. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84350. /**
  84351. * Gets the current list of angular speed gradients.
  84352. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84353. * @returns the list of angular speed gradients
  84354. */
  84355. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84356. /**
  84357. * Adds a new angular speed gradient
  84358. * @param gradient defines the gradient to use (between 0 and 1)
  84359. * @param factor defines the angular speed to affect to the specified gradient
  84360. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84361. * @returns the current particle system
  84362. */
  84363. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84364. /**
  84365. * Remove a specific angular speed gradient
  84366. * @param gradient defines the gradient to remove
  84367. * @returns the current particle system
  84368. */
  84369. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84370. /**
  84371. * Gets the current list of velocity gradients.
  84372. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84373. * @returns the list of velocity gradients
  84374. */
  84375. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84376. /**
  84377. * Adds a new velocity gradient
  84378. * @param gradient defines the gradient to use (between 0 and 1)
  84379. * @param factor defines the velocity to affect to the specified gradient
  84380. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84381. * @returns the current particle system
  84382. */
  84383. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84384. /**
  84385. * Remove a specific velocity gradient
  84386. * @param gradient defines the gradient to remove
  84387. * @returns the current particle system
  84388. */
  84389. removeVelocityGradient(gradient: number): IParticleSystem;
  84390. /**
  84391. * Gets the current list of limit velocity gradients.
  84392. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84393. * @returns the list of limit velocity gradients
  84394. */
  84395. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84396. /**
  84397. * Adds a new limit velocity gradient
  84398. * @param gradient defines the gradient to use (between 0 and 1)
  84399. * @param factor defines the limit velocity to affect to the specified gradient
  84400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84401. * @returns the current particle system
  84402. */
  84403. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84404. /**
  84405. * Remove a specific limit velocity gradient
  84406. * @param gradient defines the gradient to remove
  84407. * @returns the current particle system
  84408. */
  84409. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84410. /**
  84411. * Adds a new drag gradient
  84412. * @param gradient defines the gradient to use (between 0 and 1)
  84413. * @param factor defines the drag to affect to the specified gradient
  84414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84415. * @returns the current particle system
  84416. */
  84417. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84418. /**
  84419. * Remove a specific drag gradient
  84420. * @param gradient defines the gradient to remove
  84421. * @returns the current particle system
  84422. */
  84423. removeDragGradient(gradient: number): IParticleSystem;
  84424. /**
  84425. * Gets the current list of drag gradients.
  84426. * You must use addDragGradient and removeDragGradient to udpate this list
  84427. * @returns the list of drag gradients
  84428. */
  84429. getDragGradients(): Nullable<Array<FactorGradient>>;
  84430. /**
  84431. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84432. * @param gradient defines the gradient to use (between 0 and 1)
  84433. * @param factor defines the emit rate to affect to the specified gradient
  84434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84435. * @returns the current particle system
  84436. */
  84437. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84438. /**
  84439. * Remove a specific emit rate gradient
  84440. * @param gradient defines the gradient to remove
  84441. * @returns the current particle system
  84442. */
  84443. removeEmitRateGradient(gradient: number): IParticleSystem;
  84444. /**
  84445. * Gets the current list of emit rate gradients.
  84446. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84447. * @returns the list of emit rate gradients
  84448. */
  84449. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84450. /**
  84451. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84452. * @param gradient defines the gradient to use (between 0 and 1)
  84453. * @param factor defines the start size to affect to the specified gradient
  84454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84455. * @returns the current particle system
  84456. */
  84457. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84458. /**
  84459. * Remove a specific start size gradient
  84460. * @param gradient defines the gradient to remove
  84461. * @returns the current particle system
  84462. */
  84463. removeStartSizeGradient(gradient: number): IParticleSystem;
  84464. /**
  84465. * Gets the current list of start size gradients.
  84466. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84467. * @returns the list of start size gradients
  84468. */
  84469. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84470. /**
  84471. * Adds a new life time gradient
  84472. * @param gradient defines the gradient to use (between 0 and 1)
  84473. * @param factor defines the life time factor to affect to the specified gradient
  84474. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84475. * @returns the current particle system
  84476. */
  84477. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84478. /**
  84479. * Remove a specific life time gradient
  84480. * @param gradient defines the gradient to remove
  84481. * @returns the current particle system
  84482. */
  84483. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84484. /**
  84485. * Gets the current list of life time gradients.
  84486. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84487. * @returns the list of life time gradients
  84488. */
  84489. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84490. /**
  84491. * Gets the current list of color gradients.
  84492. * You must use addColorGradient and removeColorGradient to udpate this list
  84493. * @returns the list of color gradients
  84494. */
  84495. getColorGradients(): Nullable<Array<ColorGradient>>;
  84496. /**
  84497. * Adds a new ramp gradient used to remap particle colors
  84498. * @param gradient defines the gradient to use (between 0 and 1)
  84499. * @param color defines the color to affect to the specified gradient
  84500. * @returns the current particle system
  84501. */
  84502. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84503. /**
  84504. * Gets the current list of ramp gradients.
  84505. * You must use addRampGradient and removeRampGradient to udpate this list
  84506. * @returns the list of ramp gradients
  84507. */
  84508. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84509. /** Gets or sets a boolean indicating that ramp gradients must be used
  84510. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84511. */
  84512. useRampGradients: boolean;
  84513. /**
  84514. * Adds a new color remap gradient
  84515. * @param gradient defines the gradient to use (between 0 and 1)
  84516. * @param min defines the color remap minimal range
  84517. * @param max defines the color remap maximal range
  84518. * @returns the current particle system
  84519. */
  84520. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84521. /**
  84522. * Gets the current list of color remap gradients.
  84523. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84524. * @returns the list of color remap gradients
  84525. */
  84526. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84527. /**
  84528. * Adds a new alpha remap gradient
  84529. * @param gradient defines the gradient to use (between 0 and 1)
  84530. * @param min defines the alpha remap minimal range
  84531. * @param max defines the alpha remap maximal range
  84532. * @returns the current particle system
  84533. */
  84534. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84535. /**
  84536. * Gets the current list of alpha remap gradients.
  84537. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84538. * @returns the list of alpha remap gradients
  84539. */
  84540. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84541. /**
  84542. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84543. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84544. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84545. * @returns the emitter
  84546. */
  84547. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84548. /**
  84549. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84550. * @param radius The radius of the hemisphere to emit from
  84551. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84552. * @returns the emitter
  84553. */
  84554. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84555. /**
  84556. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84557. * @param radius The radius of the sphere to emit from
  84558. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84559. * @returns the emitter
  84560. */
  84561. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84562. /**
  84563. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84564. * @param radius The radius of the sphere to emit from
  84565. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84566. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84567. * @returns the emitter
  84568. */
  84569. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84570. /**
  84571. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84572. * @param radius The radius of the emission cylinder
  84573. * @param height The height of the emission cylinder
  84574. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84575. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84576. * @returns the emitter
  84577. */
  84578. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84579. /**
  84580. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84581. * @param radius The radius of the cylinder to emit from
  84582. * @param height The height of the emission cylinder
  84583. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84584. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84585. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84586. * @returns the emitter
  84587. */
  84588. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84589. /**
  84590. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84591. * @param radius The radius of the cone to emit from
  84592. * @param angle The base angle of the cone
  84593. * @returns the emitter
  84594. */
  84595. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84596. /**
  84597. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84598. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84599. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84600. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84601. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84602. * @returns the emitter
  84603. */
  84604. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84605. /**
  84606. * Get hosting scene
  84607. * @returns the scene
  84608. */
  84609. getScene(): Scene;
  84610. }
  84611. }
  84612. declare module BABYLON {
  84613. /**
  84614. * Creates an instance based on a source mesh.
  84615. */
  84616. export class InstancedMesh extends AbstractMesh {
  84617. private _sourceMesh;
  84618. private _currentLOD;
  84619. /** @hidden */
  84620. _indexInSourceMeshInstanceArray: number;
  84621. constructor(name: string, source: Mesh);
  84622. /**
  84623. * Returns the string "InstancedMesh".
  84624. */
  84625. getClassName(): string;
  84626. /** Gets the list of lights affecting that mesh */
  84627. readonly lightSources: Light[];
  84628. _resyncLightSources(): void;
  84629. _resyncLighSource(light: Light): void;
  84630. _removeLightSource(light: Light, dispose: boolean): void;
  84631. /**
  84632. * If the source mesh receives shadows
  84633. */
  84634. readonly receiveShadows: boolean;
  84635. /**
  84636. * The material of the source mesh
  84637. */
  84638. readonly material: Nullable<Material>;
  84639. /**
  84640. * Visibility of the source mesh
  84641. */
  84642. readonly visibility: number;
  84643. /**
  84644. * Skeleton of the source mesh
  84645. */
  84646. readonly skeleton: Nullable<Skeleton>;
  84647. /**
  84648. * Rendering ground id of the source mesh
  84649. */
  84650. renderingGroupId: number;
  84651. /**
  84652. * Returns the total number of vertices (integer).
  84653. */
  84654. getTotalVertices(): number;
  84655. /**
  84656. * Returns a positive integer : the total number of indices in this mesh geometry.
  84657. * @returns the numner of indices or zero if the mesh has no geometry.
  84658. */
  84659. getTotalIndices(): number;
  84660. /**
  84661. * The source mesh of the instance
  84662. */
  84663. readonly sourceMesh: Mesh;
  84664. /**
  84665. * Is this node ready to be used/rendered
  84666. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84667. * @return {boolean} is it ready
  84668. */
  84669. isReady(completeCheck?: boolean): boolean;
  84670. /**
  84671. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84672. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  84673. * @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.
  84674. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  84675. */
  84676. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  84677. /**
  84678. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84679. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84680. * The `data` are either a numeric array either a Float32Array.
  84681. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  84682. * 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).
  84683. * Note that a new underlying VertexBuffer object is created each call.
  84684. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84685. *
  84686. * Possible `kind` values :
  84687. * - VertexBuffer.PositionKind
  84688. * - VertexBuffer.UVKind
  84689. * - VertexBuffer.UV2Kind
  84690. * - VertexBuffer.UV3Kind
  84691. * - VertexBuffer.UV4Kind
  84692. * - VertexBuffer.UV5Kind
  84693. * - VertexBuffer.UV6Kind
  84694. * - VertexBuffer.ColorKind
  84695. * - VertexBuffer.MatricesIndicesKind
  84696. * - VertexBuffer.MatricesIndicesExtraKind
  84697. * - VertexBuffer.MatricesWeightsKind
  84698. * - VertexBuffer.MatricesWeightsExtraKind
  84699. *
  84700. * Returns the Mesh.
  84701. */
  84702. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84703. /**
  84704. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84705. * If the mesh has no geometry, it is simply returned as it is.
  84706. * The `data` are either a numeric array either a Float32Array.
  84707. * No new underlying VertexBuffer object is created.
  84708. * 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.
  84709. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  84710. *
  84711. * Possible `kind` values :
  84712. * - VertexBuffer.PositionKind
  84713. * - VertexBuffer.UVKind
  84714. * - VertexBuffer.UV2Kind
  84715. * - VertexBuffer.UV3Kind
  84716. * - VertexBuffer.UV4Kind
  84717. * - VertexBuffer.UV5Kind
  84718. * - VertexBuffer.UV6Kind
  84719. * - VertexBuffer.ColorKind
  84720. * - VertexBuffer.MatricesIndicesKind
  84721. * - VertexBuffer.MatricesIndicesExtraKind
  84722. * - VertexBuffer.MatricesWeightsKind
  84723. * - VertexBuffer.MatricesWeightsExtraKind
  84724. *
  84725. * Returns the Mesh.
  84726. */
  84727. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  84728. /**
  84729. * Sets the mesh indices.
  84730. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  84731. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84732. * This method creates a new index buffer each call.
  84733. * Returns the Mesh.
  84734. */
  84735. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  84736. /**
  84737. * Boolean : True if the mesh owns the requested kind of data.
  84738. */
  84739. isVerticesDataPresent(kind: string): boolean;
  84740. /**
  84741. * Returns an array of indices (IndicesArray).
  84742. */
  84743. getIndices(): Nullable<IndicesArray>;
  84744. readonly _positions: Nullable<Vector3[]>;
  84745. /**
  84746. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84747. * This means the mesh underlying bounding box and sphere are recomputed.
  84748. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84749. * @returns the current mesh
  84750. */
  84751. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  84752. /** @hidden */
  84753. _preActivate(): InstancedMesh;
  84754. /** @hidden */
  84755. _activate(renderId: number, intermediateRendering: boolean): boolean;
  84756. /** @hidden */
  84757. _postActivate(): void;
  84758. getWorldMatrix(): Matrix;
  84759. readonly isAnInstance: boolean;
  84760. /**
  84761. * Returns the current associated LOD AbstractMesh.
  84762. */
  84763. getLOD(camera: Camera): AbstractMesh;
  84764. /** @hidden */
  84765. _syncSubMeshes(): InstancedMesh;
  84766. /** @hidden */
  84767. _generatePointsArray(): boolean;
  84768. /**
  84769. * Creates a new InstancedMesh from the current mesh.
  84770. * - name (string) : the cloned mesh name
  84771. * - newParent (optional Node) : the optional Node to parent the clone to.
  84772. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  84773. *
  84774. * Returns the clone.
  84775. */
  84776. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84777. /**
  84778. * Disposes the InstancedMesh.
  84779. * Returns nothing.
  84780. */
  84781. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84782. }
  84783. }
  84784. declare module BABYLON {
  84785. /**
  84786. * Defines the options associated with the creation of a shader material.
  84787. */
  84788. export interface IShaderMaterialOptions {
  84789. /**
  84790. * Does the material work in alpha blend mode
  84791. */
  84792. needAlphaBlending: boolean;
  84793. /**
  84794. * Does the material work in alpha test mode
  84795. */
  84796. needAlphaTesting: boolean;
  84797. /**
  84798. * The list of attribute names used in the shader
  84799. */
  84800. attributes: string[];
  84801. /**
  84802. * The list of unifrom names used in the shader
  84803. */
  84804. uniforms: string[];
  84805. /**
  84806. * The list of UBO names used in the shader
  84807. */
  84808. uniformBuffers: string[];
  84809. /**
  84810. * The list of sampler names used in the shader
  84811. */
  84812. samplers: string[];
  84813. /**
  84814. * The list of defines used in the shader
  84815. */
  84816. defines: string[];
  84817. }
  84818. /**
  84819. * 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.
  84820. *
  84821. * This returned material effects how the mesh will look based on the code in the shaders.
  84822. *
  84823. * @see http://doc.babylonjs.com/how_to/shader_material
  84824. */
  84825. export class ShaderMaterial extends Material {
  84826. private _shaderPath;
  84827. private _options;
  84828. private _textures;
  84829. private _textureArrays;
  84830. private _floats;
  84831. private _ints;
  84832. private _floatsArrays;
  84833. private _colors3;
  84834. private _colors3Arrays;
  84835. private _colors4;
  84836. private _colors4Arrays;
  84837. private _vectors2;
  84838. private _vectors3;
  84839. private _vectors4;
  84840. private _matrices;
  84841. private _matrices3x3;
  84842. private _matrices2x2;
  84843. private _vectors2Arrays;
  84844. private _vectors3Arrays;
  84845. private _vectors4Arrays;
  84846. private _cachedWorldViewMatrix;
  84847. private _cachedWorldViewProjectionMatrix;
  84848. private _renderId;
  84849. /**
  84850. * Instantiate a new shader material.
  84851. * 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.
  84852. * This returned material effects how the mesh will look based on the code in the shaders.
  84853. * @see http://doc.babylonjs.com/how_to/shader_material
  84854. * @param name Define the name of the material in the scene
  84855. * @param scene Define the scene the material belongs to
  84856. * @param shaderPath Defines the route to the shader code in one of three ways:
  84857. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  84858. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  84859. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  84860. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  84861. * @param options Define the options used to create the shader
  84862. */
  84863. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  84864. /**
  84865. * Gets the options used to compile the shader.
  84866. * They can be modified to trigger a new compilation
  84867. */
  84868. readonly options: IShaderMaterialOptions;
  84869. /**
  84870. * Gets the current class name of the material e.g. "ShaderMaterial"
  84871. * Mainly use in serialization.
  84872. * @returns the class name
  84873. */
  84874. getClassName(): string;
  84875. /**
  84876. * Specifies if the material will require alpha blending
  84877. * @returns a boolean specifying if alpha blending is needed
  84878. */
  84879. needAlphaBlending(): boolean;
  84880. /**
  84881. * Specifies if this material should be rendered in alpha test mode
  84882. * @returns a boolean specifying if an alpha test is needed.
  84883. */
  84884. needAlphaTesting(): boolean;
  84885. private _checkUniform;
  84886. /**
  84887. * Set a texture in the shader.
  84888. * @param name Define the name of the uniform samplers as defined in the shader
  84889. * @param texture Define the texture to bind to this sampler
  84890. * @return the material itself allowing "fluent" like uniform updates
  84891. */
  84892. setTexture(name: string, texture: Texture): ShaderMaterial;
  84893. /**
  84894. * Set a texture array in the shader.
  84895. * @param name Define the name of the uniform sampler array as defined in the shader
  84896. * @param textures Define the list of textures to bind to this sampler
  84897. * @return the material itself allowing "fluent" like uniform updates
  84898. */
  84899. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  84900. /**
  84901. * Set a float in the shader.
  84902. * @param name Define the name of the uniform as defined in the shader
  84903. * @param value Define the value to give to the uniform
  84904. * @return the material itself allowing "fluent" like uniform updates
  84905. */
  84906. setFloat(name: string, value: number): ShaderMaterial;
  84907. /**
  84908. * Set a int in the shader.
  84909. * @param name Define the name of the uniform as defined in the shader
  84910. * @param value Define the value to give to the uniform
  84911. * @return the material itself allowing "fluent" like uniform updates
  84912. */
  84913. setInt(name: string, value: number): ShaderMaterial;
  84914. /**
  84915. * Set an array of floats in the shader.
  84916. * @param name Define the name of the uniform as defined in the shader
  84917. * @param value Define the value to give to the uniform
  84918. * @return the material itself allowing "fluent" like uniform updates
  84919. */
  84920. setFloats(name: string, value: number[]): ShaderMaterial;
  84921. /**
  84922. * Set a vec3 in the shader from a Color3.
  84923. * @param name Define the name of the uniform as defined in the shader
  84924. * @param value Define the value to give to the uniform
  84925. * @return the material itself allowing "fluent" like uniform updates
  84926. */
  84927. setColor3(name: string, value: Color3): ShaderMaterial;
  84928. /**
  84929. * Set a vec3 array in the shader from a Color3 array.
  84930. * @param name Define the name of the uniform as defined in the shader
  84931. * @param value Define the value to give to the uniform
  84932. * @return the material itself allowing "fluent" like uniform updates
  84933. */
  84934. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  84935. /**
  84936. * Set a vec4 in the shader from a Color4.
  84937. * @param name Define the name of the uniform as defined in the shader
  84938. * @param value Define the value to give to the uniform
  84939. * @return the material itself allowing "fluent" like uniform updates
  84940. */
  84941. setColor4(name: string, value: Color4): ShaderMaterial;
  84942. /**
  84943. * Set a vec4 array in the shader from a Color4 array.
  84944. * @param name Define the name of the uniform as defined in the shader
  84945. * @param value Define the value to give to the uniform
  84946. * @return the material itself allowing "fluent" like uniform updates
  84947. */
  84948. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  84949. /**
  84950. * Set a vec2 in the shader from a Vector2.
  84951. * @param name Define the name of the uniform as defined in the shader
  84952. * @param value Define the value to give to the uniform
  84953. * @return the material itself allowing "fluent" like uniform updates
  84954. */
  84955. setVector2(name: string, value: Vector2): ShaderMaterial;
  84956. /**
  84957. * Set a vec3 in the shader from a Vector3.
  84958. * @param name Define the name of the uniform as defined in the shader
  84959. * @param value Define the value to give to the uniform
  84960. * @return the material itself allowing "fluent" like uniform updates
  84961. */
  84962. setVector3(name: string, value: Vector3): ShaderMaterial;
  84963. /**
  84964. * Set a vec4 in the shader from a Vector4.
  84965. * @param name Define the name of the uniform as defined in the shader
  84966. * @param value Define the value to give to the uniform
  84967. * @return the material itself allowing "fluent" like uniform updates
  84968. */
  84969. setVector4(name: string, value: Vector4): ShaderMaterial;
  84970. /**
  84971. * Set a mat4 in the shader from a Matrix.
  84972. * @param name Define the name of the uniform as defined in the shader
  84973. * @param value Define the value to give to the uniform
  84974. * @return the material itself allowing "fluent" like uniform updates
  84975. */
  84976. setMatrix(name: string, value: Matrix): ShaderMaterial;
  84977. /**
  84978. * Set a mat3 in the shader from a Float32Array.
  84979. * @param name Define the name of the uniform as defined in the shader
  84980. * @param value Define the value to give to the uniform
  84981. * @return the material itself allowing "fluent" like uniform updates
  84982. */
  84983. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  84984. /**
  84985. * Set a mat2 in the shader from a Float32Array.
  84986. * @param name Define the name of the uniform as defined in the shader
  84987. * @param value Define the value to give to the uniform
  84988. * @return the material itself allowing "fluent" like uniform updates
  84989. */
  84990. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  84991. /**
  84992. * Set a vec2 array in the shader from a number array.
  84993. * @param name Define the name of the uniform as defined in the shader
  84994. * @param value Define the value to give to the uniform
  84995. * @return the material itself allowing "fluent" like uniform updates
  84996. */
  84997. setArray2(name: string, value: number[]): ShaderMaterial;
  84998. /**
  84999. * Set a vec3 array in the shader from a number array.
  85000. * @param name Define the name of the uniform as defined in the shader
  85001. * @param value Define the value to give to the uniform
  85002. * @return the material itself allowing "fluent" like uniform updates
  85003. */
  85004. setArray3(name: string, value: number[]): ShaderMaterial;
  85005. /**
  85006. * Set a vec4 array in the shader from a number array.
  85007. * @param name Define the name of the uniform as defined in the shader
  85008. * @param value Define the value to give to the uniform
  85009. * @return the material itself allowing "fluent" like uniform updates
  85010. */
  85011. setArray4(name: string, value: number[]): ShaderMaterial;
  85012. private _checkCache;
  85013. /**
  85014. * Specifies that the submesh is ready to be used
  85015. * @param mesh defines the mesh to check
  85016. * @param subMesh defines which submesh to check
  85017. * @param useInstances specifies that instances should be used
  85018. * @returns a boolean indicating that the submesh is ready or not
  85019. */
  85020. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85021. /**
  85022. * Checks if the material is ready to render the requested mesh
  85023. * @param mesh Define the mesh to render
  85024. * @param useInstances Define whether or not the material is used with instances
  85025. * @returns true if ready, otherwise false
  85026. */
  85027. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85028. /**
  85029. * Binds the world matrix to the material
  85030. * @param world defines the world transformation matrix
  85031. */
  85032. bindOnlyWorldMatrix(world: Matrix): void;
  85033. /**
  85034. * Binds the material to the mesh
  85035. * @param world defines the world transformation matrix
  85036. * @param mesh defines the mesh to bind the material to
  85037. */
  85038. bind(world: Matrix, mesh?: Mesh): void;
  85039. /**
  85040. * Gets the active textures from the material
  85041. * @returns an array of textures
  85042. */
  85043. getActiveTextures(): BaseTexture[];
  85044. /**
  85045. * Specifies if the material uses a texture
  85046. * @param texture defines the texture to check against the material
  85047. * @returns a boolean specifying if the material uses the texture
  85048. */
  85049. hasTexture(texture: BaseTexture): boolean;
  85050. /**
  85051. * Makes a duplicate of the material, and gives it a new name
  85052. * @param name defines the new name for the duplicated material
  85053. * @returns the cloned material
  85054. */
  85055. clone(name: string): ShaderMaterial;
  85056. /**
  85057. * Disposes the material
  85058. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85059. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85060. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85061. */
  85062. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85063. /**
  85064. * Serializes this material in a JSON representation
  85065. * @returns the serialized material object
  85066. */
  85067. serialize(): any;
  85068. /**
  85069. * Creates a shader material from parsed shader material data
  85070. * @param source defines the JSON represnetation of the material
  85071. * @param scene defines the hosting scene
  85072. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85073. * @returns a new material
  85074. */
  85075. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  85076. }
  85077. }
  85078. declare module BABYLON {
  85079. /** @hidden */
  85080. export var colorPixelShader: {
  85081. name: string;
  85082. shader: string;
  85083. };
  85084. }
  85085. declare module BABYLON {
  85086. /** @hidden */
  85087. export var colorVertexShader: {
  85088. name: string;
  85089. shader: string;
  85090. };
  85091. }
  85092. declare module BABYLON {
  85093. /**
  85094. * Line mesh
  85095. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  85096. */
  85097. export class LinesMesh extends Mesh {
  85098. /**
  85099. * If vertex color should be applied to the mesh
  85100. */
  85101. readonly useVertexColor?: boolean | undefined;
  85102. /**
  85103. * If vertex alpha should be applied to the mesh
  85104. */
  85105. readonly useVertexAlpha?: boolean | undefined;
  85106. /**
  85107. * Color of the line (Default: White)
  85108. */
  85109. color: Color3;
  85110. /**
  85111. * Alpha of the line (Default: 1)
  85112. */
  85113. alpha: number;
  85114. /**
  85115. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85116. * This margin is expressed in world space coordinates, so its value may vary.
  85117. * Default value is 0.1
  85118. */
  85119. intersectionThreshold: number;
  85120. private _colorShader;
  85121. private color4;
  85122. /**
  85123. * Creates a new LinesMesh
  85124. * @param name defines the name
  85125. * @param scene defines the hosting scene
  85126. * @param parent defines the parent mesh if any
  85127. * @param source defines the optional source LinesMesh used to clone data from
  85128. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85129. * When false, achieved by calling a clone(), also passing False.
  85130. * This will make creation of children, recursive.
  85131. * @param useVertexColor defines if this LinesMesh supports vertex color
  85132. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  85133. */
  85134. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  85135. /**
  85136. * If vertex color should be applied to the mesh
  85137. */
  85138. useVertexColor?: boolean | undefined,
  85139. /**
  85140. * If vertex alpha should be applied to the mesh
  85141. */
  85142. useVertexAlpha?: boolean | undefined);
  85143. private _addClipPlaneDefine;
  85144. private _removeClipPlaneDefine;
  85145. isReady(): boolean;
  85146. /**
  85147. * Returns the string "LineMesh"
  85148. */
  85149. getClassName(): string;
  85150. /**
  85151. * @hidden
  85152. */
  85153. /**
  85154. * @hidden
  85155. */
  85156. material: Material;
  85157. /**
  85158. * @hidden
  85159. */
  85160. readonly checkCollisions: boolean;
  85161. /** @hidden */
  85162. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  85163. /** @hidden */
  85164. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  85165. /**
  85166. * Disposes of the line mesh
  85167. * @param doNotRecurse If children should be disposed
  85168. */
  85169. dispose(doNotRecurse?: boolean): void;
  85170. /**
  85171. * Returns a new LineMesh object cloned from the current one.
  85172. */
  85173. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85174. /**
  85175. * Creates a new InstancedLinesMesh object from the mesh model.
  85176. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85177. * @param name defines the name of the new instance
  85178. * @returns a new InstancedLinesMesh
  85179. */
  85180. createInstance(name: string): InstancedLinesMesh;
  85181. }
  85182. /**
  85183. * Creates an instance based on a source LinesMesh
  85184. */
  85185. export class InstancedLinesMesh extends InstancedMesh {
  85186. /**
  85187. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85188. * This margin is expressed in world space coordinates, so its value may vary.
  85189. * Initilized with the intersectionThreshold value of the source LinesMesh
  85190. */
  85191. intersectionThreshold: number;
  85192. constructor(name: string, source: LinesMesh);
  85193. /**
  85194. * Returns the string "InstancedLinesMesh".
  85195. */
  85196. getClassName(): string;
  85197. }
  85198. }
  85199. declare module BABYLON {
  85200. /** @hidden */
  85201. export var linePixelShader: {
  85202. name: string;
  85203. shader: string;
  85204. };
  85205. }
  85206. declare module BABYLON {
  85207. /** @hidden */
  85208. export var lineVertexShader: {
  85209. name: string;
  85210. shader: string;
  85211. };
  85212. }
  85213. declare module BABYLON {
  85214. interface AbstractMesh {
  85215. /**
  85216. * Gets the edgesRenderer associated with the mesh
  85217. */
  85218. edgesRenderer: Nullable<EdgesRenderer>;
  85219. }
  85220. interface LinesMesh {
  85221. /**
  85222. * Enables the edge rendering mode on the mesh.
  85223. * This mode makes the mesh edges visible
  85224. * @param epsilon defines the maximal distance between two angles to detect a face
  85225. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85226. * @returns the currentAbstractMesh
  85227. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85228. */
  85229. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  85230. }
  85231. interface InstancedLinesMesh {
  85232. /**
  85233. * Enables the edge rendering mode on the mesh.
  85234. * This mode makes the mesh edges visible
  85235. * @param epsilon defines the maximal distance between two angles to detect a face
  85236. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85237. * @returns the current InstancedLinesMesh
  85238. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85239. */
  85240. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  85241. }
  85242. /**
  85243. * Defines the minimum contract an Edges renderer should follow.
  85244. */
  85245. export interface IEdgesRenderer extends IDisposable {
  85246. /**
  85247. * Gets or sets a boolean indicating if the edgesRenderer is active
  85248. */
  85249. isEnabled: boolean;
  85250. /**
  85251. * Renders the edges of the attached mesh,
  85252. */
  85253. render(): void;
  85254. /**
  85255. * Checks wether or not the edges renderer is ready to render.
  85256. * @return true if ready, otherwise false.
  85257. */
  85258. isReady(): boolean;
  85259. }
  85260. /**
  85261. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  85262. */
  85263. export class EdgesRenderer implements IEdgesRenderer {
  85264. /**
  85265. * Define the size of the edges with an orthographic camera
  85266. */
  85267. edgesWidthScalerForOrthographic: number;
  85268. /**
  85269. * Define the size of the edges with a perspective camera
  85270. */
  85271. edgesWidthScalerForPerspective: number;
  85272. protected _source: AbstractMesh;
  85273. protected _linesPositions: number[];
  85274. protected _linesNormals: number[];
  85275. protected _linesIndices: number[];
  85276. protected _epsilon: number;
  85277. protected _indicesCount: number;
  85278. protected _lineShader: ShaderMaterial;
  85279. protected _ib: DataBuffer;
  85280. protected _buffers: {
  85281. [key: string]: Nullable<VertexBuffer>;
  85282. };
  85283. protected _checkVerticesInsteadOfIndices: boolean;
  85284. private _meshRebuildObserver;
  85285. private _meshDisposeObserver;
  85286. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  85287. isEnabled: boolean;
  85288. /**
  85289. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  85290. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  85291. * @param source Mesh used to create edges
  85292. * @param epsilon sum of angles in adjacency to check for edge
  85293. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  85294. * @param generateEdgesLines - should generate Lines or only prepare resources.
  85295. */
  85296. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  85297. protected _prepareRessources(): void;
  85298. /** @hidden */
  85299. _rebuild(): void;
  85300. /**
  85301. * Releases the required resources for the edges renderer
  85302. */
  85303. dispose(): void;
  85304. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  85305. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  85306. /**
  85307. * Checks if the pair of p0 and p1 is en edge
  85308. * @param faceIndex
  85309. * @param edge
  85310. * @param faceNormals
  85311. * @param p0
  85312. * @param p1
  85313. * @private
  85314. */
  85315. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  85316. /**
  85317. * push line into the position, normal and index buffer
  85318. * @protected
  85319. */
  85320. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  85321. /**
  85322. * Generates lines edges from adjacencjes
  85323. * @private
  85324. */
  85325. _generateEdgesLines(): void;
  85326. /**
  85327. * Checks wether or not the edges renderer is ready to render.
  85328. * @return true if ready, otherwise false.
  85329. */
  85330. isReady(): boolean;
  85331. /**
  85332. * Renders the edges of the attached mesh,
  85333. */
  85334. render(): void;
  85335. }
  85336. /**
  85337. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  85338. */
  85339. export class LineEdgesRenderer extends EdgesRenderer {
  85340. /**
  85341. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  85342. * @param source LineMesh used to generate edges
  85343. * @param epsilon not important (specified angle for edge detection)
  85344. * @param checkVerticesInsteadOfIndices not important for LineMesh
  85345. */
  85346. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  85347. /**
  85348. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  85349. */
  85350. _generateEdgesLines(): void;
  85351. }
  85352. }
  85353. declare module BABYLON {
  85354. /**
  85355. * This represents the object necessary to create a rendering group.
  85356. * This is exclusively used and created by the rendering manager.
  85357. * To modify the behavior, you use the available helpers in your scene or meshes.
  85358. * @hidden
  85359. */
  85360. export class RenderingGroup {
  85361. index: number;
  85362. private static _zeroVector;
  85363. private _scene;
  85364. private _opaqueSubMeshes;
  85365. private _transparentSubMeshes;
  85366. private _alphaTestSubMeshes;
  85367. private _depthOnlySubMeshes;
  85368. private _particleSystems;
  85369. private _spriteManagers;
  85370. private _opaqueSortCompareFn;
  85371. private _alphaTestSortCompareFn;
  85372. private _transparentSortCompareFn;
  85373. private _renderOpaque;
  85374. private _renderAlphaTest;
  85375. private _renderTransparent;
  85376. /** @hidden */
  85377. _edgesRenderers: SmartArray<IEdgesRenderer>;
  85378. onBeforeTransparentRendering: () => void;
  85379. /**
  85380. * Set the opaque sort comparison function.
  85381. * If null the sub meshes will be render in the order they were created
  85382. */
  85383. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85384. /**
  85385. * Set the alpha test sort comparison function.
  85386. * If null the sub meshes will be render in the order they were created
  85387. */
  85388. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85389. /**
  85390. * Set the transparent sort comparison function.
  85391. * If null the sub meshes will be render in the order they were created
  85392. */
  85393. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85394. /**
  85395. * Creates a new rendering group.
  85396. * @param index The rendering group index
  85397. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  85398. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  85399. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  85400. */
  85401. 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>);
  85402. /**
  85403. * Render all the sub meshes contained in the group.
  85404. * @param customRenderFunction Used to override the default render behaviour of the group.
  85405. * @returns true if rendered some submeshes.
  85406. */
  85407. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  85408. /**
  85409. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  85410. * @param subMeshes The submeshes to render
  85411. */
  85412. private renderOpaqueSorted;
  85413. /**
  85414. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  85415. * @param subMeshes The submeshes to render
  85416. */
  85417. private renderAlphaTestSorted;
  85418. /**
  85419. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  85420. * @param subMeshes The submeshes to render
  85421. */
  85422. private renderTransparentSorted;
  85423. /**
  85424. * Renders the submeshes in a specified order.
  85425. * @param subMeshes The submeshes to sort before render
  85426. * @param sortCompareFn The comparison function use to sort
  85427. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  85428. * @param transparent Specifies to activate blending if true
  85429. */
  85430. private static renderSorted;
  85431. /**
  85432. * Renders the submeshes in the order they were dispatched (no sort applied).
  85433. * @param subMeshes The submeshes to render
  85434. */
  85435. private static renderUnsorted;
  85436. /**
  85437. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85438. * are rendered back to front if in the same alpha index.
  85439. *
  85440. * @param a The first submesh
  85441. * @param b The second submesh
  85442. * @returns The result of the comparison
  85443. */
  85444. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  85445. /**
  85446. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85447. * are rendered back to front.
  85448. *
  85449. * @param a The first submesh
  85450. * @param b The second submesh
  85451. * @returns The result of the comparison
  85452. */
  85453. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  85454. /**
  85455. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85456. * are rendered front to back (prevent overdraw).
  85457. *
  85458. * @param a The first submesh
  85459. * @param b The second submesh
  85460. * @returns The result of the comparison
  85461. */
  85462. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  85463. /**
  85464. * Resets the different lists of submeshes to prepare a new frame.
  85465. */
  85466. prepare(): void;
  85467. dispose(): void;
  85468. /**
  85469. * Inserts the submesh in its correct queue depending on its material.
  85470. * @param subMesh The submesh to dispatch
  85471. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85472. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85473. */
  85474. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85475. dispatchSprites(spriteManager: ISpriteManager): void;
  85476. dispatchParticles(particleSystem: IParticleSystem): void;
  85477. private _renderParticles;
  85478. private _renderSprites;
  85479. }
  85480. }
  85481. declare module BABYLON {
  85482. /**
  85483. * Interface describing the different options available in the rendering manager
  85484. * regarding Auto Clear between groups.
  85485. */
  85486. export interface IRenderingManagerAutoClearSetup {
  85487. /**
  85488. * Defines whether or not autoclear is enable.
  85489. */
  85490. autoClear: boolean;
  85491. /**
  85492. * Defines whether or not to autoclear the depth buffer.
  85493. */
  85494. depth: boolean;
  85495. /**
  85496. * Defines whether or not to autoclear the stencil buffer.
  85497. */
  85498. stencil: boolean;
  85499. }
  85500. /**
  85501. * This class is used by the onRenderingGroupObservable
  85502. */
  85503. export class RenderingGroupInfo {
  85504. /**
  85505. * The Scene that being rendered
  85506. */
  85507. scene: Scene;
  85508. /**
  85509. * The camera currently used for the rendering pass
  85510. */
  85511. camera: Nullable<Camera>;
  85512. /**
  85513. * The ID of the renderingGroup being processed
  85514. */
  85515. renderingGroupId: number;
  85516. }
  85517. /**
  85518. * This is the manager responsible of all the rendering for meshes sprites and particles.
  85519. * It is enable to manage the different groups as well as the different necessary sort functions.
  85520. * This should not be used directly aside of the few static configurations
  85521. */
  85522. export class RenderingManager {
  85523. /**
  85524. * The max id used for rendering groups (not included)
  85525. */
  85526. static MAX_RENDERINGGROUPS: number;
  85527. /**
  85528. * The min id used for rendering groups (included)
  85529. */
  85530. static MIN_RENDERINGGROUPS: number;
  85531. /**
  85532. * Used to globally prevent autoclearing scenes.
  85533. */
  85534. static AUTOCLEAR: boolean;
  85535. /**
  85536. * @hidden
  85537. */
  85538. _useSceneAutoClearSetup: boolean;
  85539. private _scene;
  85540. private _renderingGroups;
  85541. private _depthStencilBufferAlreadyCleaned;
  85542. private _autoClearDepthStencil;
  85543. private _customOpaqueSortCompareFn;
  85544. private _customAlphaTestSortCompareFn;
  85545. private _customTransparentSortCompareFn;
  85546. private _renderingGroupInfo;
  85547. /**
  85548. * Instantiates a new rendering group for a particular scene
  85549. * @param scene Defines the scene the groups belongs to
  85550. */
  85551. constructor(scene: Scene);
  85552. private _clearDepthStencilBuffer;
  85553. /**
  85554. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  85555. * @hidden
  85556. */
  85557. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  85558. /**
  85559. * Resets the different information of the group to prepare a new frame
  85560. * @hidden
  85561. */
  85562. reset(): void;
  85563. /**
  85564. * Dispose and release the group and its associated resources.
  85565. * @hidden
  85566. */
  85567. dispose(): void;
  85568. /**
  85569. * Clear the info related to rendering groups preventing retention points during dispose.
  85570. */
  85571. freeRenderingGroups(): void;
  85572. private _prepareRenderingGroup;
  85573. /**
  85574. * Add a sprite manager to the rendering manager in order to render it this frame.
  85575. * @param spriteManager Define the sprite manager to render
  85576. */
  85577. dispatchSprites(spriteManager: ISpriteManager): void;
  85578. /**
  85579. * Add a particle system to the rendering manager in order to render it this frame.
  85580. * @param particleSystem Define the particle system to render
  85581. */
  85582. dispatchParticles(particleSystem: IParticleSystem): void;
  85583. /**
  85584. * Add a submesh to the manager in order to render it this frame
  85585. * @param subMesh The submesh to dispatch
  85586. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85587. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85588. */
  85589. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85590. /**
  85591. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85592. * This allowed control for front to back rendering or reversly depending of the special needs.
  85593. *
  85594. * @param renderingGroupId The rendering group id corresponding to its index
  85595. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85596. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85597. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85598. */
  85599. 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;
  85600. /**
  85601. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85602. *
  85603. * @param renderingGroupId The rendering group id corresponding to its index
  85604. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85605. * @param depth Automatically clears depth between groups if true and autoClear is true.
  85606. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  85607. */
  85608. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  85609. /**
  85610. * Gets the current auto clear configuration for one rendering group of the rendering
  85611. * manager.
  85612. * @param index the rendering group index to get the information for
  85613. * @returns The auto clear setup for the requested rendering group
  85614. */
  85615. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  85616. }
  85617. }
  85618. declare module BABYLON {
  85619. /**
  85620. * This Helps creating a texture that will be created from a camera in your scene.
  85621. * It is basically a dynamic texture that could be used to create special effects for instance.
  85622. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  85623. */
  85624. export class RenderTargetTexture extends Texture {
  85625. isCube: boolean;
  85626. /**
  85627. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  85628. */
  85629. static readonly REFRESHRATE_RENDER_ONCE: number;
  85630. /**
  85631. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  85632. */
  85633. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  85634. /**
  85635. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  85636. * the central point of your effect and can save a lot of performances.
  85637. */
  85638. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  85639. /**
  85640. * Use this predicate to dynamically define the list of mesh you want to render.
  85641. * If set, the renderList property will be overwritten.
  85642. */
  85643. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  85644. private _renderList;
  85645. /**
  85646. * Use this list to define the list of mesh you want to render.
  85647. */
  85648. renderList: Nullable<Array<AbstractMesh>>;
  85649. private _hookArray;
  85650. /**
  85651. * Define if particles should be rendered in your texture.
  85652. */
  85653. renderParticles: boolean;
  85654. /**
  85655. * Define if sprites should be rendered in your texture.
  85656. */
  85657. renderSprites: boolean;
  85658. /**
  85659. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  85660. */
  85661. coordinatesMode: number;
  85662. /**
  85663. * Define the camera used to render the texture.
  85664. */
  85665. activeCamera: Nullable<Camera>;
  85666. /**
  85667. * Override the render function of the texture with your own one.
  85668. */
  85669. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  85670. /**
  85671. * Define if camera post processes should be use while rendering the texture.
  85672. */
  85673. useCameraPostProcesses: boolean;
  85674. /**
  85675. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  85676. */
  85677. ignoreCameraViewport: boolean;
  85678. private _postProcessManager;
  85679. private _postProcesses;
  85680. private _resizeObserver;
  85681. /**
  85682. * An event triggered when the texture is unbind.
  85683. */
  85684. onBeforeBindObservable: Observable<RenderTargetTexture>;
  85685. /**
  85686. * An event triggered when the texture is unbind.
  85687. */
  85688. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  85689. private _onAfterUnbindObserver;
  85690. /**
  85691. * Set a after unbind callback in the texture.
  85692. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  85693. */
  85694. onAfterUnbind: () => void;
  85695. /**
  85696. * An event triggered before rendering the texture
  85697. */
  85698. onBeforeRenderObservable: Observable<number>;
  85699. private _onBeforeRenderObserver;
  85700. /**
  85701. * Set a before render callback in the texture.
  85702. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  85703. */
  85704. onBeforeRender: (faceIndex: number) => void;
  85705. /**
  85706. * An event triggered after rendering the texture
  85707. */
  85708. onAfterRenderObservable: Observable<number>;
  85709. private _onAfterRenderObserver;
  85710. /**
  85711. * Set a after render callback in the texture.
  85712. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  85713. */
  85714. onAfterRender: (faceIndex: number) => void;
  85715. /**
  85716. * An event triggered after the texture clear
  85717. */
  85718. onClearObservable: Observable<Engine>;
  85719. private _onClearObserver;
  85720. /**
  85721. * Set a clear callback in the texture.
  85722. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  85723. */
  85724. onClear: (Engine: Engine) => void;
  85725. /**
  85726. * An event triggered when the texture is resized.
  85727. */
  85728. onResizeObservable: Observable<RenderTargetTexture>;
  85729. /**
  85730. * Define the clear color of the Render Target if it should be different from the scene.
  85731. */
  85732. clearColor: Color4;
  85733. protected _size: number | {
  85734. width: number;
  85735. height: number;
  85736. };
  85737. protected _initialSizeParameter: number | {
  85738. width: number;
  85739. height: number;
  85740. } | {
  85741. ratio: number;
  85742. };
  85743. protected _sizeRatio: Nullable<number>;
  85744. /** @hidden */
  85745. _generateMipMaps: boolean;
  85746. protected _renderingManager: RenderingManager;
  85747. /** @hidden */
  85748. _waitingRenderList: string[];
  85749. protected _doNotChangeAspectRatio: boolean;
  85750. protected _currentRefreshId: number;
  85751. protected _refreshRate: number;
  85752. protected _textureMatrix: Matrix;
  85753. protected _samples: number;
  85754. protected _renderTargetOptions: RenderTargetCreationOptions;
  85755. /**
  85756. * Gets render target creation options that were used.
  85757. */
  85758. readonly renderTargetOptions: RenderTargetCreationOptions;
  85759. protected _engine: Engine;
  85760. protected _onRatioRescale(): void;
  85761. /**
  85762. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  85763. * It must define where the camera used to render the texture is set
  85764. */
  85765. boundingBoxPosition: Vector3;
  85766. private _boundingBoxSize;
  85767. /**
  85768. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  85769. * When defined, the cubemap will switch to local mode
  85770. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85771. * @example https://www.babylonjs-playground.com/#RNASML
  85772. */
  85773. boundingBoxSize: Vector3;
  85774. /**
  85775. * In case the RTT has been created with a depth texture, get the associated
  85776. * depth texture.
  85777. * Otherwise, return null.
  85778. */
  85779. depthStencilTexture: Nullable<InternalTexture>;
  85780. /**
  85781. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  85782. * or used a shadow, depth texture...
  85783. * @param name The friendly name of the texture
  85784. * @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)
  85785. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  85786. * @param generateMipMaps True if mip maps need to be generated after render.
  85787. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  85788. * @param type The type of the buffer in the RTT (int, half float, float...)
  85789. * @param isCube True if a cube texture needs to be created
  85790. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  85791. * @param generateDepthBuffer True to generate a depth buffer
  85792. * @param generateStencilBuffer True to generate a stencil buffer
  85793. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  85794. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  85795. * @param delayAllocation if the texture allocation should be delayed (default: false)
  85796. */
  85797. constructor(name: string, size: number | {
  85798. width: number;
  85799. height: number;
  85800. } | {
  85801. ratio: number;
  85802. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  85803. /**
  85804. * Creates a depth stencil texture.
  85805. * This is only available in WebGL 2 or with the depth texture extension available.
  85806. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  85807. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  85808. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  85809. */
  85810. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  85811. private _processSizeParameter;
  85812. /**
  85813. * Define the number of samples to use in case of MSAA.
  85814. * It defaults to one meaning no MSAA has been enabled.
  85815. */
  85816. samples: number;
  85817. /**
  85818. * Resets the refresh counter of the texture and start bak from scratch.
  85819. * Could be useful to regenerate the texture if it is setup to render only once.
  85820. */
  85821. resetRefreshCounter(): void;
  85822. /**
  85823. * Define the refresh rate of the texture or the rendering frequency.
  85824. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85825. */
  85826. refreshRate: number;
  85827. /**
  85828. * Adds a post process to the render target rendering passes.
  85829. * @param postProcess define the post process to add
  85830. */
  85831. addPostProcess(postProcess: PostProcess): void;
  85832. /**
  85833. * Clear all the post processes attached to the render target
  85834. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  85835. */
  85836. clearPostProcesses(dispose?: boolean): void;
  85837. /**
  85838. * Remove one of the post process from the list of attached post processes to the texture
  85839. * @param postProcess define the post process to remove from the list
  85840. */
  85841. removePostProcess(postProcess: PostProcess): void;
  85842. /** @hidden */
  85843. _shouldRender(): boolean;
  85844. /**
  85845. * Gets the actual render size of the texture.
  85846. * @returns the width of the render size
  85847. */
  85848. getRenderSize(): number;
  85849. /**
  85850. * Gets the actual render width of the texture.
  85851. * @returns the width of the render size
  85852. */
  85853. getRenderWidth(): number;
  85854. /**
  85855. * Gets the actual render height of the texture.
  85856. * @returns the height of the render size
  85857. */
  85858. getRenderHeight(): number;
  85859. /**
  85860. * Get if the texture can be rescaled or not.
  85861. */
  85862. readonly canRescale: boolean;
  85863. /**
  85864. * Resize the texture using a ratio.
  85865. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  85866. */
  85867. scale(ratio: number): void;
  85868. /**
  85869. * Get the texture reflection matrix used to rotate/transform the reflection.
  85870. * @returns the reflection matrix
  85871. */
  85872. getReflectionTextureMatrix(): Matrix;
  85873. /**
  85874. * Resize the texture to a new desired size.
  85875. * Be carrefull as it will recreate all the data in the new texture.
  85876. * @param size Define the new size. It can be:
  85877. * - a number for squared texture,
  85878. * - an object containing { width: number, height: number }
  85879. * - or an object containing a ratio { ratio: number }
  85880. */
  85881. resize(size: number | {
  85882. width: number;
  85883. height: number;
  85884. } | {
  85885. ratio: number;
  85886. }): void;
  85887. /**
  85888. * Renders all the objects from the render list into the texture.
  85889. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  85890. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  85891. */
  85892. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  85893. private _bestReflectionRenderTargetDimension;
  85894. /**
  85895. * @hidden
  85896. * @param faceIndex face index to bind to if this is a cubetexture
  85897. */
  85898. _bindFrameBuffer(faceIndex?: number): void;
  85899. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85900. private renderToTarget;
  85901. /**
  85902. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85903. * This allowed control for front to back rendering or reversly depending of the special needs.
  85904. *
  85905. * @param renderingGroupId The rendering group id corresponding to its index
  85906. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85907. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85908. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85909. */
  85910. 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;
  85911. /**
  85912. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85913. *
  85914. * @param renderingGroupId The rendering group id corresponding to its index
  85915. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85916. */
  85917. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85918. /**
  85919. * Clones the texture.
  85920. * @returns the cloned texture
  85921. */
  85922. clone(): RenderTargetTexture;
  85923. /**
  85924. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85925. * @returns The JSON representation of the texture
  85926. */
  85927. serialize(): any;
  85928. /**
  85929. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85930. */
  85931. disposeFramebufferObjects(): void;
  85932. /**
  85933. * Dispose the texture and release its associated resources.
  85934. */
  85935. dispose(): void;
  85936. /** @hidden */
  85937. _rebuild(): void;
  85938. /**
  85939. * Clear the info related to rendering groups preventing retention point in material dispose.
  85940. */
  85941. freeRenderingGroups(): void;
  85942. /**
  85943. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85944. * @returns the view count
  85945. */
  85946. getViewCount(): number;
  85947. }
  85948. }
  85949. declare module BABYLON {
  85950. /**
  85951. * Base class for the main features of a material in Babylon.js
  85952. */
  85953. export class Material implements IAnimatable {
  85954. /**
  85955. * Returns the triangle fill mode
  85956. */
  85957. static readonly TriangleFillMode: number;
  85958. /**
  85959. * Returns the wireframe mode
  85960. */
  85961. static readonly WireFrameFillMode: number;
  85962. /**
  85963. * Returns the point fill mode
  85964. */
  85965. static readonly PointFillMode: number;
  85966. /**
  85967. * Returns the point list draw mode
  85968. */
  85969. static readonly PointListDrawMode: number;
  85970. /**
  85971. * Returns the line list draw mode
  85972. */
  85973. static readonly LineListDrawMode: number;
  85974. /**
  85975. * Returns the line loop draw mode
  85976. */
  85977. static readonly LineLoopDrawMode: number;
  85978. /**
  85979. * Returns the line strip draw mode
  85980. */
  85981. static readonly LineStripDrawMode: number;
  85982. /**
  85983. * Returns the triangle strip draw mode
  85984. */
  85985. static readonly TriangleStripDrawMode: number;
  85986. /**
  85987. * Returns the triangle fan draw mode
  85988. */
  85989. static readonly TriangleFanDrawMode: number;
  85990. /**
  85991. * Stores the clock-wise side orientation
  85992. */
  85993. static readonly ClockWiseSideOrientation: number;
  85994. /**
  85995. * Stores the counter clock-wise side orientation
  85996. */
  85997. static readonly CounterClockWiseSideOrientation: number;
  85998. /**
  85999. * The dirty texture flag value
  86000. */
  86001. static readonly TextureDirtyFlag: number;
  86002. /**
  86003. * The dirty light flag value
  86004. */
  86005. static readonly LightDirtyFlag: number;
  86006. /**
  86007. * The dirty fresnel flag value
  86008. */
  86009. static readonly FresnelDirtyFlag: number;
  86010. /**
  86011. * The dirty attribute flag value
  86012. */
  86013. static readonly AttributesDirtyFlag: number;
  86014. /**
  86015. * The dirty misc flag value
  86016. */
  86017. static readonly MiscDirtyFlag: number;
  86018. /**
  86019. * The all dirty flag value
  86020. */
  86021. static readonly AllDirtyFlag: number;
  86022. /**
  86023. * The ID of the material
  86024. */
  86025. id: string;
  86026. /**
  86027. * Gets or sets the unique id of the material
  86028. */
  86029. uniqueId: number;
  86030. /**
  86031. * The name of the material
  86032. */
  86033. name: string;
  86034. /**
  86035. * Gets or sets user defined metadata
  86036. */
  86037. metadata: any;
  86038. /**
  86039. * For internal use only. Please do not use.
  86040. */
  86041. reservedDataStore: any;
  86042. /**
  86043. * Specifies if the ready state should be checked on each call
  86044. */
  86045. checkReadyOnEveryCall: boolean;
  86046. /**
  86047. * Specifies if the ready state should be checked once
  86048. */
  86049. checkReadyOnlyOnce: boolean;
  86050. /**
  86051. * The state of the material
  86052. */
  86053. state: string;
  86054. /**
  86055. * The alpha value of the material
  86056. */
  86057. protected _alpha: number;
  86058. /**
  86059. * List of inspectable custom properties (used by the Inspector)
  86060. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86061. */
  86062. inspectableCustomProperties: IInspectable[];
  86063. /**
  86064. * Sets the alpha value of the material
  86065. */
  86066. /**
  86067. * Gets the alpha value of the material
  86068. */
  86069. alpha: number;
  86070. /**
  86071. * Specifies if back face culling is enabled
  86072. */
  86073. protected _backFaceCulling: boolean;
  86074. /**
  86075. * Sets the back-face culling state
  86076. */
  86077. /**
  86078. * Gets the back-face culling state
  86079. */
  86080. backFaceCulling: boolean;
  86081. /**
  86082. * Stores the value for side orientation
  86083. */
  86084. sideOrientation: number;
  86085. /**
  86086. * Callback triggered when the material is compiled
  86087. */
  86088. onCompiled: Nullable<(effect: Effect) => void>;
  86089. /**
  86090. * Callback triggered when an error occurs
  86091. */
  86092. onError: Nullable<(effect: Effect, errors: string) => void>;
  86093. /**
  86094. * Callback triggered to get the render target textures
  86095. */
  86096. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  86097. /**
  86098. * Gets a boolean indicating that current material needs to register RTT
  86099. */
  86100. readonly hasRenderTargetTextures: boolean;
  86101. /**
  86102. * Specifies if the material should be serialized
  86103. */
  86104. doNotSerialize: boolean;
  86105. /**
  86106. * @hidden
  86107. */
  86108. _storeEffectOnSubMeshes: boolean;
  86109. /**
  86110. * Stores the animations for the material
  86111. */
  86112. animations: Nullable<Array<Animation>>;
  86113. /**
  86114. * An event triggered when the material is disposed
  86115. */
  86116. onDisposeObservable: Observable<Material>;
  86117. /**
  86118. * An observer which watches for dispose events
  86119. */
  86120. private _onDisposeObserver;
  86121. private _onUnBindObservable;
  86122. /**
  86123. * Called during a dispose event
  86124. */
  86125. onDispose: () => void;
  86126. private _onBindObservable;
  86127. /**
  86128. * An event triggered when the material is bound
  86129. */
  86130. readonly onBindObservable: Observable<AbstractMesh>;
  86131. /**
  86132. * An observer which watches for bind events
  86133. */
  86134. private _onBindObserver;
  86135. /**
  86136. * Called during a bind event
  86137. */
  86138. onBind: (Mesh: AbstractMesh) => void;
  86139. /**
  86140. * An event triggered when the material is unbound
  86141. */
  86142. readonly onUnBindObservable: Observable<Material>;
  86143. /**
  86144. * Stores the value of the alpha mode
  86145. */
  86146. private _alphaMode;
  86147. /**
  86148. * Sets the value of the alpha mode.
  86149. *
  86150. * | Value | Type | Description |
  86151. * | --- | --- | --- |
  86152. * | 0 | ALPHA_DISABLE | |
  86153. * | 1 | ALPHA_ADD | |
  86154. * | 2 | ALPHA_COMBINE | |
  86155. * | 3 | ALPHA_SUBTRACT | |
  86156. * | 4 | ALPHA_MULTIPLY | |
  86157. * | 5 | ALPHA_MAXIMIZED | |
  86158. * | 6 | ALPHA_ONEONE | |
  86159. * | 7 | ALPHA_PREMULTIPLIED | |
  86160. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  86161. * | 9 | ALPHA_INTERPOLATE | |
  86162. * | 10 | ALPHA_SCREENMODE | |
  86163. *
  86164. */
  86165. /**
  86166. * Gets the value of the alpha mode
  86167. */
  86168. alphaMode: number;
  86169. /**
  86170. * Stores the state of the need depth pre-pass value
  86171. */
  86172. private _needDepthPrePass;
  86173. /**
  86174. * Sets the need depth pre-pass value
  86175. */
  86176. /**
  86177. * Gets the depth pre-pass value
  86178. */
  86179. needDepthPrePass: boolean;
  86180. /**
  86181. * Specifies if depth writing should be disabled
  86182. */
  86183. disableDepthWrite: boolean;
  86184. /**
  86185. * Specifies if depth writing should be forced
  86186. */
  86187. forceDepthWrite: boolean;
  86188. /**
  86189. * Specifies if there should be a separate pass for culling
  86190. */
  86191. separateCullingPass: boolean;
  86192. /**
  86193. * Stores the state specifing if fog should be enabled
  86194. */
  86195. private _fogEnabled;
  86196. /**
  86197. * Sets the state for enabling fog
  86198. */
  86199. /**
  86200. * Gets the value of the fog enabled state
  86201. */
  86202. fogEnabled: boolean;
  86203. /**
  86204. * Stores the size of points
  86205. */
  86206. pointSize: number;
  86207. /**
  86208. * Stores the z offset value
  86209. */
  86210. zOffset: number;
  86211. /**
  86212. * Gets a value specifying if wireframe mode is enabled
  86213. */
  86214. /**
  86215. * Sets the state of wireframe mode
  86216. */
  86217. wireframe: boolean;
  86218. /**
  86219. * Gets the value specifying if point clouds are enabled
  86220. */
  86221. /**
  86222. * Sets the state of point cloud mode
  86223. */
  86224. pointsCloud: boolean;
  86225. /**
  86226. * Gets the material fill mode
  86227. */
  86228. /**
  86229. * Sets the material fill mode
  86230. */
  86231. fillMode: number;
  86232. /**
  86233. * @hidden
  86234. * Stores the effects for the material
  86235. */
  86236. _effect: Nullable<Effect>;
  86237. /**
  86238. * @hidden
  86239. * Specifies if the material was previously ready
  86240. */
  86241. _wasPreviouslyReady: boolean;
  86242. /**
  86243. * Specifies if uniform buffers should be used
  86244. */
  86245. private _useUBO;
  86246. /**
  86247. * Stores a reference to the scene
  86248. */
  86249. private _scene;
  86250. /**
  86251. * Stores the fill mode state
  86252. */
  86253. private _fillMode;
  86254. /**
  86255. * Specifies if the depth write state should be cached
  86256. */
  86257. private _cachedDepthWriteState;
  86258. /**
  86259. * Stores the uniform buffer
  86260. */
  86261. protected _uniformBuffer: UniformBuffer;
  86262. /** @hidden */
  86263. _indexInSceneMaterialArray: number;
  86264. /** @hidden */
  86265. meshMap: Nullable<{
  86266. [id: string]: AbstractMesh | undefined;
  86267. }>;
  86268. /**
  86269. * Creates a material instance
  86270. * @param name defines the name of the material
  86271. * @param scene defines the scene to reference
  86272. * @param doNotAdd specifies if the material should be added to the scene
  86273. */
  86274. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  86275. /**
  86276. * Returns a string representation of the current material
  86277. * @param fullDetails defines a boolean indicating which levels of logging is desired
  86278. * @returns a string with material information
  86279. */
  86280. toString(fullDetails?: boolean): string;
  86281. /**
  86282. * Gets the class name of the material
  86283. * @returns a string with the class name of the material
  86284. */
  86285. getClassName(): string;
  86286. /**
  86287. * Specifies if updates for the material been locked
  86288. */
  86289. readonly isFrozen: boolean;
  86290. /**
  86291. * Locks updates for the material
  86292. */
  86293. freeze(): void;
  86294. /**
  86295. * Unlocks updates for the material
  86296. */
  86297. unfreeze(): void;
  86298. /**
  86299. * Specifies if the material is ready to be used
  86300. * @param mesh defines the mesh to check
  86301. * @param useInstances specifies if instances should be used
  86302. * @returns a boolean indicating if the material is ready to be used
  86303. */
  86304. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86305. /**
  86306. * Specifies that the submesh is ready to be used
  86307. * @param mesh defines the mesh to check
  86308. * @param subMesh defines which submesh to check
  86309. * @param useInstances specifies that instances should be used
  86310. * @returns a boolean indicating that the submesh is ready or not
  86311. */
  86312. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86313. /**
  86314. * Returns the material effect
  86315. * @returns the effect associated with the material
  86316. */
  86317. getEffect(): Nullable<Effect>;
  86318. /**
  86319. * Returns the current scene
  86320. * @returns a Scene
  86321. */
  86322. getScene(): Scene;
  86323. /**
  86324. * Specifies if the material will require alpha blending
  86325. * @returns a boolean specifying if alpha blending is needed
  86326. */
  86327. needAlphaBlending(): boolean;
  86328. /**
  86329. * Specifies if the mesh will require alpha blending
  86330. * @param mesh defines the mesh to check
  86331. * @returns a boolean specifying if alpha blending is needed for the mesh
  86332. */
  86333. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  86334. /**
  86335. * Specifies if this material should be rendered in alpha test mode
  86336. * @returns a boolean specifying if an alpha test is needed.
  86337. */
  86338. needAlphaTesting(): boolean;
  86339. /**
  86340. * Gets the texture used for the alpha test
  86341. * @returns the texture to use for alpha testing
  86342. */
  86343. getAlphaTestTexture(): Nullable<BaseTexture>;
  86344. /**
  86345. * Marks the material to indicate that it needs to be re-calculated
  86346. */
  86347. markDirty(): void;
  86348. /** @hidden */
  86349. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  86350. /**
  86351. * Binds the material to the mesh
  86352. * @param world defines the world transformation matrix
  86353. * @param mesh defines the mesh to bind the material to
  86354. */
  86355. bind(world: Matrix, mesh?: Mesh): void;
  86356. /**
  86357. * Binds the submesh to the material
  86358. * @param world defines the world transformation matrix
  86359. * @param mesh defines the mesh containing the submesh
  86360. * @param subMesh defines the submesh to bind the material to
  86361. */
  86362. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  86363. /**
  86364. * Binds the world matrix to the material
  86365. * @param world defines the world transformation matrix
  86366. */
  86367. bindOnlyWorldMatrix(world: Matrix): void;
  86368. /**
  86369. * Binds the scene's uniform buffer to the effect.
  86370. * @param effect defines the effect to bind to the scene uniform buffer
  86371. * @param sceneUbo defines the uniform buffer storing scene data
  86372. */
  86373. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  86374. /**
  86375. * Binds the view matrix to the effect
  86376. * @param effect defines the effect to bind the view matrix to
  86377. */
  86378. bindView(effect: Effect): void;
  86379. /**
  86380. * Binds the view projection matrix to the effect
  86381. * @param effect defines the effect to bind the view projection matrix to
  86382. */
  86383. bindViewProjection(effect: Effect): void;
  86384. /**
  86385. * Specifies if material alpha testing should be turned on for the mesh
  86386. * @param mesh defines the mesh to check
  86387. */
  86388. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  86389. /**
  86390. * Processes to execute after binding the material to a mesh
  86391. * @param mesh defines the rendered mesh
  86392. */
  86393. protected _afterBind(mesh?: Mesh): void;
  86394. /**
  86395. * Unbinds the material from the mesh
  86396. */
  86397. unbind(): void;
  86398. /**
  86399. * Gets the active textures from the material
  86400. * @returns an array of textures
  86401. */
  86402. getActiveTextures(): BaseTexture[];
  86403. /**
  86404. * Specifies if the material uses a texture
  86405. * @param texture defines the texture to check against the material
  86406. * @returns a boolean specifying if the material uses the texture
  86407. */
  86408. hasTexture(texture: BaseTexture): boolean;
  86409. /**
  86410. * Makes a duplicate of the material, and gives it a new name
  86411. * @param name defines the new name for the duplicated material
  86412. * @returns the cloned material
  86413. */
  86414. clone(name: string): Nullable<Material>;
  86415. /**
  86416. * Gets the meshes bound to the material
  86417. * @returns an array of meshes bound to the material
  86418. */
  86419. getBindedMeshes(): AbstractMesh[];
  86420. /**
  86421. * Force shader compilation
  86422. * @param mesh defines the mesh associated with this material
  86423. * @param onCompiled defines a function to execute once the material is compiled
  86424. * @param options defines the options to configure the compilation
  86425. */
  86426. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  86427. clipPlane: boolean;
  86428. }>): void;
  86429. /**
  86430. * Force shader compilation
  86431. * @param mesh defines the mesh that will use this material
  86432. * @param options defines additional options for compiling the shaders
  86433. * @returns a promise that resolves when the compilation completes
  86434. */
  86435. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  86436. clipPlane: boolean;
  86437. }>): Promise<void>;
  86438. private static readonly _AllDirtyCallBack;
  86439. private static readonly _ImageProcessingDirtyCallBack;
  86440. private static readonly _TextureDirtyCallBack;
  86441. private static readonly _FresnelDirtyCallBack;
  86442. private static readonly _MiscDirtyCallBack;
  86443. private static readonly _LightsDirtyCallBack;
  86444. private static readonly _AttributeDirtyCallBack;
  86445. private static _FresnelAndMiscDirtyCallBack;
  86446. private static _TextureAndMiscDirtyCallBack;
  86447. private static readonly _DirtyCallbackArray;
  86448. private static readonly _RunDirtyCallBacks;
  86449. /**
  86450. * Marks a define in the material to indicate that it needs to be re-computed
  86451. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  86452. */
  86453. markAsDirty(flag: number): void;
  86454. /**
  86455. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  86456. * @param func defines a function which checks material defines against the submeshes
  86457. */
  86458. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  86459. /**
  86460. * Indicates that we need to re-calculated for all submeshes
  86461. */
  86462. protected _markAllSubMeshesAsAllDirty(): void;
  86463. /**
  86464. * Indicates that image processing needs to be re-calculated for all submeshes
  86465. */
  86466. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  86467. /**
  86468. * Indicates that textures need to be re-calculated for all submeshes
  86469. */
  86470. protected _markAllSubMeshesAsTexturesDirty(): void;
  86471. /**
  86472. * Indicates that fresnel needs to be re-calculated for all submeshes
  86473. */
  86474. protected _markAllSubMeshesAsFresnelDirty(): void;
  86475. /**
  86476. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  86477. */
  86478. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  86479. /**
  86480. * Indicates that lights need to be re-calculated for all submeshes
  86481. */
  86482. protected _markAllSubMeshesAsLightsDirty(): void;
  86483. /**
  86484. * Indicates that attributes need to be re-calculated for all submeshes
  86485. */
  86486. protected _markAllSubMeshesAsAttributesDirty(): void;
  86487. /**
  86488. * Indicates that misc needs to be re-calculated for all submeshes
  86489. */
  86490. protected _markAllSubMeshesAsMiscDirty(): void;
  86491. /**
  86492. * Indicates that textures and misc need to be re-calculated for all submeshes
  86493. */
  86494. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  86495. /**
  86496. * Disposes the material
  86497. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86498. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86499. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86500. */
  86501. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86502. /** @hidden */
  86503. private releaseVertexArrayObject;
  86504. /**
  86505. * Serializes this material
  86506. * @returns the serialized material object
  86507. */
  86508. serialize(): any;
  86509. /**
  86510. * Creates a material from parsed material data
  86511. * @param parsedMaterial defines parsed material data
  86512. * @param scene defines the hosting scene
  86513. * @param rootUrl defines the root URL to use to load textures
  86514. * @returns a new material
  86515. */
  86516. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  86517. }
  86518. }
  86519. declare module BABYLON {
  86520. /**
  86521. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86522. * separate meshes. This can be use to improve performances.
  86523. * @see http://doc.babylonjs.com/how_to/multi_materials
  86524. */
  86525. export class MultiMaterial extends Material {
  86526. private _subMaterials;
  86527. /**
  86528. * Gets or Sets the list of Materials used within the multi material.
  86529. * They need to be ordered according to the submeshes order in the associated mesh
  86530. */
  86531. subMaterials: Nullable<Material>[];
  86532. /**
  86533. * Function used to align with Node.getChildren()
  86534. * @returns the list of Materials used within the multi material
  86535. */
  86536. getChildren(): Nullable<Material>[];
  86537. /**
  86538. * Instantiates a new Multi Material
  86539. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86540. * separate meshes. This can be use to improve performances.
  86541. * @see http://doc.babylonjs.com/how_to/multi_materials
  86542. * @param name Define the name in the scene
  86543. * @param scene Define the scene the material belongs to
  86544. */
  86545. constructor(name: string, scene: Scene);
  86546. private _hookArray;
  86547. /**
  86548. * Get one of the submaterial by its index in the submaterials array
  86549. * @param index The index to look the sub material at
  86550. * @returns The Material if the index has been defined
  86551. */
  86552. getSubMaterial(index: number): Nullable<Material>;
  86553. /**
  86554. * Get the list of active textures for the whole sub materials list.
  86555. * @returns All the textures that will be used during the rendering
  86556. */
  86557. getActiveTextures(): BaseTexture[];
  86558. /**
  86559. * Gets the current class name of the material e.g. "MultiMaterial"
  86560. * Mainly use in serialization.
  86561. * @returns the class name
  86562. */
  86563. getClassName(): string;
  86564. /**
  86565. * Checks if the material is ready to render the requested sub mesh
  86566. * @param mesh Define the mesh the submesh belongs to
  86567. * @param subMesh Define the sub mesh to look readyness for
  86568. * @param useInstances Define whether or not the material is used with instances
  86569. * @returns true if ready, otherwise false
  86570. */
  86571. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86572. /**
  86573. * Clones the current material and its related sub materials
  86574. * @param name Define the name of the newly cloned material
  86575. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  86576. * @returns the cloned material
  86577. */
  86578. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  86579. /**
  86580. * Serializes the materials into a JSON representation.
  86581. * @returns the JSON representation
  86582. */
  86583. serialize(): any;
  86584. /**
  86585. * Dispose the material and release its associated resources
  86586. * @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)
  86587. * @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)
  86588. * @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)
  86589. */
  86590. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  86591. /**
  86592. * Creates a MultiMaterial from parsed MultiMaterial data.
  86593. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  86594. * @param scene defines the hosting scene
  86595. * @returns a new MultiMaterial
  86596. */
  86597. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  86598. }
  86599. }
  86600. declare module BABYLON {
  86601. /**
  86602. * Base class for submeshes
  86603. */
  86604. export class BaseSubMesh {
  86605. /** @hidden */
  86606. _materialDefines: Nullable<MaterialDefines>;
  86607. /** @hidden */
  86608. _materialEffect: Nullable<Effect>;
  86609. /**
  86610. * Gets associated effect
  86611. */
  86612. readonly effect: Nullable<Effect>;
  86613. /**
  86614. * Sets associated effect (effect used to render this submesh)
  86615. * @param effect defines the effect to associate with
  86616. * @param defines defines the set of defines used to compile this effect
  86617. */
  86618. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  86619. }
  86620. /**
  86621. * Defines a subdivision inside a mesh
  86622. */
  86623. export class SubMesh extends BaseSubMesh implements ICullable {
  86624. /** the material index to use */
  86625. materialIndex: number;
  86626. /** vertex index start */
  86627. verticesStart: number;
  86628. /** vertices count */
  86629. verticesCount: number;
  86630. /** index start */
  86631. indexStart: number;
  86632. /** indices count */
  86633. indexCount: number;
  86634. /** @hidden */
  86635. _linesIndexCount: number;
  86636. private _mesh;
  86637. private _renderingMesh;
  86638. private _boundingInfo;
  86639. private _linesIndexBuffer;
  86640. /** @hidden */
  86641. _lastColliderWorldVertices: Nullable<Vector3[]>;
  86642. /** @hidden */
  86643. _trianglePlanes: Plane[];
  86644. /** @hidden */
  86645. _lastColliderTransformMatrix: Nullable<Matrix>;
  86646. /** @hidden */
  86647. _renderId: number;
  86648. /** @hidden */
  86649. _alphaIndex: number;
  86650. /** @hidden */
  86651. _distanceToCamera: number;
  86652. /** @hidden */
  86653. _id: number;
  86654. private _currentMaterial;
  86655. /**
  86656. * Add a new submesh to a mesh
  86657. * @param materialIndex defines the material index to use
  86658. * @param verticesStart defines vertex index start
  86659. * @param verticesCount defines vertices count
  86660. * @param indexStart defines index start
  86661. * @param indexCount defines indices count
  86662. * @param mesh defines the parent mesh
  86663. * @param renderingMesh defines an optional rendering mesh
  86664. * @param createBoundingBox defines if bounding box should be created for this submesh
  86665. * @returns the new submesh
  86666. */
  86667. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  86668. /**
  86669. * Creates a new submesh
  86670. * @param materialIndex defines the material index to use
  86671. * @param verticesStart defines vertex index start
  86672. * @param verticesCount defines vertices count
  86673. * @param indexStart defines index start
  86674. * @param indexCount defines indices count
  86675. * @param mesh defines the parent mesh
  86676. * @param renderingMesh defines an optional rendering mesh
  86677. * @param createBoundingBox defines if bounding box should be created for this submesh
  86678. */
  86679. constructor(
  86680. /** the material index to use */
  86681. materialIndex: number,
  86682. /** vertex index start */
  86683. verticesStart: number,
  86684. /** vertices count */
  86685. verticesCount: number,
  86686. /** index start */
  86687. indexStart: number,
  86688. /** indices count */
  86689. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  86690. /**
  86691. * Returns true if this submesh covers the entire parent mesh
  86692. * @ignorenaming
  86693. */
  86694. readonly IsGlobal: boolean;
  86695. /**
  86696. * Returns the submesh BoudingInfo object
  86697. * @returns current bounding info (or mesh's one if the submesh is global)
  86698. */
  86699. getBoundingInfo(): BoundingInfo;
  86700. /**
  86701. * Sets the submesh BoundingInfo
  86702. * @param boundingInfo defines the new bounding info to use
  86703. * @returns the SubMesh
  86704. */
  86705. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  86706. /**
  86707. * Returns the mesh of the current submesh
  86708. * @return the parent mesh
  86709. */
  86710. getMesh(): AbstractMesh;
  86711. /**
  86712. * Returns the rendering mesh of the submesh
  86713. * @returns the rendering mesh (could be different from parent mesh)
  86714. */
  86715. getRenderingMesh(): Mesh;
  86716. /**
  86717. * Returns the submesh material
  86718. * @returns null or the current material
  86719. */
  86720. getMaterial(): Nullable<Material>;
  86721. /**
  86722. * Sets a new updated BoundingInfo object to the submesh
  86723. * @param data defines an optional position array to use to determine the bounding info
  86724. * @returns the SubMesh
  86725. */
  86726. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  86727. /** @hidden */
  86728. _checkCollision(collider: Collider): boolean;
  86729. /**
  86730. * Updates the submesh BoundingInfo
  86731. * @param world defines the world matrix to use to update the bounding info
  86732. * @returns the submesh
  86733. */
  86734. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  86735. /**
  86736. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  86737. * @param frustumPlanes defines the frustum planes
  86738. * @returns true if the submesh is intersecting with the frustum
  86739. */
  86740. isInFrustum(frustumPlanes: Plane[]): boolean;
  86741. /**
  86742. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  86743. * @param frustumPlanes defines the frustum planes
  86744. * @returns true if the submesh is inside the frustum
  86745. */
  86746. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86747. /**
  86748. * Renders the submesh
  86749. * @param enableAlphaMode defines if alpha needs to be used
  86750. * @returns the submesh
  86751. */
  86752. render(enableAlphaMode: boolean): SubMesh;
  86753. /**
  86754. * @hidden
  86755. */
  86756. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  86757. /**
  86758. * Checks if the submesh intersects with a ray
  86759. * @param ray defines the ray to test
  86760. * @returns true is the passed ray intersects the submesh bounding box
  86761. */
  86762. canIntersects(ray: Ray): boolean;
  86763. /**
  86764. * Intersects current submesh with a ray
  86765. * @param ray defines the ray to test
  86766. * @param positions defines mesh's positions array
  86767. * @param indices defines mesh's indices array
  86768. * @param fastCheck defines if only bounding info should be used
  86769. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  86770. * @returns intersection info or null if no intersection
  86771. */
  86772. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  86773. /** @hidden */
  86774. private _intersectLines;
  86775. /** @hidden */
  86776. private _intersectUnIndexedLines;
  86777. /** @hidden */
  86778. private _intersectTriangles;
  86779. /** @hidden */
  86780. private _intersectUnIndexedTriangles;
  86781. /** @hidden */
  86782. _rebuild(): void;
  86783. /**
  86784. * Creates a new submesh from the passed mesh
  86785. * @param newMesh defines the new hosting mesh
  86786. * @param newRenderingMesh defines an optional rendering mesh
  86787. * @returns the new submesh
  86788. */
  86789. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  86790. /**
  86791. * Release associated resources
  86792. */
  86793. dispose(): void;
  86794. /**
  86795. * Gets the class name
  86796. * @returns the string "SubMesh".
  86797. */
  86798. getClassName(): string;
  86799. /**
  86800. * Creates a new submesh from indices data
  86801. * @param materialIndex the index of the main mesh material
  86802. * @param startIndex the index where to start the copy in the mesh indices array
  86803. * @param indexCount the number of indices to copy then from the startIndex
  86804. * @param mesh the main mesh to create the submesh from
  86805. * @param renderingMesh the optional rendering mesh
  86806. * @returns a new submesh
  86807. */
  86808. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  86809. }
  86810. }
  86811. declare module BABYLON {
  86812. /**
  86813. * Class used to represent data loading progression
  86814. */
  86815. export class SceneLoaderFlags {
  86816. private static _ForceFullSceneLoadingForIncremental;
  86817. private static _ShowLoadingScreen;
  86818. private static _CleanBoneMatrixWeights;
  86819. private static _loggingLevel;
  86820. /**
  86821. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  86822. */
  86823. static ForceFullSceneLoadingForIncremental: boolean;
  86824. /**
  86825. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  86826. */
  86827. static ShowLoadingScreen: boolean;
  86828. /**
  86829. * Defines the current logging level (while loading the scene)
  86830. * @ignorenaming
  86831. */
  86832. static loggingLevel: number;
  86833. /**
  86834. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  86835. */
  86836. static CleanBoneMatrixWeights: boolean;
  86837. }
  86838. }
  86839. declare module BABYLON {
  86840. /**
  86841. * Class used to store geometry data (vertex buffers + index buffer)
  86842. */
  86843. export class Geometry implements IGetSetVerticesData {
  86844. /**
  86845. * Gets or sets the ID of the geometry
  86846. */
  86847. id: string;
  86848. /**
  86849. * Gets or sets the unique ID of the geometry
  86850. */
  86851. uniqueId: number;
  86852. /**
  86853. * Gets the delay loading state of the geometry (none by default which means not delayed)
  86854. */
  86855. delayLoadState: number;
  86856. /**
  86857. * Gets the file containing the data to load when running in delay load state
  86858. */
  86859. delayLoadingFile: Nullable<string>;
  86860. /**
  86861. * Callback called when the geometry is updated
  86862. */
  86863. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  86864. private _scene;
  86865. private _engine;
  86866. private _meshes;
  86867. private _totalVertices;
  86868. /** @hidden */
  86869. _indices: IndicesArray;
  86870. /** @hidden */
  86871. _vertexBuffers: {
  86872. [key: string]: VertexBuffer;
  86873. };
  86874. private _isDisposed;
  86875. private _extend;
  86876. private _boundingBias;
  86877. /** @hidden */
  86878. _delayInfo: Array<string>;
  86879. private _indexBuffer;
  86880. private _indexBufferIsUpdatable;
  86881. /** @hidden */
  86882. _boundingInfo: Nullable<BoundingInfo>;
  86883. /** @hidden */
  86884. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  86885. /** @hidden */
  86886. _softwareSkinningFrameId: number;
  86887. private _vertexArrayObjects;
  86888. private _updatable;
  86889. /** @hidden */
  86890. _positions: Nullable<Vector3[]>;
  86891. /**
  86892. * 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
  86893. */
  86894. /**
  86895. * 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
  86896. */
  86897. boundingBias: Vector2;
  86898. /**
  86899. * Static function used to attach a new empty geometry to a mesh
  86900. * @param mesh defines the mesh to attach the geometry to
  86901. * @returns the new Geometry
  86902. */
  86903. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  86904. /**
  86905. * Creates a new geometry
  86906. * @param id defines the unique ID
  86907. * @param scene defines the hosting scene
  86908. * @param vertexData defines the VertexData used to get geometry data
  86909. * @param updatable defines if geometry must be updatable (false by default)
  86910. * @param mesh defines the mesh that will be associated with the geometry
  86911. */
  86912. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  86913. /**
  86914. * Gets the current extend of the geometry
  86915. */
  86916. readonly extend: {
  86917. minimum: Vector3;
  86918. maximum: Vector3;
  86919. };
  86920. /**
  86921. * Gets the hosting scene
  86922. * @returns the hosting Scene
  86923. */
  86924. getScene(): Scene;
  86925. /**
  86926. * Gets the hosting engine
  86927. * @returns the hosting Engine
  86928. */
  86929. getEngine(): Engine;
  86930. /**
  86931. * Defines if the geometry is ready to use
  86932. * @returns true if the geometry is ready to be used
  86933. */
  86934. isReady(): boolean;
  86935. /**
  86936. * Gets a value indicating that the geometry should not be serialized
  86937. */
  86938. readonly doNotSerialize: boolean;
  86939. /** @hidden */
  86940. _rebuild(): void;
  86941. /**
  86942. * Affects all geometry data in one call
  86943. * @param vertexData defines the geometry data
  86944. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  86945. */
  86946. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  86947. /**
  86948. * Set specific vertex data
  86949. * @param kind defines the data kind (Position, normal, etc...)
  86950. * @param data defines the vertex data to use
  86951. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86952. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86953. */
  86954. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  86955. /**
  86956. * Removes a specific vertex data
  86957. * @param kind defines the data kind (Position, normal, etc...)
  86958. */
  86959. removeVerticesData(kind: string): void;
  86960. /**
  86961. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  86962. * @param buffer defines the vertex buffer to use
  86963. * @param totalVertices defines the total number of vertices for position kind (could be null)
  86964. */
  86965. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  86966. /**
  86967. * Update a specific vertex buffer
  86968. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86969. * It will do nothing if the buffer is not updatable
  86970. * @param kind defines the data kind (Position, normal, etc...)
  86971. * @param data defines the data to use
  86972. * @param offset defines the offset in the target buffer where to store the data
  86973. * @param useBytes set to true if the offset is in bytes
  86974. */
  86975. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86976. /**
  86977. * Update a specific vertex buffer
  86978. * This function will create a new buffer if the current one is not updatable
  86979. * @param kind defines the data kind (Position, normal, etc...)
  86980. * @param data defines the data to use
  86981. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86982. */
  86983. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86984. private _updateBoundingInfo;
  86985. /** @hidden */
  86986. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86987. /**
  86988. * Gets total number of vertices
  86989. * @returns the total number of vertices
  86990. */
  86991. getTotalVertices(): number;
  86992. /**
  86993. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86994. * @param kind defines the data kind (Position, normal, etc...)
  86995. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86996. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86997. * @returns a float array containing vertex data
  86998. */
  86999. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87000. /**
  87001. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87002. * @param kind defines the data kind (Position, normal, etc...)
  87003. * @returns true if the vertex buffer with the specified kind is updatable
  87004. */
  87005. isVertexBufferUpdatable(kind: string): boolean;
  87006. /**
  87007. * Gets a specific vertex buffer
  87008. * @param kind defines the data kind (Position, normal, etc...)
  87009. * @returns a VertexBuffer
  87010. */
  87011. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87012. /**
  87013. * Returns all vertex buffers
  87014. * @return an object holding all vertex buffers indexed by kind
  87015. */
  87016. getVertexBuffers(): Nullable<{
  87017. [key: string]: VertexBuffer;
  87018. }>;
  87019. /**
  87020. * Gets a boolean indicating if specific vertex buffer is present
  87021. * @param kind defines the data kind (Position, normal, etc...)
  87022. * @returns true if data is present
  87023. */
  87024. isVerticesDataPresent(kind: string): boolean;
  87025. /**
  87026. * Gets a list of all attached data kinds (Position, normal, etc...)
  87027. * @returns a list of string containing all kinds
  87028. */
  87029. getVerticesDataKinds(): string[];
  87030. /**
  87031. * Update index buffer
  87032. * @param indices defines the indices to store in the index buffer
  87033. * @param offset defines the offset in the target buffer where to store the data
  87034. * @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)
  87035. */
  87036. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87037. /**
  87038. * Creates a new index buffer
  87039. * @param indices defines the indices to store in the index buffer
  87040. * @param totalVertices defines the total number of vertices (could be null)
  87041. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87042. */
  87043. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87044. /**
  87045. * Return the total number of indices
  87046. * @returns the total number of indices
  87047. */
  87048. getTotalIndices(): number;
  87049. /**
  87050. * Gets the index buffer array
  87051. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87052. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87053. * @returns the index buffer array
  87054. */
  87055. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87056. /**
  87057. * Gets the index buffer
  87058. * @return the index buffer
  87059. */
  87060. getIndexBuffer(): Nullable<DataBuffer>;
  87061. /** @hidden */
  87062. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  87063. /**
  87064. * Release the associated resources for a specific mesh
  87065. * @param mesh defines the source mesh
  87066. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  87067. */
  87068. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  87069. /**
  87070. * Apply current geometry to a given mesh
  87071. * @param mesh defines the mesh to apply geometry to
  87072. */
  87073. applyToMesh(mesh: Mesh): void;
  87074. private _updateExtend;
  87075. private _applyToMesh;
  87076. private notifyUpdate;
  87077. /**
  87078. * Load the geometry if it was flagged as delay loaded
  87079. * @param scene defines the hosting scene
  87080. * @param onLoaded defines a callback called when the geometry is loaded
  87081. */
  87082. load(scene: Scene, onLoaded?: () => void): void;
  87083. private _queueLoad;
  87084. /**
  87085. * Invert the geometry to move from a right handed system to a left handed one.
  87086. */
  87087. toLeftHanded(): void;
  87088. /** @hidden */
  87089. _resetPointsArrayCache(): void;
  87090. /** @hidden */
  87091. _generatePointsArray(): boolean;
  87092. /**
  87093. * Gets a value indicating if the geometry is disposed
  87094. * @returns true if the geometry was disposed
  87095. */
  87096. isDisposed(): boolean;
  87097. private _disposeVertexArrayObjects;
  87098. /**
  87099. * Free all associated resources
  87100. */
  87101. dispose(): void;
  87102. /**
  87103. * Clone the current geometry into a new geometry
  87104. * @param id defines the unique ID of the new geometry
  87105. * @returns a new geometry object
  87106. */
  87107. copy(id: string): Geometry;
  87108. /**
  87109. * Serialize the current geometry info (and not the vertices data) into a JSON object
  87110. * @return a JSON representation of the current geometry data (without the vertices data)
  87111. */
  87112. serialize(): any;
  87113. private toNumberArray;
  87114. /**
  87115. * Serialize all vertices data into a JSON oject
  87116. * @returns a JSON representation of the current geometry data
  87117. */
  87118. serializeVerticeData(): any;
  87119. /**
  87120. * Extracts a clone of a mesh geometry
  87121. * @param mesh defines the source mesh
  87122. * @param id defines the unique ID of the new geometry object
  87123. * @returns the new geometry object
  87124. */
  87125. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  87126. /**
  87127. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  87128. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87129. * Be aware Math.random() could cause collisions, but:
  87130. * "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"
  87131. * @returns a string containing a new GUID
  87132. */
  87133. static RandomId(): string;
  87134. /** @hidden */
  87135. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  87136. private static _CleanMatricesWeights;
  87137. /**
  87138. * Create a new geometry from persisted data (Using .babylon file format)
  87139. * @param parsedVertexData defines the persisted data
  87140. * @param scene defines the hosting scene
  87141. * @param rootUrl defines the root url to use to load assets (like delayed data)
  87142. * @returns the new geometry object
  87143. */
  87144. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  87145. }
  87146. }
  87147. declare module BABYLON {
  87148. /**
  87149. * Define an interface for all classes that will get and set the data on vertices
  87150. */
  87151. export interface IGetSetVerticesData {
  87152. /**
  87153. * Gets a boolean indicating if specific vertex data is present
  87154. * @param kind defines the vertex data kind to use
  87155. * @returns true is data kind is present
  87156. */
  87157. isVerticesDataPresent(kind: string): boolean;
  87158. /**
  87159. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87160. * @param kind defines the data kind (Position, normal, etc...)
  87161. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87162. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87163. * @returns a float array containing vertex data
  87164. */
  87165. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87166. /**
  87167. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87168. * @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.
  87169. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87170. * @returns the indices array or an empty array if the mesh has no geometry
  87171. */
  87172. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87173. /**
  87174. * Set specific vertex data
  87175. * @param kind defines the data kind (Position, normal, etc...)
  87176. * @param data defines the vertex data to use
  87177. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87178. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87179. */
  87180. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  87181. /**
  87182. * Update a specific associated vertex buffer
  87183. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87184. * - VertexBuffer.PositionKind
  87185. * - VertexBuffer.UVKind
  87186. * - VertexBuffer.UV2Kind
  87187. * - VertexBuffer.UV3Kind
  87188. * - VertexBuffer.UV4Kind
  87189. * - VertexBuffer.UV5Kind
  87190. * - VertexBuffer.UV6Kind
  87191. * - VertexBuffer.ColorKind
  87192. * - VertexBuffer.MatricesIndicesKind
  87193. * - VertexBuffer.MatricesIndicesExtraKind
  87194. * - VertexBuffer.MatricesWeightsKind
  87195. * - VertexBuffer.MatricesWeightsExtraKind
  87196. * @param data defines the data source
  87197. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87198. * @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)
  87199. */
  87200. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  87201. /**
  87202. * Creates a new index buffer
  87203. * @param indices defines the indices to store in the index buffer
  87204. * @param totalVertices defines the total number of vertices (could be null)
  87205. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87206. */
  87207. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  87208. }
  87209. /**
  87210. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  87211. */
  87212. export class VertexData {
  87213. /**
  87214. * Mesh side orientation : usually the external or front surface
  87215. */
  87216. static readonly FRONTSIDE: number;
  87217. /**
  87218. * Mesh side orientation : usually the internal or back surface
  87219. */
  87220. static readonly BACKSIDE: number;
  87221. /**
  87222. * Mesh side orientation : both internal and external or front and back surfaces
  87223. */
  87224. static readonly DOUBLESIDE: number;
  87225. /**
  87226. * Mesh side orientation : by default, `FRONTSIDE`
  87227. */
  87228. static readonly DEFAULTSIDE: number;
  87229. /**
  87230. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  87231. */
  87232. positions: Nullable<FloatArray>;
  87233. /**
  87234. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  87235. */
  87236. normals: Nullable<FloatArray>;
  87237. /**
  87238. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  87239. */
  87240. tangents: Nullable<FloatArray>;
  87241. /**
  87242. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87243. */
  87244. uvs: Nullable<FloatArray>;
  87245. /**
  87246. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87247. */
  87248. uvs2: Nullable<FloatArray>;
  87249. /**
  87250. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87251. */
  87252. uvs3: Nullable<FloatArray>;
  87253. /**
  87254. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87255. */
  87256. uvs4: Nullable<FloatArray>;
  87257. /**
  87258. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87259. */
  87260. uvs5: Nullable<FloatArray>;
  87261. /**
  87262. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87263. */
  87264. uvs6: Nullable<FloatArray>;
  87265. /**
  87266. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  87267. */
  87268. colors: Nullable<FloatArray>;
  87269. /**
  87270. * 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).
  87271. */
  87272. matricesIndices: Nullable<FloatArray>;
  87273. /**
  87274. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  87275. */
  87276. matricesWeights: Nullable<FloatArray>;
  87277. /**
  87278. * An array extending the number of possible indices
  87279. */
  87280. matricesIndicesExtra: Nullable<FloatArray>;
  87281. /**
  87282. * An array extending the number of possible weights when the number of indices is extended
  87283. */
  87284. matricesWeightsExtra: Nullable<FloatArray>;
  87285. /**
  87286. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  87287. */
  87288. indices: Nullable<IndicesArray>;
  87289. /**
  87290. * Uses the passed data array to set the set the values for the specified kind of data
  87291. * @param data a linear array of floating numbers
  87292. * @param kind the type of data that is being set, eg positions, colors etc
  87293. */
  87294. set(data: FloatArray, kind: string): void;
  87295. /**
  87296. * Associates the vertexData to the passed Mesh.
  87297. * Sets it as updatable or not (default `false`)
  87298. * @param mesh the mesh the vertexData is applied to
  87299. * @param updatable when used and having the value true allows new data to update the vertexData
  87300. * @returns the VertexData
  87301. */
  87302. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  87303. /**
  87304. * Associates the vertexData to the passed Geometry.
  87305. * Sets it as updatable or not (default `false`)
  87306. * @param geometry the geometry the vertexData is applied to
  87307. * @param updatable when used and having the value true allows new data to update the vertexData
  87308. * @returns VertexData
  87309. */
  87310. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  87311. /**
  87312. * Updates the associated mesh
  87313. * @param mesh the mesh to be updated
  87314. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87315. * @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
  87316. * @returns VertexData
  87317. */
  87318. updateMesh(mesh: Mesh): VertexData;
  87319. /**
  87320. * Updates the associated geometry
  87321. * @param geometry the geometry to be updated
  87322. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87323. * @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
  87324. * @returns VertexData.
  87325. */
  87326. updateGeometry(geometry: Geometry): VertexData;
  87327. private _applyTo;
  87328. private _update;
  87329. /**
  87330. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87331. * @param matrix the transforming matrix
  87332. * @returns the VertexData
  87333. */
  87334. transform(matrix: Matrix): VertexData;
  87335. /**
  87336. * Merges the passed VertexData into the current one
  87337. * @param other the VertexData to be merged into the current one
  87338. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87339. * @returns the modified VertexData
  87340. */
  87341. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  87342. private _mergeElement;
  87343. private _validate;
  87344. /**
  87345. * Serializes the VertexData
  87346. * @returns a serialized object
  87347. */
  87348. serialize(): any;
  87349. /**
  87350. * Extracts the vertexData from a mesh
  87351. * @param mesh the mesh from which to extract the VertexData
  87352. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87353. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87354. * @returns the object VertexData associated to the passed mesh
  87355. */
  87356. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87357. /**
  87358. * Extracts the vertexData from the geometry
  87359. * @param geometry the geometry from which to extract the VertexData
  87360. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87361. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87362. * @returns the object VertexData associated to the passed mesh
  87363. */
  87364. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87365. private static _ExtractFrom;
  87366. /**
  87367. * Creates the VertexData for a Ribbon
  87368. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87369. * * pathArray array of paths, each of which an array of successive Vector3
  87370. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87371. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87372. * * 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
  87373. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87374. * * 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)
  87375. * * 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)
  87376. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87377. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87378. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87379. * @returns the VertexData of the ribbon
  87380. */
  87381. static CreateRibbon(options: {
  87382. pathArray: Vector3[][];
  87383. closeArray?: boolean;
  87384. closePath?: boolean;
  87385. offset?: number;
  87386. sideOrientation?: number;
  87387. frontUVs?: Vector4;
  87388. backUVs?: Vector4;
  87389. invertUV?: boolean;
  87390. uvs?: Vector2[];
  87391. colors?: Color4[];
  87392. }): VertexData;
  87393. /**
  87394. * Creates the VertexData for a box
  87395. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87396. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87397. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87398. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87399. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87400. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87401. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87402. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87403. * * 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)
  87404. * * 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)
  87405. * @returns the VertexData of the box
  87406. */
  87407. static CreateBox(options: {
  87408. size?: number;
  87409. width?: number;
  87410. height?: number;
  87411. depth?: number;
  87412. faceUV?: Vector4[];
  87413. faceColors?: Color4[];
  87414. sideOrientation?: number;
  87415. frontUVs?: Vector4;
  87416. backUVs?: Vector4;
  87417. }): VertexData;
  87418. /**
  87419. * Creates the VertexData for a tiled box
  87420. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87421. * * faceTiles sets the pattern, tile size and number of tiles for a face
  87422. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87423. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87424. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87425. * @returns the VertexData of the box
  87426. */
  87427. static CreateTiledBox(options: {
  87428. pattern?: number;
  87429. width?: number;
  87430. height?: number;
  87431. depth?: number;
  87432. tileSize?: number;
  87433. tileWidth?: number;
  87434. tileHeight?: number;
  87435. alignHorizontal?: number;
  87436. alignVertical?: number;
  87437. faceUV?: Vector4[];
  87438. faceColors?: Color4[];
  87439. sideOrientation?: number;
  87440. }): VertexData;
  87441. /**
  87442. * Creates the VertexData for a tiled plane
  87443. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87444. * * pattern a limited pattern arrangement depending on the number
  87445. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  87446. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  87447. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  87448. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87449. * * 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)
  87450. * * 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)
  87451. * @returns the VertexData of the tiled plane
  87452. */
  87453. static CreateTiledPlane(options: {
  87454. pattern?: number;
  87455. tileSize?: number;
  87456. tileWidth?: number;
  87457. tileHeight?: number;
  87458. size?: number;
  87459. width?: number;
  87460. height?: number;
  87461. alignHorizontal?: number;
  87462. alignVertical?: number;
  87463. sideOrientation?: number;
  87464. frontUVs?: Vector4;
  87465. backUVs?: Vector4;
  87466. }): VertexData;
  87467. /**
  87468. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87469. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87470. * * segments sets the number of horizontal strips optional, default 32
  87471. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87472. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87473. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87474. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87475. * * 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
  87476. * * 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
  87477. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87478. * * 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)
  87479. * * 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)
  87480. * @returns the VertexData of the ellipsoid
  87481. */
  87482. static CreateSphere(options: {
  87483. segments?: number;
  87484. diameter?: number;
  87485. diameterX?: number;
  87486. diameterY?: number;
  87487. diameterZ?: number;
  87488. arc?: number;
  87489. slice?: number;
  87490. sideOrientation?: number;
  87491. frontUVs?: Vector4;
  87492. backUVs?: Vector4;
  87493. }): VertexData;
  87494. /**
  87495. * Creates the VertexData for a cylinder, cone or prism
  87496. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87497. * * height sets the height (y direction) of the cylinder, optional, default 2
  87498. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87499. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87500. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87501. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87502. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87503. * * 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
  87504. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87505. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87506. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87507. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87508. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87509. * * 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)
  87510. * * 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)
  87511. * @returns the VertexData of the cylinder, cone or prism
  87512. */
  87513. static CreateCylinder(options: {
  87514. height?: number;
  87515. diameterTop?: number;
  87516. diameterBottom?: number;
  87517. diameter?: number;
  87518. tessellation?: number;
  87519. subdivisions?: number;
  87520. arc?: number;
  87521. faceColors?: Color4[];
  87522. faceUV?: Vector4[];
  87523. hasRings?: boolean;
  87524. enclose?: boolean;
  87525. sideOrientation?: number;
  87526. frontUVs?: Vector4;
  87527. backUVs?: Vector4;
  87528. }): VertexData;
  87529. /**
  87530. * Creates the VertexData for a torus
  87531. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87532. * * diameter the diameter of the torus, optional default 1
  87533. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87534. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87535. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87536. * * 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)
  87537. * * 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)
  87538. * @returns the VertexData of the torus
  87539. */
  87540. static CreateTorus(options: {
  87541. diameter?: number;
  87542. thickness?: number;
  87543. tessellation?: number;
  87544. sideOrientation?: number;
  87545. frontUVs?: Vector4;
  87546. backUVs?: Vector4;
  87547. }): VertexData;
  87548. /**
  87549. * Creates the VertexData of the LineSystem
  87550. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87551. * - lines an array of lines, each line being an array of successive Vector3
  87552. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87553. * @returns the VertexData of the LineSystem
  87554. */
  87555. static CreateLineSystem(options: {
  87556. lines: Vector3[][];
  87557. colors?: Nullable<Color4[][]>;
  87558. }): VertexData;
  87559. /**
  87560. * Create the VertexData for a DashedLines
  87561. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87562. * - points an array successive Vector3
  87563. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87564. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87565. * - dashNb the intended total number of dashes, optional, default 200
  87566. * @returns the VertexData for the DashedLines
  87567. */
  87568. static CreateDashedLines(options: {
  87569. points: Vector3[];
  87570. dashSize?: number;
  87571. gapSize?: number;
  87572. dashNb?: number;
  87573. }): VertexData;
  87574. /**
  87575. * Creates the VertexData for a Ground
  87576. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87577. * - width the width (x direction) of the ground, optional, default 1
  87578. * - height the height (z direction) of the ground, optional, default 1
  87579. * - subdivisions the number of subdivisions per side, optional, default 1
  87580. * @returns the VertexData of the Ground
  87581. */
  87582. static CreateGround(options: {
  87583. width?: number;
  87584. height?: number;
  87585. subdivisions?: number;
  87586. subdivisionsX?: number;
  87587. subdivisionsY?: number;
  87588. }): VertexData;
  87589. /**
  87590. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87591. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87592. * * xmin the ground minimum X coordinate, optional, default -1
  87593. * * zmin the ground minimum Z coordinate, optional, default -1
  87594. * * xmax the ground maximum X coordinate, optional, default 1
  87595. * * zmax the ground maximum Z coordinate, optional, default 1
  87596. * * 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}
  87597. * * 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}
  87598. * @returns the VertexData of the TiledGround
  87599. */
  87600. static CreateTiledGround(options: {
  87601. xmin: number;
  87602. zmin: number;
  87603. xmax: number;
  87604. zmax: number;
  87605. subdivisions?: {
  87606. w: number;
  87607. h: number;
  87608. };
  87609. precision?: {
  87610. w: number;
  87611. h: number;
  87612. };
  87613. }): VertexData;
  87614. /**
  87615. * Creates the VertexData of the Ground designed from a heightmap
  87616. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87617. * * width the width (x direction) of the ground
  87618. * * height the height (z direction) of the ground
  87619. * * subdivisions the number of subdivisions per side
  87620. * * minHeight the minimum altitude on the ground, optional, default 0
  87621. * * maxHeight the maximum altitude on the ground, optional default 1
  87622. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87623. * * buffer the array holding the image color data
  87624. * * bufferWidth the width of image
  87625. * * bufferHeight the height of image
  87626. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87627. * @returns the VertexData of the Ground designed from a heightmap
  87628. */
  87629. static CreateGroundFromHeightMap(options: {
  87630. width: number;
  87631. height: number;
  87632. subdivisions: number;
  87633. minHeight: number;
  87634. maxHeight: number;
  87635. colorFilter: Color3;
  87636. buffer: Uint8Array;
  87637. bufferWidth: number;
  87638. bufferHeight: number;
  87639. alphaFilter: number;
  87640. }): VertexData;
  87641. /**
  87642. * Creates the VertexData for a Plane
  87643. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87644. * * size sets the width and height of the plane to the value of size, optional default 1
  87645. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87646. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87647. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87648. * * 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)
  87649. * * 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)
  87650. * @returns the VertexData of the box
  87651. */
  87652. static CreatePlane(options: {
  87653. size?: number;
  87654. width?: number;
  87655. height?: number;
  87656. sideOrientation?: number;
  87657. frontUVs?: Vector4;
  87658. backUVs?: Vector4;
  87659. }): VertexData;
  87660. /**
  87661. * Creates the VertexData of the Disc or regular Polygon
  87662. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87663. * * radius the radius of the disc, optional default 0.5
  87664. * * tessellation the number of polygon sides, optional, default 64
  87665. * * 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
  87666. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87667. * * 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)
  87668. * * 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)
  87669. * @returns the VertexData of the box
  87670. */
  87671. static CreateDisc(options: {
  87672. radius?: number;
  87673. tessellation?: number;
  87674. arc?: number;
  87675. sideOrientation?: number;
  87676. frontUVs?: Vector4;
  87677. backUVs?: Vector4;
  87678. }): VertexData;
  87679. /**
  87680. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87681. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87682. * @param polygon a mesh built from polygonTriangulation.build()
  87683. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87684. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87685. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87686. * @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)
  87687. * @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)
  87688. * @returns the VertexData of the Polygon
  87689. */
  87690. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  87691. /**
  87692. * Creates the VertexData of the IcoSphere
  87693. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87694. * * radius the radius of the IcoSphere, optional default 1
  87695. * * radiusX allows stretching in the x direction, optional, default radius
  87696. * * radiusY allows stretching in the y direction, optional, default radius
  87697. * * radiusZ allows stretching in the z direction, optional, default radius
  87698. * * flat when true creates a flat shaded mesh, optional, default true
  87699. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87700. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87701. * * 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)
  87702. * * 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)
  87703. * @returns the VertexData of the IcoSphere
  87704. */
  87705. static CreateIcoSphere(options: {
  87706. radius?: number;
  87707. radiusX?: number;
  87708. radiusY?: number;
  87709. radiusZ?: number;
  87710. flat?: boolean;
  87711. subdivisions?: number;
  87712. sideOrientation?: number;
  87713. frontUVs?: Vector4;
  87714. backUVs?: Vector4;
  87715. }): VertexData;
  87716. /**
  87717. * Creates the VertexData for a Polyhedron
  87718. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87719. * * type provided types are:
  87720. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87721. * * 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)
  87722. * * size the size of the IcoSphere, optional default 1
  87723. * * sizeX allows stretching in the x direction, optional, default size
  87724. * * sizeY allows stretching in the y direction, optional, default size
  87725. * * sizeZ allows stretching in the z direction, optional, default size
  87726. * * 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
  87727. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87728. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87729. * * flat when true creates a flat shaded mesh, optional, default true
  87730. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87731. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87732. * * 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)
  87733. * * 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)
  87734. * @returns the VertexData of the Polyhedron
  87735. */
  87736. static CreatePolyhedron(options: {
  87737. type?: number;
  87738. size?: number;
  87739. sizeX?: number;
  87740. sizeY?: number;
  87741. sizeZ?: number;
  87742. custom?: any;
  87743. faceUV?: Vector4[];
  87744. faceColors?: Color4[];
  87745. flat?: boolean;
  87746. sideOrientation?: number;
  87747. frontUVs?: Vector4;
  87748. backUVs?: Vector4;
  87749. }): VertexData;
  87750. /**
  87751. * Creates the VertexData for a TorusKnot
  87752. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87753. * * radius the radius of the torus knot, optional, default 2
  87754. * * tube the thickness of the tube, optional, default 0.5
  87755. * * radialSegments the number of sides on each tube segments, optional, default 32
  87756. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87757. * * p the number of windings around the z axis, optional, default 2
  87758. * * q the number of windings around the x axis, optional, default 3
  87759. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87760. * * 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)
  87761. * * 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)
  87762. * @returns the VertexData of the Torus Knot
  87763. */
  87764. static CreateTorusKnot(options: {
  87765. radius?: number;
  87766. tube?: number;
  87767. radialSegments?: number;
  87768. tubularSegments?: number;
  87769. p?: number;
  87770. q?: number;
  87771. sideOrientation?: number;
  87772. frontUVs?: Vector4;
  87773. backUVs?: Vector4;
  87774. }): VertexData;
  87775. /**
  87776. * Compute normals for given positions and indices
  87777. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87778. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87779. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87780. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87781. * * facetNormals : optional array of facet normals (vector3)
  87782. * * facetPositions : optional array of facet positions (vector3)
  87783. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87784. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87785. * * bInfo : optional bounding info, required for facetPartitioning computation
  87786. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87787. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87788. * * useRightHandedSystem: optional boolean to for right handed system computation
  87789. * * depthSort : optional boolean to enable the facet depth sort computation
  87790. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87791. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87792. */
  87793. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  87794. facetNormals?: any;
  87795. facetPositions?: any;
  87796. facetPartitioning?: any;
  87797. ratio?: number;
  87798. bInfo?: any;
  87799. bbSize?: Vector3;
  87800. subDiv?: any;
  87801. useRightHandedSystem?: boolean;
  87802. depthSort?: boolean;
  87803. distanceTo?: Vector3;
  87804. depthSortedFacets?: any;
  87805. }): void;
  87806. /** @hidden */
  87807. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  87808. /**
  87809. * Applies VertexData created from the imported parameters to the geometry
  87810. * @param parsedVertexData the parsed data from an imported file
  87811. * @param geometry the geometry to apply the VertexData to
  87812. */
  87813. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  87814. }
  87815. }
  87816. declare module BABYLON {
  87817. /**
  87818. * Defines a target to use with MorphTargetManager
  87819. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87820. */
  87821. export class MorphTarget implements IAnimatable {
  87822. /** defines the name of the target */
  87823. name: string;
  87824. /**
  87825. * Gets or sets the list of animations
  87826. */
  87827. animations: Animation[];
  87828. private _scene;
  87829. private _positions;
  87830. private _normals;
  87831. private _tangents;
  87832. private _uvs;
  87833. private _influence;
  87834. /**
  87835. * Observable raised when the influence changes
  87836. */
  87837. onInfluenceChanged: Observable<boolean>;
  87838. /** @hidden */
  87839. _onDataLayoutChanged: Observable<void>;
  87840. /**
  87841. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  87842. */
  87843. influence: number;
  87844. /**
  87845. * Gets or sets the id of the morph Target
  87846. */
  87847. id: string;
  87848. private _animationPropertiesOverride;
  87849. /**
  87850. * Gets or sets the animation properties override
  87851. */
  87852. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87853. /**
  87854. * Creates a new MorphTarget
  87855. * @param name defines the name of the target
  87856. * @param influence defines the influence to use
  87857. * @param scene defines the scene the morphtarget belongs to
  87858. */
  87859. constructor(
  87860. /** defines the name of the target */
  87861. name: string, influence?: number, scene?: Nullable<Scene>);
  87862. /**
  87863. * Gets a boolean defining if the target contains position data
  87864. */
  87865. readonly hasPositions: boolean;
  87866. /**
  87867. * Gets a boolean defining if the target contains normal data
  87868. */
  87869. readonly hasNormals: boolean;
  87870. /**
  87871. * Gets a boolean defining if the target contains tangent data
  87872. */
  87873. readonly hasTangents: boolean;
  87874. /**
  87875. * Gets a boolean defining if the target contains texture coordinates data
  87876. */
  87877. readonly hasUVs: boolean;
  87878. /**
  87879. * Affects position data to this target
  87880. * @param data defines the position data to use
  87881. */
  87882. setPositions(data: Nullable<FloatArray>): void;
  87883. /**
  87884. * Gets the position data stored in this target
  87885. * @returns a FloatArray containing the position data (or null if not present)
  87886. */
  87887. getPositions(): Nullable<FloatArray>;
  87888. /**
  87889. * Affects normal data to this target
  87890. * @param data defines the normal data to use
  87891. */
  87892. setNormals(data: Nullable<FloatArray>): void;
  87893. /**
  87894. * Gets the normal data stored in this target
  87895. * @returns a FloatArray containing the normal data (or null if not present)
  87896. */
  87897. getNormals(): Nullable<FloatArray>;
  87898. /**
  87899. * Affects tangent data to this target
  87900. * @param data defines the tangent data to use
  87901. */
  87902. setTangents(data: Nullable<FloatArray>): void;
  87903. /**
  87904. * Gets the tangent data stored in this target
  87905. * @returns a FloatArray containing the tangent data (or null if not present)
  87906. */
  87907. getTangents(): Nullable<FloatArray>;
  87908. /**
  87909. * Affects texture coordinates data to this target
  87910. * @param data defines the texture coordinates data to use
  87911. */
  87912. setUVs(data: Nullable<FloatArray>): void;
  87913. /**
  87914. * Gets the texture coordinates data stored in this target
  87915. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  87916. */
  87917. getUVs(): Nullable<FloatArray>;
  87918. /**
  87919. * Serializes the current target into a Serialization object
  87920. * @returns the serialized object
  87921. */
  87922. serialize(): any;
  87923. /**
  87924. * Returns the string "MorphTarget"
  87925. * @returns "MorphTarget"
  87926. */
  87927. getClassName(): string;
  87928. /**
  87929. * Creates a new target from serialized data
  87930. * @param serializationObject defines the serialized data to use
  87931. * @returns a new MorphTarget
  87932. */
  87933. static Parse(serializationObject: any): MorphTarget;
  87934. /**
  87935. * Creates a MorphTarget from mesh data
  87936. * @param mesh defines the source mesh
  87937. * @param name defines the name to use for the new target
  87938. * @param influence defines the influence to attach to the target
  87939. * @returns a new MorphTarget
  87940. */
  87941. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  87942. }
  87943. }
  87944. declare module BABYLON {
  87945. /**
  87946. * This class is used to deform meshes using morphing between different targets
  87947. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87948. */
  87949. export class MorphTargetManager {
  87950. private _targets;
  87951. private _targetInfluenceChangedObservers;
  87952. private _targetDataLayoutChangedObservers;
  87953. private _activeTargets;
  87954. private _scene;
  87955. private _influences;
  87956. private _supportsNormals;
  87957. private _supportsTangents;
  87958. private _supportsUVs;
  87959. private _vertexCount;
  87960. private _uniqueId;
  87961. private _tempInfluences;
  87962. /**
  87963. * Gets or sets a boolean indicating if normals must be morphed
  87964. */
  87965. enableNormalMorphing: boolean;
  87966. /**
  87967. * Gets or sets a boolean indicating if tangents must be morphed
  87968. */
  87969. enableTangentMorphing: boolean;
  87970. /**
  87971. * Gets or sets a boolean indicating if UV must be morphed
  87972. */
  87973. enableUVMorphing: boolean;
  87974. /**
  87975. * Creates a new MorphTargetManager
  87976. * @param scene defines the current scene
  87977. */
  87978. constructor(scene?: Nullable<Scene>);
  87979. /**
  87980. * Gets the unique ID of this manager
  87981. */
  87982. readonly uniqueId: number;
  87983. /**
  87984. * Gets the number of vertices handled by this manager
  87985. */
  87986. readonly vertexCount: number;
  87987. /**
  87988. * Gets a boolean indicating if this manager supports morphing of normals
  87989. */
  87990. readonly supportsNormals: boolean;
  87991. /**
  87992. * Gets a boolean indicating if this manager supports morphing of tangents
  87993. */
  87994. readonly supportsTangents: boolean;
  87995. /**
  87996. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  87997. */
  87998. readonly supportsUVs: boolean;
  87999. /**
  88000. * Gets the number of targets stored in this manager
  88001. */
  88002. readonly numTargets: number;
  88003. /**
  88004. * Gets the number of influencers (ie. the number of targets with influences > 0)
  88005. */
  88006. readonly numInfluencers: number;
  88007. /**
  88008. * Gets the list of influences (one per target)
  88009. */
  88010. readonly influences: Float32Array;
  88011. /**
  88012. * Gets the active target at specified index. An active target is a target with an influence > 0
  88013. * @param index defines the index to check
  88014. * @returns the requested target
  88015. */
  88016. getActiveTarget(index: number): MorphTarget;
  88017. /**
  88018. * Gets the target at specified index
  88019. * @param index defines the index to check
  88020. * @returns the requested target
  88021. */
  88022. getTarget(index: number): MorphTarget;
  88023. /**
  88024. * Add a new target to this manager
  88025. * @param target defines the target to add
  88026. */
  88027. addTarget(target: MorphTarget): void;
  88028. /**
  88029. * Removes a target from the manager
  88030. * @param target defines the target to remove
  88031. */
  88032. removeTarget(target: MorphTarget): void;
  88033. /**
  88034. * Serializes the current manager into a Serialization object
  88035. * @returns the serialized object
  88036. */
  88037. serialize(): any;
  88038. private _syncActiveTargets;
  88039. /**
  88040. * Syncrhonize the targets with all the meshes using this morph target manager
  88041. */
  88042. synchronize(): void;
  88043. /**
  88044. * Creates a new MorphTargetManager from serialized data
  88045. * @param serializationObject defines the serialized data
  88046. * @param scene defines the hosting scene
  88047. * @returns the new MorphTargetManager
  88048. */
  88049. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  88050. }
  88051. }
  88052. declare module BABYLON {
  88053. /**
  88054. * Class used to represent a specific level of detail of a mesh
  88055. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88056. */
  88057. export class MeshLODLevel {
  88058. /** Defines the distance where this level should start being displayed */
  88059. distance: number;
  88060. /** Defines the mesh to use to render this level */
  88061. mesh: Nullable<Mesh>;
  88062. /**
  88063. * Creates a new LOD level
  88064. * @param distance defines the distance where this level should star being displayed
  88065. * @param mesh defines the mesh to use to render this level
  88066. */
  88067. constructor(
  88068. /** Defines the distance where this level should start being displayed */
  88069. distance: number,
  88070. /** Defines the mesh to use to render this level */
  88071. mesh: Nullable<Mesh>);
  88072. }
  88073. }
  88074. declare module BABYLON {
  88075. /**
  88076. * Mesh representing the gorund
  88077. */
  88078. export class GroundMesh extends Mesh {
  88079. /** If octree should be generated */
  88080. generateOctree: boolean;
  88081. private _heightQuads;
  88082. /** @hidden */
  88083. _subdivisionsX: number;
  88084. /** @hidden */
  88085. _subdivisionsY: number;
  88086. /** @hidden */
  88087. _width: number;
  88088. /** @hidden */
  88089. _height: number;
  88090. /** @hidden */
  88091. _minX: number;
  88092. /** @hidden */
  88093. _maxX: number;
  88094. /** @hidden */
  88095. _minZ: number;
  88096. /** @hidden */
  88097. _maxZ: number;
  88098. constructor(name: string, scene: Scene);
  88099. /**
  88100. * "GroundMesh"
  88101. * @returns "GroundMesh"
  88102. */
  88103. getClassName(): string;
  88104. /**
  88105. * The minimum of x and y subdivisions
  88106. */
  88107. readonly subdivisions: number;
  88108. /**
  88109. * X subdivisions
  88110. */
  88111. readonly subdivisionsX: number;
  88112. /**
  88113. * Y subdivisions
  88114. */
  88115. readonly subdivisionsY: number;
  88116. /**
  88117. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  88118. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  88119. * @param chunksCount the number of subdivisions for x and y
  88120. * @param octreeBlocksSize (Default: 32)
  88121. */
  88122. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  88123. /**
  88124. * Returns a height (y) value in the Worl system :
  88125. * the ground altitude at the coordinates (x, z) expressed in the World system.
  88126. * @param x x coordinate
  88127. * @param z z coordinate
  88128. * @returns the ground y position if (x, z) are outside the ground surface.
  88129. */
  88130. getHeightAtCoordinates(x: number, z: number): number;
  88131. /**
  88132. * Returns a normalized vector (Vector3) orthogonal to the ground
  88133. * at the ground coordinates (x, z) expressed in the World system.
  88134. * @param x x coordinate
  88135. * @param z z coordinate
  88136. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  88137. */
  88138. getNormalAtCoordinates(x: number, z: number): Vector3;
  88139. /**
  88140. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  88141. * at the ground coordinates (x, z) expressed in the World system.
  88142. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  88143. * @param x x coordinate
  88144. * @param z z coordinate
  88145. * @param ref vector to store the result
  88146. * @returns the GroundMesh.
  88147. */
  88148. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  88149. /**
  88150. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  88151. * if the ground has been updated.
  88152. * This can be used in the render loop.
  88153. * @returns the GroundMesh.
  88154. */
  88155. updateCoordinateHeights(): GroundMesh;
  88156. private _getFacetAt;
  88157. private _initHeightQuads;
  88158. private _computeHeightQuads;
  88159. /**
  88160. * Serializes this ground mesh
  88161. * @param serializationObject object to write serialization to
  88162. */
  88163. serialize(serializationObject: any): void;
  88164. /**
  88165. * Parses a serialized ground mesh
  88166. * @param parsedMesh the serialized mesh
  88167. * @param scene the scene to create the ground mesh in
  88168. * @returns the created ground mesh
  88169. */
  88170. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  88171. }
  88172. }
  88173. declare module BABYLON {
  88174. /**
  88175. * Interface for Physics-Joint data
  88176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88177. */
  88178. export interface PhysicsJointData {
  88179. /**
  88180. * The main pivot of the joint
  88181. */
  88182. mainPivot?: Vector3;
  88183. /**
  88184. * The connected pivot of the joint
  88185. */
  88186. connectedPivot?: Vector3;
  88187. /**
  88188. * The main axis of the joint
  88189. */
  88190. mainAxis?: Vector3;
  88191. /**
  88192. * The connected axis of the joint
  88193. */
  88194. connectedAxis?: Vector3;
  88195. /**
  88196. * The collision of the joint
  88197. */
  88198. collision?: boolean;
  88199. /**
  88200. * Native Oimo/Cannon/Energy data
  88201. */
  88202. nativeParams?: any;
  88203. }
  88204. /**
  88205. * This is a holder class for the physics joint created by the physics plugin
  88206. * It holds a set of functions to control the underlying joint
  88207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88208. */
  88209. export class PhysicsJoint {
  88210. /**
  88211. * The type of the physics joint
  88212. */
  88213. type: number;
  88214. /**
  88215. * The data for the physics joint
  88216. */
  88217. jointData: PhysicsJointData;
  88218. private _physicsJoint;
  88219. protected _physicsPlugin: IPhysicsEnginePlugin;
  88220. /**
  88221. * Initializes the physics joint
  88222. * @param type The type of the physics joint
  88223. * @param jointData The data for the physics joint
  88224. */
  88225. constructor(
  88226. /**
  88227. * The type of the physics joint
  88228. */
  88229. type: number,
  88230. /**
  88231. * The data for the physics joint
  88232. */
  88233. jointData: PhysicsJointData);
  88234. /**
  88235. * Gets the physics joint
  88236. */
  88237. /**
  88238. * Sets the physics joint
  88239. */
  88240. physicsJoint: any;
  88241. /**
  88242. * Sets the physics plugin
  88243. */
  88244. physicsPlugin: IPhysicsEnginePlugin;
  88245. /**
  88246. * Execute a function that is physics-plugin specific.
  88247. * @param {Function} func the function that will be executed.
  88248. * It accepts two parameters: the physics world and the physics joint
  88249. */
  88250. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  88251. /**
  88252. * Distance-Joint type
  88253. */
  88254. static DistanceJoint: number;
  88255. /**
  88256. * Hinge-Joint type
  88257. */
  88258. static HingeJoint: number;
  88259. /**
  88260. * Ball-and-Socket joint type
  88261. */
  88262. static BallAndSocketJoint: number;
  88263. /**
  88264. * Wheel-Joint type
  88265. */
  88266. static WheelJoint: number;
  88267. /**
  88268. * Slider-Joint type
  88269. */
  88270. static SliderJoint: number;
  88271. /**
  88272. * Prismatic-Joint type
  88273. */
  88274. static PrismaticJoint: number;
  88275. /**
  88276. * Universal-Joint type
  88277. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  88278. */
  88279. static UniversalJoint: number;
  88280. /**
  88281. * Hinge-Joint 2 type
  88282. */
  88283. static Hinge2Joint: number;
  88284. /**
  88285. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  88286. */
  88287. static PointToPointJoint: number;
  88288. /**
  88289. * Spring-Joint type
  88290. */
  88291. static SpringJoint: number;
  88292. /**
  88293. * Lock-Joint type
  88294. */
  88295. static LockJoint: number;
  88296. }
  88297. /**
  88298. * A class representing a physics distance joint
  88299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88300. */
  88301. export class DistanceJoint extends PhysicsJoint {
  88302. /**
  88303. *
  88304. * @param jointData The data for the Distance-Joint
  88305. */
  88306. constructor(jointData: DistanceJointData);
  88307. /**
  88308. * Update the predefined distance.
  88309. * @param maxDistance The maximum preferred distance
  88310. * @param minDistance The minimum preferred distance
  88311. */
  88312. updateDistance(maxDistance: number, minDistance?: number): void;
  88313. }
  88314. /**
  88315. * Represents a Motor-Enabled Joint
  88316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88317. */
  88318. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  88319. /**
  88320. * Initializes the Motor-Enabled Joint
  88321. * @param type The type of the joint
  88322. * @param jointData The physica joint data for the joint
  88323. */
  88324. constructor(type: number, jointData: PhysicsJointData);
  88325. /**
  88326. * Set the motor values.
  88327. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88328. * @param force the force to apply
  88329. * @param maxForce max force for this motor.
  88330. */
  88331. setMotor(force?: number, maxForce?: number): void;
  88332. /**
  88333. * Set the motor's limits.
  88334. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88335. * @param upperLimit The upper limit of the motor
  88336. * @param lowerLimit The lower limit of the motor
  88337. */
  88338. setLimit(upperLimit: number, lowerLimit?: number): void;
  88339. }
  88340. /**
  88341. * This class represents a single physics Hinge-Joint
  88342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88343. */
  88344. export class HingeJoint extends MotorEnabledJoint {
  88345. /**
  88346. * Initializes the Hinge-Joint
  88347. * @param jointData The joint data for the Hinge-Joint
  88348. */
  88349. constructor(jointData: PhysicsJointData);
  88350. /**
  88351. * Set the motor values.
  88352. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88353. * @param {number} force the force to apply
  88354. * @param {number} maxForce max force for this motor.
  88355. */
  88356. setMotor(force?: number, maxForce?: number): void;
  88357. /**
  88358. * Set the motor's limits.
  88359. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88360. * @param upperLimit The upper limit of the motor
  88361. * @param lowerLimit The lower limit of the motor
  88362. */
  88363. setLimit(upperLimit: number, lowerLimit?: number): void;
  88364. }
  88365. /**
  88366. * This class represents a dual hinge physics joint (same as wheel joint)
  88367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88368. */
  88369. export class Hinge2Joint extends MotorEnabledJoint {
  88370. /**
  88371. * Initializes the Hinge2-Joint
  88372. * @param jointData The joint data for the Hinge2-Joint
  88373. */
  88374. constructor(jointData: PhysicsJointData);
  88375. /**
  88376. * Set the motor values.
  88377. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88378. * @param {number} targetSpeed the speed the motor is to reach
  88379. * @param {number} maxForce max force for this motor.
  88380. * @param {motorIndex} the motor's index, 0 or 1.
  88381. */
  88382. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  88383. /**
  88384. * Set the motor limits.
  88385. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88386. * @param {number} upperLimit the upper limit
  88387. * @param {number} lowerLimit lower limit
  88388. * @param {motorIndex} the motor's index, 0 or 1.
  88389. */
  88390. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88391. }
  88392. /**
  88393. * Interface for a motor enabled joint
  88394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88395. */
  88396. export interface IMotorEnabledJoint {
  88397. /**
  88398. * Physics joint
  88399. */
  88400. physicsJoint: any;
  88401. /**
  88402. * Sets the motor of the motor-enabled joint
  88403. * @param force The force of the motor
  88404. * @param maxForce The maximum force of the motor
  88405. * @param motorIndex The index of the motor
  88406. */
  88407. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  88408. /**
  88409. * Sets the limit of the motor
  88410. * @param upperLimit The upper limit of the motor
  88411. * @param lowerLimit The lower limit of the motor
  88412. * @param motorIndex The index of the motor
  88413. */
  88414. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88415. }
  88416. /**
  88417. * Joint data for a Distance-Joint
  88418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88419. */
  88420. export interface DistanceJointData extends PhysicsJointData {
  88421. /**
  88422. * Max distance the 2 joint objects can be apart
  88423. */
  88424. maxDistance: number;
  88425. }
  88426. /**
  88427. * Joint data from a spring joint
  88428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88429. */
  88430. export interface SpringJointData extends PhysicsJointData {
  88431. /**
  88432. * Length of the spring
  88433. */
  88434. length: number;
  88435. /**
  88436. * Stiffness of the spring
  88437. */
  88438. stiffness: number;
  88439. /**
  88440. * Damping of the spring
  88441. */
  88442. damping: number;
  88443. /** this callback will be called when applying the force to the impostors. */
  88444. forceApplicationCallback: () => void;
  88445. }
  88446. }
  88447. declare module BABYLON {
  88448. /**
  88449. * Holds the data for the raycast result
  88450. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88451. */
  88452. export class PhysicsRaycastResult {
  88453. private _hasHit;
  88454. private _hitDistance;
  88455. private _hitNormalWorld;
  88456. private _hitPointWorld;
  88457. private _rayFromWorld;
  88458. private _rayToWorld;
  88459. /**
  88460. * Gets if there was a hit
  88461. */
  88462. readonly hasHit: boolean;
  88463. /**
  88464. * Gets the distance from the hit
  88465. */
  88466. readonly hitDistance: number;
  88467. /**
  88468. * Gets the hit normal/direction in the world
  88469. */
  88470. readonly hitNormalWorld: Vector3;
  88471. /**
  88472. * Gets the hit point in the world
  88473. */
  88474. readonly hitPointWorld: Vector3;
  88475. /**
  88476. * Gets the ray "start point" of the ray in the world
  88477. */
  88478. readonly rayFromWorld: Vector3;
  88479. /**
  88480. * Gets the ray "end point" of the ray in the world
  88481. */
  88482. readonly rayToWorld: Vector3;
  88483. /**
  88484. * Sets the hit data (normal & point in world space)
  88485. * @param hitNormalWorld defines the normal in world space
  88486. * @param hitPointWorld defines the point in world space
  88487. */
  88488. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  88489. /**
  88490. * Sets the distance from the start point to the hit point
  88491. * @param distance
  88492. */
  88493. setHitDistance(distance: number): void;
  88494. /**
  88495. * Calculates the distance manually
  88496. */
  88497. calculateHitDistance(): void;
  88498. /**
  88499. * Resets all the values to default
  88500. * @param from The from point on world space
  88501. * @param to The to point on world space
  88502. */
  88503. reset(from?: Vector3, to?: Vector3): void;
  88504. }
  88505. /**
  88506. * Interface for the size containing width and height
  88507. */
  88508. interface IXYZ {
  88509. /**
  88510. * X
  88511. */
  88512. x: number;
  88513. /**
  88514. * Y
  88515. */
  88516. y: number;
  88517. /**
  88518. * Z
  88519. */
  88520. z: number;
  88521. }
  88522. }
  88523. declare module BABYLON {
  88524. /**
  88525. * Interface used to describe a physics joint
  88526. */
  88527. export interface PhysicsImpostorJoint {
  88528. /** Defines the main impostor to which the joint is linked */
  88529. mainImpostor: PhysicsImpostor;
  88530. /** Defines the impostor that is connected to the main impostor using this joint */
  88531. connectedImpostor: PhysicsImpostor;
  88532. /** Defines the joint itself */
  88533. joint: PhysicsJoint;
  88534. }
  88535. /** @hidden */
  88536. export interface IPhysicsEnginePlugin {
  88537. world: any;
  88538. name: string;
  88539. setGravity(gravity: Vector3): void;
  88540. setTimeStep(timeStep: number): void;
  88541. getTimeStep(): number;
  88542. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  88543. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88544. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88545. generatePhysicsBody(impostor: PhysicsImpostor): void;
  88546. removePhysicsBody(impostor: PhysicsImpostor): void;
  88547. generateJoint(joint: PhysicsImpostorJoint): void;
  88548. removeJoint(joint: PhysicsImpostorJoint): void;
  88549. isSupported(): boolean;
  88550. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  88551. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  88552. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88553. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88554. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88555. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88556. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  88557. getBodyMass(impostor: PhysicsImpostor): number;
  88558. getBodyFriction(impostor: PhysicsImpostor): number;
  88559. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  88560. getBodyRestitution(impostor: PhysicsImpostor): number;
  88561. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  88562. getBodyPressure?(impostor: PhysicsImpostor): number;
  88563. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  88564. getBodyStiffness?(impostor: PhysicsImpostor): number;
  88565. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  88566. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  88567. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  88568. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  88569. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  88570. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88571. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88572. sleepBody(impostor: PhysicsImpostor): void;
  88573. wakeUpBody(impostor: PhysicsImpostor): void;
  88574. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88575. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  88576. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  88577. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88578. getRadius(impostor: PhysicsImpostor): number;
  88579. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  88580. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  88581. dispose(): void;
  88582. }
  88583. /**
  88584. * Interface used to define a physics engine
  88585. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  88586. */
  88587. export interface IPhysicsEngine {
  88588. /**
  88589. * Gets the gravity vector used by the simulation
  88590. */
  88591. gravity: Vector3;
  88592. /**
  88593. * Sets the gravity vector used by the simulation
  88594. * @param gravity defines the gravity vector to use
  88595. */
  88596. setGravity(gravity: Vector3): void;
  88597. /**
  88598. * Set the time step of the physics engine.
  88599. * Default is 1/60.
  88600. * To slow it down, enter 1/600 for example.
  88601. * To speed it up, 1/30
  88602. * @param newTimeStep the new timestep to apply to this world.
  88603. */
  88604. setTimeStep(newTimeStep: number): void;
  88605. /**
  88606. * Get the time step of the physics engine.
  88607. * @returns the current time step
  88608. */
  88609. getTimeStep(): number;
  88610. /**
  88611. * Release all resources
  88612. */
  88613. dispose(): void;
  88614. /**
  88615. * Gets the name of the current physics plugin
  88616. * @returns the name of the plugin
  88617. */
  88618. getPhysicsPluginName(): string;
  88619. /**
  88620. * Adding a new impostor for the impostor tracking.
  88621. * This will be done by the impostor itself.
  88622. * @param impostor the impostor to add
  88623. */
  88624. addImpostor(impostor: PhysicsImpostor): void;
  88625. /**
  88626. * Remove an impostor from the engine.
  88627. * This impostor and its mesh will not longer be updated by the physics engine.
  88628. * @param impostor the impostor to remove
  88629. */
  88630. removeImpostor(impostor: PhysicsImpostor): void;
  88631. /**
  88632. * Add a joint to the physics engine
  88633. * @param mainImpostor defines the main impostor to which the joint is added.
  88634. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  88635. * @param joint defines the joint that will connect both impostors.
  88636. */
  88637. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88638. /**
  88639. * Removes a joint from the simulation
  88640. * @param mainImpostor defines the impostor used with the joint
  88641. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  88642. * @param joint defines the joint to remove
  88643. */
  88644. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88645. /**
  88646. * Gets the current plugin used to run the simulation
  88647. * @returns current plugin
  88648. */
  88649. getPhysicsPlugin(): IPhysicsEnginePlugin;
  88650. /**
  88651. * Gets the list of physic impostors
  88652. * @returns an array of PhysicsImpostor
  88653. */
  88654. getImpostors(): Array<PhysicsImpostor>;
  88655. /**
  88656. * Gets the impostor for a physics enabled object
  88657. * @param object defines the object impersonated by the impostor
  88658. * @returns the PhysicsImpostor or null if not found
  88659. */
  88660. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88661. /**
  88662. * Gets the impostor for a physics body object
  88663. * @param body defines physics body used by the impostor
  88664. * @returns the PhysicsImpostor or null if not found
  88665. */
  88666. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  88667. /**
  88668. * Does a raycast in the physics world
  88669. * @param from when should the ray start?
  88670. * @param to when should the ray end?
  88671. * @returns PhysicsRaycastResult
  88672. */
  88673. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88674. /**
  88675. * Called by the scene. No need to call it.
  88676. * @param delta defines the timespam between frames
  88677. */
  88678. _step(delta: number): void;
  88679. }
  88680. }
  88681. declare module BABYLON {
  88682. /**
  88683. * The interface for the physics imposter parameters
  88684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88685. */
  88686. export interface PhysicsImpostorParameters {
  88687. /**
  88688. * The mass of the physics imposter
  88689. */
  88690. mass: number;
  88691. /**
  88692. * The friction of the physics imposter
  88693. */
  88694. friction?: number;
  88695. /**
  88696. * The coefficient of restitution of the physics imposter
  88697. */
  88698. restitution?: number;
  88699. /**
  88700. * The native options of the physics imposter
  88701. */
  88702. nativeOptions?: any;
  88703. /**
  88704. * Specifies if the parent should be ignored
  88705. */
  88706. ignoreParent?: boolean;
  88707. /**
  88708. * Specifies if bi-directional transformations should be disabled
  88709. */
  88710. disableBidirectionalTransformation?: boolean;
  88711. /**
  88712. * The pressure inside the physics imposter, soft object only
  88713. */
  88714. pressure?: number;
  88715. /**
  88716. * The stiffness the physics imposter, soft object only
  88717. */
  88718. stiffness?: number;
  88719. /**
  88720. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  88721. */
  88722. velocityIterations?: number;
  88723. /**
  88724. * The number of iterations used in maintaining consistent vertex positions, soft object only
  88725. */
  88726. positionIterations?: number;
  88727. /**
  88728. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  88729. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  88730. * Add to fix multiple points
  88731. */
  88732. fixedPoints?: number;
  88733. /**
  88734. * The collision margin around a soft object
  88735. */
  88736. margin?: number;
  88737. /**
  88738. * The collision margin around a soft object
  88739. */
  88740. damping?: number;
  88741. /**
  88742. * The path for a rope based on an extrusion
  88743. */
  88744. path?: any;
  88745. /**
  88746. * The shape of an extrusion used for a rope based on an extrusion
  88747. */
  88748. shape?: any;
  88749. }
  88750. /**
  88751. * Interface for a physics-enabled object
  88752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88753. */
  88754. export interface IPhysicsEnabledObject {
  88755. /**
  88756. * The position of the physics-enabled object
  88757. */
  88758. position: Vector3;
  88759. /**
  88760. * The rotation of the physics-enabled object
  88761. */
  88762. rotationQuaternion: Nullable<Quaternion>;
  88763. /**
  88764. * The scale of the physics-enabled object
  88765. */
  88766. scaling: Vector3;
  88767. /**
  88768. * The rotation of the physics-enabled object
  88769. */
  88770. rotation?: Vector3;
  88771. /**
  88772. * The parent of the physics-enabled object
  88773. */
  88774. parent?: any;
  88775. /**
  88776. * The bounding info of the physics-enabled object
  88777. * @returns The bounding info of the physics-enabled object
  88778. */
  88779. getBoundingInfo(): BoundingInfo;
  88780. /**
  88781. * Computes the world matrix
  88782. * @param force Specifies if the world matrix should be computed by force
  88783. * @returns A world matrix
  88784. */
  88785. computeWorldMatrix(force: boolean): Matrix;
  88786. /**
  88787. * Gets the world matrix
  88788. * @returns A world matrix
  88789. */
  88790. getWorldMatrix?(): Matrix;
  88791. /**
  88792. * Gets the child meshes
  88793. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  88794. * @returns An array of abstract meshes
  88795. */
  88796. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  88797. /**
  88798. * Gets the vertex data
  88799. * @param kind The type of vertex data
  88800. * @returns A nullable array of numbers, or a float32 array
  88801. */
  88802. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  88803. /**
  88804. * Gets the indices from the mesh
  88805. * @returns A nullable array of index arrays
  88806. */
  88807. getIndices?(): Nullable<IndicesArray>;
  88808. /**
  88809. * Gets the scene from the mesh
  88810. * @returns the indices array or null
  88811. */
  88812. getScene?(): Scene;
  88813. /**
  88814. * Gets the absolute position from the mesh
  88815. * @returns the absolute position
  88816. */
  88817. getAbsolutePosition(): Vector3;
  88818. /**
  88819. * Gets the absolute pivot point from the mesh
  88820. * @returns the absolute pivot point
  88821. */
  88822. getAbsolutePivotPoint(): Vector3;
  88823. /**
  88824. * Rotates the mesh
  88825. * @param axis The axis of rotation
  88826. * @param amount The amount of rotation
  88827. * @param space The space of the rotation
  88828. * @returns The rotation transform node
  88829. */
  88830. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88831. /**
  88832. * Translates the mesh
  88833. * @param axis The axis of translation
  88834. * @param distance The distance of translation
  88835. * @param space The space of the translation
  88836. * @returns The transform node
  88837. */
  88838. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88839. /**
  88840. * Sets the absolute position of the mesh
  88841. * @param absolutePosition The absolute position of the mesh
  88842. * @returns The transform node
  88843. */
  88844. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88845. /**
  88846. * Gets the class name of the mesh
  88847. * @returns The class name
  88848. */
  88849. getClassName(): string;
  88850. }
  88851. /**
  88852. * Represents a physics imposter
  88853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88854. */
  88855. export class PhysicsImpostor {
  88856. /**
  88857. * The physics-enabled object used as the physics imposter
  88858. */
  88859. object: IPhysicsEnabledObject;
  88860. /**
  88861. * The type of the physics imposter
  88862. */
  88863. type: number;
  88864. private _options;
  88865. private _scene?;
  88866. /**
  88867. * The default object size of the imposter
  88868. */
  88869. static DEFAULT_OBJECT_SIZE: Vector3;
  88870. /**
  88871. * The identity quaternion of the imposter
  88872. */
  88873. static IDENTITY_QUATERNION: Quaternion;
  88874. /** @hidden */
  88875. _pluginData: any;
  88876. private _physicsEngine;
  88877. private _physicsBody;
  88878. private _bodyUpdateRequired;
  88879. private _onBeforePhysicsStepCallbacks;
  88880. private _onAfterPhysicsStepCallbacks;
  88881. /** @hidden */
  88882. _onPhysicsCollideCallbacks: Array<{
  88883. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  88884. otherImpostors: Array<PhysicsImpostor>;
  88885. }>;
  88886. private _deltaPosition;
  88887. private _deltaRotation;
  88888. private _deltaRotationConjugated;
  88889. /** @hidden */
  88890. _isFromLine: boolean;
  88891. private _parent;
  88892. private _isDisposed;
  88893. private static _tmpVecs;
  88894. private static _tmpQuat;
  88895. /**
  88896. * Specifies if the physics imposter is disposed
  88897. */
  88898. readonly isDisposed: boolean;
  88899. /**
  88900. * Gets the mass of the physics imposter
  88901. */
  88902. mass: number;
  88903. /**
  88904. * Gets the coefficient of friction
  88905. */
  88906. /**
  88907. * Sets the coefficient of friction
  88908. */
  88909. friction: number;
  88910. /**
  88911. * Gets the coefficient of restitution
  88912. */
  88913. /**
  88914. * Sets the coefficient of restitution
  88915. */
  88916. restitution: number;
  88917. /**
  88918. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  88919. */
  88920. /**
  88921. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  88922. */
  88923. pressure: number;
  88924. /**
  88925. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88926. */
  88927. /**
  88928. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88929. */
  88930. stiffness: number;
  88931. /**
  88932. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88933. */
  88934. /**
  88935. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88936. */
  88937. velocityIterations: number;
  88938. /**
  88939. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88940. */
  88941. /**
  88942. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88943. */
  88944. positionIterations: number;
  88945. /**
  88946. * The unique id of the physics imposter
  88947. * set by the physics engine when adding this impostor to the array
  88948. */
  88949. uniqueId: number;
  88950. /**
  88951. * @hidden
  88952. */
  88953. soft: boolean;
  88954. /**
  88955. * @hidden
  88956. */
  88957. segments: number;
  88958. private _joints;
  88959. /**
  88960. * Initializes the physics imposter
  88961. * @param object The physics-enabled object used as the physics imposter
  88962. * @param type The type of the physics imposter
  88963. * @param _options The options for the physics imposter
  88964. * @param _scene The Babylon scene
  88965. */
  88966. constructor(
  88967. /**
  88968. * The physics-enabled object used as the physics imposter
  88969. */
  88970. object: IPhysicsEnabledObject,
  88971. /**
  88972. * The type of the physics imposter
  88973. */
  88974. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  88975. /**
  88976. * This function will completly initialize this impostor.
  88977. * It will create a new body - but only if this mesh has no parent.
  88978. * If it has, this impostor will not be used other than to define the impostor
  88979. * of the child mesh.
  88980. * @hidden
  88981. */
  88982. _init(): void;
  88983. private _getPhysicsParent;
  88984. /**
  88985. * Should a new body be generated.
  88986. * @returns boolean specifying if body initialization is required
  88987. */
  88988. isBodyInitRequired(): boolean;
  88989. /**
  88990. * Sets the updated scaling
  88991. * @param updated Specifies if the scaling is updated
  88992. */
  88993. setScalingUpdated(): void;
  88994. /**
  88995. * Force a regeneration of this or the parent's impostor's body.
  88996. * Use under cautious - This will remove all joints already implemented.
  88997. */
  88998. forceUpdate(): void;
  88999. /**
  89000. * Gets the body that holds this impostor. Either its own, or its parent.
  89001. */
  89002. /**
  89003. * Set the physics body. Used mainly by the physics engine/plugin
  89004. */
  89005. physicsBody: any;
  89006. /**
  89007. * Get the parent of the physics imposter
  89008. * @returns Physics imposter or null
  89009. */
  89010. /**
  89011. * Sets the parent of the physics imposter
  89012. */
  89013. parent: Nullable<PhysicsImpostor>;
  89014. /**
  89015. * Resets the update flags
  89016. */
  89017. resetUpdateFlags(): void;
  89018. /**
  89019. * Gets the object extend size
  89020. * @returns the object extend size
  89021. */
  89022. getObjectExtendSize(): Vector3;
  89023. /**
  89024. * Gets the object center
  89025. * @returns The object center
  89026. */
  89027. getObjectCenter(): Vector3;
  89028. /**
  89029. * Get a specific parametes from the options parameter
  89030. * @param paramName The object parameter name
  89031. * @returns The object parameter
  89032. */
  89033. getParam(paramName: string): any;
  89034. /**
  89035. * Sets a specific parameter in the options given to the physics plugin
  89036. * @param paramName The parameter name
  89037. * @param value The value of the parameter
  89038. */
  89039. setParam(paramName: string, value: number): void;
  89040. /**
  89041. * Specifically change the body's mass option. Won't recreate the physics body object
  89042. * @param mass The mass of the physics imposter
  89043. */
  89044. setMass(mass: number): void;
  89045. /**
  89046. * Gets the linear velocity
  89047. * @returns linear velocity or null
  89048. */
  89049. getLinearVelocity(): Nullable<Vector3>;
  89050. /**
  89051. * Sets the linear velocity
  89052. * @param velocity linear velocity or null
  89053. */
  89054. setLinearVelocity(velocity: Nullable<Vector3>): void;
  89055. /**
  89056. * Gets the angular velocity
  89057. * @returns angular velocity or null
  89058. */
  89059. getAngularVelocity(): Nullable<Vector3>;
  89060. /**
  89061. * Sets the angular velocity
  89062. * @param velocity The velocity or null
  89063. */
  89064. setAngularVelocity(velocity: Nullable<Vector3>): void;
  89065. /**
  89066. * Execute a function with the physics plugin native code
  89067. * Provide a function the will have two variables - the world object and the physics body object
  89068. * @param func The function to execute with the physics plugin native code
  89069. */
  89070. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  89071. /**
  89072. * Register a function that will be executed before the physics world is stepping forward
  89073. * @param func The function to execute before the physics world is stepped forward
  89074. */
  89075. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89076. /**
  89077. * Unregister a function that will be executed before the physics world is stepping forward
  89078. * @param func The function to execute before the physics world is stepped forward
  89079. */
  89080. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89081. /**
  89082. * Register a function that will be executed after the physics step
  89083. * @param func The function to execute after physics step
  89084. */
  89085. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89086. /**
  89087. * Unregisters a function that will be executed after the physics step
  89088. * @param func The function to execute after physics step
  89089. */
  89090. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89091. /**
  89092. * register a function that will be executed when this impostor collides against a different body
  89093. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  89094. * @param func Callback that is executed on collision
  89095. */
  89096. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  89097. /**
  89098. * Unregisters the physics imposter on contact
  89099. * @param collideAgainst The physics object to collide against
  89100. * @param func Callback to execute on collision
  89101. */
  89102. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  89103. private _tmpQuat;
  89104. private _tmpQuat2;
  89105. /**
  89106. * Get the parent rotation
  89107. * @returns The parent rotation
  89108. */
  89109. getParentsRotation(): Quaternion;
  89110. /**
  89111. * this function is executed by the physics engine.
  89112. */
  89113. beforeStep: () => void;
  89114. /**
  89115. * this function is executed by the physics engine
  89116. */
  89117. afterStep: () => void;
  89118. /**
  89119. * Legacy collision detection event support
  89120. */
  89121. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  89122. /**
  89123. * event and body object due to cannon's event-based architecture.
  89124. */
  89125. onCollide: (e: {
  89126. body: any;
  89127. }) => void;
  89128. /**
  89129. * Apply a force
  89130. * @param force The force to apply
  89131. * @param contactPoint The contact point for the force
  89132. * @returns The physics imposter
  89133. */
  89134. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89135. /**
  89136. * Apply an impulse
  89137. * @param force The impulse force
  89138. * @param contactPoint The contact point for the impulse force
  89139. * @returns The physics imposter
  89140. */
  89141. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89142. /**
  89143. * A help function to create a joint
  89144. * @param otherImpostor A physics imposter used to create a joint
  89145. * @param jointType The type of joint
  89146. * @param jointData The data for the joint
  89147. * @returns The physics imposter
  89148. */
  89149. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  89150. /**
  89151. * Add a joint to this impostor with a different impostor
  89152. * @param otherImpostor A physics imposter used to add a joint
  89153. * @param joint The joint to add
  89154. * @returns The physics imposter
  89155. */
  89156. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  89157. /**
  89158. * Add an anchor to a cloth impostor
  89159. * @param otherImpostor rigid impostor to anchor to
  89160. * @param width ratio across width from 0 to 1
  89161. * @param height ratio up height from 0 to 1
  89162. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  89163. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  89164. * @returns impostor the soft imposter
  89165. */
  89166. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89167. /**
  89168. * Add a hook to a rope impostor
  89169. * @param otherImpostor rigid impostor to anchor to
  89170. * @param length ratio across rope from 0 to 1
  89171. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  89172. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  89173. * @returns impostor the rope imposter
  89174. */
  89175. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89176. /**
  89177. * Will keep this body still, in a sleep mode.
  89178. * @returns the physics imposter
  89179. */
  89180. sleep(): PhysicsImpostor;
  89181. /**
  89182. * Wake the body up.
  89183. * @returns The physics imposter
  89184. */
  89185. wakeUp(): PhysicsImpostor;
  89186. /**
  89187. * Clones the physics imposter
  89188. * @param newObject The physics imposter clones to this physics-enabled object
  89189. * @returns A nullable physics imposter
  89190. */
  89191. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89192. /**
  89193. * Disposes the physics imposter
  89194. */
  89195. dispose(): void;
  89196. /**
  89197. * Sets the delta position
  89198. * @param position The delta position amount
  89199. */
  89200. setDeltaPosition(position: Vector3): void;
  89201. /**
  89202. * Sets the delta rotation
  89203. * @param rotation The delta rotation amount
  89204. */
  89205. setDeltaRotation(rotation: Quaternion): void;
  89206. /**
  89207. * Gets the box size of the physics imposter and stores the result in the input parameter
  89208. * @param result Stores the box size
  89209. * @returns The physics imposter
  89210. */
  89211. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  89212. /**
  89213. * Gets the radius of the physics imposter
  89214. * @returns Radius of the physics imposter
  89215. */
  89216. getRadius(): number;
  89217. /**
  89218. * Sync a bone with this impostor
  89219. * @param bone The bone to sync to the impostor.
  89220. * @param boneMesh The mesh that the bone is influencing.
  89221. * @param jointPivot The pivot of the joint / bone in local space.
  89222. * @param distToJoint Optional distance from the impostor to the joint.
  89223. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89224. */
  89225. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  89226. /**
  89227. * Sync impostor to a bone
  89228. * @param bone The bone that the impostor will be synced to.
  89229. * @param boneMesh The mesh that the bone is influencing.
  89230. * @param jointPivot The pivot of the joint / bone in local space.
  89231. * @param distToJoint Optional distance from the impostor to the joint.
  89232. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89233. * @param boneAxis Optional vector3 axis the bone is aligned with
  89234. */
  89235. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  89236. /**
  89237. * No-Imposter type
  89238. */
  89239. static NoImpostor: number;
  89240. /**
  89241. * Sphere-Imposter type
  89242. */
  89243. static SphereImpostor: number;
  89244. /**
  89245. * Box-Imposter type
  89246. */
  89247. static BoxImpostor: number;
  89248. /**
  89249. * Plane-Imposter type
  89250. */
  89251. static PlaneImpostor: number;
  89252. /**
  89253. * Mesh-imposter type
  89254. */
  89255. static MeshImpostor: number;
  89256. /**
  89257. * Capsule-Impostor type (Ammo.js plugin only)
  89258. */
  89259. static CapsuleImpostor: number;
  89260. /**
  89261. * Cylinder-Imposter type
  89262. */
  89263. static CylinderImpostor: number;
  89264. /**
  89265. * Particle-Imposter type
  89266. */
  89267. static ParticleImpostor: number;
  89268. /**
  89269. * Heightmap-Imposter type
  89270. */
  89271. static HeightmapImpostor: number;
  89272. /**
  89273. * ConvexHull-Impostor type (Ammo.js plugin only)
  89274. */
  89275. static ConvexHullImpostor: number;
  89276. /**
  89277. * Rope-Imposter type
  89278. */
  89279. static RopeImpostor: number;
  89280. /**
  89281. * Cloth-Imposter type
  89282. */
  89283. static ClothImpostor: number;
  89284. /**
  89285. * Softbody-Imposter type
  89286. */
  89287. static SoftbodyImpostor: number;
  89288. }
  89289. }
  89290. declare module BABYLON {
  89291. /**
  89292. * @hidden
  89293. **/
  89294. export class _CreationDataStorage {
  89295. closePath?: boolean;
  89296. closeArray?: boolean;
  89297. idx: number[];
  89298. dashSize: number;
  89299. gapSize: number;
  89300. path3D: Path3D;
  89301. pathArray: Vector3[][];
  89302. arc: number;
  89303. radius: number;
  89304. cap: number;
  89305. tessellation: number;
  89306. }
  89307. /**
  89308. * @hidden
  89309. **/
  89310. class _InstanceDataStorage {
  89311. visibleInstances: any;
  89312. batchCache: _InstancesBatch;
  89313. instancesBufferSize: number;
  89314. instancesBuffer: Nullable<Buffer>;
  89315. instancesData: Float32Array;
  89316. overridenInstanceCount: number;
  89317. isFrozen: boolean;
  89318. previousBatch: Nullable<_InstancesBatch>;
  89319. hardwareInstancedRendering: boolean;
  89320. sideOrientation: number;
  89321. }
  89322. /**
  89323. * @hidden
  89324. **/
  89325. export class _InstancesBatch {
  89326. mustReturn: boolean;
  89327. visibleInstances: Nullable<InstancedMesh[]>[];
  89328. renderSelf: boolean[];
  89329. hardwareInstancedRendering: boolean[];
  89330. }
  89331. /**
  89332. * Class used to represent renderable models
  89333. */
  89334. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  89335. /**
  89336. * Mesh side orientation : usually the external or front surface
  89337. */
  89338. static readonly FRONTSIDE: number;
  89339. /**
  89340. * Mesh side orientation : usually the internal or back surface
  89341. */
  89342. static readonly BACKSIDE: number;
  89343. /**
  89344. * Mesh side orientation : both internal and external or front and back surfaces
  89345. */
  89346. static readonly DOUBLESIDE: number;
  89347. /**
  89348. * Mesh side orientation : by default, `FRONTSIDE`
  89349. */
  89350. static readonly DEFAULTSIDE: number;
  89351. /**
  89352. * Mesh cap setting : no cap
  89353. */
  89354. static readonly NO_CAP: number;
  89355. /**
  89356. * Mesh cap setting : one cap at the beginning of the mesh
  89357. */
  89358. static readonly CAP_START: number;
  89359. /**
  89360. * Mesh cap setting : one cap at the end of the mesh
  89361. */
  89362. static readonly CAP_END: number;
  89363. /**
  89364. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  89365. */
  89366. static readonly CAP_ALL: number;
  89367. /**
  89368. * Mesh pattern setting : no flip or rotate
  89369. */
  89370. static readonly NO_FLIP: number;
  89371. /**
  89372. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  89373. */
  89374. static readonly FLIP_TILE: number;
  89375. /**
  89376. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  89377. */
  89378. static readonly ROTATE_TILE: number;
  89379. /**
  89380. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  89381. */
  89382. static readonly FLIP_ROW: number;
  89383. /**
  89384. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  89385. */
  89386. static readonly ROTATE_ROW: number;
  89387. /**
  89388. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  89389. */
  89390. static readonly FLIP_N_ROTATE_TILE: number;
  89391. /**
  89392. * Mesh pattern setting : rotate pattern and rotate
  89393. */
  89394. static readonly FLIP_N_ROTATE_ROW: number;
  89395. /**
  89396. * Mesh tile positioning : part tiles same on left/right or top/bottom
  89397. */
  89398. static readonly CENTER: number;
  89399. /**
  89400. * Mesh tile positioning : part tiles on left
  89401. */
  89402. static readonly LEFT: number;
  89403. /**
  89404. * Mesh tile positioning : part tiles on right
  89405. */
  89406. static readonly RIGHT: number;
  89407. /**
  89408. * Mesh tile positioning : part tiles on top
  89409. */
  89410. static readonly TOP: number;
  89411. /**
  89412. * Mesh tile positioning : part tiles on bottom
  89413. */
  89414. static readonly BOTTOM: number;
  89415. /**
  89416. * Gets the default side orientation.
  89417. * @param orientation the orientation to value to attempt to get
  89418. * @returns the default orientation
  89419. * @hidden
  89420. */
  89421. static _GetDefaultSideOrientation(orientation?: number): number;
  89422. private _internalMeshDataInfo;
  89423. /**
  89424. * An event triggered before rendering the mesh
  89425. */
  89426. readonly onBeforeRenderObservable: Observable<Mesh>;
  89427. /**
  89428. * An event triggered before binding the mesh
  89429. */
  89430. readonly onBeforeBindObservable: Observable<Mesh>;
  89431. /**
  89432. * An event triggered after rendering the mesh
  89433. */
  89434. readonly onAfterRenderObservable: Observable<Mesh>;
  89435. /**
  89436. * An event triggered before drawing the mesh
  89437. */
  89438. readonly onBeforeDrawObservable: Observable<Mesh>;
  89439. private _onBeforeDrawObserver;
  89440. /**
  89441. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  89442. */
  89443. onBeforeDraw: () => void;
  89444. readonly hasInstances: boolean;
  89445. /**
  89446. * Gets the delay loading state of the mesh (when delay loading is turned on)
  89447. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  89448. */
  89449. delayLoadState: number;
  89450. /**
  89451. * Gets the list of instances created from this mesh
  89452. * it is not supposed to be modified manually.
  89453. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  89454. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89455. */
  89456. instances: InstancedMesh[];
  89457. /**
  89458. * Gets the file containing delay loading data for this mesh
  89459. */
  89460. delayLoadingFile: string;
  89461. /** @hidden */
  89462. _binaryInfo: any;
  89463. /**
  89464. * User defined function used to change how LOD level selection is done
  89465. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89466. */
  89467. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  89468. /**
  89469. * Gets or sets the morph target manager
  89470. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89471. */
  89472. morphTargetManager: Nullable<MorphTargetManager>;
  89473. /** @hidden */
  89474. _creationDataStorage: Nullable<_CreationDataStorage>;
  89475. /** @hidden */
  89476. _geometry: Nullable<Geometry>;
  89477. /** @hidden */
  89478. _delayInfo: Array<string>;
  89479. /** @hidden */
  89480. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  89481. /** @hidden */
  89482. _instanceDataStorage: _InstanceDataStorage;
  89483. private _effectiveMaterial;
  89484. /** @hidden */
  89485. _shouldGenerateFlatShading: boolean;
  89486. /** @hidden */
  89487. _originalBuilderSideOrientation: number;
  89488. /**
  89489. * Use this property to change the original side orientation defined at construction time
  89490. */
  89491. overrideMaterialSideOrientation: Nullable<number>;
  89492. /**
  89493. * Gets the source mesh (the one used to clone this one from)
  89494. */
  89495. readonly source: Nullable<Mesh>;
  89496. /**
  89497. * Gets or sets a boolean indicating that this mesh does not use index buffer
  89498. */
  89499. isUnIndexed: boolean;
  89500. /**
  89501. * @constructor
  89502. * @param name The value used by scene.getMeshByName() to do a lookup.
  89503. * @param scene The scene to add this mesh to.
  89504. * @param parent The parent of this mesh, if it has one
  89505. * @param source An optional Mesh from which geometry is shared, cloned.
  89506. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89507. * When false, achieved by calling a clone(), also passing False.
  89508. * This will make creation of children, recursive.
  89509. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  89510. */
  89511. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  89512. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  89513. /**
  89514. * Gets the class name
  89515. * @returns the string "Mesh".
  89516. */
  89517. getClassName(): string;
  89518. /** @hidden */
  89519. readonly _isMesh: boolean;
  89520. /**
  89521. * Returns a description of this mesh
  89522. * @param fullDetails define if full details about this mesh must be used
  89523. * @returns a descriptive string representing this mesh
  89524. */
  89525. toString(fullDetails?: boolean): string;
  89526. /** @hidden */
  89527. _unBindEffect(): void;
  89528. /**
  89529. * Gets a boolean indicating if this mesh has LOD
  89530. */
  89531. readonly hasLODLevels: boolean;
  89532. /**
  89533. * Gets the list of MeshLODLevel associated with the current mesh
  89534. * @returns an array of MeshLODLevel
  89535. */
  89536. getLODLevels(): MeshLODLevel[];
  89537. private _sortLODLevels;
  89538. /**
  89539. * Add a mesh as LOD level triggered at the given distance.
  89540. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89541. * @param distance The distance from the center of the object to show this level
  89542. * @param mesh The mesh to be added as LOD level (can be null)
  89543. * @return This mesh (for chaining)
  89544. */
  89545. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  89546. /**
  89547. * Returns the LOD level mesh at the passed distance or null if not found.
  89548. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89549. * @param distance The distance from the center of the object to show this level
  89550. * @returns a Mesh or `null`
  89551. */
  89552. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  89553. /**
  89554. * Remove a mesh from the LOD array
  89555. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89556. * @param mesh defines the mesh to be removed
  89557. * @return This mesh (for chaining)
  89558. */
  89559. removeLODLevel(mesh: Mesh): Mesh;
  89560. /**
  89561. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  89562. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89563. * @param camera defines the camera to use to compute distance
  89564. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  89565. * @return This mesh (for chaining)
  89566. */
  89567. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  89568. /**
  89569. * Gets the mesh internal Geometry object
  89570. */
  89571. readonly geometry: Nullable<Geometry>;
  89572. /**
  89573. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  89574. * @returns the total number of vertices
  89575. */
  89576. getTotalVertices(): number;
  89577. /**
  89578. * Returns the content of an associated vertex buffer
  89579. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89580. * - VertexBuffer.PositionKind
  89581. * - VertexBuffer.UVKind
  89582. * - VertexBuffer.UV2Kind
  89583. * - VertexBuffer.UV3Kind
  89584. * - VertexBuffer.UV4Kind
  89585. * - VertexBuffer.UV5Kind
  89586. * - VertexBuffer.UV6Kind
  89587. * - VertexBuffer.ColorKind
  89588. * - VertexBuffer.MatricesIndicesKind
  89589. * - VertexBuffer.MatricesIndicesExtraKind
  89590. * - VertexBuffer.MatricesWeightsKind
  89591. * - VertexBuffer.MatricesWeightsExtraKind
  89592. * @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
  89593. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  89594. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  89595. */
  89596. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89597. /**
  89598. * Returns the mesh VertexBuffer object from the requested `kind`
  89599. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89600. * - VertexBuffer.PositionKind
  89601. * - VertexBuffer.NormalKind
  89602. * - VertexBuffer.UVKind
  89603. * - VertexBuffer.UV2Kind
  89604. * - VertexBuffer.UV3Kind
  89605. * - VertexBuffer.UV4Kind
  89606. * - VertexBuffer.UV5Kind
  89607. * - VertexBuffer.UV6Kind
  89608. * - VertexBuffer.ColorKind
  89609. * - VertexBuffer.MatricesIndicesKind
  89610. * - VertexBuffer.MatricesIndicesExtraKind
  89611. * - VertexBuffer.MatricesWeightsKind
  89612. * - VertexBuffer.MatricesWeightsExtraKind
  89613. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  89614. */
  89615. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89616. /**
  89617. * Tests if a specific vertex buffer is associated with this mesh
  89618. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89619. * - VertexBuffer.PositionKind
  89620. * - VertexBuffer.NormalKind
  89621. * - VertexBuffer.UVKind
  89622. * - VertexBuffer.UV2Kind
  89623. * - VertexBuffer.UV3Kind
  89624. * - VertexBuffer.UV4Kind
  89625. * - VertexBuffer.UV5Kind
  89626. * - VertexBuffer.UV6Kind
  89627. * - VertexBuffer.ColorKind
  89628. * - VertexBuffer.MatricesIndicesKind
  89629. * - VertexBuffer.MatricesIndicesExtraKind
  89630. * - VertexBuffer.MatricesWeightsKind
  89631. * - VertexBuffer.MatricesWeightsExtraKind
  89632. * @returns a boolean
  89633. */
  89634. isVerticesDataPresent(kind: string): boolean;
  89635. /**
  89636. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  89637. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89638. * - VertexBuffer.PositionKind
  89639. * - VertexBuffer.UVKind
  89640. * - VertexBuffer.UV2Kind
  89641. * - VertexBuffer.UV3Kind
  89642. * - VertexBuffer.UV4Kind
  89643. * - VertexBuffer.UV5Kind
  89644. * - VertexBuffer.UV6Kind
  89645. * - VertexBuffer.ColorKind
  89646. * - VertexBuffer.MatricesIndicesKind
  89647. * - VertexBuffer.MatricesIndicesExtraKind
  89648. * - VertexBuffer.MatricesWeightsKind
  89649. * - VertexBuffer.MatricesWeightsExtraKind
  89650. * @returns a boolean
  89651. */
  89652. isVertexBufferUpdatable(kind: string): boolean;
  89653. /**
  89654. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  89655. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89656. * - VertexBuffer.PositionKind
  89657. * - VertexBuffer.NormalKind
  89658. * - VertexBuffer.UVKind
  89659. * - VertexBuffer.UV2Kind
  89660. * - VertexBuffer.UV3Kind
  89661. * - VertexBuffer.UV4Kind
  89662. * - VertexBuffer.UV5Kind
  89663. * - VertexBuffer.UV6Kind
  89664. * - VertexBuffer.ColorKind
  89665. * - VertexBuffer.MatricesIndicesKind
  89666. * - VertexBuffer.MatricesIndicesExtraKind
  89667. * - VertexBuffer.MatricesWeightsKind
  89668. * - VertexBuffer.MatricesWeightsExtraKind
  89669. * @returns an array of strings
  89670. */
  89671. getVerticesDataKinds(): string[];
  89672. /**
  89673. * Returns a positive integer : the total number of indices in this mesh geometry.
  89674. * @returns the numner of indices or zero if the mesh has no geometry.
  89675. */
  89676. getTotalIndices(): number;
  89677. /**
  89678. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89679. * @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.
  89680. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89681. * @returns the indices array or an empty array if the mesh has no geometry
  89682. */
  89683. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89684. readonly isBlocked: boolean;
  89685. /**
  89686. * Determine if the current mesh is ready to be rendered
  89687. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89688. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  89689. * @returns true if all associated assets are ready (material, textures, shaders)
  89690. */
  89691. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  89692. /**
  89693. * 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.
  89694. */
  89695. readonly areNormalsFrozen: boolean;
  89696. /**
  89697. * 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.
  89698. * @returns the current mesh
  89699. */
  89700. freezeNormals(): Mesh;
  89701. /**
  89702. * 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
  89703. * @returns the current mesh
  89704. */
  89705. unfreezeNormals(): Mesh;
  89706. /**
  89707. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  89708. */
  89709. overridenInstanceCount: number;
  89710. /** @hidden */
  89711. _preActivate(): Mesh;
  89712. /** @hidden */
  89713. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89714. /** @hidden */
  89715. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  89716. /**
  89717. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89718. * This means the mesh underlying bounding box and sphere are recomputed.
  89719. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89720. * @returns the current mesh
  89721. */
  89722. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  89723. /** @hidden */
  89724. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  89725. /**
  89726. * This function will subdivide the mesh into multiple submeshes
  89727. * @param count defines the expected number of submeshes
  89728. */
  89729. subdivide(count: number): void;
  89730. /**
  89731. * Copy a FloatArray into a specific associated vertex buffer
  89732. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89733. * - VertexBuffer.PositionKind
  89734. * - VertexBuffer.UVKind
  89735. * - VertexBuffer.UV2Kind
  89736. * - VertexBuffer.UV3Kind
  89737. * - VertexBuffer.UV4Kind
  89738. * - VertexBuffer.UV5Kind
  89739. * - VertexBuffer.UV6Kind
  89740. * - VertexBuffer.ColorKind
  89741. * - VertexBuffer.MatricesIndicesKind
  89742. * - VertexBuffer.MatricesIndicesExtraKind
  89743. * - VertexBuffer.MatricesWeightsKind
  89744. * - VertexBuffer.MatricesWeightsExtraKind
  89745. * @param data defines the data source
  89746. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89747. * @param stride defines the data stride size (can be null)
  89748. * @returns the current mesh
  89749. */
  89750. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89751. /**
  89752. * Flags an associated vertex buffer as updatable
  89753. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  89754. * - VertexBuffer.PositionKind
  89755. * - VertexBuffer.UVKind
  89756. * - VertexBuffer.UV2Kind
  89757. * - VertexBuffer.UV3Kind
  89758. * - VertexBuffer.UV4Kind
  89759. * - VertexBuffer.UV5Kind
  89760. * - VertexBuffer.UV6Kind
  89761. * - VertexBuffer.ColorKind
  89762. * - VertexBuffer.MatricesIndicesKind
  89763. * - VertexBuffer.MatricesIndicesExtraKind
  89764. * - VertexBuffer.MatricesWeightsKind
  89765. * - VertexBuffer.MatricesWeightsExtraKind
  89766. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89767. */
  89768. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  89769. /**
  89770. * Sets the mesh global Vertex Buffer
  89771. * @param buffer defines the buffer to use
  89772. * @returns the current mesh
  89773. */
  89774. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  89775. /**
  89776. * Update a specific associated vertex buffer
  89777. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89778. * - VertexBuffer.PositionKind
  89779. * - VertexBuffer.UVKind
  89780. * - VertexBuffer.UV2Kind
  89781. * - VertexBuffer.UV3Kind
  89782. * - VertexBuffer.UV4Kind
  89783. * - VertexBuffer.UV5Kind
  89784. * - VertexBuffer.UV6Kind
  89785. * - VertexBuffer.ColorKind
  89786. * - VertexBuffer.MatricesIndicesKind
  89787. * - VertexBuffer.MatricesIndicesExtraKind
  89788. * - VertexBuffer.MatricesWeightsKind
  89789. * - VertexBuffer.MatricesWeightsExtraKind
  89790. * @param data defines the data source
  89791. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89792. * @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)
  89793. * @returns the current mesh
  89794. */
  89795. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89796. /**
  89797. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  89798. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  89799. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  89800. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  89801. * @returns the current mesh
  89802. */
  89803. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  89804. /**
  89805. * Creates a un-shared specific occurence of the geometry for the mesh.
  89806. * @returns the current mesh
  89807. */
  89808. makeGeometryUnique(): Mesh;
  89809. /**
  89810. * Set the index buffer of this mesh
  89811. * @param indices defines the source data
  89812. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  89813. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  89814. * @returns the current mesh
  89815. */
  89816. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  89817. /**
  89818. * Update the current index buffer
  89819. * @param indices defines the source data
  89820. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89821. * @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)
  89822. * @returns the current mesh
  89823. */
  89824. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89825. /**
  89826. * Invert the geometry to move from a right handed system to a left handed one.
  89827. * @returns the current mesh
  89828. */
  89829. toLeftHanded(): Mesh;
  89830. /** @hidden */
  89831. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89832. /** @hidden */
  89833. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89834. /**
  89835. * Registers for this mesh a javascript function called just before the rendering process
  89836. * @param func defines the function to call before rendering this mesh
  89837. * @returns the current mesh
  89838. */
  89839. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89840. /**
  89841. * Disposes a previously registered javascript function called before the rendering
  89842. * @param func defines the function to remove
  89843. * @returns the current mesh
  89844. */
  89845. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89846. /**
  89847. * Registers for this mesh a javascript function called just after the rendering is complete
  89848. * @param func defines the function to call after rendering this mesh
  89849. * @returns the current mesh
  89850. */
  89851. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89852. /**
  89853. * Disposes a previously registered javascript function called after the rendering.
  89854. * @param func defines the function to remove
  89855. * @returns the current mesh
  89856. */
  89857. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89858. /** @hidden */
  89859. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  89860. /** @hidden */
  89861. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  89862. /** @hidden */
  89863. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  89864. /** @hidden */
  89865. _rebuild(): void;
  89866. /** @hidden */
  89867. _freeze(): void;
  89868. /** @hidden */
  89869. _unFreeze(): void;
  89870. /**
  89871. * 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
  89872. * @param subMesh defines the subMesh to render
  89873. * @param enableAlphaMode defines if alpha mode can be changed
  89874. * @returns the current mesh
  89875. */
  89876. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  89877. private _onBeforeDraw;
  89878. /**
  89879. * Renormalize the mesh and patch it up if there are no weights
  89880. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  89881. * However in the case of zero weights then we set just a single influence to 1.
  89882. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  89883. */
  89884. cleanMatrixWeights(): void;
  89885. private normalizeSkinFourWeights;
  89886. private normalizeSkinWeightsAndExtra;
  89887. /**
  89888. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  89889. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  89890. * the user know there was an issue with importing the mesh
  89891. * @returns a validation object with skinned, valid and report string
  89892. */
  89893. validateSkinning(): {
  89894. skinned: boolean;
  89895. valid: boolean;
  89896. report: string;
  89897. };
  89898. /** @hidden */
  89899. _checkDelayState(): Mesh;
  89900. private _queueLoad;
  89901. /**
  89902. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89903. * A mesh is in the frustum if its bounding box intersects the frustum
  89904. * @param frustumPlanes defines the frustum to test
  89905. * @returns true if the mesh is in the frustum planes
  89906. */
  89907. isInFrustum(frustumPlanes: Plane[]): boolean;
  89908. /**
  89909. * Sets the mesh material by the material or multiMaterial `id` property
  89910. * @param id is a string identifying the material or the multiMaterial
  89911. * @returns the current mesh
  89912. */
  89913. setMaterialByID(id: string): Mesh;
  89914. /**
  89915. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  89916. * @returns an array of IAnimatable
  89917. */
  89918. getAnimatables(): IAnimatable[];
  89919. /**
  89920. * Modifies the mesh geometry according to the passed transformation matrix.
  89921. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  89922. * The mesh normals are modified using the same transformation.
  89923. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89924. * @param transform defines the transform matrix to use
  89925. * @see http://doc.babylonjs.com/resources/baking_transformations
  89926. * @returns the current mesh
  89927. */
  89928. bakeTransformIntoVertices(transform: Matrix): Mesh;
  89929. /**
  89930. * Modifies the mesh geometry according to its own current World Matrix.
  89931. * The mesh World Matrix is then reset.
  89932. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  89933. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89934. * @see http://doc.babylonjs.com/resources/baking_transformations
  89935. * @returns the current mesh
  89936. */
  89937. bakeCurrentTransformIntoVertices(): Mesh;
  89938. /** @hidden */
  89939. readonly _positions: Nullable<Vector3[]>;
  89940. /** @hidden */
  89941. _resetPointsArrayCache(): Mesh;
  89942. /** @hidden */
  89943. _generatePointsArray(): boolean;
  89944. /**
  89945. * Returns a new Mesh object generated from the current mesh properties.
  89946. * This method must not get confused with createInstance()
  89947. * @param name is a string, the name given to the new mesh
  89948. * @param newParent can be any Node object (default `null`)
  89949. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  89950. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  89951. * @returns a new mesh
  89952. */
  89953. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  89954. /**
  89955. * Releases resources associated with this mesh.
  89956. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89957. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89958. */
  89959. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89960. /**
  89961. * Modifies the mesh geometry according to a displacement map.
  89962. * 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.
  89963. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89964. * @param url is a string, the URL from the image file is to be downloaded.
  89965. * @param minHeight is the lower limit of the displacement.
  89966. * @param maxHeight is the upper limit of the displacement.
  89967. * @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.
  89968. * @param uvOffset is an optional vector2 used to offset UV.
  89969. * @param uvScale is an optional vector2 used to scale UV.
  89970. * @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.
  89971. * @returns the Mesh.
  89972. */
  89973. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89974. /**
  89975. * Modifies the mesh geometry according to a displacementMap buffer.
  89976. * 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.
  89977. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89978. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89979. * @param heightMapWidth is the width of the buffer image.
  89980. * @param heightMapHeight is the height of the buffer image.
  89981. * @param minHeight is the lower limit of the displacement.
  89982. * @param maxHeight is the upper limit of the displacement.
  89983. * @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.
  89984. * @param uvOffset is an optional vector2 used to offset UV.
  89985. * @param uvScale is an optional vector2 used to scale UV.
  89986. * @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.
  89987. * @returns the Mesh.
  89988. */
  89989. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89990. /**
  89991. * Modify the mesh to get a flat shading rendering.
  89992. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89993. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89994. * @returns current mesh
  89995. */
  89996. convertToFlatShadedMesh(): Mesh;
  89997. /**
  89998. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89999. * In other words, more vertices, no more indices and a single bigger VBO.
  90000. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90001. * @returns current mesh
  90002. */
  90003. convertToUnIndexedMesh(): Mesh;
  90004. /**
  90005. * Inverses facet orientations.
  90006. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90007. * @param flipNormals will also inverts the normals
  90008. * @returns current mesh
  90009. */
  90010. flipFaces(flipNormals?: boolean): Mesh;
  90011. /**
  90012. * Increase the number of facets and hence vertices in a mesh
  90013. * Vertex normals are interpolated from existing vertex normals
  90014. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90015. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  90016. */
  90017. increaseVertices(numberPerEdge: number): void;
  90018. /**
  90019. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  90020. * This will undo any application of covertToFlatShadedMesh
  90021. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90022. */
  90023. forceSharedVertices(): void;
  90024. /** @hidden */
  90025. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  90026. /** @hidden */
  90027. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  90028. /**
  90029. * Creates a new InstancedMesh object from the mesh model.
  90030. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90031. * @param name defines the name of the new instance
  90032. * @returns a new InstancedMesh
  90033. */
  90034. createInstance(name: string): InstancedMesh;
  90035. /**
  90036. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90037. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90038. * @returns the current mesh
  90039. */
  90040. synchronizeInstances(): Mesh;
  90041. /**
  90042. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90043. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90044. * This should be used together with the simplification to avoid disappearing triangles.
  90045. * @param successCallback an optional success callback to be called after the optimization finished.
  90046. * @returns the current mesh
  90047. */
  90048. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  90049. /**
  90050. * Serialize current mesh
  90051. * @param serializationObject defines the object which will receive the serialization data
  90052. */
  90053. serialize(serializationObject: any): void;
  90054. /** @hidden */
  90055. _syncGeometryWithMorphTargetManager(): void;
  90056. /** @hidden */
  90057. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  90058. /**
  90059. * Returns a new Mesh object parsed from the source provided.
  90060. * @param parsedMesh is the source
  90061. * @param scene defines the hosting scene
  90062. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  90063. * @returns a new Mesh
  90064. */
  90065. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  90066. /**
  90067. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  90068. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90069. * @param name defines the name of the mesh to create
  90070. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  90071. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  90072. * @param closePath creates a seam between the first and the last points of each path of the path array
  90073. * @param offset is taken in account only if the `pathArray` is containing a single path
  90074. * @param scene defines the hosting scene
  90075. * @param updatable defines if the mesh must be flagged as updatable
  90076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90077. * @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)
  90078. * @returns a new Mesh
  90079. */
  90080. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90081. /**
  90082. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  90083. * @param name defines the name of the mesh to create
  90084. * @param radius sets the radius size (float) of the polygon (default 0.5)
  90085. * @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
  90086. * @param scene defines the hosting scene
  90087. * @param updatable defines if the mesh must be flagged as updatable
  90088. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90089. * @returns a new Mesh
  90090. */
  90091. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90092. /**
  90093. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  90094. * @param name defines the name of the mesh to create
  90095. * @param size sets the size (float) of each box side (default 1)
  90096. * @param scene defines the hosting scene
  90097. * @param updatable defines if the mesh must be flagged as updatable
  90098. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90099. * @returns a new Mesh
  90100. */
  90101. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90102. /**
  90103. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  90104. * @param name defines the name of the mesh to create
  90105. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90106. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90107. * @param scene defines the hosting scene
  90108. * @param updatable defines if the mesh must be flagged as updatable
  90109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90110. * @returns a new Mesh
  90111. */
  90112. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90113. /**
  90114. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  90115. * @param name defines the name of the mesh to create
  90116. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90117. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90118. * @param scene defines the hosting scene
  90119. * @returns a new Mesh
  90120. */
  90121. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  90122. /**
  90123. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  90124. * @param name defines the name of the mesh to create
  90125. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  90126. * @param diameterTop set the top cap diameter (floats, default 1)
  90127. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  90128. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  90129. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  90130. * @param scene defines the hosting scene
  90131. * @param updatable defines if the mesh must be flagged as updatable
  90132. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90133. * @returns a new Mesh
  90134. */
  90135. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  90136. /**
  90137. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  90138. * @param name defines the name of the mesh to create
  90139. * @param diameter sets the diameter size (float) of the torus (default 1)
  90140. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  90141. * @param tessellation sets the number of torus sides (postive integer, default 16)
  90142. * @param scene defines the hosting scene
  90143. * @param updatable defines if the mesh must be flagged as updatable
  90144. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90145. * @returns a new Mesh
  90146. */
  90147. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90148. /**
  90149. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  90150. * @param name defines the name of the mesh to create
  90151. * @param radius sets the global radius size (float) of the torus knot (default 2)
  90152. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  90153. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  90154. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  90155. * @param p the number of windings on X axis (positive integers, default 2)
  90156. * @param q the number of windings on Y axis (positive integers, default 3)
  90157. * @param scene defines the hosting scene
  90158. * @param updatable defines if the mesh must be flagged as updatable
  90159. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90160. * @returns a new Mesh
  90161. */
  90162. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90163. /**
  90164. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  90165. * @param name defines the name of the mesh to create
  90166. * @param points is an array successive Vector3
  90167. * @param scene defines the hosting scene
  90168. * @param updatable defines if the mesh must be flagged as updatable
  90169. * @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).
  90170. * @returns a new Mesh
  90171. */
  90172. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  90173. /**
  90174. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  90175. * @param name defines the name of the mesh to create
  90176. * @param points is an array successive Vector3
  90177. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  90178. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90179. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  90180. * @param scene defines the hosting scene
  90181. * @param updatable defines if the mesh must be flagged as updatable
  90182. * @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)
  90183. * @returns a new Mesh
  90184. */
  90185. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  90186. /**
  90187. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  90188. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  90189. * 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.
  90190. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90191. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90192. * Remember you can only change the shape positions, not their number when updating a polygon.
  90193. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  90194. * @param name defines the name of the mesh to create
  90195. * @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
  90196. * @param scene defines the hosting scene
  90197. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90198. * @param updatable defines if the mesh must be flagged as updatable
  90199. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90200. * @param earcutInjection can be used to inject your own earcut reference
  90201. * @returns a new Mesh
  90202. */
  90203. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90204. /**
  90205. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  90206. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  90207. * @param name defines the name of the mesh to create
  90208. * @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
  90209. * @param depth defines the height of extrusion
  90210. * @param scene defines the hosting scene
  90211. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90212. * @param updatable defines if the mesh must be flagged as updatable
  90213. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90214. * @param earcutInjection can be used to inject your own earcut reference
  90215. * @returns a new Mesh
  90216. */
  90217. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90218. /**
  90219. * Creates an extruded shape mesh.
  90220. * 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
  90221. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90222. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90223. * @param name defines the name of the mesh to create
  90224. * @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
  90225. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90226. * @param scale is the value to scale the shape
  90227. * @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
  90228. * @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
  90229. * @param scene defines the hosting scene
  90230. * @param updatable defines if the mesh must be flagged as updatable
  90231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90232. * @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)
  90233. * @returns a new Mesh
  90234. */
  90235. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90236. /**
  90237. * Creates an custom extruded shape mesh.
  90238. * The custom extrusion is a parametric shape.
  90239. * It has no predefined shape. Its final shape will depend on the input parameters.
  90240. * Please consider using the same method from the MeshBuilder class instead
  90241. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90242. * @param name defines the name of the mesh to create
  90243. * @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
  90244. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90245. * @param scaleFunction is a custom Javascript function called on each path point
  90246. * @param rotationFunction is a custom Javascript function called on each path point
  90247. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90248. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90249. * @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
  90250. * @param scene defines the hosting scene
  90251. * @param updatable defines if the mesh must be flagged as updatable
  90252. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90253. * @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)
  90254. * @returns a new Mesh
  90255. */
  90256. 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;
  90257. /**
  90258. * Creates lathe mesh.
  90259. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90260. * Please consider using the same method from the MeshBuilder class instead
  90261. * @param name defines the name of the mesh to create
  90262. * @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
  90263. * @param radius is the radius value of the lathe
  90264. * @param tessellation is the side number of the lathe.
  90265. * @param scene defines the hosting scene
  90266. * @param updatable defines if the mesh must be flagged as updatable
  90267. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90268. * @returns a new Mesh
  90269. */
  90270. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90271. /**
  90272. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90273. * @param name defines the name of the mesh to create
  90274. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90275. * @param scene defines the hosting scene
  90276. * @param updatable defines if the mesh must be flagged as updatable
  90277. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90278. * @returns a new Mesh
  90279. */
  90280. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90281. /**
  90282. * Creates a ground mesh.
  90283. * Please consider using the same method from the MeshBuilder class instead
  90284. * @param name defines the name of the mesh to create
  90285. * @param width set the width of the ground
  90286. * @param height set the height of the ground
  90287. * @param subdivisions sets the number of subdivisions per side
  90288. * @param scene defines the hosting scene
  90289. * @param updatable defines if the mesh must be flagged as updatable
  90290. * @returns a new Mesh
  90291. */
  90292. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  90293. /**
  90294. * Creates a tiled ground mesh.
  90295. * Please consider using the same method from the MeshBuilder class instead
  90296. * @param name defines the name of the mesh to create
  90297. * @param xmin set the ground minimum X coordinate
  90298. * @param zmin set the ground minimum Y coordinate
  90299. * @param xmax set the ground maximum X coordinate
  90300. * @param zmax set the ground maximum Z coordinate
  90301. * @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
  90302. * @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
  90303. * @param scene defines the hosting scene
  90304. * @param updatable defines if the mesh must be flagged as updatable
  90305. * @returns a new Mesh
  90306. */
  90307. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  90308. w: number;
  90309. h: number;
  90310. }, precision: {
  90311. w: number;
  90312. h: number;
  90313. }, scene: Scene, updatable?: boolean): Mesh;
  90314. /**
  90315. * Creates a ground mesh from a height map.
  90316. * Please consider using the same method from the MeshBuilder class instead
  90317. * @see http://doc.babylonjs.com/babylon101/height_map
  90318. * @param name defines the name of the mesh to create
  90319. * @param url sets the URL of the height map image resource
  90320. * @param width set the ground width size
  90321. * @param height set the ground height size
  90322. * @param subdivisions sets the number of subdivision per side
  90323. * @param minHeight is the minimum altitude on the ground
  90324. * @param maxHeight is the maximum altitude on the ground
  90325. * @param scene defines the hosting scene
  90326. * @param updatable defines if the mesh must be flagged as updatable
  90327. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90328. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90329. * @returns a new Mesh
  90330. */
  90331. 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;
  90332. /**
  90333. * Creates a tube mesh.
  90334. * The tube is a parametric shape.
  90335. * It has no predefined shape. Its final shape will depend on the input parameters.
  90336. * Please consider using the same method from the MeshBuilder class instead
  90337. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90338. * @param name defines the name of the mesh to create
  90339. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90340. * @param radius sets the tube radius size
  90341. * @param tessellation is the number of sides on the tubular surface
  90342. * @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
  90343. * @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
  90344. * @param scene defines the hosting scene
  90345. * @param updatable defines if the mesh must be flagged as updatable
  90346. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90347. * @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)
  90348. * @returns a new Mesh
  90349. */
  90350. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  90351. (i: number, distance: number): number;
  90352. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90353. /**
  90354. * Creates a polyhedron mesh.
  90355. * Please consider using the same method from the MeshBuilder class instead.
  90356. * * 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
  90357. * * The parameter `size` (positive float, default 1) sets the polygon size
  90358. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90359. * * 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`
  90360. * * 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
  90361. * * 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)`)
  90362. * * 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
  90363. * * 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
  90364. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90365. * * If you create a double-sided mesh, you can choose what parts of 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
  90366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90367. * @param name defines the name of the mesh to create
  90368. * @param options defines the options used to create the mesh
  90369. * @param scene defines the hosting scene
  90370. * @returns a new Mesh
  90371. */
  90372. static CreatePolyhedron(name: string, options: {
  90373. type?: number;
  90374. size?: number;
  90375. sizeX?: number;
  90376. sizeY?: number;
  90377. sizeZ?: number;
  90378. custom?: any;
  90379. faceUV?: Vector4[];
  90380. faceColors?: Color4[];
  90381. updatable?: boolean;
  90382. sideOrientation?: number;
  90383. }, scene: Scene): Mesh;
  90384. /**
  90385. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90386. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90387. * * 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`)
  90388. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90389. * * 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
  90390. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90391. * * If you create a double-sided mesh, you can choose what parts of 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
  90392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90393. * @param name defines the name of the mesh
  90394. * @param options defines the options used to create the mesh
  90395. * @param scene defines the hosting scene
  90396. * @returns a new Mesh
  90397. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90398. */
  90399. static CreateIcoSphere(name: string, options: {
  90400. radius?: number;
  90401. flat?: boolean;
  90402. subdivisions?: number;
  90403. sideOrientation?: number;
  90404. updatable?: boolean;
  90405. }, scene: Scene): Mesh;
  90406. /**
  90407. * Creates a decal mesh.
  90408. * Please consider using the same method from the MeshBuilder class instead.
  90409. * A decal is a mesh usually applied as a model onto the surface of another mesh
  90410. * @param name defines the name of the mesh
  90411. * @param sourceMesh defines the mesh receiving the decal
  90412. * @param position sets the position of the decal in world coordinates
  90413. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  90414. * @param size sets the decal scaling
  90415. * @param angle sets the angle to rotate the decal
  90416. * @returns a new Mesh
  90417. */
  90418. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  90419. /**
  90420. * Prepare internal position array for software CPU skinning
  90421. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  90422. */
  90423. setPositionsForCPUSkinning(): Float32Array;
  90424. /**
  90425. * Prepare internal normal array for software CPU skinning
  90426. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  90427. */
  90428. setNormalsForCPUSkinning(): Float32Array;
  90429. /**
  90430. * Updates the vertex buffer by applying transformation from the bones
  90431. * @param skeleton defines the skeleton to apply to current mesh
  90432. * @returns the current mesh
  90433. */
  90434. applySkeleton(skeleton: Skeleton): Mesh;
  90435. /**
  90436. * 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
  90437. * @param meshes defines the list of meshes to scan
  90438. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  90439. */
  90440. static MinMax(meshes: AbstractMesh[]): {
  90441. min: Vector3;
  90442. max: Vector3;
  90443. };
  90444. /**
  90445. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  90446. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  90447. * @returns a vector3
  90448. */
  90449. static Center(meshesOrMinMaxVector: {
  90450. min: Vector3;
  90451. max: Vector3;
  90452. } | AbstractMesh[]): Vector3;
  90453. /**
  90454. * Merge the array of meshes into a single mesh for performance reasons.
  90455. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  90456. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  90457. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  90458. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  90459. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  90460. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  90461. * @returns a new mesh
  90462. */
  90463. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  90464. /** @hidden */
  90465. addInstance(instance: InstancedMesh): void;
  90466. /** @hidden */
  90467. removeInstance(instance: InstancedMesh): void;
  90468. }
  90469. }
  90470. declare module BABYLON {
  90471. /**
  90472. * This is the base class of all the camera used in the application.
  90473. * @see http://doc.babylonjs.com/features/cameras
  90474. */
  90475. export class Camera extends Node {
  90476. /** @hidden */
  90477. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90478. /**
  90479. * This is the default projection mode used by the cameras.
  90480. * It helps recreating a feeling of perspective and better appreciate depth.
  90481. * This is the best way to simulate real life cameras.
  90482. */
  90483. static readonly PERSPECTIVE_CAMERA: number;
  90484. /**
  90485. * This helps creating camera with an orthographic mode.
  90486. * 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.
  90487. */
  90488. static readonly ORTHOGRAPHIC_CAMERA: number;
  90489. /**
  90490. * This is the default FOV mode for perspective cameras.
  90491. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90492. */
  90493. static readonly FOVMODE_VERTICAL_FIXED: number;
  90494. /**
  90495. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90496. */
  90497. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90498. /**
  90499. * This specifies ther is no need for a camera rig.
  90500. * Basically only one eye is rendered corresponding to the camera.
  90501. */
  90502. static readonly RIG_MODE_NONE: number;
  90503. /**
  90504. * Simulates a camera Rig with one blue eye and one red eye.
  90505. * This can be use with 3d blue and red glasses.
  90506. */
  90507. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90508. /**
  90509. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90510. */
  90511. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90512. /**
  90513. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90514. */
  90515. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90516. /**
  90517. * Defines that both eyes of the camera will be rendered over under each other.
  90518. */
  90519. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90520. /**
  90521. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90522. */
  90523. static readonly RIG_MODE_VR: number;
  90524. /**
  90525. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90526. */
  90527. static readonly RIG_MODE_WEBVR: number;
  90528. /**
  90529. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90530. */
  90531. static readonly RIG_MODE_CUSTOM: number;
  90532. /**
  90533. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90534. */
  90535. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90536. /**
  90537. * Define the input manager associated with the camera.
  90538. */
  90539. inputs: CameraInputsManager<Camera>;
  90540. /** @hidden */
  90541. _position: Vector3;
  90542. /**
  90543. * Define the current local position of the camera in the scene
  90544. */
  90545. position: Vector3;
  90546. /**
  90547. * The vector the camera should consider as up.
  90548. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90549. */
  90550. upVector: Vector3;
  90551. /**
  90552. * Define the current limit on the left side for an orthographic camera
  90553. * In scene unit
  90554. */
  90555. orthoLeft: Nullable<number>;
  90556. /**
  90557. * Define the current limit on the right side for an orthographic camera
  90558. * In scene unit
  90559. */
  90560. orthoRight: Nullable<number>;
  90561. /**
  90562. * Define the current limit on the bottom side for an orthographic camera
  90563. * In scene unit
  90564. */
  90565. orthoBottom: Nullable<number>;
  90566. /**
  90567. * Define the current limit on the top side for an orthographic camera
  90568. * In scene unit
  90569. */
  90570. orthoTop: Nullable<number>;
  90571. /**
  90572. * Field Of View is set in Radians. (default is 0.8)
  90573. */
  90574. fov: number;
  90575. /**
  90576. * Define the minimum distance the camera can see from.
  90577. * This is important to note that the depth buffer are not infinite and the closer it starts
  90578. * the more your scene might encounter depth fighting issue.
  90579. */
  90580. minZ: number;
  90581. /**
  90582. * Define the maximum distance the camera can see to.
  90583. * This is important to note that the depth buffer are not infinite and the further it end
  90584. * the more your scene might encounter depth fighting issue.
  90585. */
  90586. maxZ: number;
  90587. /**
  90588. * Define the default inertia of the camera.
  90589. * This helps giving a smooth feeling to the camera movement.
  90590. */
  90591. inertia: number;
  90592. /**
  90593. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  90594. */
  90595. mode: number;
  90596. /**
  90597. * Define wether the camera is intermediate.
  90598. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90599. */
  90600. isIntermediate: boolean;
  90601. /**
  90602. * Define the viewport of the camera.
  90603. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90604. */
  90605. viewport: Viewport;
  90606. /**
  90607. * Restricts the camera to viewing objects with the same layerMask.
  90608. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90609. */
  90610. layerMask: number;
  90611. /**
  90612. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90613. */
  90614. fovMode: number;
  90615. /**
  90616. * Rig mode of the camera.
  90617. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90618. * This is normally controlled byt the camera themselves as internal use.
  90619. */
  90620. cameraRigMode: number;
  90621. /**
  90622. * Defines the distance between both "eyes" in case of a RIG
  90623. */
  90624. interaxialDistance: number;
  90625. /**
  90626. * Defines if stereoscopic rendering is done side by side or over under.
  90627. */
  90628. isStereoscopicSideBySide: boolean;
  90629. /**
  90630. * 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
  90631. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90632. * else in the scene. (Eg. security camera)
  90633. *
  90634. * 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)
  90635. */
  90636. customRenderTargets: RenderTargetTexture[];
  90637. /**
  90638. * When set, the camera will render to this render target instead of the default canvas
  90639. *
  90640. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  90641. */
  90642. outputRenderTarget: Nullable<RenderTargetTexture>;
  90643. /**
  90644. * Observable triggered when the camera view matrix has changed.
  90645. */
  90646. onViewMatrixChangedObservable: Observable<Camera>;
  90647. /**
  90648. * Observable triggered when the camera Projection matrix has changed.
  90649. */
  90650. onProjectionMatrixChangedObservable: Observable<Camera>;
  90651. /**
  90652. * Observable triggered when the inputs have been processed.
  90653. */
  90654. onAfterCheckInputsObservable: Observable<Camera>;
  90655. /**
  90656. * Observable triggered when reset has been called and applied to the camera.
  90657. */
  90658. onRestoreStateObservable: Observable<Camera>;
  90659. /** @hidden */
  90660. _cameraRigParams: any;
  90661. /** @hidden */
  90662. _rigCameras: Camera[];
  90663. /** @hidden */
  90664. _rigPostProcess: Nullable<PostProcess>;
  90665. protected _webvrViewMatrix: Matrix;
  90666. /** @hidden */
  90667. _skipRendering: boolean;
  90668. /** @hidden */
  90669. _projectionMatrix: Matrix;
  90670. /** @hidden */
  90671. _postProcesses: Nullable<PostProcess>[];
  90672. /** @hidden */
  90673. _activeMeshes: SmartArray<AbstractMesh>;
  90674. protected _globalPosition: Vector3;
  90675. /** @hidden */
  90676. _computedViewMatrix: Matrix;
  90677. private _doNotComputeProjectionMatrix;
  90678. private _transformMatrix;
  90679. private _frustumPlanes;
  90680. private _refreshFrustumPlanes;
  90681. private _storedFov;
  90682. private _stateStored;
  90683. /**
  90684. * Instantiates a new camera object.
  90685. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90686. * @see http://doc.babylonjs.com/features/cameras
  90687. * @param name Defines the name of the camera in the scene
  90688. * @param position Defines the position of the camera
  90689. * @param scene Defines the scene the camera belongs too
  90690. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90691. */
  90692. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90693. /**
  90694. * Store current camera state (fov, position, etc..)
  90695. * @returns the camera
  90696. */
  90697. storeState(): Camera;
  90698. /**
  90699. * Restores the camera state values if it has been stored. You must call storeState() first
  90700. */
  90701. protected _restoreStateValues(): boolean;
  90702. /**
  90703. * Restored camera state. You must call storeState() first.
  90704. * @returns true if restored and false otherwise
  90705. */
  90706. restoreState(): boolean;
  90707. /**
  90708. * Gets the class name of the camera.
  90709. * @returns the class name
  90710. */
  90711. getClassName(): string;
  90712. /** @hidden */
  90713. readonly _isCamera: boolean;
  90714. /**
  90715. * Gets a string representation of the camera useful for debug purpose.
  90716. * @param fullDetails Defines that a more verboe level of logging is required
  90717. * @returns the string representation
  90718. */
  90719. toString(fullDetails?: boolean): string;
  90720. /**
  90721. * Gets the current world space position of the camera.
  90722. */
  90723. readonly globalPosition: Vector3;
  90724. /**
  90725. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90726. * @returns the active meshe list
  90727. */
  90728. getActiveMeshes(): SmartArray<AbstractMesh>;
  90729. /**
  90730. * Check wether a mesh is part of the current active mesh list of the camera
  90731. * @param mesh Defines the mesh to check
  90732. * @returns true if active, false otherwise
  90733. */
  90734. isActiveMesh(mesh: Mesh): boolean;
  90735. /**
  90736. * Is this camera ready to be used/rendered
  90737. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90738. * @return true if the camera is ready
  90739. */
  90740. isReady(completeCheck?: boolean): boolean;
  90741. /** @hidden */
  90742. _initCache(): void;
  90743. /** @hidden */
  90744. _updateCache(ignoreParentClass?: boolean): void;
  90745. /** @hidden */
  90746. _isSynchronized(): boolean;
  90747. /** @hidden */
  90748. _isSynchronizedViewMatrix(): boolean;
  90749. /** @hidden */
  90750. _isSynchronizedProjectionMatrix(): boolean;
  90751. /**
  90752. * Attach the input controls to a specific dom element to get the input from.
  90753. * @param element Defines the element the controls should be listened from
  90754. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90755. */
  90756. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90757. /**
  90758. * Detach the current controls from the specified dom element.
  90759. * @param element Defines the element to stop listening the inputs from
  90760. */
  90761. detachControl(element: HTMLElement): void;
  90762. /**
  90763. * Update the camera state according to the different inputs gathered during the frame.
  90764. */
  90765. update(): void;
  90766. /** @hidden */
  90767. _checkInputs(): void;
  90768. /** @hidden */
  90769. readonly rigCameras: Camera[];
  90770. /**
  90771. * Gets the post process used by the rig cameras
  90772. */
  90773. readonly rigPostProcess: Nullable<PostProcess>;
  90774. /**
  90775. * Internal, gets the first post proces.
  90776. * @returns the first post process to be run on this camera.
  90777. */
  90778. _getFirstPostProcess(): Nullable<PostProcess>;
  90779. private _cascadePostProcessesToRigCams;
  90780. /**
  90781. * Attach a post process to the camera.
  90782. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90783. * @param postProcess The post process to attach to the camera
  90784. * @param insertAt The position of the post process in case several of them are in use in the scene
  90785. * @returns the position the post process has been inserted at
  90786. */
  90787. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90788. /**
  90789. * Detach a post process to the camera.
  90790. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90791. * @param postProcess The post process to detach from the camera
  90792. */
  90793. detachPostProcess(postProcess: PostProcess): void;
  90794. /**
  90795. * Gets the current world matrix of the camera
  90796. */
  90797. getWorldMatrix(): Matrix;
  90798. /** @hidden */
  90799. _getViewMatrix(): Matrix;
  90800. /**
  90801. * Gets the current view matrix of the camera.
  90802. * @param force forces the camera to recompute the matrix without looking at the cached state
  90803. * @returns the view matrix
  90804. */
  90805. getViewMatrix(force?: boolean): Matrix;
  90806. /**
  90807. * Freeze the projection matrix.
  90808. * It will prevent the cache check of the camera projection compute and can speed up perf
  90809. * if no parameter of the camera are meant to change
  90810. * @param projection Defines manually a projection if necessary
  90811. */
  90812. freezeProjectionMatrix(projection?: Matrix): void;
  90813. /**
  90814. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90815. */
  90816. unfreezeProjectionMatrix(): void;
  90817. /**
  90818. * Gets the current projection matrix of the camera.
  90819. * @param force forces the camera to recompute the matrix without looking at the cached state
  90820. * @returns the projection matrix
  90821. */
  90822. getProjectionMatrix(force?: boolean): Matrix;
  90823. /**
  90824. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90825. * @returns a Matrix
  90826. */
  90827. getTransformationMatrix(): Matrix;
  90828. private _updateFrustumPlanes;
  90829. /**
  90830. * Checks if a cullable object (mesh...) is in the camera frustum
  90831. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90832. * @param target The object to check
  90833. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90834. * @returns true if the object is in frustum otherwise false
  90835. */
  90836. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90837. /**
  90838. * Checks if a cullable object (mesh...) is in the camera frustum
  90839. * Unlike isInFrustum this cheks the full bounding box
  90840. * @param target The object to check
  90841. * @returns true if the object is in frustum otherwise false
  90842. */
  90843. isCompletelyInFrustum(target: ICullable): boolean;
  90844. /**
  90845. * Gets a ray in the forward direction from the camera.
  90846. * @param length Defines the length of the ray to create
  90847. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90848. * @param origin Defines the start point of the ray which defaults to the camera position
  90849. * @returns the forward ray
  90850. */
  90851. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90852. /**
  90853. * Releases resources associated with this node.
  90854. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90855. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90856. */
  90857. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90858. /** @hidden */
  90859. _isLeftCamera: boolean;
  90860. /**
  90861. * Gets the left camera of a rig setup in case of Rigged Camera
  90862. */
  90863. readonly isLeftCamera: boolean;
  90864. /** @hidden */
  90865. _isRightCamera: boolean;
  90866. /**
  90867. * Gets the right camera of a rig setup in case of Rigged Camera
  90868. */
  90869. readonly isRightCamera: boolean;
  90870. /**
  90871. * Gets the left camera of a rig setup in case of Rigged Camera
  90872. */
  90873. readonly leftCamera: Nullable<FreeCamera>;
  90874. /**
  90875. * Gets the right camera of a rig setup in case of Rigged Camera
  90876. */
  90877. readonly rightCamera: Nullable<FreeCamera>;
  90878. /**
  90879. * Gets the left camera target of a rig setup in case of Rigged Camera
  90880. * @returns the target position
  90881. */
  90882. getLeftTarget(): Nullable<Vector3>;
  90883. /**
  90884. * Gets the right camera target of a rig setup in case of Rigged Camera
  90885. * @returns the target position
  90886. */
  90887. getRightTarget(): Nullable<Vector3>;
  90888. /**
  90889. * @hidden
  90890. */
  90891. setCameraRigMode(mode: number, rigParams: any): void;
  90892. /** @hidden */
  90893. static _setStereoscopicRigMode(camera: Camera): void;
  90894. /** @hidden */
  90895. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90896. /** @hidden */
  90897. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90898. /** @hidden */
  90899. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90900. /** @hidden */
  90901. _getVRProjectionMatrix(): Matrix;
  90902. protected _updateCameraRotationMatrix(): void;
  90903. protected _updateWebVRCameraRotationMatrix(): void;
  90904. /**
  90905. * This function MUST be overwritten by the different WebVR cameras available.
  90906. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90907. * @hidden
  90908. */
  90909. _getWebVRProjectionMatrix(): Matrix;
  90910. /**
  90911. * This function MUST be overwritten by the different WebVR cameras available.
  90912. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90913. * @hidden
  90914. */
  90915. _getWebVRViewMatrix(): Matrix;
  90916. /** @hidden */
  90917. setCameraRigParameter(name: string, value: any): void;
  90918. /**
  90919. * needs to be overridden by children so sub has required properties to be copied
  90920. * @hidden
  90921. */
  90922. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90923. /**
  90924. * May need to be overridden by children
  90925. * @hidden
  90926. */
  90927. _updateRigCameras(): void;
  90928. /** @hidden */
  90929. _setupInputs(): void;
  90930. /**
  90931. * Serialiaze the camera setup to a json represention
  90932. * @returns the JSON representation
  90933. */
  90934. serialize(): any;
  90935. /**
  90936. * Clones the current camera.
  90937. * @param name The cloned camera name
  90938. * @returns the cloned camera
  90939. */
  90940. clone(name: string): Camera;
  90941. /**
  90942. * Gets the direction of the camera relative to a given local axis.
  90943. * @param localAxis Defines the reference axis to provide a relative direction.
  90944. * @return the direction
  90945. */
  90946. getDirection(localAxis: Vector3): Vector3;
  90947. /**
  90948. * Returns the current camera absolute rotation
  90949. */
  90950. readonly absoluteRotation: Quaternion;
  90951. /**
  90952. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90953. * @param localAxis Defines the reference axis to provide a relative direction.
  90954. * @param result Defines the vector to store the result in
  90955. */
  90956. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90957. /**
  90958. * Gets a camera constructor for a given camera type
  90959. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90960. * @param name The name of the camera the result will be able to instantiate
  90961. * @param scene The scene the result will construct the camera in
  90962. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90963. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90964. * @returns a factory method to construc the camera
  90965. */
  90966. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90967. /**
  90968. * Compute the world matrix of the camera.
  90969. * @returns the camera workd matrix
  90970. */
  90971. computeWorldMatrix(): Matrix;
  90972. /**
  90973. * Parse a JSON and creates the camera from the parsed information
  90974. * @param parsedCamera The JSON to parse
  90975. * @param scene The scene to instantiate the camera in
  90976. * @returns the newly constructed camera
  90977. */
  90978. static Parse(parsedCamera: any, scene: Scene): Camera;
  90979. }
  90980. }
  90981. declare module BABYLON {
  90982. /**
  90983. * Class containing static functions to help procedurally build meshes
  90984. */
  90985. export class DiscBuilder {
  90986. /**
  90987. * Creates a plane polygonal mesh. By default, this is a disc
  90988. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90989. * * 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
  90990. * * 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
  90991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90992. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90994. * @param name defines the name of the mesh
  90995. * @param options defines the options used to create the mesh
  90996. * @param scene defines the hosting scene
  90997. * @returns the plane polygonal mesh
  90998. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90999. */
  91000. static CreateDisc(name: string, options: {
  91001. radius?: number;
  91002. tessellation?: number;
  91003. arc?: number;
  91004. updatable?: boolean;
  91005. sideOrientation?: number;
  91006. frontUVs?: Vector4;
  91007. backUVs?: Vector4;
  91008. }, scene?: Nullable<Scene>): Mesh;
  91009. }
  91010. }
  91011. declare module BABYLON {
  91012. /**
  91013. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  91014. *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.
  91015. * The SPS is also a particle system. It provides some methods to manage the particles.
  91016. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  91017. *
  91018. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  91019. */
  91020. export class SolidParticleSystem implements IDisposable {
  91021. /**
  91022. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  91023. * Example : var p = SPS.particles[i];
  91024. */
  91025. particles: SolidParticle[];
  91026. /**
  91027. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  91028. */
  91029. nbParticles: number;
  91030. /**
  91031. * If the particles must ever face the camera (default false). Useful for planar particles.
  91032. */
  91033. billboard: boolean;
  91034. /**
  91035. * Recompute normals when adding a shape
  91036. */
  91037. recomputeNormals: boolean;
  91038. /**
  91039. * This a counter ofr your own usage. It's not set by any SPS functions.
  91040. */
  91041. counter: number;
  91042. /**
  91043. * The SPS name. This name is also given to the underlying mesh.
  91044. */
  91045. name: string;
  91046. /**
  91047. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  91048. */
  91049. mesh: Mesh;
  91050. /**
  91051. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  91052. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  91053. */
  91054. vars: any;
  91055. /**
  91056. * This array is populated when the SPS is set as 'pickable'.
  91057. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  91058. * Each element of this array is an object `{idx: int, faceId: int}`.
  91059. * `idx` is the picked particle index in the `SPS.particles` array
  91060. * `faceId` is the picked face index counted within this particle.
  91061. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  91062. */
  91063. pickedParticles: {
  91064. idx: number;
  91065. faceId: number;
  91066. }[];
  91067. /**
  91068. * This array is populated when `enableDepthSort` is set to true.
  91069. * Each element of this array is an instance of the class DepthSortedParticle.
  91070. */
  91071. depthSortedParticles: DepthSortedParticle[];
  91072. /**
  91073. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  91074. * @hidden
  91075. */
  91076. _bSphereOnly: boolean;
  91077. /**
  91078. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  91079. * @hidden
  91080. */
  91081. _bSphereRadiusFactor: number;
  91082. private _scene;
  91083. private _positions;
  91084. private _indices;
  91085. private _normals;
  91086. private _colors;
  91087. private _uvs;
  91088. private _indices32;
  91089. private _positions32;
  91090. private _normals32;
  91091. private _fixedNormal32;
  91092. private _colors32;
  91093. private _uvs32;
  91094. private _index;
  91095. private _updatable;
  91096. private _pickable;
  91097. private _isVisibilityBoxLocked;
  91098. private _alwaysVisible;
  91099. private _depthSort;
  91100. private _shapeCounter;
  91101. private _copy;
  91102. private _color;
  91103. private _computeParticleColor;
  91104. private _computeParticleTexture;
  91105. private _computeParticleRotation;
  91106. private _computeParticleVertex;
  91107. private _computeBoundingBox;
  91108. private _depthSortParticles;
  91109. private _camera;
  91110. private _mustUnrotateFixedNormals;
  91111. private _particlesIntersect;
  91112. private _needs32Bits;
  91113. /**
  91114. * Creates a SPS (Solid Particle System) object.
  91115. * @param name (String) is the SPS name, this will be the underlying mesh name.
  91116. * @param scene (Scene) is the scene in which the SPS is added.
  91117. * @param options defines the options of the sps e.g.
  91118. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  91119. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  91120. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  91121. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  91122. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  91123. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  91124. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  91125. */
  91126. constructor(name: string, scene: Scene, options?: {
  91127. updatable?: boolean;
  91128. isPickable?: boolean;
  91129. enableDepthSort?: boolean;
  91130. particleIntersection?: boolean;
  91131. boundingSphereOnly?: boolean;
  91132. bSphereRadiusFactor?: number;
  91133. });
  91134. /**
  91135. * Builds the SPS underlying mesh. Returns a standard Mesh.
  91136. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  91137. * @returns the created mesh
  91138. */
  91139. buildMesh(): Mesh;
  91140. /**
  91141. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  91142. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  91143. * Thus the particles generated from `digest()` have their property `position` set yet.
  91144. * @param mesh ( Mesh ) is the mesh to be digested
  91145. * @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
  91146. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  91147. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  91148. * @returns the current SPS
  91149. */
  91150. digest(mesh: Mesh, options?: {
  91151. facetNb?: number;
  91152. number?: number;
  91153. delta?: number;
  91154. }): SolidParticleSystem;
  91155. private _unrotateFixedNormals;
  91156. private _resetCopy;
  91157. private _meshBuilder;
  91158. private _posToShape;
  91159. private _uvsToShapeUV;
  91160. private _addParticle;
  91161. /**
  91162. * Adds some particles to the SPS from the model shape. Returns the shape id.
  91163. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  91164. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  91165. * @param nb (positive integer) the number of particles to be created from this model
  91166. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  91167. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  91168. * @returns the number of shapes in the system
  91169. */
  91170. addShape(mesh: Mesh, nb: number, options?: {
  91171. positionFunction?: any;
  91172. vertexFunction?: any;
  91173. }): number;
  91174. private _rebuildParticle;
  91175. /**
  91176. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  91177. * @returns the SPS.
  91178. */
  91179. rebuildMesh(): SolidParticleSystem;
  91180. /**
  91181. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  91182. * This method calls `updateParticle()` for each particle of the SPS.
  91183. * For an animated SPS, it is usually called within the render loop.
  91184. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  91185. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  91186. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  91187. * @returns the SPS.
  91188. */
  91189. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  91190. /**
  91191. * Disposes the SPS.
  91192. */
  91193. dispose(): void;
  91194. /**
  91195. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  91196. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91197. * @returns the SPS.
  91198. */
  91199. refreshVisibleSize(): SolidParticleSystem;
  91200. /**
  91201. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  91202. * @param size the size (float) of the visibility box
  91203. * note : this doesn't lock the SPS mesh bounding box.
  91204. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91205. */
  91206. setVisibilityBox(size: number): void;
  91207. /**
  91208. * Gets whether the SPS as always visible or not
  91209. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91210. */
  91211. /**
  91212. * Sets the SPS as always visible or not
  91213. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91214. */
  91215. isAlwaysVisible: boolean;
  91216. /**
  91217. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91218. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91219. */
  91220. /**
  91221. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91222. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91223. */
  91224. isVisibilityBoxLocked: boolean;
  91225. /**
  91226. * Tells to `setParticles()` to compute the particle rotations or not.
  91227. * Default value : true. The SPS is faster when it's set to false.
  91228. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91229. */
  91230. /**
  91231. * Gets if `setParticles()` computes the particle rotations or not.
  91232. * Default value : true. The SPS is faster when it's set to false.
  91233. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91234. */
  91235. computeParticleRotation: boolean;
  91236. /**
  91237. * Tells to `setParticles()` to compute the particle colors or not.
  91238. * Default value : true. The SPS is faster when it's set to false.
  91239. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91240. */
  91241. /**
  91242. * Gets if `setParticles()` computes the particle colors or not.
  91243. * Default value : true. The SPS is faster when it's set to false.
  91244. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91245. */
  91246. computeParticleColor: boolean;
  91247. /**
  91248. * Gets if `setParticles()` computes the particle textures or not.
  91249. * Default value : true. The SPS is faster when it's set to false.
  91250. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  91251. */
  91252. computeParticleTexture: boolean;
  91253. /**
  91254. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  91255. * Default value : false. The SPS is faster when it's set to false.
  91256. * Note : the particle custom vertex positions aren't stored values.
  91257. */
  91258. /**
  91259. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  91260. * Default value : false. The SPS is faster when it's set to false.
  91261. * Note : the particle custom vertex positions aren't stored values.
  91262. */
  91263. computeParticleVertex: boolean;
  91264. /**
  91265. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  91266. */
  91267. /**
  91268. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  91269. */
  91270. computeBoundingBox: boolean;
  91271. /**
  91272. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  91273. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91274. * Default : `true`
  91275. */
  91276. /**
  91277. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  91278. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91279. * Default : `true`
  91280. */
  91281. depthSortParticles: boolean;
  91282. /**
  91283. * This function does nothing. It may be overwritten to set all the particle first values.
  91284. * The SPS doesn't call this function, you may have to call it by your own.
  91285. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91286. */
  91287. initParticles(): void;
  91288. /**
  91289. * This function does nothing. It may be overwritten to recycle a particle.
  91290. * The SPS doesn't call this function, you may have to call it by your own.
  91291. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91292. * @param particle The particle to recycle
  91293. * @returns the recycled particle
  91294. */
  91295. recycleParticle(particle: SolidParticle): SolidParticle;
  91296. /**
  91297. * Updates a particle : this function should be overwritten by the user.
  91298. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  91299. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91300. * @example : just set a particle position or velocity and recycle conditions
  91301. * @param particle The particle to update
  91302. * @returns the updated particle
  91303. */
  91304. updateParticle(particle: SolidParticle): SolidParticle;
  91305. /**
  91306. * Updates a vertex of a particle : it can be overwritten by the user.
  91307. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  91308. * @param particle the current particle
  91309. * @param vertex the current index of the current particle
  91310. * @param pt the index of the current vertex in the particle shape
  91311. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  91312. * @example : just set a vertex particle position
  91313. * @returns the updated vertex
  91314. */
  91315. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  91316. /**
  91317. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  91318. * This does nothing and may be overwritten by the user.
  91319. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91320. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91321. * @param update the boolean update value actually passed to setParticles()
  91322. */
  91323. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91324. /**
  91325. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  91326. * This will be passed three parameters.
  91327. * This does nothing and may be overwritten by the user.
  91328. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91329. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91330. * @param update the boolean update value actually passed to setParticles()
  91331. */
  91332. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91333. }
  91334. }
  91335. declare module BABYLON {
  91336. /**
  91337. * Represents one particle of a solid particle system.
  91338. */
  91339. export class SolidParticle {
  91340. /**
  91341. * particle global index
  91342. */
  91343. idx: number;
  91344. /**
  91345. * The color of the particle
  91346. */
  91347. color: Nullable<Color4>;
  91348. /**
  91349. * The world space position of the particle.
  91350. */
  91351. position: Vector3;
  91352. /**
  91353. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  91354. */
  91355. rotation: Vector3;
  91356. /**
  91357. * The world space rotation quaternion of the particle.
  91358. */
  91359. rotationQuaternion: Nullable<Quaternion>;
  91360. /**
  91361. * The scaling of the particle.
  91362. */
  91363. scaling: Vector3;
  91364. /**
  91365. * The uvs of the particle.
  91366. */
  91367. uvs: Vector4;
  91368. /**
  91369. * The current speed of the particle.
  91370. */
  91371. velocity: Vector3;
  91372. /**
  91373. * The pivot point in the particle local space.
  91374. */
  91375. pivot: Vector3;
  91376. /**
  91377. * Must the particle be translated from its pivot point in its local space ?
  91378. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  91379. * Default : false
  91380. */
  91381. translateFromPivot: boolean;
  91382. /**
  91383. * Is the particle active or not ?
  91384. */
  91385. alive: boolean;
  91386. /**
  91387. * Is the particle visible or not ?
  91388. */
  91389. isVisible: boolean;
  91390. /**
  91391. * Index of this particle in the global "positions" array (Internal use)
  91392. * @hidden
  91393. */
  91394. _pos: number;
  91395. /**
  91396. * @hidden Index of this particle in the global "indices" array (Internal use)
  91397. */
  91398. _ind: number;
  91399. /**
  91400. * @hidden ModelShape of this particle (Internal use)
  91401. */
  91402. _model: ModelShape;
  91403. /**
  91404. * ModelShape id of this particle
  91405. */
  91406. shapeId: number;
  91407. /**
  91408. * Index of the particle in its shape id
  91409. */
  91410. idxInShape: number;
  91411. /**
  91412. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  91413. */
  91414. _modelBoundingInfo: BoundingInfo;
  91415. /**
  91416. * @hidden Particle BoundingInfo object (Internal use)
  91417. */
  91418. _boundingInfo: BoundingInfo;
  91419. /**
  91420. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  91421. */
  91422. _sps: SolidParticleSystem;
  91423. /**
  91424. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  91425. */
  91426. _stillInvisible: boolean;
  91427. /**
  91428. * @hidden Last computed particle rotation matrix
  91429. */
  91430. _rotationMatrix: number[];
  91431. /**
  91432. * Parent particle Id, if any.
  91433. * Default null.
  91434. */
  91435. parentId: Nullable<number>;
  91436. /**
  91437. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  91438. * The possible values are :
  91439. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91440. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91441. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91442. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91443. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91444. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  91445. * */
  91446. cullingStrategy: number;
  91447. /**
  91448. * @hidden Internal global position in the SPS.
  91449. */
  91450. _globalPosition: Vector3;
  91451. /**
  91452. * Creates a Solid Particle object.
  91453. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  91454. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  91455. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  91456. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  91457. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  91458. * @param shapeId (integer) is the model shape identifier in the SPS.
  91459. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  91460. * @param sps defines the sps it is associated to
  91461. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  91462. */
  91463. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  91464. /**
  91465. * Legacy support, changed scale to scaling
  91466. */
  91467. /**
  91468. * Legacy support, changed scale to scaling
  91469. */
  91470. scale: Vector3;
  91471. /**
  91472. * Legacy support, changed quaternion to rotationQuaternion
  91473. */
  91474. /**
  91475. * Legacy support, changed quaternion to rotationQuaternion
  91476. */
  91477. quaternion: Nullable<Quaternion>;
  91478. /**
  91479. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  91480. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  91481. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  91482. * @returns true if it intersects
  91483. */
  91484. intersectsMesh(target: Mesh | SolidParticle): boolean;
  91485. /**
  91486. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  91487. * A particle is in the frustum if its bounding box intersects the frustum
  91488. * @param frustumPlanes defines the frustum to test
  91489. * @returns true if the particle is in the frustum planes
  91490. */
  91491. isInFrustum(frustumPlanes: Plane[]): boolean;
  91492. /**
  91493. * get the rotation matrix of the particle
  91494. * @hidden
  91495. */
  91496. getRotationMatrix(m: Matrix): void;
  91497. }
  91498. /**
  91499. * Represents the shape of the model used by one particle of a solid particle system.
  91500. * SPS internal tool, don't use it manually.
  91501. */
  91502. export class ModelShape {
  91503. /**
  91504. * The shape id
  91505. * @hidden
  91506. */
  91507. shapeID: number;
  91508. /**
  91509. * flat array of model positions (internal use)
  91510. * @hidden
  91511. */
  91512. _shape: Vector3[];
  91513. /**
  91514. * flat array of model UVs (internal use)
  91515. * @hidden
  91516. */
  91517. _shapeUV: number[];
  91518. /**
  91519. * length of the shape in the model indices array (internal use)
  91520. * @hidden
  91521. */
  91522. _indicesLength: number;
  91523. /**
  91524. * Custom position function (internal use)
  91525. * @hidden
  91526. */
  91527. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  91528. /**
  91529. * Custom vertex function (internal use)
  91530. * @hidden
  91531. */
  91532. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  91533. /**
  91534. * 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.
  91535. * SPS internal tool, don't use it manually.
  91536. * @hidden
  91537. */
  91538. 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>);
  91539. }
  91540. /**
  91541. * Represents a Depth Sorted Particle in the solid particle system.
  91542. */
  91543. export class DepthSortedParticle {
  91544. /**
  91545. * Index of the particle in the "indices" array
  91546. */
  91547. ind: number;
  91548. /**
  91549. * Length of the particle shape in the "indices" array
  91550. */
  91551. indicesLength: number;
  91552. /**
  91553. * Squared distance from the particle to the camera
  91554. */
  91555. sqDistance: number;
  91556. }
  91557. }
  91558. declare module BABYLON {
  91559. /**
  91560. * @hidden
  91561. */
  91562. export class _MeshCollisionData {
  91563. _checkCollisions: boolean;
  91564. _collisionMask: number;
  91565. _collisionGroup: number;
  91566. _collider: Nullable<Collider>;
  91567. _oldPositionForCollisions: Vector3;
  91568. _diffPositionForCollisions: Vector3;
  91569. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  91570. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  91571. }
  91572. }
  91573. declare module BABYLON {
  91574. /** @hidden */
  91575. class _FacetDataStorage {
  91576. facetPositions: Vector3[];
  91577. facetNormals: Vector3[];
  91578. facetPartitioning: number[][];
  91579. facetNb: number;
  91580. partitioningSubdivisions: number;
  91581. partitioningBBoxRatio: number;
  91582. facetDataEnabled: boolean;
  91583. facetParameters: any;
  91584. bbSize: Vector3;
  91585. subDiv: {
  91586. max: number;
  91587. X: number;
  91588. Y: number;
  91589. Z: number;
  91590. };
  91591. facetDepthSort: boolean;
  91592. facetDepthSortEnabled: boolean;
  91593. depthSortedIndices: IndicesArray;
  91594. depthSortedFacets: {
  91595. ind: number;
  91596. sqDistance: number;
  91597. }[];
  91598. facetDepthSortFunction: (f1: {
  91599. ind: number;
  91600. sqDistance: number;
  91601. }, f2: {
  91602. ind: number;
  91603. sqDistance: number;
  91604. }) => number;
  91605. facetDepthSortFrom: Vector3;
  91606. facetDepthSortOrigin: Vector3;
  91607. invertedMatrix: Matrix;
  91608. }
  91609. /**
  91610. * @hidden
  91611. **/
  91612. class _InternalAbstractMeshDataInfo {
  91613. _hasVertexAlpha: boolean;
  91614. _useVertexColors: boolean;
  91615. _numBoneInfluencers: number;
  91616. _applyFog: boolean;
  91617. _receiveShadows: boolean;
  91618. _facetData: _FacetDataStorage;
  91619. _visibility: number;
  91620. _skeleton: Nullable<Skeleton>;
  91621. _layerMask: number;
  91622. _computeBonesUsingShaders: boolean;
  91623. _isActive: boolean;
  91624. _onlyForInstances: boolean;
  91625. _isActiveIntermediate: boolean;
  91626. _onlyForInstancesIntermediate: boolean;
  91627. }
  91628. /**
  91629. * Class used to store all common mesh properties
  91630. */
  91631. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  91632. /** No occlusion */
  91633. static OCCLUSION_TYPE_NONE: number;
  91634. /** Occlusion set to optimisitic */
  91635. static OCCLUSION_TYPE_OPTIMISTIC: number;
  91636. /** Occlusion set to strict */
  91637. static OCCLUSION_TYPE_STRICT: number;
  91638. /** Use an accurante occlusion algorithm */
  91639. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  91640. /** Use a conservative occlusion algorithm */
  91641. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  91642. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  91643. * Test order :
  91644. * Is the bounding sphere outside the frustum ?
  91645. * If not, are the bounding box vertices outside the frustum ?
  91646. * It not, then the cullable object is in the frustum.
  91647. */
  91648. static readonly CULLINGSTRATEGY_STANDARD: number;
  91649. /** Culling strategy : Bounding Sphere Only.
  91650. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  91651. * It's also less accurate than the standard because some not visible objects can still be selected.
  91652. * Test : is the bounding sphere outside the frustum ?
  91653. * If not, then the cullable object is in the frustum.
  91654. */
  91655. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  91656. /** Culling strategy : Optimistic Inclusion.
  91657. * This in an inclusion test first, then the standard exclusion test.
  91658. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  91659. * 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.
  91660. * Anyway, it's as accurate as the standard strategy.
  91661. * Test :
  91662. * Is the cullable object bounding sphere center in the frustum ?
  91663. * If not, apply the default culling strategy.
  91664. */
  91665. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  91666. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  91667. * This in an inclusion test first, then the bounding sphere only exclusion test.
  91668. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  91669. * 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.
  91670. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  91671. * Test :
  91672. * Is the cullable object bounding sphere center in the frustum ?
  91673. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  91674. */
  91675. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  91676. /**
  91677. * No billboard
  91678. */
  91679. static readonly BILLBOARDMODE_NONE: number;
  91680. /** Billboard on X axis */
  91681. static readonly BILLBOARDMODE_X: number;
  91682. /** Billboard on Y axis */
  91683. static readonly BILLBOARDMODE_Y: number;
  91684. /** Billboard on Z axis */
  91685. static readonly BILLBOARDMODE_Z: number;
  91686. /** Billboard on all axes */
  91687. static readonly BILLBOARDMODE_ALL: number;
  91688. /** Billboard on using position instead of orientation */
  91689. static readonly BILLBOARDMODE_USE_POSITION: number;
  91690. /** @hidden */
  91691. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  91692. /**
  91693. * The culling strategy to use to check whether the mesh must be rendered or not.
  91694. * This value can be changed at any time and will be used on the next render mesh selection.
  91695. * The possible values are :
  91696. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91697. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91698. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91699. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91700. * Please read each static variable documentation to get details about the culling process.
  91701. * */
  91702. cullingStrategy: number;
  91703. /**
  91704. * Gets the number of facets in the mesh
  91705. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91706. */
  91707. readonly facetNb: number;
  91708. /**
  91709. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  91710. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91711. */
  91712. partitioningSubdivisions: number;
  91713. /**
  91714. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  91715. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  91716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91717. */
  91718. partitioningBBoxRatio: number;
  91719. /**
  91720. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  91721. * Works only for updatable meshes.
  91722. * Doesn't work with multi-materials
  91723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91724. */
  91725. mustDepthSortFacets: boolean;
  91726. /**
  91727. * The location (Vector3) where the facet depth sort must be computed from.
  91728. * By default, the active camera position.
  91729. * Used only when facet depth sort is enabled
  91730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91731. */
  91732. facetDepthSortFrom: Vector3;
  91733. /**
  91734. * gets a boolean indicating if facetData is enabled
  91735. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91736. */
  91737. readonly isFacetDataEnabled: boolean;
  91738. /** @hidden */
  91739. _updateNonUniformScalingState(value: boolean): boolean;
  91740. /**
  91741. * An event triggered when this mesh collides with another one
  91742. */
  91743. onCollideObservable: Observable<AbstractMesh>;
  91744. /** Set a function to call when this mesh collides with another one */
  91745. onCollide: () => void;
  91746. /**
  91747. * An event triggered when the collision's position changes
  91748. */
  91749. onCollisionPositionChangeObservable: Observable<Vector3>;
  91750. /** Set a function to call when the collision's position changes */
  91751. onCollisionPositionChange: () => void;
  91752. /**
  91753. * An event triggered when material is changed
  91754. */
  91755. onMaterialChangedObservable: Observable<AbstractMesh>;
  91756. /**
  91757. * Gets or sets the orientation for POV movement & rotation
  91758. */
  91759. definedFacingForward: boolean;
  91760. /** @hidden */
  91761. _occlusionQuery: Nullable<WebGLQuery>;
  91762. /** @hidden */
  91763. _renderingGroup: Nullable<RenderingGroup>;
  91764. /**
  91765. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91766. */
  91767. /**
  91768. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91769. */
  91770. visibility: number;
  91771. /** Gets or sets the alpha index used to sort transparent meshes
  91772. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  91773. */
  91774. alphaIndex: number;
  91775. /**
  91776. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  91777. */
  91778. isVisible: boolean;
  91779. /**
  91780. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91781. */
  91782. isPickable: boolean;
  91783. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  91784. showSubMeshesBoundingBox: boolean;
  91785. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  91786. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  91787. */
  91788. isBlocker: boolean;
  91789. /**
  91790. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  91791. */
  91792. enablePointerMoveEvents: boolean;
  91793. /**
  91794. * Specifies the rendering group id for this mesh (0 by default)
  91795. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91796. */
  91797. renderingGroupId: number;
  91798. private _material;
  91799. /** Gets or sets current material */
  91800. material: Nullable<Material>;
  91801. /**
  91802. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  91803. * @see http://doc.babylonjs.com/babylon101/shadows
  91804. */
  91805. receiveShadows: boolean;
  91806. /** Defines color to use when rendering outline */
  91807. outlineColor: Color3;
  91808. /** Define width to use when rendering outline */
  91809. outlineWidth: number;
  91810. /** Defines color to use when rendering overlay */
  91811. overlayColor: Color3;
  91812. /** Defines alpha to use when rendering overlay */
  91813. overlayAlpha: number;
  91814. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  91815. hasVertexAlpha: boolean;
  91816. /** 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) */
  91817. useVertexColors: boolean;
  91818. /**
  91819. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  91820. */
  91821. computeBonesUsingShaders: boolean;
  91822. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  91823. numBoneInfluencers: number;
  91824. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  91825. applyFog: boolean;
  91826. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  91827. useOctreeForRenderingSelection: boolean;
  91828. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  91829. useOctreeForPicking: boolean;
  91830. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  91831. useOctreeForCollisions: boolean;
  91832. /**
  91833. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  91834. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  91835. */
  91836. layerMask: number;
  91837. /**
  91838. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  91839. */
  91840. alwaysSelectAsActiveMesh: boolean;
  91841. /**
  91842. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  91843. */
  91844. doNotSyncBoundingInfo: boolean;
  91845. /**
  91846. * Gets or sets the current action manager
  91847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91848. */
  91849. actionManager: Nullable<AbstractActionManager>;
  91850. private _meshCollisionData;
  91851. /**
  91852. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  91853. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91854. */
  91855. ellipsoid: Vector3;
  91856. /**
  91857. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  91858. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91859. */
  91860. ellipsoidOffset: Vector3;
  91861. /**
  91862. * Gets or sets a collision mask used to mask collisions (default is -1).
  91863. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91864. */
  91865. collisionMask: number;
  91866. /**
  91867. * Gets or sets the current collision group mask (-1 by default).
  91868. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91869. */
  91870. collisionGroup: number;
  91871. /**
  91872. * Defines edge width used when edgesRenderer is enabled
  91873. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91874. */
  91875. edgesWidth: number;
  91876. /**
  91877. * Defines edge color used when edgesRenderer is enabled
  91878. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91879. */
  91880. edgesColor: Color4;
  91881. /** @hidden */
  91882. _edgesRenderer: Nullable<IEdgesRenderer>;
  91883. /** @hidden */
  91884. _masterMesh: Nullable<AbstractMesh>;
  91885. /** @hidden */
  91886. _boundingInfo: Nullable<BoundingInfo>;
  91887. /** @hidden */
  91888. _renderId: number;
  91889. /**
  91890. * Gets or sets the list of subMeshes
  91891. * @see http://doc.babylonjs.com/how_to/multi_materials
  91892. */
  91893. subMeshes: SubMesh[];
  91894. /** @hidden */
  91895. _intersectionsInProgress: AbstractMesh[];
  91896. /** @hidden */
  91897. _unIndexed: boolean;
  91898. /** @hidden */
  91899. _lightSources: Light[];
  91900. /** Gets the list of lights affecting that mesh */
  91901. readonly lightSources: Light[];
  91902. /** @hidden */
  91903. readonly _positions: Nullable<Vector3[]>;
  91904. /** @hidden */
  91905. _waitingData: {
  91906. lods: Nullable<any>;
  91907. actions: Nullable<any>;
  91908. freezeWorldMatrix: Nullable<boolean>;
  91909. };
  91910. /** @hidden */
  91911. _bonesTransformMatrices: Nullable<Float32Array>;
  91912. /** @hidden */
  91913. _transformMatrixTexture: Nullable<RawTexture>;
  91914. /**
  91915. * Gets or sets a skeleton to apply skining transformations
  91916. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91917. */
  91918. skeleton: Nullable<Skeleton>;
  91919. /**
  91920. * An event triggered when the mesh is rebuilt.
  91921. */
  91922. onRebuildObservable: Observable<AbstractMesh>;
  91923. /**
  91924. * Creates a new AbstractMesh
  91925. * @param name defines the name of the mesh
  91926. * @param scene defines the hosting scene
  91927. */
  91928. constructor(name: string, scene?: Nullable<Scene>);
  91929. /**
  91930. * Returns the string "AbstractMesh"
  91931. * @returns "AbstractMesh"
  91932. */
  91933. getClassName(): string;
  91934. /**
  91935. * Gets a string representation of the current mesh
  91936. * @param fullDetails defines a boolean indicating if full details must be included
  91937. * @returns a string representation of the current mesh
  91938. */
  91939. toString(fullDetails?: boolean): string;
  91940. /**
  91941. * @hidden
  91942. */
  91943. protected _getEffectiveParent(): Nullable<Node>;
  91944. /** @hidden */
  91945. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91946. /** @hidden */
  91947. _rebuild(): void;
  91948. /** @hidden */
  91949. _resyncLightSources(): void;
  91950. /** @hidden */
  91951. _resyncLighSource(light: Light): void;
  91952. /** @hidden */
  91953. _unBindEffect(): void;
  91954. /** @hidden */
  91955. _removeLightSource(light: Light, dispose: boolean): void;
  91956. private _markSubMeshesAsDirty;
  91957. /** @hidden */
  91958. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  91959. /** @hidden */
  91960. _markSubMeshesAsAttributesDirty(): void;
  91961. /** @hidden */
  91962. _markSubMeshesAsMiscDirty(): void;
  91963. /**
  91964. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  91965. */
  91966. scaling: Vector3;
  91967. /**
  91968. * Returns true if the mesh is blocked. Implemented by child classes
  91969. */
  91970. readonly isBlocked: boolean;
  91971. /**
  91972. * Returns the mesh itself by default. Implemented by child classes
  91973. * @param camera defines the camera to use to pick the right LOD level
  91974. * @returns the currentAbstractMesh
  91975. */
  91976. getLOD(camera: Camera): Nullable<AbstractMesh>;
  91977. /**
  91978. * Returns 0 by default. Implemented by child classes
  91979. * @returns an integer
  91980. */
  91981. getTotalVertices(): number;
  91982. /**
  91983. * Returns a positive integer : the total number of indices in this mesh geometry.
  91984. * @returns the numner of indices or zero if the mesh has no geometry.
  91985. */
  91986. getTotalIndices(): number;
  91987. /**
  91988. * Returns null by default. Implemented by child classes
  91989. * @returns null
  91990. */
  91991. getIndices(): Nullable<IndicesArray>;
  91992. /**
  91993. * Returns the array of the requested vertex data kind. Implemented by child classes
  91994. * @param kind defines the vertex data kind to use
  91995. * @returns null
  91996. */
  91997. getVerticesData(kind: string): Nullable<FloatArray>;
  91998. /**
  91999. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92000. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92001. * Note that a new underlying VertexBuffer object is created each call.
  92002. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92003. * @param kind defines vertex data kind:
  92004. * * VertexBuffer.PositionKind
  92005. * * VertexBuffer.UVKind
  92006. * * VertexBuffer.UV2Kind
  92007. * * VertexBuffer.UV3Kind
  92008. * * VertexBuffer.UV4Kind
  92009. * * VertexBuffer.UV5Kind
  92010. * * VertexBuffer.UV6Kind
  92011. * * VertexBuffer.ColorKind
  92012. * * VertexBuffer.MatricesIndicesKind
  92013. * * VertexBuffer.MatricesIndicesExtraKind
  92014. * * VertexBuffer.MatricesWeightsKind
  92015. * * VertexBuffer.MatricesWeightsExtraKind
  92016. * @param data defines the data source
  92017. * @param updatable defines if the data must be flagged as updatable (or static)
  92018. * @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
  92019. * @returns the current mesh
  92020. */
  92021. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92022. /**
  92023. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92024. * If the mesh has no geometry, it is simply returned as it is.
  92025. * @param kind defines vertex data kind:
  92026. * * VertexBuffer.PositionKind
  92027. * * VertexBuffer.UVKind
  92028. * * VertexBuffer.UV2Kind
  92029. * * VertexBuffer.UV3Kind
  92030. * * VertexBuffer.UV4Kind
  92031. * * VertexBuffer.UV5Kind
  92032. * * VertexBuffer.UV6Kind
  92033. * * VertexBuffer.ColorKind
  92034. * * VertexBuffer.MatricesIndicesKind
  92035. * * VertexBuffer.MatricesIndicesExtraKind
  92036. * * VertexBuffer.MatricesWeightsKind
  92037. * * VertexBuffer.MatricesWeightsExtraKind
  92038. * @param data defines the data source
  92039. * @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
  92040. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92041. * @returns the current mesh
  92042. */
  92043. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92044. /**
  92045. * Sets the mesh indices,
  92046. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92047. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  92048. * @param totalVertices Defines the total number of vertices
  92049. * @returns the current mesh
  92050. */
  92051. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  92052. /**
  92053. * Gets a boolean indicating if specific vertex data is present
  92054. * @param kind defines the vertex data kind to use
  92055. * @returns true is data kind is present
  92056. */
  92057. isVerticesDataPresent(kind: string): boolean;
  92058. /**
  92059. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  92060. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  92061. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  92062. * @returns a BoundingInfo
  92063. */
  92064. getBoundingInfo(): BoundingInfo;
  92065. /**
  92066. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92067. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92068. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92069. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92070. * @returns the current mesh
  92071. */
  92072. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  92073. /**
  92074. * Overwrite the current bounding info
  92075. * @param boundingInfo defines the new bounding info
  92076. * @returns the current mesh
  92077. */
  92078. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  92079. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  92080. readonly useBones: boolean;
  92081. /** @hidden */
  92082. _preActivate(): void;
  92083. /** @hidden */
  92084. _preActivateForIntermediateRendering(renderId: number): void;
  92085. /** @hidden */
  92086. _activate(renderId: number, intermediateRendering: boolean): boolean;
  92087. /** @hidden */
  92088. _postActivate(): void;
  92089. /** @hidden */
  92090. _freeze(): void;
  92091. /** @hidden */
  92092. _unFreeze(): void;
  92093. /**
  92094. * Gets the current world matrix
  92095. * @returns a Matrix
  92096. */
  92097. getWorldMatrix(): Matrix;
  92098. /** @hidden */
  92099. _getWorldMatrixDeterminant(): number;
  92100. /**
  92101. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  92102. */
  92103. readonly isAnInstance: boolean;
  92104. /**
  92105. * Gets a boolean indicating if this mesh has instances
  92106. */
  92107. readonly hasInstances: boolean;
  92108. /**
  92109. * Perform relative position change from the point of view of behind the front of the mesh.
  92110. * This is performed taking into account the meshes current rotation, so you do not have to care.
  92111. * Supports definition of mesh facing forward or backward
  92112. * @param amountRight defines the distance on the right axis
  92113. * @param amountUp defines the distance on the up axis
  92114. * @param amountForward defines the distance on the forward axis
  92115. * @returns the current mesh
  92116. */
  92117. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  92118. /**
  92119. * Calculate relative position change from the point of view of behind the front of the mesh.
  92120. * This is performed taking into account the meshes current rotation, so you do not have to care.
  92121. * Supports definition of mesh facing forward or backward
  92122. * @param amountRight defines the distance on the right axis
  92123. * @param amountUp defines the distance on the up axis
  92124. * @param amountForward defines the distance on the forward axis
  92125. * @returns the new displacement vector
  92126. */
  92127. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  92128. /**
  92129. * Perform relative rotation change from the point of view of behind the front of the mesh.
  92130. * Supports definition of mesh facing forward or backward
  92131. * @param flipBack defines the flip
  92132. * @param twirlClockwise defines the twirl
  92133. * @param tiltRight defines the tilt
  92134. * @returns the current mesh
  92135. */
  92136. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  92137. /**
  92138. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  92139. * Supports definition of mesh facing forward or backward.
  92140. * @param flipBack defines the flip
  92141. * @param twirlClockwise defines the twirl
  92142. * @param tiltRight defines the tilt
  92143. * @returns the new rotation vector
  92144. */
  92145. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  92146. /**
  92147. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92148. * This means the mesh underlying bounding box and sphere are recomputed.
  92149. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92150. * @returns the current mesh
  92151. */
  92152. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  92153. /** @hidden */
  92154. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  92155. /** @hidden */
  92156. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  92157. /** @hidden */
  92158. _updateBoundingInfo(): AbstractMesh;
  92159. /** @hidden */
  92160. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  92161. /** @hidden */
  92162. protected _afterComputeWorldMatrix(): void;
  92163. /** @hidden */
  92164. readonly _effectiveMesh: AbstractMesh;
  92165. /**
  92166. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92167. * A mesh is in the frustum if its bounding box intersects the frustum
  92168. * @param frustumPlanes defines the frustum to test
  92169. * @returns true if the mesh is in the frustum planes
  92170. */
  92171. isInFrustum(frustumPlanes: Plane[]): boolean;
  92172. /**
  92173. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  92174. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  92175. * @param frustumPlanes defines the frustum to test
  92176. * @returns true if the mesh is completely in the frustum planes
  92177. */
  92178. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92179. /**
  92180. * True if the mesh intersects another mesh or a SolidParticle object
  92181. * @param mesh defines a target mesh or SolidParticle to test
  92182. * @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)
  92183. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  92184. * @returns true if there is an intersection
  92185. */
  92186. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  92187. /**
  92188. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  92189. * @param point defines the point to test
  92190. * @returns true if there is an intersection
  92191. */
  92192. intersectsPoint(point: Vector3): boolean;
  92193. /**
  92194. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  92195. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92196. */
  92197. checkCollisions: boolean;
  92198. /**
  92199. * Gets Collider object used to compute collisions (not physics)
  92200. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92201. */
  92202. readonly collider: Nullable<Collider>;
  92203. /**
  92204. * Move the mesh using collision engine
  92205. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92206. * @param displacement defines the requested displacement vector
  92207. * @returns the current mesh
  92208. */
  92209. moveWithCollisions(displacement: Vector3): AbstractMesh;
  92210. private _onCollisionPositionChange;
  92211. /** @hidden */
  92212. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  92213. /** @hidden */
  92214. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  92215. /** @hidden */
  92216. _checkCollision(collider: Collider): AbstractMesh;
  92217. /** @hidden */
  92218. _generatePointsArray(): boolean;
  92219. /**
  92220. * Checks if the passed Ray intersects with the mesh
  92221. * @param ray defines the ray to use
  92222. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  92223. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92224. * @returns the picking info
  92225. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92226. */
  92227. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  92228. /**
  92229. * Clones the current mesh
  92230. * @param name defines the mesh name
  92231. * @param newParent defines the new mesh parent
  92232. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  92233. * @returns the new mesh
  92234. */
  92235. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  92236. /**
  92237. * Disposes all the submeshes of the current meshnp
  92238. * @returns the current mesh
  92239. */
  92240. releaseSubMeshes(): AbstractMesh;
  92241. /**
  92242. * Releases resources associated with this abstract mesh.
  92243. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92244. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92245. */
  92246. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92247. /**
  92248. * Adds the passed mesh as a child to the current mesh
  92249. * @param mesh defines the child mesh
  92250. * @returns the current mesh
  92251. */
  92252. addChild(mesh: AbstractMesh): AbstractMesh;
  92253. /**
  92254. * Removes the passed mesh from the current mesh children list
  92255. * @param mesh defines the child mesh
  92256. * @returns the current mesh
  92257. */
  92258. removeChild(mesh: AbstractMesh): AbstractMesh;
  92259. /** @hidden */
  92260. private _initFacetData;
  92261. /**
  92262. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  92263. * This method can be called within the render loop.
  92264. * 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
  92265. * @returns the current mesh
  92266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92267. */
  92268. updateFacetData(): AbstractMesh;
  92269. /**
  92270. * Returns the facetLocalNormals array.
  92271. * The normals are expressed in the mesh local spac
  92272. * @returns an array of Vector3
  92273. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92274. */
  92275. getFacetLocalNormals(): Vector3[];
  92276. /**
  92277. * Returns the facetLocalPositions array.
  92278. * The facet positions are expressed in the mesh local space
  92279. * @returns an array of Vector3
  92280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92281. */
  92282. getFacetLocalPositions(): Vector3[];
  92283. /**
  92284. * Returns the facetLocalPartioning array
  92285. * @returns an array of array of numbers
  92286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92287. */
  92288. getFacetLocalPartitioning(): number[][];
  92289. /**
  92290. * Returns the i-th facet position in the world system.
  92291. * This method allocates a new Vector3 per call
  92292. * @param i defines the facet index
  92293. * @returns a new Vector3
  92294. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92295. */
  92296. getFacetPosition(i: number): Vector3;
  92297. /**
  92298. * Sets the reference Vector3 with the i-th facet position in the world system
  92299. * @param i defines the facet index
  92300. * @param ref defines the target vector
  92301. * @returns the current mesh
  92302. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92303. */
  92304. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  92305. /**
  92306. * Returns the i-th facet normal in the world system.
  92307. * This method allocates a new Vector3 per call
  92308. * @param i defines the facet index
  92309. * @returns a new Vector3
  92310. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92311. */
  92312. getFacetNormal(i: number): Vector3;
  92313. /**
  92314. * Sets the reference Vector3 with the i-th facet normal in the world system
  92315. * @param i defines the facet index
  92316. * @param ref defines the target vector
  92317. * @returns the current mesh
  92318. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92319. */
  92320. getFacetNormalToRef(i: number, ref: Vector3): this;
  92321. /**
  92322. * 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)
  92323. * @param x defines x coordinate
  92324. * @param y defines y coordinate
  92325. * @param z defines z coordinate
  92326. * @returns the array of facet indexes
  92327. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92328. */
  92329. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  92330. /**
  92331. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  92332. * @param projected sets as the (x,y,z) world projection on the facet
  92333. * @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
  92334. * @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
  92335. * @param x defines x coordinate
  92336. * @param y defines y coordinate
  92337. * @param z defines z coordinate
  92338. * @returns the face index if found (or null instead)
  92339. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92340. */
  92341. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92342. /**
  92343. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  92344. * @param projected sets as the (x,y,z) local projection on the facet
  92345. * @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
  92346. * @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
  92347. * @param x defines x coordinate
  92348. * @param y defines y coordinate
  92349. * @param z defines z coordinate
  92350. * @returns the face index if found (or null instead)
  92351. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92352. */
  92353. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92354. /**
  92355. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  92356. * @returns the parameters
  92357. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92358. */
  92359. getFacetDataParameters(): any;
  92360. /**
  92361. * Disables the feature FacetData and frees the related memory
  92362. * @returns the current mesh
  92363. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92364. */
  92365. disableFacetData(): AbstractMesh;
  92366. /**
  92367. * Updates the AbstractMesh indices array
  92368. * @param indices defines the data source
  92369. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92370. * @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)
  92371. * @returns the current mesh
  92372. */
  92373. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92374. /**
  92375. * Creates new normals data for the mesh
  92376. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  92377. * @returns the current mesh
  92378. */
  92379. createNormals(updatable: boolean): AbstractMesh;
  92380. /**
  92381. * Align the mesh with a normal
  92382. * @param normal defines the normal to use
  92383. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  92384. * @returns the current mesh
  92385. */
  92386. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  92387. /** @hidden */
  92388. _checkOcclusionQuery(): boolean;
  92389. /**
  92390. * Disables the mesh edge rendering mode
  92391. * @returns the currentAbstractMesh
  92392. */
  92393. disableEdgesRendering(): AbstractMesh;
  92394. /**
  92395. * Enables the edge rendering mode on the mesh.
  92396. * This mode makes the mesh edges visible
  92397. * @param epsilon defines the maximal distance between two angles to detect a face
  92398. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92399. * @returns the currentAbstractMesh
  92400. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92401. */
  92402. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92403. }
  92404. }
  92405. declare module BABYLON {
  92406. /**
  92407. * Interface used to define ActionEvent
  92408. */
  92409. export interface IActionEvent {
  92410. /** The mesh or sprite that triggered the action */
  92411. source: any;
  92412. /** The X mouse cursor position at the time of the event */
  92413. pointerX: number;
  92414. /** The Y mouse cursor position at the time of the event */
  92415. pointerY: number;
  92416. /** The mesh that is currently pointed at (can be null) */
  92417. meshUnderPointer: Nullable<AbstractMesh>;
  92418. /** the original (browser) event that triggered the ActionEvent */
  92419. sourceEvent?: any;
  92420. /** additional data for the event */
  92421. additionalData?: any;
  92422. }
  92423. /**
  92424. * ActionEvent is the event being sent when an action is triggered.
  92425. */
  92426. export class ActionEvent implements IActionEvent {
  92427. /** The mesh or sprite that triggered the action */
  92428. source: any;
  92429. /** The X mouse cursor position at the time of the event */
  92430. pointerX: number;
  92431. /** The Y mouse cursor position at the time of the event */
  92432. pointerY: number;
  92433. /** The mesh that is currently pointed at (can be null) */
  92434. meshUnderPointer: Nullable<AbstractMesh>;
  92435. /** the original (browser) event that triggered the ActionEvent */
  92436. sourceEvent?: any;
  92437. /** additional data for the event */
  92438. additionalData?: any;
  92439. /**
  92440. * Creates a new ActionEvent
  92441. * @param source The mesh or sprite that triggered the action
  92442. * @param pointerX The X mouse cursor position at the time of the event
  92443. * @param pointerY The Y mouse cursor position at the time of the event
  92444. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  92445. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  92446. * @param additionalData additional data for the event
  92447. */
  92448. constructor(
  92449. /** The mesh or sprite that triggered the action */
  92450. source: any,
  92451. /** The X mouse cursor position at the time of the event */
  92452. pointerX: number,
  92453. /** The Y mouse cursor position at the time of the event */
  92454. pointerY: number,
  92455. /** The mesh that is currently pointed at (can be null) */
  92456. meshUnderPointer: Nullable<AbstractMesh>,
  92457. /** the original (browser) event that triggered the ActionEvent */
  92458. sourceEvent?: any,
  92459. /** additional data for the event */
  92460. additionalData?: any);
  92461. /**
  92462. * Helper function to auto-create an ActionEvent from a source mesh.
  92463. * @param source The source mesh that triggered the event
  92464. * @param evt The original (browser) event
  92465. * @param additionalData additional data for the event
  92466. * @returns the new ActionEvent
  92467. */
  92468. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  92469. /**
  92470. * Helper function to auto-create an ActionEvent from a source sprite
  92471. * @param source The source sprite that triggered the event
  92472. * @param scene Scene associated with the sprite
  92473. * @param evt The original (browser) event
  92474. * @param additionalData additional data for the event
  92475. * @returns the new ActionEvent
  92476. */
  92477. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  92478. /**
  92479. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  92480. * @param scene the scene where the event occurred
  92481. * @param evt The original (browser) event
  92482. * @returns the new ActionEvent
  92483. */
  92484. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  92485. /**
  92486. * Helper function to auto-create an ActionEvent from a primitive
  92487. * @param prim defines the target primitive
  92488. * @param pointerPos defines the pointer position
  92489. * @param evt The original (browser) event
  92490. * @param additionalData additional data for the event
  92491. * @returns the new ActionEvent
  92492. */
  92493. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  92494. }
  92495. }
  92496. declare module BABYLON {
  92497. /**
  92498. * Abstract class used to decouple action Manager from scene and meshes.
  92499. * Do not instantiate.
  92500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92501. */
  92502. export abstract class AbstractActionManager implements IDisposable {
  92503. /** Gets the list of active triggers */
  92504. static Triggers: {
  92505. [key: string]: number;
  92506. };
  92507. /** Gets the cursor to use when hovering items */
  92508. hoverCursor: string;
  92509. /** Gets the list of actions */
  92510. actions: IAction[];
  92511. /**
  92512. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  92513. */
  92514. isRecursive: boolean;
  92515. /**
  92516. * Releases all associated resources
  92517. */
  92518. abstract dispose(): void;
  92519. /**
  92520. * Does this action manager has pointer triggers
  92521. */
  92522. abstract readonly hasPointerTriggers: boolean;
  92523. /**
  92524. * Does this action manager has pick triggers
  92525. */
  92526. abstract readonly hasPickTriggers: boolean;
  92527. /**
  92528. * Process a specific trigger
  92529. * @param trigger defines the trigger to process
  92530. * @param evt defines the event details to be processed
  92531. */
  92532. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  92533. /**
  92534. * Does this action manager handles actions of any of the given triggers
  92535. * @param triggers defines the triggers to be tested
  92536. * @return a boolean indicating whether one (or more) of the triggers is handled
  92537. */
  92538. abstract hasSpecificTriggers(triggers: number[]): boolean;
  92539. /**
  92540. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92541. * speed.
  92542. * @param triggerA defines the trigger to be tested
  92543. * @param triggerB defines the trigger to be tested
  92544. * @return a boolean indicating whether one (or more) of the triggers is handled
  92545. */
  92546. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92547. /**
  92548. * Does this action manager handles actions of a given trigger
  92549. * @param trigger defines the trigger to be tested
  92550. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92551. * @return whether the trigger is handled
  92552. */
  92553. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92554. /**
  92555. * Serialize this manager to a JSON object
  92556. * @param name defines the property name to store this manager
  92557. * @returns a JSON representation of this manager
  92558. */
  92559. abstract serialize(name: string): any;
  92560. /**
  92561. * Registers an action to this action manager
  92562. * @param action defines the action to be registered
  92563. * @return the action amended (prepared) after registration
  92564. */
  92565. abstract registerAction(action: IAction): Nullable<IAction>;
  92566. /**
  92567. * Unregisters an action to this action manager
  92568. * @param action defines the action to be unregistered
  92569. * @return a boolean indicating whether the action has been unregistered
  92570. */
  92571. abstract unregisterAction(action: IAction): Boolean;
  92572. /**
  92573. * Does exist one action manager with at least one trigger
  92574. **/
  92575. static readonly HasTriggers: boolean;
  92576. /**
  92577. * Does exist one action manager with at least one pick trigger
  92578. **/
  92579. static readonly HasPickTriggers: boolean;
  92580. /**
  92581. * Does exist one action manager that handles actions of a given trigger
  92582. * @param trigger defines the trigger to be tested
  92583. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  92584. **/
  92585. static HasSpecificTrigger(trigger: number): boolean;
  92586. }
  92587. }
  92588. declare module BABYLON {
  92589. /**
  92590. * Defines how a node can be built from a string name.
  92591. */
  92592. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  92593. /**
  92594. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  92595. */
  92596. export class Node implements IBehaviorAware<Node> {
  92597. /** @hidden */
  92598. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  92599. private static _NodeConstructors;
  92600. /**
  92601. * Add a new node constructor
  92602. * @param type defines the type name of the node to construct
  92603. * @param constructorFunc defines the constructor function
  92604. */
  92605. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  92606. /**
  92607. * Returns a node constructor based on type name
  92608. * @param type defines the type name
  92609. * @param name defines the new node name
  92610. * @param scene defines the hosting scene
  92611. * @param options defines optional options to transmit to constructors
  92612. * @returns the new constructor or null
  92613. */
  92614. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  92615. /**
  92616. * Gets or sets the name of the node
  92617. */
  92618. name: string;
  92619. /**
  92620. * Gets or sets the id of the node
  92621. */
  92622. id: string;
  92623. /**
  92624. * Gets or sets the unique id of the node
  92625. */
  92626. uniqueId: number;
  92627. /**
  92628. * Gets or sets a string used to store user defined state for the node
  92629. */
  92630. state: string;
  92631. /**
  92632. * Gets or sets an object used to store user defined information for the node
  92633. */
  92634. metadata: any;
  92635. /**
  92636. * For internal use only. Please do not use.
  92637. */
  92638. reservedDataStore: any;
  92639. /**
  92640. * List of inspectable custom properties (used by the Inspector)
  92641. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92642. */
  92643. inspectableCustomProperties: IInspectable[];
  92644. /**
  92645. * Gets or sets a boolean used to define if the node must be serialized
  92646. */
  92647. doNotSerialize: boolean;
  92648. /** @hidden */
  92649. _isDisposed: boolean;
  92650. /**
  92651. * Gets a list of Animations associated with the node
  92652. */
  92653. animations: Animation[];
  92654. protected _ranges: {
  92655. [name: string]: Nullable<AnimationRange>;
  92656. };
  92657. /**
  92658. * Callback raised when the node is ready to be used
  92659. */
  92660. onReady: Nullable<(node: Node) => void>;
  92661. private _isEnabled;
  92662. private _isParentEnabled;
  92663. private _isReady;
  92664. /** @hidden */
  92665. _currentRenderId: number;
  92666. private _parentUpdateId;
  92667. /** @hidden */
  92668. _childUpdateId: number;
  92669. /** @hidden */
  92670. _waitingParentId: Nullable<string>;
  92671. /** @hidden */
  92672. _scene: Scene;
  92673. /** @hidden */
  92674. _cache: any;
  92675. private _parentNode;
  92676. private _children;
  92677. /** @hidden */
  92678. _worldMatrix: Matrix;
  92679. /** @hidden */
  92680. _worldMatrixDeterminant: number;
  92681. /** @hidden */
  92682. _worldMatrixDeterminantIsDirty: boolean;
  92683. /** @hidden */
  92684. private _sceneRootNodesIndex;
  92685. /**
  92686. * Gets a boolean indicating if the node has been disposed
  92687. * @returns true if the node was disposed
  92688. */
  92689. isDisposed(): boolean;
  92690. /**
  92691. * Gets or sets the parent of the node (without keeping the current position in the scene)
  92692. * @see https://doc.babylonjs.com/how_to/parenting
  92693. */
  92694. parent: Nullable<Node>;
  92695. private addToSceneRootNodes;
  92696. private removeFromSceneRootNodes;
  92697. private _animationPropertiesOverride;
  92698. /**
  92699. * Gets or sets the animation properties override
  92700. */
  92701. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92702. /**
  92703. * Gets a string idenfifying the name of the class
  92704. * @returns "Node" string
  92705. */
  92706. getClassName(): string;
  92707. /** @hidden */
  92708. readonly _isNode: boolean;
  92709. /**
  92710. * An event triggered when the mesh is disposed
  92711. */
  92712. onDisposeObservable: Observable<Node>;
  92713. private _onDisposeObserver;
  92714. /**
  92715. * Sets a callback that will be raised when the node will be disposed
  92716. */
  92717. onDispose: () => void;
  92718. /**
  92719. * Creates a new Node
  92720. * @param name the name and id to be given to this node
  92721. * @param scene the scene this node will be added to
  92722. * @param addToRootNodes the node will be added to scene.rootNodes
  92723. */
  92724. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  92725. /**
  92726. * Gets the scene of the node
  92727. * @returns a scene
  92728. */
  92729. getScene(): Scene;
  92730. /**
  92731. * Gets the engine of the node
  92732. * @returns a Engine
  92733. */
  92734. getEngine(): Engine;
  92735. private _behaviors;
  92736. /**
  92737. * Attach a behavior to the node
  92738. * @see http://doc.babylonjs.com/features/behaviour
  92739. * @param behavior defines the behavior to attach
  92740. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  92741. * @returns the current Node
  92742. */
  92743. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  92744. /**
  92745. * Remove an attached behavior
  92746. * @see http://doc.babylonjs.com/features/behaviour
  92747. * @param behavior defines the behavior to attach
  92748. * @returns the current Node
  92749. */
  92750. removeBehavior(behavior: Behavior<Node>): Node;
  92751. /**
  92752. * Gets the list of attached behaviors
  92753. * @see http://doc.babylonjs.com/features/behaviour
  92754. */
  92755. readonly behaviors: Behavior<Node>[];
  92756. /**
  92757. * Gets an attached behavior by name
  92758. * @param name defines the name of the behavior to look for
  92759. * @see http://doc.babylonjs.com/features/behaviour
  92760. * @returns null if behavior was not found else the requested behavior
  92761. */
  92762. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  92763. /**
  92764. * Returns the latest update of the World matrix
  92765. * @returns a Matrix
  92766. */
  92767. getWorldMatrix(): Matrix;
  92768. /** @hidden */
  92769. _getWorldMatrixDeterminant(): number;
  92770. /**
  92771. * Returns directly the latest state of the mesh World matrix.
  92772. * A Matrix is returned.
  92773. */
  92774. readonly worldMatrixFromCache: Matrix;
  92775. /** @hidden */
  92776. _initCache(): void;
  92777. /** @hidden */
  92778. updateCache(force?: boolean): void;
  92779. /** @hidden */
  92780. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92781. /** @hidden */
  92782. _updateCache(ignoreParentClass?: boolean): void;
  92783. /** @hidden */
  92784. _isSynchronized(): boolean;
  92785. /** @hidden */
  92786. _markSyncedWithParent(): void;
  92787. /** @hidden */
  92788. isSynchronizedWithParent(): boolean;
  92789. /** @hidden */
  92790. isSynchronized(): boolean;
  92791. /**
  92792. * Is this node ready to be used/rendered
  92793. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92794. * @return true if the node is ready
  92795. */
  92796. isReady(completeCheck?: boolean): boolean;
  92797. /**
  92798. * Is this node enabled?
  92799. * 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
  92800. * @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
  92801. * @return whether this node (and its parent) is enabled
  92802. */
  92803. isEnabled(checkAncestors?: boolean): boolean;
  92804. /** @hidden */
  92805. protected _syncParentEnabledState(): void;
  92806. /**
  92807. * Set the enabled state of this node
  92808. * @param value defines the new enabled state
  92809. */
  92810. setEnabled(value: boolean): void;
  92811. /**
  92812. * Is this node a descendant of the given node?
  92813. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  92814. * @param ancestor defines the parent node to inspect
  92815. * @returns a boolean indicating if this node is a descendant of the given node
  92816. */
  92817. isDescendantOf(ancestor: Node): boolean;
  92818. /** @hidden */
  92819. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  92820. /**
  92821. * Will return all nodes that have this node as ascendant
  92822. * @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
  92823. * @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
  92824. * @return all children nodes of all types
  92825. */
  92826. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  92827. /**
  92828. * Get all child-meshes of this node
  92829. * @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)
  92830. * @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
  92831. * @returns an array of AbstractMesh
  92832. */
  92833. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  92834. /**
  92835. * Get all direct children of this node
  92836. * @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
  92837. * @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)
  92838. * @returns an array of Node
  92839. */
  92840. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  92841. /** @hidden */
  92842. _setReady(state: boolean): void;
  92843. /**
  92844. * Get an animation by name
  92845. * @param name defines the name of the animation to look for
  92846. * @returns null if not found else the requested animation
  92847. */
  92848. getAnimationByName(name: string): Nullable<Animation>;
  92849. /**
  92850. * Creates an animation range for this node
  92851. * @param name defines the name of the range
  92852. * @param from defines the starting key
  92853. * @param to defines the end key
  92854. */
  92855. createAnimationRange(name: string, from: number, to: number): void;
  92856. /**
  92857. * Delete a specific animation range
  92858. * @param name defines the name of the range to delete
  92859. * @param deleteFrames defines if animation frames from the range must be deleted as well
  92860. */
  92861. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  92862. /**
  92863. * Get an animation range by name
  92864. * @param name defines the name of the animation range to look for
  92865. * @returns null if not found else the requested animation range
  92866. */
  92867. getAnimationRange(name: string): Nullable<AnimationRange>;
  92868. /**
  92869. * Gets the list of all animation ranges defined on this node
  92870. * @returns an array
  92871. */
  92872. getAnimationRanges(): Nullable<AnimationRange>[];
  92873. /**
  92874. * Will start the animation sequence
  92875. * @param name defines the range frames for animation sequence
  92876. * @param loop defines if the animation should loop (false by default)
  92877. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  92878. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  92879. * @returns the object created for this animation. If range does not exist, it will return null
  92880. */
  92881. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  92882. /**
  92883. * Serialize animation ranges into a JSON compatible object
  92884. * @returns serialization object
  92885. */
  92886. serializeAnimationRanges(): any;
  92887. /**
  92888. * Computes the world matrix of the node
  92889. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92890. * @returns the world matrix
  92891. */
  92892. computeWorldMatrix(force?: boolean): Matrix;
  92893. /**
  92894. * Releases resources associated with this node.
  92895. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92896. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92897. */
  92898. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92899. /**
  92900. * Parse animation range data from a serialization object and store them into a given node
  92901. * @param node defines where to store the animation ranges
  92902. * @param parsedNode defines the serialization object to read data from
  92903. * @param scene defines the hosting scene
  92904. */
  92905. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  92906. /**
  92907. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  92908. * @param includeDescendants Include bounding info from descendants as well (true by default)
  92909. * @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
  92910. * @returns the new bounding vectors
  92911. */
  92912. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  92913. min: Vector3;
  92914. max: Vector3;
  92915. };
  92916. }
  92917. }
  92918. declare module BABYLON {
  92919. /**
  92920. * @hidden
  92921. */
  92922. export class _IAnimationState {
  92923. key: number;
  92924. repeatCount: number;
  92925. workValue?: any;
  92926. loopMode?: number;
  92927. offsetValue?: any;
  92928. highLimitValue?: any;
  92929. }
  92930. /**
  92931. * Class used to store any kind of animation
  92932. */
  92933. export class Animation {
  92934. /**Name of the animation */
  92935. name: string;
  92936. /**Property to animate */
  92937. targetProperty: string;
  92938. /**The frames per second of the animation */
  92939. framePerSecond: number;
  92940. /**The data type of the animation */
  92941. dataType: number;
  92942. /**The loop mode of the animation */
  92943. loopMode?: number | undefined;
  92944. /**Specifies if blending should be enabled */
  92945. enableBlending?: boolean | undefined;
  92946. /**
  92947. * Use matrix interpolation instead of using direct key value when animating matrices
  92948. */
  92949. static AllowMatricesInterpolation: boolean;
  92950. /**
  92951. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  92952. */
  92953. static AllowMatrixDecomposeForInterpolation: boolean;
  92954. /**
  92955. * Stores the key frames of the animation
  92956. */
  92957. private _keys;
  92958. /**
  92959. * Stores the easing function of the animation
  92960. */
  92961. private _easingFunction;
  92962. /**
  92963. * @hidden Internal use only
  92964. */
  92965. _runtimeAnimations: RuntimeAnimation[];
  92966. /**
  92967. * The set of event that will be linked to this animation
  92968. */
  92969. private _events;
  92970. /**
  92971. * Stores an array of target property paths
  92972. */
  92973. targetPropertyPath: string[];
  92974. /**
  92975. * Stores the blending speed of the animation
  92976. */
  92977. blendingSpeed: number;
  92978. /**
  92979. * Stores the animation ranges for the animation
  92980. */
  92981. private _ranges;
  92982. /**
  92983. * @hidden Internal use
  92984. */
  92985. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  92986. /**
  92987. * Sets up an animation
  92988. * @param property The property to animate
  92989. * @param animationType The animation type to apply
  92990. * @param framePerSecond The frames per second of the animation
  92991. * @param easingFunction The easing function used in the animation
  92992. * @returns The created animation
  92993. */
  92994. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  92995. /**
  92996. * Create and start an animation on a node
  92997. * @param name defines the name of the global animation that will be run on all nodes
  92998. * @param node defines the root node where the animation will take place
  92999. * @param targetProperty defines property to animate
  93000. * @param framePerSecond defines the number of frame per second yo use
  93001. * @param totalFrame defines the number of frames in total
  93002. * @param from defines the initial value
  93003. * @param to defines the final value
  93004. * @param loopMode defines which loop mode you want to use (off by default)
  93005. * @param easingFunction defines the easing function to use (linear by default)
  93006. * @param onAnimationEnd defines the callback to call when animation end
  93007. * @returns the animatable created for this animation
  93008. */
  93009. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93010. /**
  93011. * Create and start an animation on a node and its descendants
  93012. * @param name defines the name of the global animation that will be run on all nodes
  93013. * @param node defines the root node where the animation will take place
  93014. * @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
  93015. * @param targetProperty defines property to animate
  93016. * @param framePerSecond defines the number of frame per second to use
  93017. * @param totalFrame defines the number of frames in total
  93018. * @param from defines the initial value
  93019. * @param to defines the final value
  93020. * @param loopMode defines which loop mode you want to use (off by default)
  93021. * @param easingFunction defines the easing function to use (linear by default)
  93022. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93023. * @returns the list of animatables created for all nodes
  93024. * @example https://www.babylonjs-playground.com/#MH0VLI
  93025. */
  93026. 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[]>;
  93027. /**
  93028. * Creates a new animation, merges it with the existing animations and starts it
  93029. * @param name Name of the animation
  93030. * @param node Node which contains the scene that begins the animations
  93031. * @param targetProperty Specifies which property to animate
  93032. * @param framePerSecond The frames per second of the animation
  93033. * @param totalFrame The total number of frames
  93034. * @param from The frame at the beginning of the animation
  93035. * @param to The frame at the end of the animation
  93036. * @param loopMode Specifies the loop mode of the animation
  93037. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93038. * @param onAnimationEnd Callback to run once the animation is complete
  93039. * @returns Nullable animation
  93040. */
  93041. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93042. /**
  93043. * Transition property of an host to the target Value
  93044. * @param property The property to transition
  93045. * @param targetValue The target Value of the property
  93046. * @param host The object where the property to animate belongs
  93047. * @param scene Scene used to run the animation
  93048. * @param frameRate Framerate (in frame/s) to use
  93049. * @param transition The transition type we want to use
  93050. * @param duration The duration of the animation, in milliseconds
  93051. * @param onAnimationEnd Callback trigger at the end of the animation
  93052. * @returns Nullable animation
  93053. */
  93054. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  93055. /**
  93056. * Return the array of runtime animations currently using this animation
  93057. */
  93058. readonly runtimeAnimations: RuntimeAnimation[];
  93059. /**
  93060. * Specifies if any of the runtime animations are currently running
  93061. */
  93062. readonly hasRunningRuntimeAnimations: boolean;
  93063. /**
  93064. * Initializes the animation
  93065. * @param name Name of the animation
  93066. * @param targetProperty Property to animate
  93067. * @param framePerSecond The frames per second of the animation
  93068. * @param dataType The data type of the animation
  93069. * @param loopMode The loop mode of the animation
  93070. * @param enableBlending Specifies if blending should be enabled
  93071. */
  93072. constructor(
  93073. /**Name of the animation */
  93074. name: string,
  93075. /**Property to animate */
  93076. targetProperty: string,
  93077. /**The frames per second of the animation */
  93078. framePerSecond: number,
  93079. /**The data type of the animation */
  93080. dataType: number,
  93081. /**The loop mode of the animation */
  93082. loopMode?: number | undefined,
  93083. /**Specifies if blending should be enabled */
  93084. enableBlending?: boolean | undefined);
  93085. /**
  93086. * Converts the animation to a string
  93087. * @param fullDetails support for multiple levels of logging within scene loading
  93088. * @returns String form of the animation
  93089. */
  93090. toString(fullDetails?: boolean): string;
  93091. /**
  93092. * Add an event to this animation
  93093. * @param event Event to add
  93094. */
  93095. addEvent(event: AnimationEvent): void;
  93096. /**
  93097. * Remove all events found at the given frame
  93098. * @param frame The frame to remove events from
  93099. */
  93100. removeEvents(frame: number): void;
  93101. /**
  93102. * Retrieves all the events from the animation
  93103. * @returns Events from the animation
  93104. */
  93105. getEvents(): AnimationEvent[];
  93106. /**
  93107. * Creates an animation range
  93108. * @param name Name of the animation range
  93109. * @param from Starting frame of the animation range
  93110. * @param to Ending frame of the animation
  93111. */
  93112. createRange(name: string, from: number, to: number): void;
  93113. /**
  93114. * Deletes an animation range by name
  93115. * @param name Name of the animation range to delete
  93116. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  93117. */
  93118. deleteRange(name: string, deleteFrames?: boolean): void;
  93119. /**
  93120. * Gets the animation range by name, or null if not defined
  93121. * @param name Name of the animation range
  93122. * @returns Nullable animation range
  93123. */
  93124. getRange(name: string): Nullable<AnimationRange>;
  93125. /**
  93126. * Gets the key frames from the animation
  93127. * @returns The key frames of the animation
  93128. */
  93129. getKeys(): Array<IAnimationKey>;
  93130. /**
  93131. * Gets the highest frame rate of the animation
  93132. * @returns Highest frame rate of the animation
  93133. */
  93134. getHighestFrame(): number;
  93135. /**
  93136. * Gets the easing function of the animation
  93137. * @returns Easing function of the animation
  93138. */
  93139. getEasingFunction(): IEasingFunction;
  93140. /**
  93141. * Sets the easing function of the animation
  93142. * @param easingFunction A custom mathematical formula for animation
  93143. */
  93144. setEasingFunction(easingFunction: EasingFunction): void;
  93145. /**
  93146. * Interpolates a scalar linearly
  93147. * @param startValue Start value of the animation curve
  93148. * @param endValue End value of the animation curve
  93149. * @param gradient Scalar amount to interpolate
  93150. * @returns Interpolated scalar value
  93151. */
  93152. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  93153. /**
  93154. * Interpolates a scalar cubically
  93155. * @param startValue Start value of the animation curve
  93156. * @param outTangent End tangent of the animation
  93157. * @param endValue End value of the animation curve
  93158. * @param inTangent Start tangent of the animation curve
  93159. * @param gradient Scalar amount to interpolate
  93160. * @returns Interpolated scalar value
  93161. */
  93162. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  93163. /**
  93164. * Interpolates a quaternion using a spherical linear interpolation
  93165. * @param startValue Start value of the animation curve
  93166. * @param endValue End value of the animation curve
  93167. * @param gradient Scalar amount to interpolate
  93168. * @returns Interpolated quaternion value
  93169. */
  93170. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  93171. /**
  93172. * Interpolates a quaternion cubically
  93173. * @param startValue Start value of the animation curve
  93174. * @param outTangent End tangent of the animation curve
  93175. * @param endValue End value of the animation curve
  93176. * @param inTangent Start tangent of the animation curve
  93177. * @param gradient Scalar amount to interpolate
  93178. * @returns Interpolated quaternion value
  93179. */
  93180. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  93181. /**
  93182. * Interpolates a Vector3 linearl
  93183. * @param startValue Start value of the animation curve
  93184. * @param endValue End value of the animation curve
  93185. * @param gradient Scalar amount to interpolate
  93186. * @returns Interpolated scalar value
  93187. */
  93188. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  93189. /**
  93190. * Interpolates a Vector3 cubically
  93191. * @param startValue Start value of the animation curve
  93192. * @param outTangent End tangent of the animation
  93193. * @param endValue End value of the animation curve
  93194. * @param inTangent Start tangent of the animation curve
  93195. * @param gradient Scalar amount to interpolate
  93196. * @returns InterpolatedVector3 value
  93197. */
  93198. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  93199. /**
  93200. * Interpolates a Vector2 linearly
  93201. * @param startValue Start value of the animation curve
  93202. * @param endValue End value of the animation curve
  93203. * @param gradient Scalar amount to interpolate
  93204. * @returns Interpolated Vector2 value
  93205. */
  93206. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  93207. /**
  93208. * Interpolates a Vector2 cubically
  93209. * @param startValue Start value of the animation curve
  93210. * @param outTangent End tangent of the animation
  93211. * @param endValue End value of the animation curve
  93212. * @param inTangent Start tangent of the animation curve
  93213. * @param gradient Scalar amount to interpolate
  93214. * @returns Interpolated Vector2 value
  93215. */
  93216. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  93217. /**
  93218. * Interpolates a size linearly
  93219. * @param startValue Start value of the animation curve
  93220. * @param endValue End value of the animation curve
  93221. * @param gradient Scalar amount to interpolate
  93222. * @returns Interpolated Size value
  93223. */
  93224. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  93225. /**
  93226. * Interpolates a Color3 linearly
  93227. * @param startValue Start value of the animation curve
  93228. * @param endValue End value of the animation curve
  93229. * @param gradient Scalar amount to interpolate
  93230. * @returns Interpolated Color3 value
  93231. */
  93232. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  93233. /**
  93234. * @hidden Internal use only
  93235. */
  93236. _getKeyValue(value: any): any;
  93237. /**
  93238. * @hidden Internal use only
  93239. */
  93240. _interpolate(currentFrame: number, state: _IAnimationState): any;
  93241. /**
  93242. * Defines the function to use to interpolate matrices
  93243. * @param startValue defines the start matrix
  93244. * @param endValue defines the end matrix
  93245. * @param gradient defines the gradient between both matrices
  93246. * @param result defines an optional target matrix where to store the interpolation
  93247. * @returns the interpolated matrix
  93248. */
  93249. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  93250. /**
  93251. * Makes a copy of the animation
  93252. * @returns Cloned animation
  93253. */
  93254. clone(): Animation;
  93255. /**
  93256. * Sets the key frames of the animation
  93257. * @param values The animation key frames to set
  93258. */
  93259. setKeys(values: Array<IAnimationKey>): void;
  93260. /**
  93261. * Serializes the animation to an object
  93262. * @returns Serialized object
  93263. */
  93264. serialize(): any;
  93265. /**
  93266. * Float animation type
  93267. */
  93268. private static _ANIMATIONTYPE_FLOAT;
  93269. /**
  93270. * Vector3 animation type
  93271. */
  93272. private static _ANIMATIONTYPE_VECTOR3;
  93273. /**
  93274. * Quaternion animation type
  93275. */
  93276. private static _ANIMATIONTYPE_QUATERNION;
  93277. /**
  93278. * Matrix animation type
  93279. */
  93280. private static _ANIMATIONTYPE_MATRIX;
  93281. /**
  93282. * Color3 animation type
  93283. */
  93284. private static _ANIMATIONTYPE_COLOR3;
  93285. /**
  93286. * Vector2 animation type
  93287. */
  93288. private static _ANIMATIONTYPE_VECTOR2;
  93289. /**
  93290. * Size animation type
  93291. */
  93292. private static _ANIMATIONTYPE_SIZE;
  93293. /**
  93294. * Relative Loop Mode
  93295. */
  93296. private static _ANIMATIONLOOPMODE_RELATIVE;
  93297. /**
  93298. * Cycle Loop Mode
  93299. */
  93300. private static _ANIMATIONLOOPMODE_CYCLE;
  93301. /**
  93302. * Constant Loop Mode
  93303. */
  93304. private static _ANIMATIONLOOPMODE_CONSTANT;
  93305. /**
  93306. * Get the float animation type
  93307. */
  93308. static readonly ANIMATIONTYPE_FLOAT: number;
  93309. /**
  93310. * Get the Vector3 animation type
  93311. */
  93312. static readonly ANIMATIONTYPE_VECTOR3: number;
  93313. /**
  93314. * Get the Vector2 animation type
  93315. */
  93316. static readonly ANIMATIONTYPE_VECTOR2: number;
  93317. /**
  93318. * Get the Size animation type
  93319. */
  93320. static readonly ANIMATIONTYPE_SIZE: number;
  93321. /**
  93322. * Get the Quaternion animation type
  93323. */
  93324. static readonly ANIMATIONTYPE_QUATERNION: number;
  93325. /**
  93326. * Get the Matrix animation type
  93327. */
  93328. static readonly ANIMATIONTYPE_MATRIX: number;
  93329. /**
  93330. * Get the Color3 animation type
  93331. */
  93332. static readonly ANIMATIONTYPE_COLOR3: number;
  93333. /**
  93334. * Get the Relative Loop Mode
  93335. */
  93336. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  93337. /**
  93338. * Get the Cycle Loop Mode
  93339. */
  93340. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  93341. /**
  93342. * Get the Constant Loop Mode
  93343. */
  93344. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  93345. /** @hidden */
  93346. static _UniversalLerp(left: any, right: any, amount: number): any;
  93347. /**
  93348. * Parses an animation object and creates an animation
  93349. * @param parsedAnimation Parsed animation object
  93350. * @returns Animation object
  93351. */
  93352. static Parse(parsedAnimation: any): Animation;
  93353. /**
  93354. * Appends the serialized animations from the source animations
  93355. * @param source Source containing the animations
  93356. * @param destination Target to store the animations
  93357. */
  93358. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93359. }
  93360. }
  93361. declare module BABYLON {
  93362. /**
  93363. * Interface containing an array of animations
  93364. */
  93365. export interface IAnimatable {
  93366. /**
  93367. * Array of animations
  93368. */
  93369. animations: Nullable<Array<Animation>>;
  93370. }
  93371. }
  93372. declare module BABYLON {
  93373. /**
  93374. * This represents all the required information to add a fresnel effect on a material:
  93375. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93376. */
  93377. export class FresnelParameters {
  93378. private _isEnabled;
  93379. /**
  93380. * Define if the fresnel effect is enable or not.
  93381. */
  93382. isEnabled: boolean;
  93383. /**
  93384. * Define the color used on edges (grazing angle)
  93385. */
  93386. leftColor: Color3;
  93387. /**
  93388. * Define the color used on center
  93389. */
  93390. rightColor: Color3;
  93391. /**
  93392. * Define bias applied to computed fresnel term
  93393. */
  93394. bias: number;
  93395. /**
  93396. * Defined the power exponent applied to fresnel term
  93397. */
  93398. power: number;
  93399. /**
  93400. * Clones the current fresnel and its valuues
  93401. * @returns a clone fresnel configuration
  93402. */
  93403. clone(): FresnelParameters;
  93404. /**
  93405. * Serializes the current fresnel parameters to a JSON representation.
  93406. * @return the JSON serialization
  93407. */
  93408. serialize(): any;
  93409. /**
  93410. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93411. * @param parsedFresnelParameters Define the JSON representation
  93412. * @returns the parsed parameters
  93413. */
  93414. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93415. }
  93416. }
  93417. declare module BABYLON {
  93418. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93419. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93420. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93421. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93422. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93423. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93424. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93425. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93426. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93427. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93428. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93429. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93430. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93431. /**
  93432. * Decorator used to define property that can be serialized as reference to a camera
  93433. * @param sourceName defines the name of the property to decorate
  93434. */
  93435. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93436. /**
  93437. * Class used to help serialization objects
  93438. */
  93439. export class SerializationHelper {
  93440. /** @hidden */
  93441. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93442. /** @hidden */
  93443. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93444. /** @hidden */
  93445. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93446. /** @hidden */
  93447. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93448. /**
  93449. * Appends the serialized animations from the source animations
  93450. * @param source Source containing the animations
  93451. * @param destination Target to store the animations
  93452. */
  93453. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93454. /**
  93455. * Static function used to serialized a specific entity
  93456. * @param entity defines the entity to serialize
  93457. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93458. * @returns a JSON compatible object representing the serialization of the entity
  93459. */
  93460. static Serialize<T>(entity: T, serializationObject?: any): any;
  93461. /**
  93462. * Creates a new entity from a serialization data object
  93463. * @param creationFunction defines a function used to instanciated the new entity
  93464. * @param source defines the source serialization data
  93465. * @param scene defines the hosting scene
  93466. * @param rootUrl defines the root url for resources
  93467. * @returns a new entity
  93468. */
  93469. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93470. /**
  93471. * Clones an object
  93472. * @param creationFunction defines the function used to instanciate the new object
  93473. * @param source defines the source object
  93474. * @returns the cloned object
  93475. */
  93476. static Clone<T>(creationFunction: () => T, source: T): T;
  93477. /**
  93478. * Instanciates a new object based on a source one (some data will be shared between both object)
  93479. * @param creationFunction defines the function used to instanciate the new object
  93480. * @param source defines the source object
  93481. * @returns the new object
  93482. */
  93483. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93484. }
  93485. }
  93486. declare module BABYLON {
  93487. /**
  93488. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  93489. */
  93490. export interface CubeMapInfo {
  93491. /**
  93492. * The pixel array for the front face.
  93493. * This is stored in format, left to right, up to down format.
  93494. */
  93495. front: Nullable<ArrayBufferView>;
  93496. /**
  93497. * The pixel array for the back face.
  93498. * This is stored in format, left to right, up to down format.
  93499. */
  93500. back: Nullable<ArrayBufferView>;
  93501. /**
  93502. * The pixel array for the left face.
  93503. * This is stored in format, left to right, up to down format.
  93504. */
  93505. left: Nullable<ArrayBufferView>;
  93506. /**
  93507. * The pixel array for the right face.
  93508. * This is stored in format, left to right, up to down format.
  93509. */
  93510. right: Nullable<ArrayBufferView>;
  93511. /**
  93512. * The pixel array for the up face.
  93513. * This is stored in format, left to right, up to down format.
  93514. */
  93515. up: Nullable<ArrayBufferView>;
  93516. /**
  93517. * The pixel array for the down face.
  93518. * This is stored in format, left to right, up to down format.
  93519. */
  93520. down: Nullable<ArrayBufferView>;
  93521. /**
  93522. * The size of the cubemap stored.
  93523. *
  93524. * Each faces will be size * size pixels.
  93525. */
  93526. size: number;
  93527. /**
  93528. * The format of the texture.
  93529. *
  93530. * RGBA, RGB.
  93531. */
  93532. format: number;
  93533. /**
  93534. * The type of the texture data.
  93535. *
  93536. * UNSIGNED_INT, FLOAT.
  93537. */
  93538. type: number;
  93539. /**
  93540. * Specifies whether the texture is in gamma space.
  93541. */
  93542. gammaSpace: boolean;
  93543. }
  93544. /**
  93545. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93546. */
  93547. export class PanoramaToCubeMapTools {
  93548. private static FACE_FRONT;
  93549. private static FACE_BACK;
  93550. private static FACE_RIGHT;
  93551. private static FACE_LEFT;
  93552. private static FACE_DOWN;
  93553. private static FACE_UP;
  93554. /**
  93555. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93556. *
  93557. * @param float32Array The source data.
  93558. * @param inputWidth The width of the input panorama.
  93559. * @param inputHeight The height of the input panorama.
  93560. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93561. * @return The cubemap data
  93562. */
  93563. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  93564. private static CreateCubemapTexture;
  93565. private static CalcProjectionSpherical;
  93566. }
  93567. }
  93568. declare module BABYLON {
  93569. /**
  93570. * Helper class dealing with the extraction of spherical polynomial dataArray
  93571. * from a cube map.
  93572. */
  93573. export class CubeMapToSphericalPolynomialTools {
  93574. private static FileFaces;
  93575. /**
  93576. * Converts a texture to the according Spherical Polynomial data.
  93577. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93578. *
  93579. * @param texture The texture to extract the information from.
  93580. * @return The Spherical Polynomial data.
  93581. */
  93582. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  93583. /**
  93584. * Converts a cubemap to the according Spherical Polynomial data.
  93585. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93586. *
  93587. * @param cubeInfo The Cube map to extract the information from.
  93588. * @return The Spherical Polynomial data.
  93589. */
  93590. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  93591. }
  93592. }
  93593. declare module BABYLON {
  93594. /**
  93595. * Class used to manipulate GUIDs
  93596. */
  93597. export class GUID {
  93598. /**
  93599. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93600. * Be aware Math.random() could cause collisions, but:
  93601. * "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"
  93602. * @returns a pseudo random id
  93603. */
  93604. static RandomId(): string;
  93605. }
  93606. }
  93607. declare module BABYLON {
  93608. /**
  93609. * Base class of all the textures in babylon.
  93610. * It groups all the common properties the materials, post process, lights... might need
  93611. * in order to make a correct use of the texture.
  93612. */
  93613. export class BaseTexture implements IAnimatable {
  93614. /**
  93615. * Default anisotropic filtering level for the application.
  93616. * It is set to 4 as a good tradeoff between perf and quality.
  93617. */
  93618. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  93619. /**
  93620. * Gets or sets the unique id of the texture
  93621. */
  93622. uniqueId: number;
  93623. /**
  93624. * Define the name of the texture.
  93625. */
  93626. name: string;
  93627. /**
  93628. * Gets or sets an object used to store user defined information.
  93629. */
  93630. metadata: any;
  93631. /**
  93632. * For internal use only. Please do not use.
  93633. */
  93634. reservedDataStore: any;
  93635. private _hasAlpha;
  93636. /**
  93637. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  93638. */
  93639. hasAlpha: boolean;
  93640. /**
  93641. * Defines if the alpha value should be determined via the rgb values.
  93642. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  93643. */
  93644. getAlphaFromRGB: boolean;
  93645. /**
  93646. * Intensity or strength of the texture.
  93647. * It is commonly used by materials to fine tune the intensity of the texture
  93648. */
  93649. level: number;
  93650. /**
  93651. * Define the UV chanel to use starting from 0 and defaulting to 0.
  93652. * This is part of the texture as textures usually maps to one uv set.
  93653. */
  93654. coordinatesIndex: number;
  93655. private _coordinatesMode;
  93656. /**
  93657. * How a texture is mapped.
  93658. *
  93659. * | Value | Type | Description |
  93660. * | ----- | ----------------------------------- | ----------- |
  93661. * | 0 | EXPLICIT_MODE | |
  93662. * | 1 | SPHERICAL_MODE | |
  93663. * | 2 | PLANAR_MODE | |
  93664. * | 3 | CUBIC_MODE | |
  93665. * | 4 | PROJECTION_MODE | |
  93666. * | 5 | SKYBOX_MODE | |
  93667. * | 6 | INVCUBIC_MODE | |
  93668. * | 7 | EQUIRECTANGULAR_MODE | |
  93669. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  93670. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  93671. */
  93672. coordinatesMode: number;
  93673. /**
  93674. * | Value | Type | Description |
  93675. * | ----- | ------------------ | ----------- |
  93676. * | 0 | CLAMP_ADDRESSMODE | |
  93677. * | 1 | WRAP_ADDRESSMODE | |
  93678. * | 2 | MIRROR_ADDRESSMODE | |
  93679. */
  93680. wrapU: number;
  93681. /**
  93682. * | Value | Type | Description |
  93683. * | ----- | ------------------ | ----------- |
  93684. * | 0 | CLAMP_ADDRESSMODE | |
  93685. * | 1 | WRAP_ADDRESSMODE | |
  93686. * | 2 | MIRROR_ADDRESSMODE | |
  93687. */
  93688. wrapV: number;
  93689. /**
  93690. * | Value | Type | Description |
  93691. * | ----- | ------------------ | ----------- |
  93692. * | 0 | CLAMP_ADDRESSMODE | |
  93693. * | 1 | WRAP_ADDRESSMODE | |
  93694. * | 2 | MIRROR_ADDRESSMODE | |
  93695. */
  93696. wrapR: number;
  93697. /**
  93698. * With compliant hardware and browser (supporting anisotropic filtering)
  93699. * this defines the level of anisotropic filtering in the texture.
  93700. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  93701. */
  93702. anisotropicFilteringLevel: number;
  93703. /**
  93704. * Define if the texture is a cube texture or if false a 2d texture.
  93705. */
  93706. isCube: boolean;
  93707. /**
  93708. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  93709. */
  93710. is3D: boolean;
  93711. /**
  93712. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  93713. * HDR texture are usually stored in linear space.
  93714. * This only impacts the PBR and Background materials
  93715. */
  93716. gammaSpace: boolean;
  93717. /**
  93718. * Gets or sets whether or not the texture contains RGBD data.
  93719. */
  93720. isRGBD: boolean;
  93721. /**
  93722. * Is Z inverted in the texture (useful in a cube texture).
  93723. */
  93724. invertZ: boolean;
  93725. /**
  93726. * Are mip maps generated for this texture or not.
  93727. */
  93728. readonly noMipmap: boolean;
  93729. /**
  93730. * @hidden
  93731. */
  93732. lodLevelInAlpha: boolean;
  93733. /**
  93734. * With prefiltered texture, defined the offset used during the prefiltering steps.
  93735. */
  93736. lodGenerationOffset: number;
  93737. /**
  93738. * With prefiltered texture, defined the scale used during the prefiltering steps.
  93739. */
  93740. lodGenerationScale: number;
  93741. /**
  93742. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  93743. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  93744. * average roughness values.
  93745. */
  93746. linearSpecularLOD: boolean;
  93747. /**
  93748. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  93749. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  93750. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  93751. */
  93752. irradianceTexture: Nullable<BaseTexture>;
  93753. /**
  93754. * Define if the texture is a render target.
  93755. */
  93756. isRenderTarget: boolean;
  93757. /**
  93758. * Define the unique id of the texture in the scene.
  93759. */
  93760. readonly uid: string;
  93761. /**
  93762. * Return a string representation of the texture.
  93763. * @returns the texture as a string
  93764. */
  93765. toString(): string;
  93766. /**
  93767. * Get the class name of the texture.
  93768. * @returns "BaseTexture"
  93769. */
  93770. getClassName(): string;
  93771. /**
  93772. * Define the list of animation attached to the texture.
  93773. */
  93774. animations: Animation[];
  93775. /**
  93776. * An event triggered when the texture is disposed.
  93777. */
  93778. onDisposeObservable: Observable<BaseTexture>;
  93779. private _onDisposeObserver;
  93780. /**
  93781. * Callback triggered when the texture has been disposed.
  93782. * Kept for back compatibility, you can use the onDisposeObservable instead.
  93783. */
  93784. onDispose: () => void;
  93785. /**
  93786. * Define the current state of the loading sequence when in delayed load mode.
  93787. */
  93788. delayLoadState: number;
  93789. private _scene;
  93790. /** @hidden */
  93791. _texture: Nullable<InternalTexture>;
  93792. private _uid;
  93793. /**
  93794. * Define if the texture is preventinga material to render or not.
  93795. * If not and the texture is not ready, the engine will use a default black texture instead.
  93796. */
  93797. readonly isBlocking: boolean;
  93798. /**
  93799. * Instantiates a new BaseTexture.
  93800. * Base class of all the textures in babylon.
  93801. * It groups all the common properties the materials, post process, lights... might need
  93802. * in order to make a correct use of the texture.
  93803. * @param scene Define the scene the texture blongs to
  93804. */
  93805. constructor(scene: Nullable<Scene>);
  93806. /**
  93807. * Get the scene the texture belongs to.
  93808. * @returns the scene or null if undefined
  93809. */
  93810. getScene(): Nullable<Scene>;
  93811. /**
  93812. * Get the texture transform matrix used to offset tile the texture for istance.
  93813. * @returns the transformation matrix
  93814. */
  93815. getTextureMatrix(): Matrix;
  93816. /**
  93817. * Get the texture reflection matrix used to rotate/transform the reflection.
  93818. * @returns the reflection matrix
  93819. */
  93820. getReflectionTextureMatrix(): Matrix;
  93821. /**
  93822. * Get the underlying lower level texture from Babylon.
  93823. * @returns the insternal texture
  93824. */
  93825. getInternalTexture(): Nullable<InternalTexture>;
  93826. /**
  93827. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  93828. * @returns true if ready or not blocking
  93829. */
  93830. isReadyOrNotBlocking(): boolean;
  93831. /**
  93832. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  93833. * @returns true if fully ready
  93834. */
  93835. isReady(): boolean;
  93836. private _cachedSize;
  93837. /**
  93838. * Get the size of the texture.
  93839. * @returns the texture size.
  93840. */
  93841. getSize(): ISize;
  93842. /**
  93843. * Get the base size of the texture.
  93844. * It can be different from the size if the texture has been resized for POT for instance
  93845. * @returns the base size
  93846. */
  93847. getBaseSize(): ISize;
  93848. /**
  93849. * Update the sampling mode of the texture.
  93850. * Default is Trilinear mode.
  93851. *
  93852. * | Value | Type | Description |
  93853. * | ----- | ------------------ | ----------- |
  93854. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  93855. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  93856. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  93857. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  93858. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  93859. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  93860. * | 7 | NEAREST_LINEAR | |
  93861. * | 8 | NEAREST_NEAREST | |
  93862. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  93863. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  93864. * | 11 | LINEAR_LINEAR | |
  93865. * | 12 | LINEAR_NEAREST | |
  93866. *
  93867. * > _mag_: magnification filter (close to the viewer)
  93868. * > _min_: minification filter (far from the viewer)
  93869. * > _mip_: filter used between mip map levels
  93870. *@param samplingMode Define the new sampling mode of the texture
  93871. */
  93872. updateSamplingMode(samplingMode: number): void;
  93873. /**
  93874. * Scales the texture if is `canRescale()`
  93875. * @param ratio the resize factor we want to use to rescale
  93876. */
  93877. scale(ratio: number): void;
  93878. /**
  93879. * Get if the texture can rescale.
  93880. */
  93881. readonly canRescale: boolean;
  93882. /** @hidden */
  93883. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  93884. /** @hidden */
  93885. _rebuild(): void;
  93886. /**
  93887. * Triggers the load sequence in delayed load mode.
  93888. */
  93889. delayLoad(): void;
  93890. /**
  93891. * Clones the texture.
  93892. * @returns the cloned texture
  93893. */
  93894. clone(): Nullable<BaseTexture>;
  93895. /**
  93896. * Get the texture underlying type (INT, FLOAT...)
  93897. */
  93898. readonly textureType: number;
  93899. /**
  93900. * Get the texture underlying format (RGB, RGBA...)
  93901. */
  93902. readonly textureFormat: number;
  93903. /**
  93904. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  93905. * This will returns an RGBA array buffer containing either in values (0-255) or
  93906. * float values (0-1) depending of the underlying buffer type.
  93907. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  93908. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  93909. * @param buffer defines a user defined buffer to fill with data (can be null)
  93910. * @returns The Array buffer containing the pixels data.
  93911. */
  93912. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  93913. /**
  93914. * Release and destroy the underlying lower level texture aka internalTexture.
  93915. */
  93916. releaseInternalTexture(): void;
  93917. /**
  93918. * Get the polynomial representation of the texture data.
  93919. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  93920. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  93921. */
  93922. sphericalPolynomial: Nullable<SphericalPolynomial>;
  93923. /** @hidden */
  93924. readonly _lodTextureHigh: Nullable<BaseTexture>;
  93925. /** @hidden */
  93926. readonly _lodTextureMid: Nullable<BaseTexture>;
  93927. /** @hidden */
  93928. readonly _lodTextureLow: Nullable<BaseTexture>;
  93929. /**
  93930. * Dispose the texture and release its associated resources.
  93931. */
  93932. dispose(): void;
  93933. /**
  93934. * Serialize the texture into a JSON representation that can be parsed later on.
  93935. * @returns the JSON representation of the texture
  93936. */
  93937. serialize(): any;
  93938. /**
  93939. * Helper function to be called back once a list of texture contains only ready textures.
  93940. * @param textures Define the list of textures to wait for
  93941. * @param callback Define the callback triggered once the entire list will be ready
  93942. */
  93943. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  93944. }
  93945. }
  93946. declare module BABYLON {
  93947. /**
  93948. * Class used to store data associated with WebGL texture data for the engine
  93949. * This class should not be used directly
  93950. */
  93951. export class InternalTexture {
  93952. /** @hidden */
  93953. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  93954. /**
  93955. * The source of the texture data is unknown
  93956. */
  93957. static DATASOURCE_UNKNOWN: number;
  93958. /**
  93959. * Texture data comes from an URL
  93960. */
  93961. static DATASOURCE_URL: number;
  93962. /**
  93963. * Texture data is only used for temporary storage
  93964. */
  93965. static DATASOURCE_TEMP: number;
  93966. /**
  93967. * Texture data comes from raw data (ArrayBuffer)
  93968. */
  93969. static DATASOURCE_RAW: number;
  93970. /**
  93971. * Texture content is dynamic (video or dynamic texture)
  93972. */
  93973. static DATASOURCE_DYNAMIC: number;
  93974. /**
  93975. * Texture content is generated by rendering to it
  93976. */
  93977. static DATASOURCE_RENDERTARGET: number;
  93978. /**
  93979. * Texture content is part of a multi render target process
  93980. */
  93981. static DATASOURCE_MULTIRENDERTARGET: number;
  93982. /**
  93983. * Texture data comes from a cube data file
  93984. */
  93985. static DATASOURCE_CUBE: number;
  93986. /**
  93987. * Texture data comes from a raw cube data
  93988. */
  93989. static DATASOURCE_CUBERAW: number;
  93990. /**
  93991. * Texture data come from a prefiltered cube data file
  93992. */
  93993. static DATASOURCE_CUBEPREFILTERED: number;
  93994. /**
  93995. * Texture content is raw 3D data
  93996. */
  93997. static DATASOURCE_RAW3D: number;
  93998. /**
  93999. * Texture content is a depth texture
  94000. */
  94001. static DATASOURCE_DEPTHTEXTURE: number;
  94002. /**
  94003. * Texture data comes from a raw cube data encoded with RGBD
  94004. */
  94005. static DATASOURCE_CUBERAW_RGBD: number;
  94006. /**
  94007. * Defines if the texture is ready
  94008. */
  94009. isReady: boolean;
  94010. /**
  94011. * Defines if the texture is a cube texture
  94012. */
  94013. isCube: boolean;
  94014. /**
  94015. * Defines if the texture contains 3D data
  94016. */
  94017. is3D: boolean;
  94018. /**
  94019. * Defines if the texture contains multiview data
  94020. */
  94021. isMultiview: boolean;
  94022. /**
  94023. * Gets the URL used to load this texture
  94024. */
  94025. url: string;
  94026. /**
  94027. * Gets the sampling mode of the texture
  94028. */
  94029. samplingMode: number;
  94030. /**
  94031. * Gets a boolean indicating if the texture needs mipmaps generation
  94032. */
  94033. generateMipMaps: boolean;
  94034. /**
  94035. * Gets the number of samples used by the texture (WebGL2+ only)
  94036. */
  94037. samples: number;
  94038. /**
  94039. * Gets the type of the texture (int, float...)
  94040. */
  94041. type: number;
  94042. /**
  94043. * Gets the format of the texture (RGB, RGBA...)
  94044. */
  94045. format: number;
  94046. /**
  94047. * Observable called when the texture is loaded
  94048. */
  94049. onLoadedObservable: Observable<InternalTexture>;
  94050. /**
  94051. * Gets the width of the texture
  94052. */
  94053. width: number;
  94054. /**
  94055. * Gets the height of the texture
  94056. */
  94057. height: number;
  94058. /**
  94059. * Gets the depth of the texture
  94060. */
  94061. depth: number;
  94062. /**
  94063. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  94064. */
  94065. baseWidth: number;
  94066. /**
  94067. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  94068. */
  94069. baseHeight: number;
  94070. /**
  94071. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  94072. */
  94073. baseDepth: number;
  94074. /**
  94075. * Gets a boolean indicating if the texture is inverted on Y axis
  94076. */
  94077. invertY: boolean;
  94078. /** @hidden */
  94079. _invertVScale: boolean;
  94080. /** @hidden */
  94081. _associatedChannel: number;
  94082. /** @hidden */
  94083. _dataSource: number;
  94084. /** @hidden */
  94085. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  94086. /** @hidden */
  94087. _bufferView: Nullable<ArrayBufferView>;
  94088. /** @hidden */
  94089. _bufferViewArray: Nullable<ArrayBufferView[]>;
  94090. /** @hidden */
  94091. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  94092. /** @hidden */
  94093. _size: number;
  94094. /** @hidden */
  94095. _extension: string;
  94096. /** @hidden */
  94097. _files: Nullable<string[]>;
  94098. /** @hidden */
  94099. _workingCanvas: Nullable<HTMLCanvasElement>;
  94100. /** @hidden */
  94101. _workingContext: Nullable<CanvasRenderingContext2D>;
  94102. /** @hidden */
  94103. _framebuffer: Nullable<WebGLFramebuffer>;
  94104. /** @hidden */
  94105. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  94106. /** @hidden */
  94107. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  94108. /** @hidden */
  94109. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  94110. /** @hidden */
  94111. _attachments: Nullable<number[]>;
  94112. /** @hidden */
  94113. _cachedCoordinatesMode: Nullable<number>;
  94114. /** @hidden */
  94115. _cachedWrapU: Nullable<number>;
  94116. /** @hidden */
  94117. _cachedWrapV: Nullable<number>;
  94118. /** @hidden */
  94119. _cachedWrapR: Nullable<number>;
  94120. /** @hidden */
  94121. _cachedAnisotropicFilteringLevel: Nullable<number>;
  94122. /** @hidden */
  94123. _isDisabled: boolean;
  94124. /** @hidden */
  94125. _compression: Nullable<string>;
  94126. /** @hidden */
  94127. _generateStencilBuffer: boolean;
  94128. /** @hidden */
  94129. _generateDepthBuffer: boolean;
  94130. /** @hidden */
  94131. _comparisonFunction: number;
  94132. /** @hidden */
  94133. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  94134. /** @hidden */
  94135. _lodGenerationScale: number;
  94136. /** @hidden */
  94137. _lodGenerationOffset: number;
  94138. /** @hidden */
  94139. _colorTextureArray: Nullable<WebGLTexture>;
  94140. /** @hidden */
  94141. _depthStencilTextureArray: Nullable<WebGLTexture>;
  94142. /** @hidden */
  94143. _lodTextureHigh: Nullable<BaseTexture>;
  94144. /** @hidden */
  94145. _lodTextureMid: Nullable<BaseTexture>;
  94146. /** @hidden */
  94147. _lodTextureLow: Nullable<BaseTexture>;
  94148. /** @hidden */
  94149. _isRGBD: boolean;
  94150. /** @hidden */
  94151. _linearSpecularLOD: boolean;
  94152. /** @hidden */
  94153. _irradianceTexture: Nullable<BaseTexture>;
  94154. /** @hidden */
  94155. _webGLTexture: Nullable<WebGLTexture>;
  94156. /** @hidden */
  94157. _references: number;
  94158. private _engine;
  94159. /**
  94160. * Gets the Engine the texture belongs to.
  94161. * @returns The babylon engine
  94162. */
  94163. getEngine(): Engine;
  94164. /**
  94165. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  94166. */
  94167. readonly dataSource: number;
  94168. /**
  94169. * Creates a new InternalTexture
  94170. * @param engine defines the engine to use
  94171. * @param dataSource defines the type of data that will be used
  94172. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94173. */
  94174. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  94175. /**
  94176. * Increments the number of references (ie. the number of Texture that point to it)
  94177. */
  94178. incrementReferences(): void;
  94179. /**
  94180. * Change the size of the texture (not the size of the content)
  94181. * @param width defines the new width
  94182. * @param height defines the new height
  94183. * @param depth defines the new depth (1 by default)
  94184. */
  94185. updateSize(width: int, height: int, depth?: int): void;
  94186. /** @hidden */
  94187. _rebuild(): void;
  94188. /** @hidden */
  94189. _swapAndDie(target: InternalTexture): void;
  94190. /**
  94191. * Dispose the current allocated resources
  94192. */
  94193. dispose(): void;
  94194. }
  94195. }
  94196. declare module BABYLON {
  94197. /**
  94198. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  94199. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  94200. */
  94201. export class EffectFallbacks {
  94202. private _defines;
  94203. private _currentRank;
  94204. private _maxRank;
  94205. private _mesh;
  94206. /**
  94207. * Removes the fallback from the bound mesh.
  94208. */
  94209. unBindMesh(): void;
  94210. /**
  94211. * Adds a fallback on the specified property.
  94212. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94213. * @param define The name of the define in the shader
  94214. */
  94215. addFallback(rank: number, define: string): void;
  94216. /**
  94217. * Sets the mesh to use CPU skinning when needing to fallback.
  94218. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94219. * @param mesh The mesh to use the fallbacks.
  94220. */
  94221. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  94222. /**
  94223. * Checks to see if more fallbacks are still availible.
  94224. */
  94225. readonly hasMoreFallbacks: boolean;
  94226. /**
  94227. * Removes the defines that should be removed when falling back.
  94228. * @param currentDefines defines the current define statements for the shader.
  94229. * @param effect defines the current effect we try to compile
  94230. * @returns The resulting defines with defines of the current rank removed.
  94231. */
  94232. reduce(currentDefines: string, effect: Effect): string;
  94233. }
  94234. /**
  94235. * Options to be used when creating an effect.
  94236. */
  94237. export class EffectCreationOptions {
  94238. /**
  94239. * Atrributes that will be used in the shader.
  94240. */
  94241. attributes: string[];
  94242. /**
  94243. * Uniform varible names that will be set in the shader.
  94244. */
  94245. uniformsNames: string[];
  94246. /**
  94247. * Uniform buffer varible names that will be set in the shader.
  94248. */
  94249. uniformBuffersNames: string[];
  94250. /**
  94251. * Sampler texture variable names that will be set in the shader.
  94252. */
  94253. samplers: string[];
  94254. /**
  94255. * Define statements that will be set in the shader.
  94256. */
  94257. defines: any;
  94258. /**
  94259. * Possible fallbacks for this effect to improve performance when needed.
  94260. */
  94261. fallbacks: Nullable<EffectFallbacks>;
  94262. /**
  94263. * Callback that will be called when the shader is compiled.
  94264. */
  94265. onCompiled: Nullable<(effect: Effect) => void>;
  94266. /**
  94267. * Callback that will be called if an error occurs during shader compilation.
  94268. */
  94269. onError: Nullable<(effect: Effect, errors: string) => void>;
  94270. /**
  94271. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94272. */
  94273. indexParameters: any;
  94274. /**
  94275. * Max number of lights that can be used in the shader.
  94276. */
  94277. maxSimultaneousLights: number;
  94278. /**
  94279. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94280. */
  94281. transformFeedbackVaryings: Nullable<string[]>;
  94282. }
  94283. /**
  94284. * Effect containing vertex and fragment shader that can be executed on an object.
  94285. */
  94286. export class Effect implements IDisposable {
  94287. /**
  94288. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94289. */
  94290. static ShadersRepository: string;
  94291. /**
  94292. * Name of the effect.
  94293. */
  94294. name: any;
  94295. /**
  94296. * String container all the define statements that should be set on the shader.
  94297. */
  94298. defines: string;
  94299. /**
  94300. * Callback that will be called when the shader is compiled.
  94301. */
  94302. onCompiled: Nullable<(effect: Effect) => void>;
  94303. /**
  94304. * Callback that will be called if an error occurs during shader compilation.
  94305. */
  94306. onError: Nullable<(effect: Effect, errors: string) => void>;
  94307. /**
  94308. * Callback that will be called when effect is bound.
  94309. */
  94310. onBind: Nullable<(effect: Effect) => void>;
  94311. /**
  94312. * Unique ID of the effect.
  94313. */
  94314. uniqueId: number;
  94315. /**
  94316. * Observable that will be called when the shader is compiled.
  94317. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94318. */
  94319. onCompileObservable: Observable<Effect>;
  94320. /**
  94321. * Observable that will be called if an error occurs during shader compilation.
  94322. */
  94323. onErrorObservable: Observable<Effect>;
  94324. /** @hidden */
  94325. _onBindObservable: Nullable<Observable<Effect>>;
  94326. /**
  94327. * Observable that will be called when effect is bound.
  94328. */
  94329. readonly onBindObservable: Observable<Effect>;
  94330. /** @hidden */
  94331. _bonesComputationForcedToCPU: boolean;
  94332. private static _uniqueIdSeed;
  94333. private _engine;
  94334. private _uniformBuffersNames;
  94335. private _uniformsNames;
  94336. private _samplerList;
  94337. private _samplers;
  94338. private _isReady;
  94339. private _compilationError;
  94340. private _attributesNames;
  94341. private _attributes;
  94342. private _uniforms;
  94343. /**
  94344. * Key for the effect.
  94345. * @hidden
  94346. */
  94347. _key: string;
  94348. private _indexParameters;
  94349. private _fallbacks;
  94350. private _vertexSourceCode;
  94351. private _fragmentSourceCode;
  94352. private _vertexSourceCodeOverride;
  94353. private _fragmentSourceCodeOverride;
  94354. private _transformFeedbackVaryings;
  94355. /**
  94356. * Compiled shader to webGL program.
  94357. * @hidden
  94358. */
  94359. _pipelineContext: Nullable<IPipelineContext>;
  94360. private _valueCache;
  94361. private static _baseCache;
  94362. /**
  94363. * Instantiates an effect.
  94364. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94365. * @param baseName Name of the effect.
  94366. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94367. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94368. * @param samplers List of sampler variables that will be passed to the shader.
  94369. * @param engine Engine to be used to render the effect
  94370. * @param defines Define statements to be added to the shader.
  94371. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94372. * @param onCompiled Callback that will be called when the shader is compiled.
  94373. * @param onError Callback that will be called if an error occurs during shader compilation.
  94374. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94375. */
  94376. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  94377. private _useFinalCode;
  94378. /**
  94379. * Unique key for this effect
  94380. */
  94381. readonly key: string;
  94382. /**
  94383. * If the effect has been compiled and prepared.
  94384. * @returns if the effect is compiled and prepared.
  94385. */
  94386. isReady(): boolean;
  94387. private _isReadyInternal;
  94388. /**
  94389. * The engine the effect was initialized with.
  94390. * @returns the engine.
  94391. */
  94392. getEngine(): Engine;
  94393. /**
  94394. * The pipeline context for this effect
  94395. * @returns the associated pipeline context
  94396. */
  94397. getPipelineContext(): Nullable<IPipelineContext>;
  94398. /**
  94399. * The set of names of attribute variables for the shader.
  94400. * @returns An array of attribute names.
  94401. */
  94402. getAttributesNames(): string[];
  94403. /**
  94404. * Returns the attribute at the given index.
  94405. * @param index The index of the attribute.
  94406. * @returns The location of the attribute.
  94407. */
  94408. getAttributeLocation(index: number): number;
  94409. /**
  94410. * Returns the attribute based on the name of the variable.
  94411. * @param name of the attribute to look up.
  94412. * @returns the attribute location.
  94413. */
  94414. getAttributeLocationByName(name: string): number;
  94415. /**
  94416. * The number of attributes.
  94417. * @returns the numnber of attributes.
  94418. */
  94419. getAttributesCount(): number;
  94420. /**
  94421. * Gets the index of a uniform variable.
  94422. * @param uniformName of the uniform to look up.
  94423. * @returns the index.
  94424. */
  94425. getUniformIndex(uniformName: string): number;
  94426. /**
  94427. * Returns the attribute based on the name of the variable.
  94428. * @param uniformName of the uniform to look up.
  94429. * @returns the location of the uniform.
  94430. */
  94431. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94432. /**
  94433. * Returns an array of sampler variable names
  94434. * @returns The array of sampler variable neames.
  94435. */
  94436. getSamplers(): string[];
  94437. /**
  94438. * The error from the last compilation.
  94439. * @returns the error string.
  94440. */
  94441. getCompilationError(): string;
  94442. /**
  94443. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94444. * @param func The callback to be used.
  94445. */
  94446. executeWhenCompiled(func: (effect: Effect) => void): void;
  94447. private _checkIsReady;
  94448. /** @hidden */
  94449. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  94450. /** @hidden */
  94451. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  94452. /** @hidden */
  94453. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  94454. /**
  94455. * Recompiles the webGL program
  94456. * @param vertexSourceCode The source code for the vertex shader.
  94457. * @param fragmentSourceCode The source code for the fragment shader.
  94458. * @param onCompiled Callback called when completed.
  94459. * @param onError Callback called on error.
  94460. * @hidden
  94461. */
  94462. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94463. /**
  94464. * Prepares the effect
  94465. * @hidden
  94466. */
  94467. _prepareEffect(): void;
  94468. private _processCompilationErrors;
  94469. /**
  94470. * Checks if the effect is supported. (Must be called after compilation)
  94471. */
  94472. readonly isSupported: boolean;
  94473. /**
  94474. * Binds a texture to the engine to be used as output of the shader.
  94475. * @param channel Name of the output variable.
  94476. * @param texture Texture to bind.
  94477. * @hidden
  94478. */
  94479. _bindTexture(channel: string, texture: InternalTexture): void;
  94480. /**
  94481. * Sets a texture on the engine to be used in the shader.
  94482. * @param channel Name of the sampler variable.
  94483. * @param texture Texture to set.
  94484. */
  94485. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  94486. /**
  94487. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  94488. * @param channel Name of the sampler variable.
  94489. * @param texture Texture to set.
  94490. */
  94491. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  94492. /**
  94493. * Sets an array of textures on the engine to be used in the shader.
  94494. * @param channel Name of the variable.
  94495. * @param textures Textures to set.
  94496. */
  94497. setTextureArray(channel: string, textures: BaseTexture[]): void;
  94498. /**
  94499. * 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)
  94500. * @param channel Name of the sampler variable.
  94501. * @param postProcess Post process to get the input texture from.
  94502. */
  94503. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  94504. /**
  94505. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  94506. * 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)
  94507. * @param channel Name of the sampler variable.
  94508. * @param postProcess Post process to get the output texture from.
  94509. */
  94510. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  94511. /** @hidden */
  94512. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  94513. /** @hidden */
  94514. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  94515. /** @hidden */
  94516. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  94517. /** @hidden */
  94518. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  94519. /**
  94520. * Binds a buffer to a uniform.
  94521. * @param buffer Buffer to bind.
  94522. * @param name Name of the uniform variable to bind to.
  94523. */
  94524. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  94525. /**
  94526. * Binds block to a uniform.
  94527. * @param blockName Name of the block to bind.
  94528. * @param index Index to bind.
  94529. */
  94530. bindUniformBlock(blockName: string, index: number): void;
  94531. /**
  94532. * Sets an interger value on a uniform variable.
  94533. * @param uniformName Name of the variable.
  94534. * @param value Value to be set.
  94535. * @returns this effect.
  94536. */
  94537. setInt(uniformName: string, value: number): Effect;
  94538. /**
  94539. * Sets an int array on a uniform variable.
  94540. * @param uniformName Name of the variable.
  94541. * @param array array to be set.
  94542. * @returns this effect.
  94543. */
  94544. setIntArray(uniformName: string, array: Int32Array): Effect;
  94545. /**
  94546. * 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)
  94547. * @param uniformName Name of the variable.
  94548. * @param array array to be set.
  94549. * @returns this effect.
  94550. */
  94551. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94552. /**
  94553. * 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)
  94554. * @param uniformName Name of the variable.
  94555. * @param array array to be set.
  94556. * @returns this effect.
  94557. */
  94558. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94559. /**
  94560. * 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)
  94561. * @param uniformName Name of the variable.
  94562. * @param array array to be set.
  94563. * @returns this effect.
  94564. */
  94565. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94566. /**
  94567. * Sets an float array on a uniform variable.
  94568. * @param uniformName Name of the variable.
  94569. * @param array array to be set.
  94570. * @returns this effect.
  94571. */
  94572. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94573. /**
  94574. * 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)
  94575. * @param uniformName Name of the variable.
  94576. * @param array array to be set.
  94577. * @returns this effect.
  94578. */
  94579. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94580. /**
  94581. * 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)
  94582. * @param uniformName Name of the variable.
  94583. * @param array array to be set.
  94584. * @returns this effect.
  94585. */
  94586. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94587. /**
  94588. * 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)
  94589. * @param uniformName Name of the variable.
  94590. * @param array array to be set.
  94591. * @returns this effect.
  94592. */
  94593. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94594. /**
  94595. * Sets an array on a uniform variable.
  94596. * @param uniformName Name of the variable.
  94597. * @param array array to be set.
  94598. * @returns this effect.
  94599. */
  94600. setArray(uniformName: string, array: number[]): Effect;
  94601. /**
  94602. * 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)
  94603. * @param uniformName Name of the variable.
  94604. * @param array array to be set.
  94605. * @returns this effect.
  94606. */
  94607. setArray2(uniformName: string, array: number[]): Effect;
  94608. /**
  94609. * 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)
  94610. * @param uniformName Name of the variable.
  94611. * @param array array to be set.
  94612. * @returns this effect.
  94613. */
  94614. setArray3(uniformName: string, array: number[]): Effect;
  94615. /**
  94616. * 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)
  94617. * @param uniformName Name of the variable.
  94618. * @param array array to be set.
  94619. * @returns this effect.
  94620. */
  94621. setArray4(uniformName: string, array: number[]): Effect;
  94622. /**
  94623. * Sets matrices on a uniform variable.
  94624. * @param uniformName Name of the variable.
  94625. * @param matrices matrices to be set.
  94626. * @returns this effect.
  94627. */
  94628. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94629. /**
  94630. * Sets matrix on a uniform variable.
  94631. * @param uniformName Name of the variable.
  94632. * @param matrix matrix to be set.
  94633. * @returns this effect.
  94634. */
  94635. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94636. /**
  94637. * 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)
  94638. * @param uniformName Name of the variable.
  94639. * @param matrix matrix to be set.
  94640. * @returns this effect.
  94641. */
  94642. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94643. /**
  94644. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94645. * @param uniformName Name of the variable.
  94646. * @param matrix matrix to be set.
  94647. * @returns this effect.
  94648. */
  94649. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94650. /**
  94651. * Sets a float on a uniform variable.
  94652. * @param uniformName Name of the variable.
  94653. * @param value value to be set.
  94654. * @returns this effect.
  94655. */
  94656. setFloat(uniformName: string, value: number): Effect;
  94657. /**
  94658. * Sets a boolean on a uniform variable.
  94659. * @param uniformName Name of the variable.
  94660. * @param bool value to be set.
  94661. * @returns this effect.
  94662. */
  94663. setBool(uniformName: string, bool: boolean): Effect;
  94664. /**
  94665. * Sets a Vector2 on a uniform variable.
  94666. * @param uniformName Name of the variable.
  94667. * @param vector2 vector2 to be set.
  94668. * @returns this effect.
  94669. */
  94670. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  94671. /**
  94672. * Sets a float2 on a uniform variable.
  94673. * @param uniformName Name of the variable.
  94674. * @param x First float in float2.
  94675. * @param y Second float in float2.
  94676. * @returns this effect.
  94677. */
  94678. setFloat2(uniformName: string, x: number, y: number): Effect;
  94679. /**
  94680. * Sets a Vector3 on a uniform variable.
  94681. * @param uniformName Name of the variable.
  94682. * @param vector3 Value to be set.
  94683. * @returns this effect.
  94684. */
  94685. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  94686. /**
  94687. * Sets a float3 on a uniform variable.
  94688. * @param uniformName Name of the variable.
  94689. * @param x First float in float3.
  94690. * @param y Second float in float3.
  94691. * @param z Third float in float3.
  94692. * @returns this effect.
  94693. */
  94694. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  94695. /**
  94696. * Sets a Vector4 on a uniform variable.
  94697. * @param uniformName Name of the variable.
  94698. * @param vector4 Value to be set.
  94699. * @returns this effect.
  94700. */
  94701. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  94702. /**
  94703. * Sets a float4 on a uniform variable.
  94704. * @param uniformName Name of the variable.
  94705. * @param x First float in float4.
  94706. * @param y Second float in float4.
  94707. * @param z Third float in float4.
  94708. * @param w Fourth float in float4.
  94709. * @returns this effect.
  94710. */
  94711. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  94712. /**
  94713. * Sets a Color3 on a uniform variable.
  94714. * @param uniformName Name of the variable.
  94715. * @param color3 Value to be set.
  94716. * @returns this effect.
  94717. */
  94718. setColor3(uniformName: string, color3: IColor3Like): Effect;
  94719. /**
  94720. * Sets a Color4 on a uniform variable.
  94721. * @param uniformName Name of the variable.
  94722. * @param color3 Value to be set.
  94723. * @param alpha Alpha value to be set.
  94724. * @returns this effect.
  94725. */
  94726. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  94727. /**
  94728. * Sets a Color4 on a uniform variable
  94729. * @param uniformName defines the name of the variable
  94730. * @param color4 defines the value to be set
  94731. * @returns this effect.
  94732. */
  94733. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  94734. /** Release all associated resources */
  94735. dispose(): void;
  94736. /**
  94737. * This function will add a new shader to the shader store
  94738. * @param name the name of the shader
  94739. * @param pixelShader optional pixel shader content
  94740. * @param vertexShader optional vertex shader content
  94741. */
  94742. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  94743. /**
  94744. * Store of each shader (The can be looked up using effect.key)
  94745. */
  94746. static ShadersStore: {
  94747. [key: string]: string;
  94748. };
  94749. /**
  94750. * Store of each included file for a shader (The can be looked up using effect.key)
  94751. */
  94752. static IncludesShadersStore: {
  94753. [key: string]: string;
  94754. };
  94755. /**
  94756. * Resets the cache of effects.
  94757. */
  94758. static ResetCache(): void;
  94759. }
  94760. }
  94761. declare module BABYLON {
  94762. /**
  94763. * Uniform buffer objects.
  94764. *
  94765. * Handles blocks of uniform on the GPU.
  94766. *
  94767. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94768. *
  94769. * For more information, please refer to :
  94770. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94771. */
  94772. export class UniformBuffer {
  94773. private _engine;
  94774. private _buffer;
  94775. private _data;
  94776. private _bufferData;
  94777. private _dynamic?;
  94778. private _uniformLocations;
  94779. private _uniformSizes;
  94780. private _uniformLocationPointer;
  94781. private _needSync;
  94782. private _noUBO;
  94783. private _currentEffect;
  94784. private static _MAX_UNIFORM_SIZE;
  94785. private static _tempBuffer;
  94786. /**
  94787. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  94788. * This is dynamic to allow compat with webgl 1 and 2.
  94789. * You will need to pass the name of the uniform as well as the value.
  94790. */
  94791. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  94792. /**
  94793. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  94794. * This is dynamic to allow compat with webgl 1 and 2.
  94795. * You will need to pass the name of the uniform as well as the value.
  94796. */
  94797. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  94798. /**
  94799. * Lambda to Update a single float in a uniform buffer.
  94800. * This is dynamic to allow compat with webgl 1 and 2.
  94801. * You will need to pass the name of the uniform as well as the value.
  94802. */
  94803. updateFloat: (name: string, x: number) => void;
  94804. /**
  94805. * Lambda to Update a vec2 of float in a uniform buffer.
  94806. * This is dynamic to allow compat with webgl 1 and 2.
  94807. * You will need to pass the name of the uniform as well as the value.
  94808. */
  94809. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  94810. /**
  94811. * Lambda to Update a vec3 of float in a uniform buffer.
  94812. * This is dynamic to allow compat with webgl 1 and 2.
  94813. * You will need to pass the name of the uniform as well as the value.
  94814. */
  94815. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  94816. /**
  94817. * Lambda to Update a vec4 of float in a uniform buffer.
  94818. * This is dynamic to allow compat with webgl 1 and 2.
  94819. * You will need to pass the name of the uniform as well as the value.
  94820. */
  94821. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  94822. /**
  94823. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  94824. * This is dynamic to allow compat with webgl 1 and 2.
  94825. * You will need to pass the name of the uniform as well as the value.
  94826. */
  94827. updateMatrix: (name: string, mat: Matrix) => void;
  94828. /**
  94829. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  94830. * This is dynamic to allow compat with webgl 1 and 2.
  94831. * You will need to pass the name of the uniform as well as the value.
  94832. */
  94833. updateVector3: (name: string, vector: Vector3) => void;
  94834. /**
  94835. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  94836. * This is dynamic to allow compat with webgl 1 and 2.
  94837. * You will need to pass the name of the uniform as well as the value.
  94838. */
  94839. updateVector4: (name: string, vector: Vector4) => void;
  94840. /**
  94841. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  94842. * This is dynamic to allow compat with webgl 1 and 2.
  94843. * You will need to pass the name of the uniform as well as the value.
  94844. */
  94845. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  94846. /**
  94847. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  94848. * This is dynamic to allow compat with webgl 1 and 2.
  94849. * You will need to pass the name of the uniform as well as the value.
  94850. */
  94851. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  94852. /**
  94853. * Instantiates a new Uniform buffer objects.
  94854. *
  94855. * Handles blocks of uniform on the GPU.
  94856. *
  94857. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94858. *
  94859. * For more information, please refer to :
  94860. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94861. * @param engine Define the engine the buffer is associated with
  94862. * @param data Define the data contained in the buffer
  94863. * @param dynamic Define if the buffer is updatable
  94864. */
  94865. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  94866. /**
  94867. * Indicates if the buffer is using the WebGL2 UBO implementation,
  94868. * or just falling back on setUniformXXX calls.
  94869. */
  94870. readonly useUbo: boolean;
  94871. /**
  94872. * Indicates if the WebGL underlying uniform buffer is in sync
  94873. * with the javascript cache data.
  94874. */
  94875. readonly isSync: boolean;
  94876. /**
  94877. * Indicates if the WebGL underlying uniform buffer is dynamic.
  94878. * Also, a dynamic UniformBuffer will disable cache verification and always
  94879. * update the underlying WebGL uniform buffer to the GPU.
  94880. * @returns if Dynamic, otherwise false
  94881. */
  94882. isDynamic(): boolean;
  94883. /**
  94884. * The data cache on JS side.
  94885. * @returns the underlying data as a float array
  94886. */
  94887. getData(): Float32Array;
  94888. /**
  94889. * The underlying WebGL Uniform buffer.
  94890. * @returns the webgl buffer
  94891. */
  94892. getBuffer(): Nullable<DataBuffer>;
  94893. /**
  94894. * std140 layout specifies how to align data within an UBO structure.
  94895. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  94896. * for specs.
  94897. */
  94898. private _fillAlignment;
  94899. /**
  94900. * Adds an uniform in the buffer.
  94901. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  94902. * for the layout to be correct !
  94903. * @param name Name of the uniform, as used in the uniform block in the shader.
  94904. * @param size Data size, or data directly.
  94905. */
  94906. addUniform(name: string, size: number | number[]): void;
  94907. /**
  94908. * Adds a Matrix 4x4 to the uniform buffer.
  94909. * @param name Name of the uniform, as used in the uniform block in the shader.
  94910. * @param mat A 4x4 matrix.
  94911. */
  94912. addMatrix(name: string, mat: Matrix): void;
  94913. /**
  94914. * Adds a vec2 to the uniform buffer.
  94915. * @param name Name of the uniform, as used in the uniform block in the shader.
  94916. * @param x Define the x component value of the vec2
  94917. * @param y Define the y component value of the vec2
  94918. */
  94919. addFloat2(name: string, x: number, y: number): void;
  94920. /**
  94921. * Adds a vec3 to the uniform buffer.
  94922. * @param name Name of the uniform, as used in the uniform block in the shader.
  94923. * @param x Define the x component value of the vec3
  94924. * @param y Define the y component value of the vec3
  94925. * @param z Define the z component value of the vec3
  94926. */
  94927. addFloat3(name: string, x: number, y: number, z: number): void;
  94928. /**
  94929. * Adds a vec3 to the uniform buffer.
  94930. * @param name Name of the uniform, as used in the uniform block in the shader.
  94931. * @param color Define the vec3 from a Color
  94932. */
  94933. addColor3(name: string, color: Color3): void;
  94934. /**
  94935. * Adds a vec4 to the uniform buffer.
  94936. * @param name Name of the uniform, as used in the uniform block in the shader.
  94937. * @param color Define the rgb components from a Color
  94938. * @param alpha Define the a component of the vec4
  94939. */
  94940. addColor4(name: string, color: Color3, alpha: number): void;
  94941. /**
  94942. * Adds a vec3 to the uniform buffer.
  94943. * @param name Name of the uniform, as used in the uniform block in the shader.
  94944. * @param vector Define the vec3 components from a Vector
  94945. */
  94946. addVector3(name: string, vector: Vector3): void;
  94947. /**
  94948. * Adds a Matrix 3x3 to the uniform buffer.
  94949. * @param name Name of the uniform, as used in the uniform block in the shader.
  94950. */
  94951. addMatrix3x3(name: string): void;
  94952. /**
  94953. * Adds a Matrix 2x2 to the uniform buffer.
  94954. * @param name Name of the uniform, as used in the uniform block in the shader.
  94955. */
  94956. addMatrix2x2(name: string): void;
  94957. /**
  94958. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  94959. */
  94960. create(): void;
  94961. /** @hidden */
  94962. _rebuild(): void;
  94963. /**
  94964. * Updates the WebGL Uniform Buffer on the GPU.
  94965. * If the `dynamic` flag is set to true, no cache comparison is done.
  94966. * Otherwise, the buffer will be updated only if the cache differs.
  94967. */
  94968. update(): void;
  94969. /**
  94970. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94971. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94972. * @param data Define the flattened data
  94973. * @param size Define the size of the data.
  94974. */
  94975. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  94976. private _valueCache;
  94977. private _cacheMatrix;
  94978. private _updateMatrix3x3ForUniform;
  94979. private _updateMatrix3x3ForEffect;
  94980. private _updateMatrix2x2ForEffect;
  94981. private _updateMatrix2x2ForUniform;
  94982. private _updateFloatForEffect;
  94983. private _updateFloatForUniform;
  94984. private _updateFloat2ForEffect;
  94985. private _updateFloat2ForUniform;
  94986. private _updateFloat3ForEffect;
  94987. private _updateFloat3ForUniform;
  94988. private _updateFloat4ForEffect;
  94989. private _updateFloat4ForUniform;
  94990. private _updateMatrixForEffect;
  94991. private _updateMatrixForUniform;
  94992. private _updateVector3ForEffect;
  94993. private _updateVector3ForUniform;
  94994. private _updateVector4ForEffect;
  94995. private _updateVector4ForUniform;
  94996. private _updateColor3ForEffect;
  94997. private _updateColor3ForUniform;
  94998. private _updateColor4ForEffect;
  94999. private _updateColor4ForUniform;
  95000. /**
  95001. * Sets a sampler uniform on the effect.
  95002. * @param name Define the name of the sampler.
  95003. * @param texture Define the texture to set in the sampler
  95004. */
  95005. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  95006. /**
  95007. * Directly updates the value of the uniform in the cache AND on the GPU.
  95008. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  95009. * @param data Define the flattened data
  95010. */
  95011. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  95012. /**
  95013. * Binds this uniform buffer to an effect.
  95014. * @param effect Define the effect to bind the buffer to
  95015. * @param name Name of the uniform block in the shader.
  95016. */
  95017. bindToEffect(effect: Effect, name: string): void;
  95018. /**
  95019. * Disposes the uniform buffer.
  95020. */
  95021. dispose(): void;
  95022. }
  95023. }
  95024. declare module BABYLON {
  95025. /**
  95026. * Class used to work with sound analyzer using fast fourier transform (FFT)
  95027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95028. */
  95029. export class Analyser {
  95030. /**
  95031. * Gets or sets the smoothing
  95032. * @ignorenaming
  95033. */
  95034. SMOOTHING: number;
  95035. /**
  95036. * Gets or sets the FFT table size
  95037. * @ignorenaming
  95038. */
  95039. FFT_SIZE: number;
  95040. /**
  95041. * Gets or sets the bar graph amplitude
  95042. * @ignorenaming
  95043. */
  95044. BARGRAPHAMPLITUDE: number;
  95045. /**
  95046. * Gets or sets the position of the debug canvas
  95047. * @ignorenaming
  95048. */
  95049. DEBUGCANVASPOS: {
  95050. x: number;
  95051. y: number;
  95052. };
  95053. /**
  95054. * Gets or sets the debug canvas size
  95055. * @ignorenaming
  95056. */
  95057. DEBUGCANVASSIZE: {
  95058. width: number;
  95059. height: number;
  95060. };
  95061. private _byteFreqs;
  95062. private _byteTime;
  95063. private _floatFreqs;
  95064. private _webAudioAnalyser;
  95065. private _debugCanvas;
  95066. private _debugCanvasContext;
  95067. private _scene;
  95068. private _registerFunc;
  95069. private _audioEngine;
  95070. /**
  95071. * Creates a new analyser
  95072. * @param scene defines hosting scene
  95073. */
  95074. constructor(scene: Scene);
  95075. /**
  95076. * Get the number of data values you will have to play with for the visualization
  95077. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  95078. * @returns a number
  95079. */
  95080. getFrequencyBinCount(): number;
  95081. /**
  95082. * Gets the current frequency data as a byte array
  95083. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  95084. * @returns a Uint8Array
  95085. */
  95086. getByteFrequencyData(): Uint8Array;
  95087. /**
  95088. * Gets the current waveform as a byte array
  95089. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  95090. * @returns a Uint8Array
  95091. */
  95092. getByteTimeDomainData(): Uint8Array;
  95093. /**
  95094. * Gets the current frequency data as a float array
  95095. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  95096. * @returns a Float32Array
  95097. */
  95098. getFloatFrequencyData(): Float32Array;
  95099. /**
  95100. * Renders the debug canvas
  95101. */
  95102. drawDebugCanvas(): void;
  95103. /**
  95104. * Stops rendering the debug canvas and removes it
  95105. */
  95106. stopDebugCanvas(): void;
  95107. /**
  95108. * Connects two audio nodes
  95109. * @param inputAudioNode defines first node to connect
  95110. * @param outputAudioNode defines second node to connect
  95111. */
  95112. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  95113. /**
  95114. * Releases all associated resources
  95115. */
  95116. dispose(): void;
  95117. }
  95118. }
  95119. declare module BABYLON {
  95120. /**
  95121. * This represents an audio engine and it is responsible
  95122. * to play, synchronize and analyse sounds throughout the application.
  95123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95124. */
  95125. export interface IAudioEngine extends IDisposable {
  95126. /**
  95127. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  95128. */
  95129. readonly canUseWebAudio: boolean;
  95130. /**
  95131. * Gets the current AudioContext if available.
  95132. */
  95133. readonly audioContext: Nullable<AudioContext>;
  95134. /**
  95135. * The master gain node defines the global audio volume of your audio engine.
  95136. */
  95137. readonly masterGain: GainNode;
  95138. /**
  95139. * Gets whether or not mp3 are supported by your browser.
  95140. */
  95141. readonly isMP3supported: boolean;
  95142. /**
  95143. * Gets whether or not ogg are supported by your browser.
  95144. */
  95145. readonly isOGGsupported: boolean;
  95146. /**
  95147. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95148. * @ignoreNaming
  95149. */
  95150. WarnedWebAudioUnsupported: boolean;
  95151. /**
  95152. * Defines if the audio engine relies on a custom unlocked button.
  95153. * In this case, the embedded button will not be displayed.
  95154. */
  95155. useCustomUnlockedButton: boolean;
  95156. /**
  95157. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  95158. */
  95159. readonly unlocked: boolean;
  95160. /**
  95161. * Event raised when audio has been unlocked on the browser.
  95162. */
  95163. onAudioUnlockedObservable: Observable<AudioEngine>;
  95164. /**
  95165. * Event raised when audio has been locked on the browser.
  95166. */
  95167. onAudioLockedObservable: Observable<AudioEngine>;
  95168. /**
  95169. * Flags the audio engine in Locked state.
  95170. * This happens due to new browser policies preventing audio to autoplay.
  95171. */
  95172. lock(): void;
  95173. /**
  95174. * Unlocks the audio engine once a user action has been done on the dom.
  95175. * This is helpful to resume play once browser policies have been satisfied.
  95176. */
  95177. unlock(): void;
  95178. }
  95179. /**
  95180. * This represents the default audio engine used in babylon.
  95181. * It is responsible to play, synchronize and analyse sounds throughout the application.
  95182. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95183. */
  95184. export class AudioEngine implements IAudioEngine {
  95185. private _audioContext;
  95186. private _audioContextInitialized;
  95187. private _muteButton;
  95188. private _hostElement;
  95189. /**
  95190. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  95191. */
  95192. canUseWebAudio: boolean;
  95193. /**
  95194. * The master gain node defines the global audio volume of your audio engine.
  95195. */
  95196. masterGain: GainNode;
  95197. /**
  95198. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95199. * @ignoreNaming
  95200. */
  95201. WarnedWebAudioUnsupported: boolean;
  95202. /**
  95203. * Gets whether or not mp3 are supported by your browser.
  95204. */
  95205. isMP3supported: boolean;
  95206. /**
  95207. * Gets whether or not ogg are supported by your browser.
  95208. */
  95209. isOGGsupported: boolean;
  95210. /**
  95211. * Gets whether audio has been unlocked on the device.
  95212. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  95213. * a user interaction has happened.
  95214. */
  95215. unlocked: boolean;
  95216. /**
  95217. * Defines if the audio engine relies on a custom unlocked button.
  95218. * In this case, the embedded button will not be displayed.
  95219. */
  95220. useCustomUnlockedButton: boolean;
  95221. /**
  95222. * Event raised when audio has been unlocked on the browser.
  95223. */
  95224. onAudioUnlockedObservable: Observable<AudioEngine>;
  95225. /**
  95226. * Event raised when audio has been locked on the browser.
  95227. */
  95228. onAudioLockedObservable: Observable<AudioEngine>;
  95229. /**
  95230. * Gets the current AudioContext if available.
  95231. */
  95232. readonly audioContext: Nullable<AudioContext>;
  95233. private _connectedAnalyser;
  95234. /**
  95235. * Instantiates a new audio engine.
  95236. *
  95237. * There should be only one per page as some browsers restrict the number
  95238. * of audio contexts you can create.
  95239. * @param hostElement defines the host element where to display the mute icon if necessary
  95240. */
  95241. constructor(hostElement?: Nullable<HTMLElement>);
  95242. /**
  95243. * Flags the audio engine in Locked state.
  95244. * This happens due to new browser policies preventing audio to autoplay.
  95245. */
  95246. lock(): void;
  95247. /**
  95248. * Unlocks the audio engine once a user action has been done on the dom.
  95249. * This is helpful to resume play once browser policies have been satisfied.
  95250. */
  95251. unlock(): void;
  95252. private _resumeAudioContext;
  95253. private _initializeAudioContext;
  95254. private _tryToRun;
  95255. private _triggerRunningState;
  95256. private _triggerSuspendedState;
  95257. private _displayMuteButton;
  95258. private _moveButtonToTopLeft;
  95259. private _onResize;
  95260. private _hideMuteButton;
  95261. /**
  95262. * Destroy and release the resources associated with the audio ccontext.
  95263. */
  95264. dispose(): void;
  95265. /**
  95266. * Gets the global volume sets on the master gain.
  95267. * @returns the global volume if set or -1 otherwise
  95268. */
  95269. getGlobalVolume(): number;
  95270. /**
  95271. * Sets the global volume of your experience (sets on the master gain).
  95272. * @param newVolume Defines the new global volume of the application
  95273. */
  95274. setGlobalVolume(newVolume: number): void;
  95275. /**
  95276. * Connect the audio engine to an audio analyser allowing some amazing
  95277. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  95278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  95279. * @param analyser The analyser to connect to the engine
  95280. */
  95281. connectToAnalyser(analyser: Analyser): void;
  95282. }
  95283. }
  95284. declare module BABYLON {
  95285. /**
  95286. * Interface used to present a loading screen while loading a scene
  95287. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95288. */
  95289. export interface ILoadingScreen {
  95290. /**
  95291. * Function called to display the loading screen
  95292. */
  95293. displayLoadingUI: () => void;
  95294. /**
  95295. * Function called to hide the loading screen
  95296. */
  95297. hideLoadingUI: () => void;
  95298. /**
  95299. * Gets or sets the color to use for the background
  95300. */
  95301. loadingUIBackgroundColor: string;
  95302. /**
  95303. * Gets or sets the text to display while loading
  95304. */
  95305. loadingUIText: string;
  95306. }
  95307. /**
  95308. * Class used for the default loading screen
  95309. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95310. */
  95311. export class DefaultLoadingScreen implements ILoadingScreen {
  95312. private _renderingCanvas;
  95313. private _loadingText;
  95314. private _loadingDivBackgroundColor;
  95315. private _loadingDiv;
  95316. private _loadingTextDiv;
  95317. /** Gets or sets the logo url to use for the default loading screen */
  95318. static DefaultLogoUrl: string;
  95319. /** Gets or sets the spinner url to use for the default loading screen */
  95320. static DefaultSpinnerUrl: string;
  95321. /**
  95322. * Creates a new default loading screen
  95323. * @param _renderingCanvas defines the canvas used to render the scene
  95324. * @param _loadingText defines the default text to display
  95325. * @param _loadingDivBackgroundColor defines the default background color
  95326. */
  95327. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  95328. /**
  95329. * Function called to display the loading screen
  95330. */
  95331. displayLoadingUI(): void;
  95332. /**
  95333. * Function called to hide the loading screen
  95334. */
  95335. hideLoadingUI(): void;
  95336. /**
  95337. * Gets or sets the text to display while loading
  95338. */
  95339. loadingUIText: string;
  95340. /**
  95341. * Gets or sets the color to use for the background
  95342. */
  95343. loadingUIBackgroundColor: string;
  95344. private _resizeLoadingUI;
  95345. }
  95346. }
  95347. declare module BABYLON {
  95348. /** @hidden */
  95349. export class WebGLPipelineContext implements IPipelineContext {
  95350. engine: Engine;
  95351. program: Nullable<WebGLProgram>;
  95352. context?: WebGLRenderingContext;
  95353. vertexShader?: WebGLShader;
  95354. fragmentShader?: WebGLShader;
  95355. isParallelCompiled: boolean;
  95356. onCompiled?: () => void;
  95357. transformFeedback?: WebGLTransformFeedback | null;
  95358. readonly isAsync: boolean;
  95359. readonly isReady: boolean;
  95360. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  95361. }
  95362. }
  95363. declare module BABYLON {
  95364. /** @hidden */
  95365. export class WebGLDataBuffer extends DataBuffer {
  95366. private _buffer;
  95367. constructor(resource: WebGLBuffer);
  95368. readonly underlyingResource: any;
  95369. }
  95370. }
  95371. declare module BABYLON {
  95372. /** @hidden */
  95373. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95374. attributeProcessor(attribute: string): string;
  95375. varyingProcessor(varying: string, isFragment: boolean): string;
  95376. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95377. }
  95378. }
  95379. declare module BABYLON {
  95380. /**
  95381. * This class is used to track a performance counter which is number based.
  95382. * The user has access to many properties which give statistics of different nature.
  95383. *
  95384. * The implementer can track two kinds of Performance Counter: time and count.
  95385. * 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.
  95386. * 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.
  95387. */
  95388. export class PerfCounter {
  95389. /**
  95390. * Gets or sets a global boolean to turn on and off all the counters
  95391. */
  95392. static Enabled: boolean;
  95393. /**
  95394. * Returns the smallest value ever
  95395. */
  95396. readonly min: number;
  95397. /**
  95398. * Returns the biggest value ever
  95399. */
  95400. readonly max: number;
  95401. /**
  95402. * Returns the average value since the performance counter is running
  95403. */
  95404. readonly average: number;
  95405. /**
  95406. * Returns the average value of the last second the counter was monitored
  95407. */
  95408. readonly lastSecAverage: number;
  95409. /**
  95410. * Returns the current value
  95411. */
  95412. readonly current: number;
  95413. /**
  95414. * Gets the accumulated total
  95415. */
  95416. readonly total: number;
  95417. /**
  95418. * Gets the total value count
  95419. */
  95420. readonly count: number;
  95421. /**
  95422. * Creates a new counter
  95423. */
  95424. constructor();
  95425. /**
  95426. * Call this method to start monitoring a new frame.
  95427. * 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.
  95428. */
  95429. fetchNewFrame(): void;
  95430. /**
  95431. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95432. * @param newCount the count value to add to the monitored count
  95433. * @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.
  95434. */
  95435. addCount(newCount: number, fetchResult: boolean): void;
  95436. /**
  95437. * Start monitoring this performance counter
  95438. */
  95439. beginMonitoring(): void;
  95440. /**
  95441. * Compute the time lapsed since the previous beginMonitoring() call.
  95442. * @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
  95443. */
  95444. endMonitoring(newFrame?: boolean): void;
  95445. private _fetchResult;
  95446. private _startMonitoringTime;
  95447. private _min;
  95448. private _max;
  95449. private _average;
  95450. private _current;
  95451. private _totalValueCount;
  95452. private _totalAccumulated;
  95453. private _lastSecAverage;
  95454. private _lastSecAccumulated;
  95455. private _lastSecTime;
  95456. private _lastSecValueCount;
  95457. }
  95458. }
  95459. declare module BABYLON {
  95460. /**
  95461. * Interface for any object that can request an animation frame
  95462. */
  95463. export interface ICustomAnimationFrameRequester {
  95464. /**
  95465. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  95466. */
  95467. renderFunction?: Function;
  95468. /**
  95469. * Called to request the next frame to render to
  95470. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  95471. */
  95472. requestAnimationFrame: Function;
  95473. /**
  95474. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  95475. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  95476. */
  95477. requestID?: number;
  95478. }
  95479. }
  95480. declare module BABYLON {
  95481. /**
  95482. * Settings for finer control over video usage
  95483. */
  95484. export interface VideoTextureSettings {
  95485. /**
  95486. * Applies `autoplay` to video, if specified
  95487. */
  95488. autoPlay?: boolean;
  95489. /**
  95490. * Applies `loop` to video, if specified
  95491. */
  95492. loop?: boolean;
  95493. /**
  95494. * Automatically updates internal texture from video at every frame in the render loop
  95495. */
  95496. autoUpdateTexture: boolean;
  95497. /**
  95498. * Image src displayed during the video loading or until the user interacts with the video.
  95499. */
  95500. poster?: string;
  95501. }
  95502. /**
  95503. * If you want to display a video in your scene, this is the special texture for that.
  95504. * This special texture works similar to other textures, with the exception of a few parameters.
  95505. * @see https://doc.babylonjs.com/how_to/video_texture
  95506. */
  95507. export class VideoTexture extends Texture {
  95508. /**
  95509. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95510. */
  95511. readonly autoUpdateTexture: boolean;
  95512. /**
  95513. * The video instance used by the texture internally
  95514. */
  95515. readonly video: HTMLVideoElement;
  95516. private _onUserActionRequestedObservable;
  95517. /**
  95518. * Event triggerd when a dom action is required by the user to play the video.
  95519. * This happens due to recent changes in browser policies preventing video to auto start.
  95520. */
  95521. readonly onUserActionRequestedObservable: Observable<Texture>;
  95522. private _generateMipMaps;
  95523. private _engine;
  95524. private _stillImageCaptured;
  95525. private _displayingPosterTexture;
  95526. private _settings;
  95527. private _createInternalTextureOnEvent;
  95528. private _frameId;
  95529. /**
  95530. * Creates a video texture.
  95531. * If you want to display a video in your scene, this is the special texture for that.
  95532. * This special texture works similar to other textures, with the exception of a few parameters.
  95533. * @see https://doc.babylonjs.com/how_to/video_texture
  95534. * @param name optional name, will detect from video source, if not defined
  95535. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95536. * @param scene is obviously the current scene.
  95537. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95538. * @param invertY is false by default but can be used to invert video on Y axis
  95539. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95540. * @param settings allows finer control over video usage
  95541. */
  95542. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95543. private _getName;
  95544. private _getVideo;
  95545. private _createInternalTexture;
  95546. private reset;
  95547. /**
  95548. * @hidden Internal method to initiate `update`.
  95549. */
  95550. _rebuild(): void;
  95551. /**
  95552. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95553. */
  95554. update(): void;
  95555. /**
  95556. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95557. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95558. */
  95559. updateTexture(isVisible: boolean): void;
  95560. protected _updateInternalTexture: () => void;
  95561. /**
  95562. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95563. * @param url New url.
  95564. */
  95565. updateURL(url: string): void;
  95566. /**
  95567. * Dispose the texture and release its associated resources.
  95568. */
  95569. dispose(): void;
  95570. /**
  95571. * Creates a video texture straight from a stream.
  95572. * @param scene Define the scene the texture should be created in
  95573. * @param stream Define the stream the texture should be created from
  95574. * @returns The created video texture as a promise
  95575. */
  95576. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95577. /**
  95578. * Creates a video texture straight from your WebCam video feed.
  95579. * @param scene Define the scene the texture should be created in
  95580. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95581. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95582. * @returns The created video texture as a promise
  95583. */
  95584. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95585. minWidth: number;
  95586. maxWidth: number;
  95587. minHeight: number;
  95588. maxHeight: number;
  95589. deviceId: string;
  95590. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95591. /**
  95592. * Creates a video texture straight from your WebCam video feed.
  95593. * @param scene Define the scene the texture should be created in
  95594. * @param onReady Define a callback to triggered once the texture will be ready
  95595. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95596. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95597. */
  95598. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95599. minWidth: number;
  95600. maxWidth: number;
  95601. minHeight: number;
  95602. maxHeight: number;
  95603. deviceId: string;
  95604. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95605. }
  95606. }
  95607. declare module BABYLON {
  95608. /**
  95609. * Defines the interface used by objects containing a viewport (like a camera)
  95610. */
  95611. interface IViewportOwnerLike {
  95612. /**
  95613. * Gets or sets the viewport
  95614. */
  95615. viewport: IViewportLike;
  95616. }
  95617. /**
  95618. * Interface for attribute information associated with buffer instanciation
  95619. */
  95620. export class InstancingAttributeInfo {
  95621. /**
  95622. * Index/offset of the attribute in the vertex shader
  95623. */
  95624. index: number;
  95625. /**
  95626. * size of the attribute, 1, 2, 3 or 4
  95627. */
  95628. attributeSize: number;
  95629. /**
  95630. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95631. * default is FLOAT
  95632. */
  95633. attribyteType: number;
  95634. /**
  95635. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95636. */
  95637. normalized: boolean;
  95638. /**
  95639. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95640. */
  95641. offset: number;
  95642. /**
  95643. * Name of the GLSL attribute, for debugging purpose only
  95644. */
  95645. attributeName: string;
  95646. }
  95647. /**
  95648. * Define options used to create a depth texture
  95649. */
  95650. export class DepthTextureCreationOptions {
  95651. /** Specifies whether or not a stencil should be allocated in the texture */
  95652. generateStencil?: boolean;
  95653. /** Specifies whether or not bilinear filtering is enable on the texture */
  95654. bilinearFiltering?: boolean;
  95655. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  95656. comparisonFunction?: number;
  95657. /** Specifies if the created texture is a cube texture */
  95658. isCube?: boolean;
  95659. }
  95660. /**
  95661. * Class used to describe the capabilities of the engine relatively to the current browser
  95662. */
  95663. export class EngineCapabilities {
  95664. /** Maximum textures units per fragment shader */
  95665. maxTexturesImageUnits: number;
  95666. /** Maximum texture units per vertex shader */
  95667. maxVertexTextureImageUnits: number;
  95668. /** Maximum textures units in the entire pipeline */
  95669. maxCombinedTexturesImageUnits: number;
  95670. /** Maximum texture size */
  95671. maxTextureSize: number;
  95672. /** Maximum cube texture size */
  95673. maxCubemapTextureSize: number;
  95674. /** Maximum render texture size */
  95675. maxRenderTextureSize: number;
  95676. /** Maximum number of vertex attributes */
  95677. maxVertexAttribs: number;
  95678. /** Maximum number of varyings */
  95679. maxVaryingVectors: number;
  95680. /** Maximum number of uniforms per vertex shader */
  95681. maxVertexUniformVectors: number;
  95682. /** Maximum number of uniforms per fragment shader */
  95683. maxFragmentUniformVectors: number;
  95684. /** Defines if standard derivates (dx/dy) are supported */
  95685. standardDerivatives: boolean;
  95686. /** Defines if s3tc texture compression is supported */
  95687. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95688. /** Defines if pvrtc texture compression is supported */
  95689. pvrtc: any;
  95690. /** Defines if etc1 texture compression is supported */
  95691. etc1: any;
  95692. /** Defines if etc2 texture compression is supported */
  95693. etc2: any;
  95694. /** Defines if astc texture compression is supported */
  95695. astc: any;
  95696. /** Defines if float textures are supported */
  95697. textureFloat: boolean;
  95698. /** Defines if vertex array objects are supported */
  95699. vertexArrayObject: boolean;
  95700. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95701. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95702. /** Gets the maximum level of anisotropy supported */
  95703. maxAnisotropy: number;
  95704. /** Defines if instancing is supported */
  95705. instancedArrays: boolean;
  95706. /** Defines if 32 bits indices are supported */
  95707. uintIndices: boolean;
  95708. /** Defines if high precision shaders are supported */
  95709. highPrecisionShaderSupported: boolean;
  95710. /** Defines if depth reading in the fragment shader is supported */
  95711. fragmentDepthSupported: boolean;
  95712. /** Defines if float texture linear filtering is supported*/
  95713. textureFloatLinearFiltering: boolean;
  95714. /** Defines if rendering to float textures is supported */
  95715. textureFloatRender: boolean;
  95716. /** Defines if half float textures are supported*/
  95717. textureHalfFloat: boolean;
  95718. /** Defines if half float texture linear filtering is supported*/
  95719. textureHalfFloatLinearFiltering: boolean;
  95720. /** Defines if rendering to half float textures is supported */
  95721. textureHalfFloatRender: boolean;
  95722. /** Defines if textureLOD shader command is supported */
  95723. textureLOD: boolean;
  95724. /** Defines if draw buffers extension is supported */
  95725. drawBuffersExtension: boolean;
  95726. /** Defines if depth textures are supported */
  95727. depthTextureExtension: boolean;
  95728. /** Defines if float color buffer are supported */
  95729. colorBufferFloat: boolean;
  95730. /** Gets disjoint timer query extension (null if not supported) */
  95731. timerQuery: EXT_disjoint_timer_query;
  95732. /** Defines if timestamp can be used with timer query */
  95733. canUseTimestampForTimerQuery: boolean;
  95734. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95735. multiview: any;
  95736. /** Function used to let the system compiles shaders in background */
  95737. parallelShaderCompile: {
  95738. COMPLETION_STATUS_KHR: number;
  95739. };
  95740. /** Max number of texture samples for MSAA */
  95741. maxMSAASamples: number;
  95742. /** Defines if the blend min max extension is supported */
  95743. blendMinMax: boolean;
  95744. }
  95745. /** Interface defining initialization parameters for Engine class */
  95746. export interface EngineOptions extends WebGLContextAttributes {
  95747. /**
  95748. * Defines if the engine should no exceed a specified device ratio
  95749. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95750. */
  95751. limitDeviceRatio?: number;
  95752. /**
  95753. * Defines if webvr should be enabled automatically
  95754. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95755. */
  95756. autoEnableWebVR?: boolean;
  95757. /**
  95758. * Defines if webgl2 should be turned off even if supported
  95759. * @see http://doc.babylonjs.com/features/webgl2
  95760. */
  95761. disableWebGL2Support?: boolean;
  95762. /**
  95763. * Defines if webaudio should be initialized as well
  95764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95765. */
  95766. audioEngine?: boolean;
  95767. /**
  95768. * Defines if animations should run using a deterministic lock step
  95769. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95770. */
  95771. deterministicLockstep?: boolean;
  95772. /** Defines the maximum steps to use with deterministic lock step mode */
  95773. lockstepMaxSteps?: number;
  95774. /**
  95775. * Defines that engine should ignore context lost events
  95776. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95777. */
  95778. doNotHandleContextLost?: boolean;
  95779. /**
  95780. * Defines that engine should ignore modifying touch action attribute and style
  95781. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95782. */
  95783. doNotHandleTouchAction?: boolean;
  95784. /**
  95785. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95786. */
  95787. useHighPrecisionFloats?: boolean;
  95788. }
  95789. /**
  95790. * Defines the interface used by display changed events
  95791. */
  95792. export interface IDisplayChangedEventArgs {
  95793. /** Gets the vrDisplay object (if any) */
  95794. vrDisplay: Nullable<any>;
  95795. /** Gets a boolean indicating if webVR is supported */
  95796. vrSupported: boolean;
  95797. }
  95798. /**
  95799. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  95800. */
  95801. export class Engine {
  95802. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95803. static ExceptionList: ({
  95804. key: string;
  95805. capture: string;
  95806. captureConstraint: number;
  95807. targets: string[];
  95808. } | {
  95809. key: string;
  95810. capture: null;
  95811. captureConstraint: null;
  95812. targets: string[];
  95813. })[];
  95814. /** Gets the list of created engines */
  95815. static readonly Instances: Engine[];
  95816. /**
  95817. * Gets the latest created engine
  95818. */
  95819. static readonly LastCreatedEngine: Nullable<Engine>;
  95820. /**
  95821. * Gets the latest created scene
  95822. */
  95823. static readonly LastCreatedScene: Nullable<Scene>;
  95824. /**
  95825. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  95826. * @param flag defines which part of the materials must be marked as dirty
  95827. * @param predicate defines a predicate used to filter which materials should be affected
  95828. */
  95829. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  95830. /** @hidden */
  95831. static _TextureLoaders: IInternalTextureLoader[];
  95832. /** Defines that alpha blending is disabled */
  95833. static readonly ALPHA_DISABLE: number;
  95834. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  95835. static readonly ALPHA_ADD: number;
  95836. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  95837. static readonly ALPHA_COMBINE: number;
  95838. /** Defines that alpha blending to DEST - SRC * DEST */
  95839. static readonly ALPHA_SUBTRACT: number;
  95840. /** Defines that alpha blending to SRC * DEST */
  95841. static readonly ALPHA_MULTIPLY: number;
  95842. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  95843. static readonly ALPHA_MAXIMIZED: number;
  95844. /** Defines that alpha blending to SRC + DEST */
  95845. static readonly ALPHA_ONEONE: number;
  95846. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  95847. static readonly ALPHA_PREMULTIPLIED: number;
  95848. /**
  95849. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  95850. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  95851. */
  95852. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  95853. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  95854. static readonly ALPHA_INTERPOLATE: number;
  95855. /**
  95856. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  95857. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  95858. */
  95859. static readonly ALPHA_SCREENMODE: number;
  95860. /** Defines that the ressource is not delayed*/
  95861. static readonly DELAYLOADSTATE_NONE: number;
  95862. /** Defines that the ressource was successfully delay loaded */
  95863. static readonly DELAYLOADSTATE_LOADED: number;
  95864. /** Defines that the ressource is currently delay loading */
  95865. static readonly DELAYLOADSTATE_LOADING: number;
  95866. /** Defines that the ressource is delayed and has not started loading */
  95867. static readonly DELAYLOADSTATE_NOTLOADED: number;
  95868. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  95869. static readonly NEVER: number;
  95870. /** 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 */
  95871. static readonly ALWAYS: number;
  95872. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  95873. static readonly LESS: number;
  95874. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  95875. static readonly EQUAL: number;
  95876. /** 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 */
  95877. static readonly LEQUAL: number;
  95878. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  95879. static readonly GREATER: number;
  95880. /** 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 */
  95881. static readonly GEQUAL: number;
  95882. /** 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 */
  95883. static readonly NOTEQUAL: number;
  95884. /** Passed to stencilOperation to specify that stencil value must be kept */
  95885. static readonly KEEP: number;
  95886. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95887. static readonly REPLACE: number;
  95888. /** Passed to stencilOperation to specify that stencil value must be incremented */
  95889. static readonly INCR: number;
  95890. /** Passed to stencilOperation to specify that stencil value must be decremented */
  95891. static readonly DECR: number;
  95892. /** Passed to stencilOperation to specify that stencil value must be inverted */
  95893. static readonly INVERT: number;
  95894. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  95895. static readonly INCR_WRAP: number;
  95896. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  95897. static readonly DECR_WRAP: number;
  95898. /** Texture is not repeating outside of 0..1 UVs */
  95899. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  95900. /** Texture is repeating outside of 0..1 UVs */
  95901. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  95902. /** Texture is repeating and mirrored */
  95903. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  95904. /** ALPHA */
  95905. static readonly TEXTUREFORMAT_ALPHA: number;
  95906. /** LUMINANCE */
  95907. static readonly TEXTUREFORMAT_LUMINANCE: number;
  95908. /** LUMINANCE_ALPHA */
  95909. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  95910. /** RGB */
  95911. static readonly TEXTUREFORMAT_RGB: number;
  95912. /** RGBA */
  95913. static readonly TEXTUREFORMAT_RGBA: number;
  95914. /** RED */
  95915. static readonly TEXTUREFORMAT_RED: number;
  95916. /** RED (2nd reference) */
  95917. static readonly TEXTUREFORMAT_R: number;
  95918. /** RG */
  95919. static readonly TEXTUREFORMAT_RG: number;
  95920. /** RED_INTEGER */
  95921. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  95922. /** RED_INTEGER (2nd reference) */
  95923. static readonly TEXTUREFORMAT_R_INTEGER: number;
  95924. /** RG_INTEGER */
  95925. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  95926. /** RGB_INTEGER */
  95927. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  95928. /** RGBA_INTEGER */
  95929. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  95930. /** UNSIGNED_BYTE */
  95931. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  95932. /** UNSIGNED_BYTE (2nd reference) */
  95933. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  95934. /** FLOAT */
  95935. static readonly TEXTURETYPE_FLOAT: number;
  95936. /** HALF_FLOAT */
  95937. static readonly TEXTURETYPE_HALF_FLOAT: number;
  95938. /** BYTE */
  95939. static readonly TEXTURETYPE_BYTE: number;
  95940. /** SHORT */
  95941. static readonly TEXTURETYPE_SHORT: number;
  95942. /** UNSIGNED_SHORT */
  95943. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  95944. /** INT */
  95945. static readonly TEXTURETYPE_INT: number;
  95946. /** UNSIGNED_INT */
  95947. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  95948. /** UNSIGNED_SHORT_4_4_4_4 */
  95949. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  95950. /** UNSIGNED_SHORT_5_5_5_1 */
  95951. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  95952. /** UNSIGNED_SHORT_5_6_5 */
  95953. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  95954. /** UNSIGNED_INT_2_10_10_10_REV */
  95955. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  95956. /** UNSIGNED_INT_24_8 */
  95957. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  95958. /** UNSIGNED_INT_10F_11F_11F_REV */
  95959. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  95960. /** UNSIGNED_INT_5_9_9_9_REV */
  95961. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  95962. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  95963. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  95964. /** nearest is mag = nearest and min = nearest and mip = linear */
  95965. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  95966. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95967. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  95968. /** Trilinear is mag = linear and min = linear and mip = linear */
  95969. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  95970. /** nearest is mag = nearest and min = nearest and mip = linear */
  95971. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  95972. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95973. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  95974. /** Trilinear is mag = linear and min = linear and mip = linear */
  95975. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  95976. /** mag = nearest and min = nearest and mip = nearest */
  95977. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  95978. /** mag = nearest and min = linear and mip = nearest */
  95979. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  95980. /** mag = nearest and min = linear and mip = linear */
  95981. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  95982. /** mag = nearest and min = linear and mip = none */
  95983. static readonly TEXTURE_NEAREST_LINEAR: number;
  95984. /** mag = nearest and min = nearest and mip = none */
  95985. static readonly TEXTURE_NEAREST_NEAREST: number;
  95986. /** mag = linear and min = nearest and mip = nearest */
  95987. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  95988. /** mag = linear and min = nearest and mip = linear */
  95989. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  95990. /** mag = linear and min = linear and mip = none */
  95991. static readonly TEXTURE_LINEAR_LINEAR: number;
  95992. /** mag = linear and min = nearest and mip = none */
  95993. static readonly TEXTURE_LINEAR_NEAREST: number;
  95994. /** Explicit coordinates mode */
  95995. static readonly TEXTURE_EXPLICIT_MODE: number;
  95996. /** Spherical coordinates mode */
  95997. static readonly TEXTURE_SPHERICAL_MODE: number;
  95998. /** Planar coordinates mode */
  95999. static readonly TEXTURE_PLANAR_MODE: number;
  96000. /** Cubic coordinates mode */
  96001. static readonly TEXTURE_CUBIC_MODE: number;
  96002. /** Projection coordinates mode */
  96003. static readonly TEXTURE_PROJECTION_MODE: number;
  96004. /** Skybox coordinates mode */
  96005. static readonly TEXTURE_SKYBOX_MODE: number;
  96006. /** Inverse Cubic coordinates mode */
  96007. static readonly TEXTURE_INVCUBIC_MODE: number;
  96008. /** Equirectangular coordinates mode */
  96009. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  96010. /** Equirectangular Fixed coordinates mode */
  96011. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  96012. /** Equirectangular Fixed Mirrored coordinates mode */
  96013. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  96014. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  96015. static readonly SCALEMODE_FLOOR: number;
  96016. /** Defines that texture rescaling will look for the nearest power of 2 size */
  96017. static readonly SCALEMODE_NEAREST: number;
  96018. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  96019. static readonly SCALEMODE_CEILING: number;
  96020. /**
  96021. * Returns the current npm package of the sdk
  96022. */
  96023. static readonly NpmPackage: string;
  96024. /**
  96025. * Returns the current version of the framework
  96026. */
  96027. static readonly Version: string;
  96028. /**
  96029. * Returns a string describing the current engine
  96030. */
  96031. readonly description: string;
  96032. /**
  96033. * Gets or sets the epsilon value used by collision engine
  96034. */
  96035. static CollisionsEpsilon: number;
  96036. /**
  96037. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96038. */
  96039. static ShadersRepository: string;
  96040. /**
  96041. * Method called to create the default loading screen.
  96042. * This can be overriden in your own app.
  96043. * @param canvas The rendering canvas element
  96044. * @returns The loading screen
  96045. */
  96046. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  96047. /**
  96048. * Method called to create the default rescale post process on each engine.
  96049. */
  96050. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  96051. /** @hidden */
  96052. _shaderProcessor: IShaderProcessor;
  96053. /**
  96054. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  96055. */
  96056. forcePOTTextures: boolean;
  96057. /**
  96058. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  96059. */
  96060. isFullscreen: boolean;
  96061. /**
  96062. * Gets a boolean indicating if the pointer is currently locked
  96063. */
  96064. isPointerLock: boolean;
  96065. /**
  96066. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  96067. */
  96068. cullBackFaces: boolean;
  96069. /**
  96070. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  96071. */
  96072. renderEvenInBackground: boolean;
  96073. /**
  96074. * Gets or sets a boolean indicating that cache can be kept between frames
  96075. */
  96076. preventCacheWipeBetweenFrames: boolean;
  96077. /**
  96078. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  96079. **/
  96080. enableOfflineSupport: boolean;
  96081. /**
  96082. * 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)
  96083. **/
  96084. disableManifestCheck: boolean;
  96085. /**
  96086. * Gets the list of created scenes
  96087. */
  96088. scenes: Scene[];
  96089. /**
  96090. * Event raised when a new scene is created
  96091. */
  96092. onNewSceneAddedObservable: Observable<Scene>;
  96093. /**
  96094. * Gets the list of created postprocesses
  96095. */
  96096. postProcesses: PostProcess[];
  96097. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  96098. validateShaderPrograms: boolean;
  96099. /**
  96100. * Observable event triggered each time the rendering canvas is resized
  96101. */
  96102. onResizeObservable: Observable<Engine>;
  96103. /**
  96104. * Observable event triggered each time the canvas loses focus
  96105. */
  96106. onCanvasBlurObservable: Observable<Engine>;
  96107. /**
  96108. * Observable event triggered each time the canvas gains focus
  96109. */
  96110. onCanvasFocusObservable: Observable<Engine>;
  96111. /**
  96112. * Observable event triggered each time the canvas receives pointerout event
  96113. */
  96114. onCanvasPointerOutObservable: Observable<PointerEvent>;
  96115. /**
  96116. * Observable event triggered before each texture is initialized
  96117. */
  96118. onBeforeTextureInitObservable: Observable<Texture>;
  96119. /**
  96120. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96121. */
  96122. disableUniformBuffers: boolean;
  96123. /** @hidden */
  96124. _uniformBuffers: UniformBuffer[];
  96125. /**
  96126. * Gets a boolean indicating that the engine supports uniform buffers
  96127. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96128. */
  96129. readonly supportsUniformBuffers: boolean;
  96130. /**
  96131. * Observable raised when the engine begins a new frame
  96132. */
  96133. onBeginFrameObservable: Observable<Engine>;
  96134. /**
  96135. * If set, will be used to request the next animation frame for the render loop
  96136. */
  96137. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  96138. /**
  96139. * Observable raised when the engine ends the current frame
  96140. */
  96141. onEndFrameObservable: Observable<Engine>;
  96142. /**
  96143. * Observable raised when the engine is about to compile a shader
  96144. */
  96145. onBeforeShaderCompilationObservable: Observable<Engine>;
  96146. /**
  96147. * Observable raised when the engine has jsut compiled a shader
  96148. */
  96149. onAfterShaderCompilationObservable: Observable<Engine>;
  96150. /** @hidden */
  96151. _gl: WebGLRenderingContext;
  96152. private _renderingCanvas;
  96153. private _windowIsBackground;
  96154. protected _webGLVersion: number;
  96155. protected _highPrecisionShadersAllowed: boolean;
  96156. /** @hidden */
  96157. readonly _shouldUseHighPrecisionShader: boolean;
  96158. /**
  96159. * Gets a boolean indicating that only power of 2 textures are supported
  96160. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96161. */
  96162. readonly needPOTTextures: boolean;
  96163. /** @hidden */
  96164. _badOS: boolean;
  96165. /** @hidden */
  96166. _badDesktopOS: boolean;
  96167. /**
  96168. * Gets the audio engine
  96169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96170. * @ignorenaming
  96171. */
  96172. static audioEngine: IAudioEngine;
  96173. /**
  96174. * Default AudioEngine factory responsible of creating the Audio Engine.
  96175. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  96176. */
  96177. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  96178. /**
  96179. * Default offline support factory responsible of creating a tool used to store data locally.
  96180. * By default, this will create a Database object if the workload has been embedded.
  96181. */
  96182. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  96183. private _onFocus;
  96184. private _onBlur;
  96185. private _onCanvasPointerOut;
  96186. private _onCanvasBlur;
  96187. private _onCanvasFocus;
  96188. private _onFullscreenChange;
  96189. private _onPointerLockChange;
  96190. private _hardwareScalingLevel;
  96191. /** @hidden */
  96192. _caps: EngineCapabilities;
  96193. private _pointerLockRequested;
  96194. private _isStencilEnable;
  96195. protected _colorWrite: boolean;
  96196. private _loadingScreen;
  96197. /** @hidden */
  96198. _drawCalls: PerfCounter;
  96199. private _glVersion;
  96200. private _glRenderer;
  96201. private _glVendor;
  96202. private _videoTextureSupported;
  96203. private _renderingQueueLaunched;
  96204. private _activeRenderLoops;
  96205. private _deterministicLockstep;
  96206. private _lockstepMaxSteps;
  96207. /**
  96208. * Observable signaled when a context lost event is raised
  96209. */
  96210. onContextLostObservable: Observable<Engine>;
  96211. /**
  96212. * Observable signaled when a context restored event is raised
  96213. */
  96214. onContextRestoredObservable: Observable<Engine>;
  96215. private _onContextLost;
  96216. private _onContextRestored;
  96217. private _contextWasLost;
  96218. /** @hidden */
  96219. _doNotHandleContextLost: boolean;
  96220. /**
  96221. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96222. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96223. */
  96224. doNotHandleContextLost: boolean;
  96225. private _performanceMonitor;
  96226. private _fps;
  96227. private _deltaTime;
  96228. /**
  96229. * Turn this value on if you want to pause FPS computation when in background
  96230. */
  96231. disablePerformanceMonitorInBackground: boolean;
  96232. /**
  96233. * Gets the performance monitor attached to this engine
  96234. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  96235. */
  96236. readonly performanceMonitor: PerformanceMonitor;
  96237. /**
  96238. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96239. */
  96240. disableVertexArrayObjects: boolean;
  96241. /** @hidden */
  96242. protected _depthCullingState: _DepthCullingState;
  96243. /** @hidden */
  96244. protected _stencilState: _StencilState;
  96245. /** @hidden */
  96246. protected _alphaState: _AlphaState;
  96247. /** @hidden */
  96248. protected _alphaMode: number;
  96249. /** @hidden */
  96250. protected _alphaEquation: number;
  96251. /** @hidden */
  96252. _internalTexturesCache: InternalTexture[];
  96253. /** @hidden */
  96254. protected _activeChannel: number;
  96255. private _currentTextureChannel;
  96256. /** @hidden */
  96257. protected _boundTexturesCache: {
  96258. [key: string]: Nullable<InternalTexture>;
  96259. };
  96260. /** @hidden */
  96261. protected _currentEffect: Nullable<Effect>;
  96262. /** @hidden */
  96263. protected _currentProgram: Nullable<WebGLProgram>;
  96264. private _compiledEffects;
  96265. private _vertexAttribArraysEnabled;
  96266. /** @hidden */
  96267. protected _cachedViewport: Nullable<IViewportLike>;
  96268. private _cachedVertexArrayObject;
  96269. /** @hidden */
  96270. protected _cachedVertexBuffers: any;
  96271. /** @hidden */
  96272. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96273. /** @hidden */
  96274. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96275. /** @hidden */
  96276. _currentRenderTarget: Nullable<InternalTexture>;
  96277. private _uintIndicesCurrentlySet;
  96278. private _currentBoundBuffer;
  96279. /** @hidden */
  96280. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96281. private _currentBufferPointers;
  96282. private _currentInstanceLocations;
  96283. private _currentInstanceBuffers;
  96284. private _textureUnits;
  96285. /** @hidden */
  96286. _workingCanvas: Nullable<HTMLCanvasElement>;
  96287. /** @hidden */
  96288. _workingContext: Nullable<CanvasRenderingContext2D>;
  96289. private _rescalePostProcess;
  96290. private _dummyFramebuffer;
  96291. private _externalData;
  96292. /** @hidden */
  96293. _bindedRenderFunction: any;
  96294. private _vaoRecordInProgress;
  96295. private _mustWipeVertexAttributes;
  96296. private _emptyTexture;
  96297. private _emptyCubeTexture;
  96298. private _emptyTexture3D;
  96299. /** @hidden */
  96300. _frameHandler: number;
  96301. private _nextFreeTextureSlots;
  96302. private _maxSimultaneousTextures;
  96303. private _activeRequests;
  96304. private _texturesSupported;
  96305. /** @hidden */
  96306. _textureFormatInUse: Nullable<string>;
  96307. /**
  96308. * Gets the list of texture formats supported
  96309. */
  96310. readonly texturesSupported: Array<string>;
  96311. /**
  96312. * Gets the list of texture formats in use
  96313. */
  96314. readonly textureFormatInUse: Nullable<string>;
  96315. /**
  96316. * Gets the current viewport
  96317. */
  96318. readonly currentViewport: Nullable<IViewportLike>;
  96319. /**
  96320. * Gets the default empty texture
  96321. */
  96322. readonly emptyTexture: InternalTexture;
  96323. /**
  96324. * Gets the default empty 3D texture
  96325. */
  96326. readonly emptyTexture3D: InternalTexture;
  96327. /**
  96328. * Gets the default empty cube texture
  96329. */
  96330. readonly emptyCubeTexture: InternalTexture;
  96331. /**
  96332. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96333. */
  96334. readonly premultipliedAlpha: boolean;
  96335. /**
  96336. * Creates a new engine
  96337. * @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
  96338. * @param antialias defines enable antialiasing (default: false)
  96339. * @param options defines further options to be sent to the getContext() function
  96340. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96341. */
  96342. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96343. /**
  96344. * Initializes a webVR display and starts listening to display change events
  96345. * The onVRDisplayChangedObservable will be notified upon these changes
  96346. * @returns The onVRDisplayChangedObservable
  96347. */
  96348. initWebVR(): Observable<IDisplayChangedEventArgs>;
  96349. /** @hidden */
  96350. _prepareVRComponent(): void;
  96351. /** @hidden */
  96352. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  96353. /** @hidden */
  96354. _submitVRFrame(): void;
  96355. /**
  96356. * Call this function to leave webVR mode
  96357. * Will do nothing if webVR is not supported or if there is no webVR device
  96358. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96359. */
  96360. disableVR(): void;
  96361. /**
  96362. * Gets a boolean indicating that the system is in VR mode and is presenting
  96363. * @returns true if VR mode is engaged
  96364. */
  96365. isVRPresenting(): boolean;
  96366. /** @hidden */
  96367. _requestVRFrame(): void;
  96368. private _disableTouchAction;
  96369. private _rebuildInternalTextures;
  96370. private _rebuildEffects;
  96371. /**
  96372. * Gets a boolean indicating if all created effects are ready
  96373. * @returns true if all effects are ready
  96374. */
  96375. areAllEffectsReady(): boolean;
  96376. private _rebuildBuffers;
  96377. private _initGLContext;
  96378. /**
  96379. * Gets version of the current webGL context
  96380. */
  96381. readonly webGLVersion: number;
  96382. /**
  96383. * Gets a string idenfifying the name of the class
  96384. * @returns "Engine" string
  96385. */
  96386. getClassName(): string;
  96387. /**
  96388. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96389. */
  96390. readonly isStencilEnable: boolean;
  96391. /** @hidden */
  96392. _prepareWorkingCanvas(): void;
  96393. /**
  96394. * Reset the texture cache to empty state
  96395. */
  96396. resetTextureCache(): void;
  96397. /**
  96398. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  96399. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96400. * @returns true if engine is in deterministic lock step mode
  96401. */
  96402. isDeterministicLockStep(): boolean;
  96403. /**
  96404. * Gets the max steps when engine is running in deterministic lock step
  96405. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96406. * @returns the max steps
  96407. */
  96408. getLockstepMaxSteps(): number;
  96409. /**
  96410. * Gets an object containing information about the current webGL context
  96411. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96412. */
  96413. getGlInfo(): {
  96414. vendor: string;
  96415. renderer: string;
  96416. version: string;
  96417. };
  96418. /**
  96419. * Gets current aspect ratio
  96420. * @param viewportOwner defines the camera to use to get the aspect ratio
  96421. * @param useScreen defines if screen size must be used (or the current render target if any)
  96422. * @returns a number defining the aspect ratio
  96423. */
  96424. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  96425. /**
  96426. * Gets current screen aspect ratio
  96427. * @returns a number defining the aspect ratio
  96428. */
  96429. getScreenAspectRatio(): number;
  96430. /**
  96431. * Gets the current render width
  96432. * @param useScreen defines if screen size must be used (or the current render target if any)
  96433. * @returns a number defining the current render width
  96434. */
  96435. getRenderWidth(useScreen?: boolean): number;
  96436. /**
  96437. * Gets the current render height
  96438. * @param useScreen defines if screen size must be used (or the current render target if any)
  96439. * @returns a number defining the current render height
  96440. */
  96441. getRenderHeight(useScreen?: boolean): number;
  96442. /**
  96443. * Gets the HTML canvas attached with the current webGL context
  96444. * @returns a HTML canvas
  96445. */
  96446. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96447. /**
  96448. * Gets host window
  96449. * @returns the host window object
  96450. */
  96451. getHostWindow(): Window;
  96452. /**
  96453. * Gets host document
  96454. * @returns the host document object
  96455. */
  96456. getHostDocument(): Document;
  96457. /**
  96458. * Gets the client rect of the HTML canvas attached with the current webGL context
  96459. * @returns a client rectanglee
  96460. */
  96461. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  96462. /**
  96463. * Defines the hardware scaling level.
  96464. * By default the hardware scaling level is computed from the window device ratio.
  96465. * 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.
  96466. * @param level defines the level to use
  96467. */
  96468. setHardwareScalingLevel(level: number): void;
  96469. /**
  96470. * Gets the current hardware scaling level.
  96471. * By default the hardware scaling level is computed from the window device ratio.
  96472. * 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.
  96473. * @returns a number indicating the current hardware scaling level
  96474. */
  96475. getHardwareScalingLevel(): number;
  96476. /**
  96477. * Gets the list of loaded textures
  96478. * @returns an array containing all loaded textures
  96479. */
  96480. getLoadedTexturesCache(): InternalTexture[];
  96481. /**
  96482. * Gets the object containing all engine capabilities
  96483. * @returns the EngineCapabilities object
  96484. */
  96485. getCaps(): EngineCapabilities;
  96486. /**
  96487. * Gets the current depth function
  96488. * @returns a number defining the depth function
  96489. */
  96490. getDepthFunction(): Nullable<number>;
  96491. /**
  96492. * Sets the current depth function
  96493. * @param depthFunc defines the function to use
  96494. */
  96495. setDepthFunction(depthFunc: number): void;
  96496. /**
  96497. * Sets the current depth function to GREATER
  96498. */
  96499. setDepthFunctionToGreater(): void;
  96500. /**
  96501. * Sets the current depth function to GEQUAL
  96502. */
  96503. setDepthFunctionToGreaterOrEqual(): void;
  96504. /**
  96505. * Sets the current depth function to LESS
  96506. */
  96507. setDepthFunctionToLess(): void;
  96508. private _cachedStencilBuffer;
  96509. private _cachedStencilFunction;
  96510. private _cachedStencilMask;
  96511. private _cachedStencilOperationPass;
  96512. private _cachedStencilOperationFail;
  96513. private _cachedStencilOperationDepthFail;
  96514. private _cachedStencilReference;
  96515. /**
  96516. * Caches the the state of the stencil buffer
  96517. */
  96518. cacheStencilState(): void;
  96519. /**
  96520. * Restores the state of the stencil buffer
  96521. */
  96522. restoreStencilState(): void;
  96523. /**
  96524. * Sets the current depth function to LEQUAL
  96525. */
  96526. setDepthFunctionToLessOrEqual(): void;
  96527. /**
  96528. * Gets a boolean indicating if stencil buffer is enabled
  96529. * @returns the current stencil buffer state
  96530. */
  96531. getStencilBuffer(): boolean;
  96532. /**
  96533. * Enable or disable the stencil buffer
  96534. * @param enable defines if the stencil buffer must be enabled or disabled
  96535. */
  96536. setStencilBuffer(enable: boolean): void;
  96537. /**
  96538. * Gets the current stencil mask
  96539. * @returns a number defining the new stencil mask to use
  96540. */
  96541. getStencilMask(): number;
  96542. /**
  96543. * Sets the current stencil mask
  96544. * @param mask defines the new stencil mask to use
  96545. */
  96546. setStencilMask(mask: number): void;
  96547. /**
  96548. * Gets the current stencil function
  96549. * @returns a number defining the stencil function to use
  96550. */
  96551. getStencilFunction(): number;
  96552. /**
  96553. * Gets the current stencil reference value
  96554. * @returns a number defining the stencil reference value to use
  96555. */
  96556. getStencilFunctionReference(): number;
  96557. /**
  96558. * Gets the current stencil mask
  96559. * @returns a number defining the stencil mask to use
  96560. */
  96561. getStencilFunctionMask(): number;
  96562. /**
  96563. * Sets the current stencil function
  96564. * @param stencilFunc defines the new stencil function to use
  96565. */
  96566. setStencilFunction(stencilFunc: number): void;
  96567. /**
  96568. * Sets the current stencil reference
  96569. * @param reference defines the new stencil reference to use
  96570. */
  96571. setStencilFunctionReference(reference: number): void;
  96572. /**
  96573. * Sets the current stencil mask
  96574. * @param mask defines the new stencil mask to use
  96575. */
  96576. setStencilFunctionMask(mask: number): void;
  96577. /**
  96578. * Gets the current stencil operation when stencil fails
  96579. * @returns a number defining stencil operation to use when stencil fails
  96580. */
  96581. getStencilOperationFail(): number;
  96582. /**
  96583. * Gets the current stencil operation when depth fails
  96584. * @returns a number defining stencil operation to use when depth fails
  96585. */
  96586. getStencilOperationDepthFail(): number;
  96587. /**
  96588. * Gets the current stencil operation when stencil passes
  96589. * @returns a number defining stencil operation to use when stencil passes
  96590. */
  96591. getStencilOperationPass(): number;
  96592. /**
  96593. * Sets the stencil operation to use when stencil fails
  96594. * @param operation defines the stencil operation to use when stencil fails
  96595. */
  96596. setStencilOperationFail(operation: number): void;
  96597. /**
  96598. * Sets the stencil operation to use when depth fails
  96599. * @param operation defines the stencil operation to use when depth fails
  96600. */
  96601. setStencilOperationDepthFail(operation: number): void;
  96602. /**
  96603. * Sets the stencil operation to use when stencil passes
  96604. * @param operation defines the stencil operation to use when stencil passes
  96605. */
  96606. setStencilOperationPass(operation: number): void;
  96607. /**
  96608. * Sets a boolean indicating if the dithering state is enabled or disabled
  96609. * @param value defines the dithering state
  96610. */
  96611. setDitheringState(value: boolean): void;
  96612. /**
  96613. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  96614. * @param value defines the rasterizer state
  96615. */
  96616. setRasterizerState(value: boolean): void;
  96617. /**
  96618. * stop executing a render loop function and remove it from the execution array
  96619. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96620. */
  96621. stopRenderLoop(renderFunction?: () => void): void;
  96622. /** @hidden */
  96623. _renderLoop(): void;
  96624. /**
  96625. * Can be used to override the current requestAnimationFrame requester.
  96626. * @hidden
  96627. */
  96628. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96629. /**
  96630. * Register and execute a render loop. The engine can have more than one render function
  96631. * @param renderFunction defines the function to continuously execute
  96632. */
  96633. runRenderLoop(renderFunction: () => void): void;
  96634. /**
  96635. * Toggle full screen mode
  96636. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96637. */
  96638. switchFullscreen(requestPointerLock: boolean): void;
  96639. /**
  96640. * Enters full screen mode
  96641. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96642. */
  96643. enterFullscreen(requestPointerLock: boolean): void;
  96644. /**
  96645. * Exits full screen mode
  96646. */
  96647. exitFullscreen(): void;
  96648. /**
  96649. * Enters Pointerlock mode
  96650. */
  96651. enterPointerlock(): void;
  96652. /**
  96653. * Exits Pointerlock mode
  96654. */
  96655. exitPointerlock(): void;
  96656. /**
  96657. * Clear the current render buffer or the current render target (if any is set up)
  96658. * @param color defines the color to use
  96659. * @param backBuffer defines if the back buffer must be cleared
  96660. * @param depth defines if the depth buffer must be cleared
  96661. * @param stencil defines if the stencil buffer must be cleared
  96662. */
  96663. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96664. /**
  96665. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  96666. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96667. * @param y defines the y-coordinate of the corner of the clear rectangle
  96668. * @param width defines the width of the clear rectangle
  96669. * @param height defines the height of the clear rectangle
  96670. * @param clearColor defines the clear color
  96671. */
  96672. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  96673. /**
  96674. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  96675. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96676. * @param y defines the y-coordinate of the corner of the clear rectangle
  96677. * @param width defines the width of the clear rectangle
  96678. * @param height defines the height of the clear rectangle
  96679. */
  96680. enableScissor(x: number, y: number, width: number, height: number): void;
  96681. /**
  96682. * Disable previously set scissor test rectangle
  96683. */
  96684. disableScissor(): void;
  96685. private _viewportCached;
  96686. /** @hidden */
  96687. _viewport(x: number, y: number, width: number, height: number): void;
  96688. /**
  96689. * Set the WebGL's viewport
  96690. * @param viewport defines the viewport element to be used
  96691. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96692. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96693. */
  96694. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96695. /**
  96696. * Directly set the WebGL Viewport
  96697. * @param x defines the x coordinate of the viewport (in screen space)
  96698. * @param y defines the y coordinate of the viewport (in screen space)
  96699. * @param width defines the width of the viewport (in screen space)
  96700. * @param height defines the height of the viewport (in screen space)
  96701. * @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
  96702. */
  96703. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  96704. /**
  96705. * Begin a new frame
  96706. */
  96707. beginFrame(): void;
  96708. /**
  96709. * Enf the current frame
  96710. */
  96711. endFrame(): void;
  96712. /**
  96713. * Resize the view according to the canvas' size
  96714. */
  96715. resize(): void;
  96716. /**
  96717. * Force a specific size of the canvas
  96718. * @param width defines the new canvas' width
  96719. * @param height defines the new canvas' height
  96720. */
  96721. setSize(width: number, height: number): void;
  96722. /**
  96723. * Binds the frame buffer to the specified texture.
  96724. * @param texture The texture to render to or null for the default canvas
  96725. * @param faceIndex The face of the texture to render to in case of cube texture
  96726. * @param requiredWidth The width of the target to render to
  96727. * @param requiredHeight The height of the target to render to
  96728. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96729. * @param depthStencilTexture The depth stencil texture to use to render
  96730. * @param lodLevel defines le lod level to bind to the frame buffer
  96731. */
  96732. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96733. /** @hidden */
  96734. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96735. /**
  96736. * Unbind the current render target texture from the webGL context
  96737. * @param texture defines the render target texture to unbind
  96738. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96739. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96740. */
  96741. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96742. /**
  96743. * Force the mipmap generation for the given render target texture
  96744. * @param texture defines the render target texture to use
  96745. */
  96746. generateMipMapsForCubemap(texture: InternalTexture): void;
  96747. /**
  96748. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96749. */
  96750. flushFramebuffer(): void;
  96751. /**
  96752. * Unbind the current render target and bind the default framebuffer
  96753. */
  96754. restoreDefaultFramebuffer(): void;
  96755. /**
  96756. * Create an uniform buffer
  96757. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96758. * @param elements defines the content of the uniform buffer
  96759. * @returns the webGL uniform buffer
  96760. */
  96761. createUniformBuffer(elements: FloatArray): DataBuffer;
  96762. /**
  96763. * Create a dynamic uniform buffer
  96764. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96765. * @param elements defines the content of the uniform buffer
  96766. * @returns the webGL uniform buffer
  96767. */
  96768. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  96769. /**
  96770. * Update an existing uniform buffer
  96771. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96772. * @param uniformBuffer defines the target uniform buffer
  96773. * @param elements defines the content to update
  96774. * @param offset defines the offset in the uniform buffer where update should start
  96775. * @param count defines the size of the data to update
  96776. */
  96777. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  96778. private _resetVertexBufferBinding;
  96779. /**
  96780. * Creates a vertex buffer
  96781. * @param data the data for the vertex buffer
  96782. * @returns the new WebGL static buffer
  96783. */
  96784. createVertexBuffer(data: DataArray): DataBuffer;
  96785. /**
  96786. * Creates a dynamic vertex buffer
  96787. * @param data the data for the dynamic vertex buffer
  96788. * @returns the new WebGL dynamic buffer
  96789. */
  96790. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96791. /**
  96792. * Update a dynamic index buffer
  96793. * @param indexBuffer defines the target index buffer
  96794. * @param indices defines the data to update
  96795. * @param offset defines the offset in the target index buffer where update should start
  96796. */
  96797. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96798. /**
  96799. * Updates a dynamic vertex buffer.
  96800. * @param vertexBuffer the vertex buffer to update
  96801. * @param data the data used to update the vertex buffer
  96802. * @param byteOffset the byte offset of the data
  96803. * @param byteLength the byte length of the data
  96804. */
  96805. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96806. private _resetIndexBufferBinding;
  96807. /**
  96808. * Creates a new index buffer
  96809. * @param indices defines the content of the index buffer
  96810. * @param updatable defines if the index buffer must be updatable
  96811. * @returns a new webGL buffer
  96812. */
  96813. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96814. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96815. /**
  96816. * Bind a webGL buffer to the webGL context
  96817. * @param buffer defines the buffer to bind
  96818. */
  96819. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96820. /**
  96821. * Bind an uniform buffer to the current webGL context
  96822. * @param buffer defines the buffer to bind
  96823. */
  96824. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  96825. /**
  96826. * Bind a buffer to the current webGL context at a given location
  96827. * @param buffer defines the buffer to bind
  96828. * @param location defines the index where to bind the buffer
  96829. */
  96830. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  96831. /**
  96832. * Bind a specific block at a given index in a specific shader program
  96833. * @param pipelineContext defines the pipeline context to use
  96834. * @param blockName defines the block name
  96835. * @param index defines the index where to bind the block
  96836. */
  96837. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  96838. private bindIndexBuffer;
  96839. private bindBuffer;
  96840. /**
  96841. * update the bound buffer with the given data
  96842. * @param data defines the data to update
  96843. */
  96844. updateArrayBuffer(data: Float32Array): void;
  96845. private _vertexAttribPointer;
  96846. private _bindIndexBufferWithCache;
  96847. private _bindVertexBuffersAttributes;
  96848. /**
  96849. * Records a vertex array object
  96850. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96851. * @param vertexBuffers defines the list of vertex buffers to store
  96852. * @param indexBuffer defines the index buffer to store
  96853. * @param effect defines the effect to store
  96854. * @returns the new vertex array object
  96855. */
  96856. recordVertexArrayObject(vertexBuffers: {
  96857. [key: string]: VertexBuffer;
  96858. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96859. /**
  96860. * Bind a specific vertex array object
  96861. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96862. * @param vertexArrayObject defines the vertex array object to bind
  96863. * @param indexBuffer defines the index buffer to bind
  96864. */
  96865. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96866. /**
  96867. * Bind webGl buffers directly to the webGL context
  96868. * @param vertexBuffer defines the vertex buffer to bind
  96869. * @param indexBuffer defines the index buffer to bind
  96870. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96871. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96872. * @param effect defines the effect associated with the vertex buffer
  96873. */
  96874. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96875. private _unbindVertexArrayObject;
  96876. /**
  96877. * Bind a list of vertex buffers to the webGL context
  96878. * @param vertexBuffers defines the list of vertex buffers to bind
  96879. * @param indexBuffer defines the index buffer to bind
  96880. * @param effect defines the effect associated with the vertex buffers
  96881. */
  96882. bindBuffers(vertexBuffers: {
  96883. [key: string]: Nullable<VertexBuffer>;
  96884. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96885. /**
  96886. * Unbind all instance attributes
  96887. */
  96888. unbindInstanceAttributes(): void;
  96889. /**
  96890. * Release and free the memory of a vertex array object
  96891. * @param vao defines the vertex array object to delete
  96892. */
  96893. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96894. /** @hidden */
  96895. _releaseBuffer(buffer: DataBuffer): boolean;
  96896. protected _deleteBuffer(buffer: DataBuffer): void;
  96897. /**
  96898. * Creates a webGL buffer to use with instanciation
  96899. * @param capacity defines the size of the buffer
  96900. * @returns the webGL buffer
  96901. */
  96902. createInstancesBuffer(capacity: number): DataBuffer;
  96903. /**
  96904. * Delete a webGL buffer used with instanciation
  96905. * @param buffer defines the webGL buffer to delete
  96906. */
  96907. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96908. /**
  96909. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96910. * @param instancesBuffer defines the webGL buffer to update and bind
  96911. * @param data defines the data to store in the buffer
  96912. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96913. */
  96914. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96915. /**
  96916. * Apply all cached states (depth, culling, stencil and alpha)
  96917. */
  96918. applyStates(): void;
  96919. /**
  96920. * Send a draw order
  96921. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96922. * @param indexStart defines the starting index
  96923. * @param indexCount defines the number of index to draw
  96924. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96925. */
  96926. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96927. /**
  96928. * Draw a list of points
  96929. * @param verticesStart defines the index of first vertex to draw
  96930. * @param verticesCount defines the count of vertices to draw
  96931. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96932. */
  96933. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96934. /**
  96935. * Draw a list of unindexed primitives
  96936. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96937. * @param verticesStart defines the index of first vertex to draw
  96938. * @param verticesCount defines the count of vertices to draw
  96939. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96940. */
  96941. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96942. /**
  96943. * Draw a list of indexed primitives
  96944. * @param fillMode defines the primitive to use
  96945. * @param indexStart defines the starting index
  96946. * @param indexCount defines the number of index to draw
  96947. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96948. */
  96949. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96950. /**
  96951. * Draw a list of unindexed primitives
  96952. * @param fillMode defines the primitive to use
  96953. * @param verticesStart defines the index of first vertex to draw
  96954. * @param verticesCount defines the count of vertices to draw
  96955. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96956. */
  96957. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96958. private _drawMode;
  96959. /** @hidden */
  96960. _releaseEffect(effect: Effect): void;
  96961. /** @hidden */
  96962. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96963. /**
  96964. * Create a new effect (used to store vertex/fragment shaders)
  96965. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96966. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96967. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96968. * @param samplers defines an array of string used to represent textures
  96969. * @param defines defines the string containing the defines to use to compile the shaders
  96970. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96971. * @param onCompiled defines a function to call when the effect creation is successful
  96972. * @param onError defines a function to call when the effect creation has failed
  96973. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96974. * @returns the new Effect
  96975. */
  96976. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96977. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96978. private _compileShader;
  96979. private _compileRawShader;
  96980. /**
  96981. * Directly creates a webGL program
  96982. * @param pipelineContext defines the pipeline context to attach to
  96983. * @param vertexCode defines the vertex shader code to use
  96984. * @param fragmentCode defines the fragment shader code to use
  96985. * @param context defines the webGL context to use (if not set, the current one will be used)
  96986. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96987. * @returns the new webGL program
  96988. */
  96989. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96990. /**
  96991. * Creates a webGL program
  96992. * @param pipelineContext defines the pipeline context to attach to
  96993. * @param vertexCode defines the vertex shader code to use
  96994. * @param fragmentCode defines the fragment shader code to use
  96995. * @param defines defines the string containing the defines to use to compile the shaders
  96996. * @param context defines the webGL context to use (if not set, the current one will be used)
  96997. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96998. * @returns the new webGL program
  96999. */
  97000. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97001. /**
  97002. * Creates a new pipeline context
  97003. * @returns the new pipeline
  97004. */
  97005. createPipelineContext(): IPipelineContext;
  97006. private _createShaderProgram;
  97007. private _finalizePipelineContext;
  97008. /** @hidden */
  97009. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  97010. /** @hidden */
  97011. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  97012. /** @hidden */
  97013. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  97014. /**
  97015. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  97016. * @param pipelineContext defines the pipeline context to use
  97017. * @param uniformsNames defines the list of uniform names
  97018. * @returns an array of webGL uniform locations
  97019. */
  97020. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  97021. /**
  97022. * Gets the lsit of active attributes for a given webGL program
  97023. * @param pipelineContext defines the pipeline context to use
  97024. * @param attributesNames defines the list of attribute names to get
  97025. * @returns an array of indices indicating the offset of each attribute
  97026. */
  97027. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  97028. /**
  97029. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  97030. * @param effect defines the effect to activate
  97031. */
  97032. enableEffect(effect: Nullable<Effect>): void;
  97033. /**
  97034. * Set the value of an uniform to an array of int32
  97035. * @param uniform defines the webGL uniform location where to store the value
  97036. * @param array defines the array of int32 to store
  97037. */
  97038. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97039. /**
  97040. * Set the value of an uniform to an array of int32 (stored as vec2)
  97041. * @param uniform defines the webGL uniform location where to store the value
  97042. * @param array defines the array of int32 to store
  97043. */
  97044. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97045. /**
  97046. * Set the value of an uniform to an array of int32 (stored as vec3)
  97047. * @param uniform defines the webGL uniform location where to store the value
  97048. * @param array defines the array of int32 to store
  97049. */
  97050. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97051. /**
  97052. * Set the value of an uniform to an array of int32 (stored as vec4)
  97053. * @param uniform defines the webGL uniform location where to store the value
  97054. * @param array defines the array of int32 to store
  97055. */
  97056. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97057. /**
  97058. * Set the value of an uniform to an array of float32
  97059. * @param uniform defines the webGL uniform location where to store the value
  97060. * @param array defines the array of float32 to store
  97061. */
  97062. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97063. /**
  97064. * Set the value of an uniform to an array of float32 (stored as vec2)
  97065. * @param uniform defines the webGL uniform location where to store the value
  97066. * @param array defines the array of float32 to store
  97067. */
  97068. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97069. /**
  97070. * Set the value of an uniform to an array of float32 (stored as vec3)
  97071. * @param uniform defines the webGL uniform location where to store the value
  97072. * @param array defines the array of float32 to store
  97073. */
  97074. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97075. /**
  97076. * Set the value of an uniform to an array of float32 (stored as vec4)
  97077. * @param uniform defines the webGL uniform location where to store the value
  97078. * @param array defines the array of float32 to store
  97079. */
  97080. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97081. /**
  97082. * Set the value of an uniform to an array of number
  97083. * @param uniform defines the webGL uniform location where to store the value
  97084. * @param array defines the array of number to store
  97085. */
  97086. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97087. /**
  97088. * Set the value of an uniform to an array of number (stored as vec2)
  97089. * @param uniform defines the webGL uniform location where to store the value
  97090. * @param array defines the array of number to store
  97091. */
  97092. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97093. /**
  97094. * Set the value of an uniform to an array of number (stored as vec3)
  97095. * @param uniform defines the webGL uniform location where to store the value
  97096. * @param array defines the array of number to store
  97097. */
  97098. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97099. /**
  97100. * Set the value of an uniform to an array of number (stored as vec4)
  97101. * @param uniform defines the webGL uniform location where to store the value
  97102. * @param array defines the array of number to store
  97103. */
  97104. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97105. /**
  97106. * Set the value of an uniform to an array of float32 (stored as matrices)
  97107. * @param uniform defines the webGL uniform location where to store the value
  97108. * @param matrices defines the array of float32 to store
  97109. */
  97110. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  97111. /**
  97112. * Set the value of an uniform to a matrix (3x3)
  97113. * @param uniform defines the webGL uniform location where to store the value
  97114. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  97115. */
  97116. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97117. /**
  97118. * Set the value of an uniform to a matrix (2x2)
  97119. * @param uniform defines the webGL uniform location where to store the value
  97120. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  97121. */
  97122. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97123. /**
  97124. * Set the value of an uniform to a number (int)
  97125. * @param uniform defines the webGL uniform location where to store the value
  97126. * @param value defines the int number to store
  97127. */
  97128. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97129. /**
  97130. * Set the value of an uniform to a number (float)
  97131. * @param uniform defines the webGL uniform location where to store the value
  97132. * @param value defines the float number to store
  97133. */
  97134. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97135. /**
  97136. * Set the value of an uniform to a vec2
  97137. * @param uniform defines the webGL uniform location where to store the value
  97138. * @param x defines the 1st component of the value
  97139. * @param y defines the 2nd component of the value
  97140. */
  97141. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97142. /**
  97143. * Set the value of an uniform to a vec3
  97144. * @param uniform defines the webGL uniform location where to store the value
  97145. * @param x defines the 1st component of the value
  97146. * @param y defines the 2nd component of the value
  97147. * @param z defines the 3rd component of the value
  97148. */
  97149. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97150. /**
  97151. * Set the value of an uniform to a boolean
  97152. * @param uniform defines the webGL uniform location where to store the value
  97153. * @param bool defines the boolean to store
  97154. */
  97155. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  97156. /**
  97157. * Set the value of an uniform to a vec4
  97158. * @param uniform defines the webGL uniform location where to store the value
  97159. * @param x defines the 1st component of the value
  97160. * @param y defines the 2nd component of the value
  97161. * @param z defines the 3rd component of the value
  97162. * @param w defines the 4th component of the value
  97163. */
  97164. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97165. /**
  97166. * Sets a Color4 on a uniform variable
  97167. * @param uniform defines the uniform location
  97168. * @param color4 defines the value to be set
  97169. */
  97170. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  97171. /**
  97172. * Set various states to the webGL context
  97173. * @param culling defines backface culling state
  97174. * @param zOffset defines the value to apply to zOffset (0 by default)
  97175. * @param force defines if states must be applied even if cache is up to date
  97176. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  97177. */
  97178. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97179. /**
  97180. * Set the z offset to apply to current rendering
  97181. * @param value defines the offset to apply
  97182. */
  97183. setZOffset(value: number): void;
  97184. /**
  97185. * Gets the current value of the zOffset
  97186. * @returns the current zOffset state
  97187. */
  97188. getZOffset(): number;
  97189. /**
  97190. * Enable or disable depth buffering
  97191. * @param enable defines the state to set
  97192. */
  97193. setDepthBuffer(enable: boolean): void;
  97194. /**
  97195. * Gets a boolean indicating if depth writing is enabled
  97196. * @returns the current depth writing state
  97197. */
  97198. getDepthWrite(): boolean;
  97199. /**
  97200. * Enable or disable depth writing
  97201. * @param enable defines the state to set
  97202. */
  97203. setDepthWrite(enable: boolean): void;
  97204. /**
  97205. * Enable or disable color writing
  97206. * @param enable defines the state to set
  97207. */
  97208. setColorWrite(enable: boolean): void;
  97209. /**
  97210. * Gets a boolean indicating if color writing is enabled
  97211. * @returns the current color writing state
  97212. */
  97213. getColorWrite(): boolean;
  97214. /**
  97215. * Sets alpha constants used by some alpha blending modes
  97216. * @param r defines the red component
  97217. * @param g defines the green component
  97218. * @param b defines the blue component
  97219. * @param a defines the alpha component
  97220. */
  97221. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  97222. /**
  97223. * Sets the current alpha mode
  97224. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  97225. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  97226. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97227. */
  97228. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97229. /**
  97230. * Gets the current alpha mode
  97231. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97232. * @returns the current alpha mode
  97233. */
  97234. getAlphaMode(): number;
  97235. /**
  97236. * Sets the current alpha equation
  97237. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  97238. */
  97239. setAlphaEquation(equation: number): void;
  97240. /**
  97241. * Gets the current alpha equation.
  97242. * @returns the current alpha equation
  97243. */
  97244. getAlphaEquation(): number;
  97245. /**
  97246. * Clears the list of texture accessible through engine.
  97247. * This can help preventing texture load conflict due to name collision.
  97248. */
  97249. clearInternalTexturesCache(): void;
  97250. /**
  97251. * Force the entire cache to be cleared
  97252. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97253. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97254. */
  97255. wipeCaches(bruteForce?: boolean): void;
  97256. /**
  97257. * Set the compressed texture format to use, based on the formats you have, and the formats
  97258. * supported by the hardware / browser.
  97259. *
  97260. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  97261. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  97262. * to API arguments needed to compressed textures. This puts the burden on the container
  97263. * generator to house the arcane code for determining these for current & future formats.
  97264. *
  97265. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  97266. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  97267. *
  97268. * Note: The result of this call is not taken into account when a texture is base64.
  97269. *
  97270. * @param formatsAvailable defines the list of those format families you have created
  97271. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  97272. *
  97273. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  97274. * @returns The extension selected.
  97275. */
  97276. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  97277. /** @hidden */
  97278. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97279. min: number;
  97280. mag: number;
  97281. };
  97282. /** @hidden */
  97283. _createTexture(): WebGLTexture;
  97284. /**
  97285. * Usually called from Texture.ts.
  97286. * Passed information to create a WebGLTexture
  97287. * @param urlArg defines a value which contains one of the following:
  97288. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97289. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97290. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97291. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97292. * @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)
  97293. * @param scene needed for loading to the correct scene
  97294. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97295. * @param onLoad optional callback to be called upon successful completion
  97296. * @param onError optional callback to be called upon failure
  97297. * @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
  97298. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97299. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97300. * @param forcedExtension defines the extension to use to pick the right loader
  97301. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97302. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97303. */
  97304. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  97305. /**
  97306. * @hidden
  97307. * Rescales a texture
  97308. * @param source input texutre
  97309. * @param destination destination texture
  97310. * @param scene scene to use to render the resize
  97311. * @param internalFormat format to use when resizing
  97312. * @param onComplete callback to be called when resize has completed
  97313. */
  97314. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  97315. private _unpackFlipYCached;
  97316. /**
  97317. * In case you are sharing the context with other applications, it might
  97318. * be interested to not cache the unpack flip y state to ensure a consistent
  97319. * value would be set.
  97320. */
  97321. enableUnpackFlipYCached: boolean;
  97322. /** @hidden */
  97323. _unpackFlipY(value: boolean): void;
  97324. /** @hidden */
  97325. _getUnpackAlignement(): number;
  97326. /**
  97327. * Creates a dynamic texture
  97328. * @param width defines the width of the texture
  97329. * @param height defines the height of the texture
  97330. * @param generateMipMaps defines if the engine should generate the mip levels
  97331. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97332. * @returns the dynamic texture inside an InternalTexture
  97333. */
  97334. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  97335. /**
  97336. * Update the sampling mode of a given texture
  97337. * @param samplingMode defines the required sampling mode
  97338. * @param texture defines the texture to update
  97339. */
  97340. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97341. /**
  97342. * Update the content of a dynamic texture
  97343. * @param texture defines the texture to update
  97344. * @param canvas defines the canvas containing the source
  97345. * @param invertY defines if data must be stored with Y axis inverted
  97346. * @param premulAlpha defines if alpha is stored as premultiplied
  97347. * @param format defines the format of the data
  97348. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  97349. */
  97350. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  97351. /**
  97352. * Update a video texture
  97353. * @param texture defines the texture to update
  97354. * @param video defines the video element to use
  97355. * @param invertY defines if data must be stored with Y axis inverted
  97356. */
  97357. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97358. /**
  97359. * Updates a depth texture Comparison Mode and Function.
  97360. * If the comparison Function is equal to 0, the mode will be set to none.
  97361. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  97362. * @param texture The texture to set the comparison function for
  97363. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  97364. */
  97365. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  97366. /** @hidden */
  97367. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97368. width: number;
  97369. height: number;
  97370. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97371. /**
  97372. * Creates a depth stencil texture.
  97373. * This is only available in WebGL 2 or with the depth texture extension available.
  97374. * @param size The size of face edge in the texture.
  97375. * @param options The options defining the texture.
  97376. * @returns The texture
  97377. */
  97378. createDepthStencilTexture(size: number | {
  97379. width: number;
  97380. height: number;
  97381. }, options: DepthTextureCreationOptions): InternalTexture;
  97382. /**
  97383. * Creates a depth stencil texture.
  97384. * This is only available in WebGL 2 or with the depth texture extension available.
  97385. * @param size The size of face edge in the texture.
  97386. * @param options The options defining the texture.
  97387. * @returns The texture
  97388. */
  97389. private _createDepthStencilTexture;
  97390. /**
  97391. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  97392. * @param renderTarget The render target to set the frame buffer for
  97393. */
  97394. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  97395. /**
  97396. * Creates a new render target texture
  97397. * @param size defines the size of the texture
  97398. * @param options defines the options used to create the texture
  97399. * @returns a new render target texture stored in an InternalTexture
  97400. */
  97401. createRenderTargetTexture(size: number | {
  97402. width: number;
  97403. height: number;
  97404. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97405. /** @hidden */
  97406. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97407. /**
  97408. * Updates the sample count of a render target texture
  97409. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  97410. * @param texture defines the texture to update
  97411. * @param samples defines the sample count to set
  97412. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  97413. */
  97414. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  97415. /** @hidden */
  97416. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97417. /** @hidden */
  97418. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97419. /** @hidden */
  97420. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97421. /** @hidden */
  97422. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97423. /**
  97424. * @hidden
  97425. */
  97426. _setCubeMapTextureParams(loadMipmap: boolean): void;
  97427. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97428. private _prepareWebGLTexture;
  97429. /** @hidden */
  97430. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  97431. /** @hidden */
  97432. _releaseFramebufferObjects(texture: InternalTexture): void;
  97433. /** @hidden */
  97434. _releaseTexture(texture: InternalTexture): void;
  97435. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97436. protected _setProgram(program: WebGLProgram): void;
  97437. protected _boundUniforms: {
  97438. [key: number]: WebGLUniformLocation;
  97439. };
  97440. /**
  97441. * Binds an effect to the webGL context
  97442. * @param effect defines the effect to bind
  97443. */
  97444. bindSamplers(effect: Effect): void;
  97445. private _activateCurrentTexture;
  97446. /** @hidden */
  97447. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97448. /** @hidden */
  97449. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97450. /**
  97451. * Sets a texture to the webGL context from a postprocess
  97452. * @param channel defines the channel to use
  97453. * @param postProcess defines the source postprocess
  97454. */
  97455. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  97456. /**
  97457. * Binds the output of the passed in post process to the texture channel specified
  97458. * @param channel The channel the texture should be bound to
  97459. * @param postProcess The post process which's output should be bound
  97460. */
  97461. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  97462. /**
  97463. * Unbind all textures from the webGL context
  97464. */
  97465. unbindAllTextures(): void;
  97466. /**
  97467. * Sets a texture to the according uniform.
  97468. * @param channel The texture channel
  97469. * @param uniform The uniform to set
  97470. * @param texture The texture to apply
  97471. */
  97472. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97473. /**
  97474. * Sets a depth stencil texture from a render target to the according uniform.
  97475. * @param channel The texture channel
  97476. * @param uniform The uniform to set
  97477. * @param texture The render target texture containing the depth stencil texture to apply
  97478. */
  97479. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  97480. private _bindSamplerUniformToChannel;
  97481. private _getTextureWrapMode;
  97482. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97483. /**
  97484. * Sets an array of texture to the webGL context
  97485. * @param channel defines the channel where the texture array must be set
  97486. * @param uniform defines the associated uniform location
  97487. * @param textures defines the array of textures to bind
  97488. */
  97489. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97490. /** @hidden */
  97491. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97492. private _setTextureParameterFloat;
  97493. private _setTextureParameterInteger;
  97494. /**
  97495. * Reads pixels from the current frame buffer. Please note that this function can be slow
  97496. * @param x defines the x coordinate of the rectangle where pixels must be read
  97497. * @param y defines the y coordinate of the rectangle where pixels must be read
  97498. * @param width defines the width of the rectangle where pixels must be read
  97499. * @param height defines the height of the rectangle where pixels must be read
  97500. * @returns a Uint8Array containing RGBA colors
  97501. */
  97502. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  97503. /**
  97504. * Add an externaly attached data from its key.
  97505. * This method call will fail and return false, if such key already exists.
  97506. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  97507. * @param key the unique key that identifies the data
  97508. * @param data the data object to associate to the key for this Engine instance
  97509. * @return true if no such key were already present and the data was added successfully, false otherwise
  97510. */
  97511. addExternalData<T>(key: string, data: T): boolean;
  97512. /**
  97513. * Get an externaly attached data from its key
  97514. * @param key the unique key that identifies the data
  97515. * @return the associated data, if present (can be null), or undefined if not present
  97516. */
  97517. getExternalData<T>(key: string): T;
  97518. /**
  97519. * Get an externaly attached data from its key, create it using a factory if it's not already present
  97520. * @param key the unique key that identifies the data
  97521. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  97522. * @return the associated data, can be null if the factory returned null.
  97523. */
  97524. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  97525. /**
  97526. * Remove an externaly attached data from the Engine instance
  97527. * @param key the unique key that identifies the data
  97528. * @return true if the data was successfully removed, false if it doesn't exist
  97529. */
  97530. removeExternalData(key: string): boolean;
  97531. /**
  97532. * Unbind all vertex attributes from the webGL context
  97533. */
  97534. unbindAllAttributes(): void;
  97535. /**
  97536. * 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
  97537. */
  97538. releaseEffects(): void;
  97539. /**
  97540. * Dispose and release all associated resources
  97541. */
  97542. dispose(): void;
  97543. /**
  97544. * Display the loading screen
  97545. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97546. */
  97547. displayLoadingUI(): void;
  97548. /**
  97549. * Hide the loading screen
  97550. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97551. */
  97552. hideLoadingUI(): void;
  97553. /**
  97554. * Gets the current loading screen object
  97555. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97556. */
  97557. /**
  97558. * Sets the current loading screen object
  97559. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97560. */
  97561. loadingScreen: ILoadingScreen;
  97562. /**
  97563. * Sets the current loading screen text
  97564. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97565. */
  97566. loadingUIText: string;
  97567. /**
  97568. * Sets the current loading screen background color
  97569. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97570. */
  97571. loadingUIBackgroundColor: string;
  97572. /**
  97573. * Attach a new callback raised when context lost event is fired
  97574. * @param callback defines the callback to call
  97575. */
  97576. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97577. /**
  97578. * Attach a new callback raised when context restored event is fired
  97579. * @param callback defines the callback to call
  97580. */
  97581. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97582. /**
  97583. * Gets the source code of the vertex shader associated with a specific webGL program
  97584. * @param program defines the program to use
  97585. * @returns a string containing the source code of the vertex shader associated with the program
  97586. */
  97587. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  97588. /**
  97589. * Gets the source code of the fragment shader associated with a specific webGL program
  97590. * @param program defines the program to use
  97591. * @returns a string containing the source code of the fragment shader associated with the program
  97592. */
  97593. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  97594. /**
  97595. * Get the current error code of the webGL context
  97596. * @returns the error code
  97597. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97598. */
  97599. getError(): number;
  97600. /**
  97601. * Gets the current framerate
  97602. * @returns a number representing the framerate
  97603. */
  97604. getFps(): number;
  97605. /**
  97606. * Gets the time spent between current and previous frame
  97607. * @returns a number representing the delta time in ms
  97608. */
  97609. getDeltaTime(): number;
  97610. private _measureFps;
  97611. /** @hidden */
  97612. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  97613. private _canRenderToFloatFramebuffer;
  97614. private _canRenderToHalfFloatFramebuffer;
  97615. private _canRenderToFramebuffer;
  97616. /** @hidden */
  97617. _getWebGLTextureType(type: number): number;
  97618. /** @hidden */
  97619. _getInternalFormat(format: number): number;
  97620. /** @hidden */
  97621. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97622. /** @hidden */
  97623. _getRGBAMultiSampleBufferFormat(type: number): number;
  97624. /** @hidden */
  97625. _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;
  97626. /** @hidden */
  97627. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97628. /**
  97629. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97630. * @returns true if the engine can be created
  97631. * @ignorenaming
  97632. */
  97633. static isSupported(): boolean;
  97634. /**
  97635. * Find the next highest power of two.
  97636. * @param x Number to start search from.
  97637. * @return Next highest power of two.
  97638. */
  97639. static CeilingPOT(x: number): number;
  97640. /**
  97641. * Find the next lowest power of two.
  97642. * @param x Number to start search from.
  97643. * @return Next lowest power of two.
  97644. */
  97645. static FloorPOT(x: number): number;
  97646. /**
  97647. * Find the nearest power of two.
  97648. * @param x Number to start search from.
  97649. * @return Next nearest power of two.
  97650. */
  97651. static NearestPOT(x: number): number;
  97652. /**
  97653. * Get the closest exponent of two
  97654. * @param value defines the value to approximate
  97655. * @param max defines the maximum value to return
  97656. * @param mode defines how to define the closest value
  97657. * @returns closest exponent of two of the given value
  97658. */
  97659. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97660. /**
  97661. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97662. * @param func - the function to be called
  97663. * @param requester - the object that will request the next frame. Falls back to window.
  97664. * @returns frame number
  97665. */
  97666. static QueueNewFrame(func: () => void, requester?: any): number;
  97667. /**
  97668. * Ask the browser to promote the current element to pointerlock mode
  97669. * @param element defines the DOM element to promote
  97670. */
  97671. static _RequestPointerlock(element: HTMLElement): void;
  97672. /**
  97673. * Asks the browser to exit pointerlock mode
  97674. */
  97675. static _ExitPointerlock(): void;
  97676. /**
  97677. * Ask the browser to promote the current element to fullscreen rendering mode
  97678. * @param element defines the DOM element to promote
  97679. */
  97680. static _RequestFullscreen(element: HTMLElement): void;
  97681. /**
  97682. * Asks the browser to exit fullscreen mode
  97683. */
  97684. static _ExitFullscreen(): void;
  97685. }
  97686. }
  97687. declare module BABYLON {
  97688. /**
  97689. * The engine store class is responsible to hold all the instances of Engine and Scene created
  97690. * during the life time of the application.
  97691. */
  97692. export class EngineStore {
  97693. /** Gets the list of created engines */
  97694. static Instances: Engine[];
  97695. /** @hidden */
  97696. static _LastCreatedScene: Nullable<Scene>;
  97697. /**
  97698. * Gets the latest created engine
  97699. */
  97700. static readonly LastCreatedEngine: Nullable<Engine>;
  97701. /**
  97702. * Gets the latest created scene
  97703. */
  97704. static readonly LastCreatedScene: Nullable<Scene>;
  97705. /**
  97706. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97707. * @ignorenaming
  97708. */
  97709. static UseFallbackTexture: boolean;
  97710. /**
  97711. * Texture content used if a texture cannot loaded
  97712. * @ignorenaming
  97713. */
  97714. static FallbackTexture: string;
  97715. }
  97716. }
  97717. declare module BABYLON {
  97718. /**
  97719. * Helper class that provides a small promise polyfill
  97720. */
  97721. export class PromisePolyfill {
  97722. /**
  97723. * Static function used to check if the polyfill is required
  97724. * If this is the case then the function will inject the polyfill to window.Promise
  97725. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  97726. */
  97727. static Apply(force?: boolean): void;
  97728. }
  97729. }
  97730. declare module BABYLON {
  97731. /**
  97732. * Interface for screenshot methods with describe argument called `size` as object with options
  97733. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  97734. */
  97735. export interface IScreenshotSize {
  97736. /**
  97737. * number in pixels for canvas height
  97738. */
  97739. height?: number;
  97740. /**
  97741. * multiplier allowing render at a higher or lower resolution
  97742. * If value is defined then height and width will be ignored and taken from camera
  97743. */
  97744. precision?: number;
  97745. /**
  97746. * number in pixels for canvas width
  97747. */
  97748. width?: number;
  97749. }
  97750. }
  97751. declare module BABYLON {
  97752. interface IColor4Like {
  97753. r: float;
  97754. g: float;
  97755. b: float;
  97756. a: float;
  97757. }
  97758. /**
  97759. * Class containing a set of static utilities functions
  97760. */
  97761. export class Tools {
  97762. /**
  97763. * Gets or sets the base URL to use to load assets
  97764. */
  97765. static BaseUrl: string;
  97766. /**
  97767. * Enable/Disable Custom HTTP Request Headers globally.
  97768. * default = false
  97769. * @see CustomRequestHeaders
  97770. */
  97771. static UseCustomRequestHeaders: boolean;
  97772. /**
  97773. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  97774. * i.e. when loading files, where the server/service expects an Authorization header
  97775. */
  97776. static CustomRequestHeaders: {
  97777. [key: string]: string;
  97778. };
  97779. /**
  97780. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  97781. */
  97782. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  97783. /**
  97784. * Default behaviour for cors in the application.
  97785. * It can be a string if the expected behavior is identical in the entire app.
  97786. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  97787. */
  97788. static CorsBehavior: string | ((url: string | string[]) => string);
  97789. /**
  97790. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97791. * @ignorenaming
  97792. */
  97793. static UseFallbackTexture: boolean;
  97794. /**
  97795. * Use this object to register external classes like custom textures or material
  97796. * to allow the laoders to instantiate them
  97797. */
  97798. static RegisteredExternalClasses: {
  97799. [key: string]: Object;
  97800. };
  97801. /**
  97802. * Texture content used if a texture cannot loaded
  97803. * @ignorenaming
  97804. */
  97805. static fallbackTexture: string;
  97806. /**
  97807. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97808. * @param u defines the coordinate on X axis
  97809. * @param v defines the coordinate on Y axis
  97810. * @param width defines the width of the source data
  97811. * @param height defines the height of the source data
  97812. * @param pixels defines the source byte array
  97813. * @param color defines the output color
  97814. */
  97815. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  97816. /**
  97817. * Interpolates between a and b via alpha
  97818. * @param a The lower value (returned when alpha = 0)
  97819. * @param b The upper value (returned when alpha = 1)
  97820. * @param alpha The interpolation-factor
  97821. * @return The mixed value
  97822. */
  97823. static Mix(a: number, b: number, alpha: number): number;
  97824. /**
  97825. * Tries to instantiate a new object from a given class name
  97826. * @param className defines the class name to instantiate
  97827. * @returns the new object or null if the system was not able to do the instantiation
  97828. */
  97829. static Instantiate(className: string): any;
  97830. /**
  97831. * Provides a slice function that will work even on IE
  97832. * @param data defines the array to slice
  97833. * @param start defines the start of the data (optional)
  97834. * @param end defines the end of the data (optional)
  97835. * @returns the new sliced array
  97836. */
  97837. static Slice<T>(data: T, start?: number, end?: number): T;
  97838. /**
  97839. * Polyfill for setImmediate
  97840. * @param action defines the action to execute after the current execution block
  97841. */
  97842. static SetImmediate(action: () => void): void;
  97843. /**
  97844. * Function indicating if a number is an exponent of 2
  97845. * @param value defines the value to test
  97846. * @returns true if the value is an exponent of 2
  97847. */
  97848. static IsExponentOfTwo(value: number): boolean;
  97849. private static _tmpFloatArray;
  97850. /**
  97851. * Returns the nearest 32-bit single precision float representation of a Number
  97852. * @param value A Number. If the parameter is of a different type, it will get converted
  97853. * to a number or to NaN if it cannot be converted
  97854. * @returns number
  97855. */
  97856. static FloatRound(value: number): number;
  97857. /**
  97858. * Extracts the filename from a path
  97859. * @param path defines the path to use
  97860. * @returns the filename
  97861. */
  97862. static GetFilename(path: string): string;
  97863. /**
  97864. * Extracts the "folder" part of a path (everything before the filename).
  97865. * @param uri The URI to extract the info from
  97866. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97867. * @returns The "folder" part of the path
  97868. */
  97869. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  97870. /**
  97871. * Extracts text content from a DOM element hierarchy
  97872. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  97873. */
  97874. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  97875. /**
  97876. * Convert an angle in radians to degrees
  97877. * @param angle defines the angle to convert
  97878. * @returns the angle in degrees
  97879. */
  97880. static ToDegrees(angle: number): number;
  97881. /**
  97882. * Convert an angle in degrees to radians
  97883. * @param angle defines the angle to convert
  97884. * @returns the angle in radians
  97885. */
  97886. static ToRadians(angle: number): number;
  97887. /**
  97888. * Encode a buffer to a base64 string
  97889. * @param buffer defines the buffer to encode
  97890. * @returns the encoded string
  97891. */
  97892. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  97893. /**
  97894. * Returns an array if obj is not an array
  97895. * @param obj defines the object to evaluate as an array
  97896. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97897. * @returns either obj directly if obj is an array or a new array containing obj
  97898. */
  97899. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  97900. /**
  97901. * Gets the pointer prefix to use
  97902. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97903. */
  97904. static GetPointerPrefix(): string;
  97905. /**
  97906. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97907. * @param url define the url we are trying
  97908. * @param element define the dom element where to configure the cors policy
  97909. */
  97910. static SetCorsBehavior(url: string | string[], element: {
  97911. crossOrigin: string | null;
  97912. }): void;
  97913. /**
  97914. * Removes unwanted characters from an url
  97915. * @param url defines the url to clean
  97916. * @returns the cleaned url
  97917. */
  97918. static CleanUrl(url: string): string;
  97919. /**
  97920. * Gets or sets a function used to pre-process url before using them to load assets
  97921. */
  97922. static PreprocessUrl: (url: string) => string;
  97923. /**
  97924. * Loads an image as an HTMLImageElement.
  97925. * @param input url string, ArrayBuffer, or Blob to load
  97926. * @param onLoad callback called when the image successfully loads
  97927. * @param onError callback called when the image fails to load
  97928. * @param offlineProvider offline provider for caching
  97929. * @returns the HTMLImageElement of the loaded image
  97930. */
  97931. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  97932. /**
  97933. * Loads a file
  97934. * @param url url string, ArrayBuffer, or Blob to load
  97935. * @param onSuccess callback called when the file successfully loads
  97936. * @param onProgress callback called while file is loading (if the server supports this mode)
  97937. * @param offlineProvider defines the offline provider for caching
  97938. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97939. * @param onError callback called when the file fails to load
  97940. * @returns a file request object
  97941. */
  97942. 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;
  97943. /**
  97944. * Loads a file from a url
  97945. * @param url the file url to load
  97946. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  97947. */
  97948. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  97949. /**
  97950. * Load a script (identified by an url). When the url returns, the
  97951. * content of this file is added into a new script element, attached to the DOM (body element)
  97952. * @param scriptUrl defines the url of the script to laod
  97953. * @param onSuccess defines the callback called when the script is loaded
  97954. * @param onError defines the callback to call if an error occurs
  97955. * @param scriptId defines the id of the script element
  97956. */
  97957. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  97958. /**
  97959. * Load an asynchronous script (identified by an url). When the url returns, the
  97960. * content of this file is added into a new script element, attached to the DOM (body element)
  97961. * @param scriptUrl defines the url of the script to laod
  97962. * @param scriptId defines the id of the script element
  97963. * @returns a promise request object
  97964. */
  97965. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  97966. /**
  97967. * Loads a file from a blob
  97968. * @param fileToLoad defines the blob to use
  97969. * @param callback defines the callback to call when data is loaded
  97970. * @param progressCallback defines the callback to call during loading process
  97971. * @returns a file request object
  97972. */
  97973. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  97974. /**
  97975. * Loads a file
  97976. * @param fileToLoad defines the file to load
  97977. * @param callback defines the callback to call when data is loaded
  97978. * @param progressCallBack defines the callback to call during loading process
  97979. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97980. * @returns a file request object
  97981. */
  97982. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  97983. /**
  97984. * Creates a data url from a given string content
  97985. * @param content defines the content to convert
  97986. * @returns the new data url link
  97987. */
  97988. static FileAsURL(content: string): string;
  97989. /**
  97990. * Format the given number to a specific decimal format
  97991. * @param value defines the number to format
  97992. * @param decimals defines the number of decimals to use
  97993. * @returns the formatted string
  97994. */
  97995. static Format(value: number, decimals?: number): string;
  97996. /**
  97997. * Tries to copy an object by duplicating every property
  97998. * @param source defines the source object
  97999. * @param destination defines the target object
  98000. * @param doNotCopyList defines a list of properties to avoid
  98001. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98002. */
  98003. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98004. /**
  98005. * Gets a boolean indicating if the given object has no own property
  98006. * @param obj defines the object to test
  98007. * @returns true if object has no own property
  98008. */
  98009. static IsEmpty(obj: any): boolean;
  98010. /**
  98011. * Function used to register events at window level
  98012. * @param windowElement defines the Window object to use
  98013. * @param events defines the events to register
  98014. */
  98015. static RegisterTopRootEvents(windowElement: Window, events: {
  98016. name: string;
  98017. handler: Nullable<(e: FocusEvent) => any>;
  98018. }[]): void;
  98019. /**
  98020. * Function used to unregister events from window level
  98021. * @param windowElement defines the Window object to use
  98022. * @param events defines the events to unregister
  98023. */
  98024. static UnregisterTopRootEvents(windowElement: Window, events: {
  98025. name: string;
  98026. handler: Nullable<(e: FocusEvent) => any>;
  98027. }[]): void;
  98028. /**
  98029. * @ignore
  98030. */
  98031. static _ScreenshotCanvas: HTMLCanvasElement;
  98032. /**
  98033. * Dumps the current bound framebuffer
  98034. * @param width defines the rendering width
  98035. * @param height defines the rendering height
  98036. * @param engine defines the hosting engine
  98037. * @param successCallback defines the callback triggered once the data are available
  98038. * @param mimeType defines the mime type of the result
  98039. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98040. */
  98041. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98042. /**
  98043. * Converts the canvas data to blob.
  98044. * This acts as a polyfill for browsers not supporting the to blob function.
  98045. * @param canvas Defines the canvas to extract the data from
  98046. * @param successCallback Defines the callback triggered once the data are available
  98047. * @param mimeType Defines the mime type of the result
  98048. */
  98049. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98050. /**
  98051. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98052. * @param successCallback defines the callback triggered once the data are available
  98053. * @param mimeType defines the mime type of the result
  98054. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98055. */
  98056. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98057. /**
  98058. * Downloads a blob in the browser
  98059. * @param blob defines the blob to download
  98060. * @param fileName defines the name of the downloaded file
  98061. */
  98062. static Download(blob: Blob, fileName: string): void;
  98063. /**
  98064. * Captures a screenshot of the current rendering
  98065. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98066. * @param engine defines the rendering engine
  98067. * @param camera defines the source camera
  98068. * @param size This parameter can be set to a single number or to an object with the
  98069. * following (optional) properties: precision, width, height. If a single number is passed,
  98070. * it will be used for both width and height. If an object is passed, the screenshot size
  98071. * will be derived from the parameters. The precision property is a multiplier allowing
  98072. * rendering at a higher or lower resolution
  98073. * @param successCallback defines the callback receives a single parameter which contains the
  98074. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98075. * src parameter of an <img> to display it
  98076. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98077. * Check your browser for supported MIME types
  98078. */
  98079. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  98080. /**
  98081. * Captures a screenshot of the current rendering
  98082. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98083. * @param engine defines the rendering engine
  98084. * @param camera defines the source camera
  98085. * @param size This parameter can be set to a single number or to an object with the
  98086. * following (optional) properties: precision, width, height. If a single number is passed,
  98087. * it will be used for both width and height. If an object is passed, the screenshot size
  98088. * will be derived from the parameters. The precision property is a multiplier allowing
  98089. * rendering at a higher or lower resolution
  98090. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98091. * Check your browser for supported MIME types
  98092. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98093. * to the src parameter of an <img> to display it
  98094. */
  98095. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  98096. /**
  98097. * Generates an image screenshot from the specified camera.
  98098. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98099. * @param engine The engine to use for rendering
  98100. * @param camera The camera to use for rendering
  98101. * @param size This parameter can be set to a single number or to an object with the
  98102. * following (optional) properties: precision, width, height. If a single number is passed,
  98103. * it will be used for both width and height. If an object is passed, the screenshot size
  98104. * will be derived from the parameters. The precision property is a multiplier allowing
  98105. * rendering at a higher or lower resolution
  98106. * @param successCallback The callback receives a single parameter which contains the
  98107. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98108. * src parameter of an <img> to display it
  98109. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98110. * Check your browser for supported MIME types
  98111. * @param samples Texture samples (default: 1)
  98112. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98113. * @param fileName A name for for the downloaded file.
  98114. */
  98115. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  98116. /**
  98117. * Generates an image screenshot from the specified camera.
  98118. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98119. * @param engine The engine to use for rendering
  98120. * @param camera The camera to use for rendering
  98121. * @param size This parameter can be set to a single number or to an object with the
  98122. * following (optional) properties: precision, width, height. If a single number is passed,
  98123. * it will be used for both width and height. If an object is passed, the screenshot size
  98124. * will be derived from the parameters. The precision property is a multiplier allowing
  98125. * rendering at a higher or lower resolution
  98126. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98127. * Check your browser for supported MIME types
  98128. * @param samples Texture samples (default: 1)
  98129. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98130. * @param fileName A name for for the downloaded file.
  98131. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98132. * to the src parameter of an <img> to display it
  98133. */
  98134. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  98135. /**
  98136. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98137. * Be aware Math.random() could cause collisions, but:
  98138. * "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"
  98139. * @returns a pseudo random id
  98140. */
  98141. static RandomId(): string;
  98142. /**
  98143. * Test if the given uri is a base64 string
  98144. * @param uri The uri to test
  98145. * @return True if the uri is a base64 string or false otherwise
  98146. */
  98147. static IsBase64(uri: string): boolean;
  98148. /**
  98149. * Decode the given base64 uri.
  98150. * @param uri The uri to decode
  98151. * @return The decoded base64 data.
  98152. */
  98153. static DecodeBase64(uri: string): ArrayBuffer;
  98154. /**
  98155. * Gets the absolute url.
  98156. * @param url the input url
  98157. * @return the absolute url
  98158. */
  98159. static GetAbsoluteUrl(url: string): string;
  98160. /**
  98161. * No log
  98162. */
  98163. static readonly NoneLogLevel: number;
  98164. /**
  98165. * Only message logs
  98166. */
  98167. static readonly MessageLogLevel: number;
  98168. /**
  98169. * Only warning logs
  98170. */
  98171. static readonly WarningLogLevel: number;
  98172. /**
  98173. * Only error logs
  98174. */
  98175. static readonly ErrorLogLevel: number;
  98176. /**
  98177. * All logs
  98178. */
  98179. static readonly AllLogLevel: number;
  98180. /**
  98181. * Gets a value indicating the number of loading errors
  98182. * @ignorenaming
  98183. */
  98184. static readonly errorsCount: number;
  98185. /**
  98186. * Callback called when a new log is added
  98187. */
  98188. static OnNewCacheEntry: (entry: string) => void;
  98189. /**
  98190. * Log a message to the console
  98191. * @param message defines the message to log
  98192. */
  98193. static Log(message: string): void;
  98194. /**
  98195. * Write a warning message to the console
  98196. * @param message defines the message to log
  98197. */
  98198. static Warn(message: string): void;
  98199. /**
  98200. * Write an error message to the console
  98201. * @param message defines the message to log
  98202. */
  98203. static Error(message: string): void;
  98204. /**
  98205. * Gets current log cache (list of logs)
  98206. */
  98207. static readonly LogCache: string;
  98208. /**
  98209. * Clears the log cache
  98210. */
  98211. static ClearLogCache(): void;
  98212. /**
  98213. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98214. */
  98215. static LogLevels: number;
  98216. /**
  98217. * Checks if the window object exists
  98218. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98219. */
  98220. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  98221. /**
  98222. * No performance log
  98223. */
  98224. static readonly PerformanceNoneLogLevel: number;
  98225. /**
  98226. * Use user marks to log performance
  98227. */
  98228. static readonly PerformanceUserMarkLogLevel: number;
  98229. /**
  98230. * Log performance to the console
  98231. */
  98232. static readonly PerformanceConsoleLogLevel: number;
  98233. private static _performance;
  98234. /**
  98235. * Sets the current performance log level
  98236. */
  98237. static PerformanceLogLevel: number;
  98238. private static _StartPerformanceCounterDisabled;
  98239. private static _EndPerformanceCounterDisabled;
  98240. private static _StartUserMark;
  98241. private static _EndUserMark;
  98242. private static _StartPerformanceConsole;
  98243. private static _EndPerformanceConsole;
  98244. /**
  98245. * Starts a performance counter
  98246. */
  98247. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98248. /**
  98249. * Ends a specific performance coutner
  98250. */
  98251. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98252. /**
  98253. * Gets either window.performance.now() if supported or Date.now() else
  98254. */
  98255. static readonly Now: number;
  98256. /**
  98257. * This method will return the name of the class used to create the instance of the given object.
  98258. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98259. * @param object the object to get the class name from
  98260. * @param isType defines if the object is actually a type
  98261. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98262. */
  98263. static GetClassName(object: any, isType?: boolean): string;
  98264. /**
  98265. * Gets the first element of an array satisfying a given predicate
  98266. * @param array defines the array to browse
  98267. * @param predicate defines the predicate to use
  98268. * @returns null if not found or the element
  98269. */
  98270. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  98271. /**
  98272. * This method will return the name of the full name of the class, including its owning module (if any).
  98273. * 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).
  98274. * @param object the object to get the class name from
  98275. * @param isType defines if the object is actually a type
  98276. * @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.
  98277. * @ignorenaming
  98278. */
  98279. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  98280. /**
  98281. * Returns a promise that resolves after the given amount of time.
  98282. * @param delay Number of milliseconds to delay
  98283. * @returns Promise that resolves after the given amount of time
  98284. */
  98285. static DelayAsync(delay: number): Promise<void>;
  98286. }
  98287. /**
  98288. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98289. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98290. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98291. * @param name The name of the class, case should be preserved
  98292. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98293. */
  98294. export function className(name: string, module?: string): (target: Object) => void;
  98295. /**
  98296. * An implementation of a loop for asynchronous functions.
  98297. */
  98298. export class AsyncLoop {
  98299. /**
  98300. * Defines the number of iterations for the loop
  98301. */
  98302. iterations: number;
  98303. /**
  98304. * Defines the current index of the loop.
  98305. */
  98306. index: number;
  98307. private _done;
  98308. private _fn;
  98309. private _successCallback;
  98310. /**
  98311. * Constructor.
  98312. * @param iterations the number of iterations.
  98313. * @param func the function to run each iteration
  98314. * @param successCallback the callback that will be called upon succesful execution
  98315. * @param offset starting offset.
  98316. */
  98317. constructor(
  98318. /**
  98319. * Defines the number of iterations for the loop
  98320. */
  98321. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  98322. /**
  98323. * Execute the next iteration. Must be called after the last iteration was finished.
  98324. */
  98325. executeNext(): void;
  98326. /**
  98327. * Break the loop and run the success callback.
  98328. */
  98329. breakLoop(): void;
  98330. /**
  98331. * Create and run an async loop.
  98332. * @param iterations the number of iterations.
  98333. * @param fn the function to run each iteration
  98334. * @param successCallback the callback that will be called upon succesful execution
  98335. * @param offset starting offset.
  98336. * @returns the created async loop object
  98337. */
  98338. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  98339. /**
  98340. * A for-loop that will run a given number of iterations synchronous and the rest async.
  98341. * @param iterations total number of iterations
  98342. * @param syncedIterations number of synchronous iterations in each async iteration.
  98343. * @param fn the function to call each iteration.
  98344. * @param callback a success call back that will be called when iterating stops.
  98345. * @param breakFunction a break condition (optional)
  98346. * @param timeout timeout settings for the setTimeout function. default - 0.
  98347. * @returns the created async loop object
  98348. */
  98349. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  98350. }
  98351. }
  98352. declare module BABYLON {
  98353. /** @hidden */
  98354. export interface ICollisionCoordinator {
  98355. createCollider(): Collider;
  98356. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98357. init(scene: Scene): void;
  98358. }
  98359. /** @hidden */
  98360. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  98361. private _scene;
  98362. private _scaledPosition;
  98363. private _scaledVelocity;
  98364. private _finalPosition;
  98365. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98366. createCollider(): Collider;
  98367. init(scene: Scene): void;
  98368. private _collideWithWorld;
  98369. }
  98370. }
  98371. declare module BABYLON {
  98372. /**
  98373. * Class used to manage all inputs for the scene.
  98374. */
  98375. export class InputManager {
  98376. /** The distance in pixel that you have to move to prevent some events */
  98377. static DragMovementThreshold: number;
  98378. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  98379. static LongPressDelay: number;
  98380. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  98381. static DoubleClickDelay: number;
  98382. /** If you need to check double click without raising a single click at first click, enable this flag */
  98383. static ExclusiveDoubleClickMode: boolean;
  98384. private _wheelEventName;
  98385. private _onPointerMove;
  98386. private _onPointerDown;
  98387. private _onPointerUp;
  98388. private _initClickEvent;
  98389. private _initActionManager;
  98390. private _delayedSimpleClick;
  98391. private _delayedSimpleClickTimeout;
  98392. private _previousDelayedSimpleClickTimeout;
  98393. private _meshPickProceed;
  98394. private _previousButtonPressed;
  98395. private _currentPickResult;
  98396. private _previousPickResult;
  98397. private _totalPointersPressed;
  98398. private _doubleClickOccured;
  98399. private _pointerOverMesh;
  98400. private _pickedDownMesh;
  98401. private _pickedUpMesh;
  98402. private _pointerX;
  98403. private _pointerY;
  98404. private _unTranslatedPointerX;
  98405. private _unTranslatedPointerY;
  98406. private _startingPointerPosition;
  98407. private _previousStartingPointerPosition;
  98408. private _startingPointerTime;
  98409. private _previousStartingPointerTime;
  98410. private _pointerCaptures;
  98411. private _onKeyDown;
  98412. private _onKeyUp;
  98413. private _onCanvasFocusObserver;
  98414. private _onCanvasBlurObserver;
  98415. private _scene;
  98416. /**
  98417. * Creates a new InputManager
  98418. * @param scene defines the hosting scene
  98419. */
  98420. constructor(scene: Scene);
  98421. /**
  98422. * Gets the mesh that is currently under the pointer
  98423. */
  98424. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98425. /**
  98426. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  98427. */
  98428. readonly unTranslatedPointer: Vector2;
  98429. /**
  98430. * Gets or sets the current on-screen X position of the pointer
  98431. */
  98432. pointerX: number;
  98433. /**
  98434. * Gets or sets the current on-screen Y position of the pointer
  98435. */
  98436. pointerY: number;
  98437. private _updatePointerPosition;
  98438. private _processPointerMove;
  98439. private _setRayOnPointerInfo;
  98440. private _checkPrePointerObservable;
  98441. /**
  98442. * Use this method to simulate a pointer move on a mesh
  98443. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98444. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98445. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98446. */
  98447. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98448. /**
  98449. * Use this method to simulate a pointer down on a mesh
  98450. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98451. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98452. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98453. */
  98454. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98455. private _processPointerDown;
  98456. /** @hidden */
  98457. _isPointerSwiping(): boolean;
  98458. /**
  98459. * Use this method to simulate a pointer up on a mesh
  98460. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98461. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98462. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98463. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98464. */
  98465. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  98466. private _processPointerUp;
  98467. /**
  98468. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98469. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98470. * @returns true if the pointer was captured
  98471. */
  98472. isPointerCaptured(pointerId?: number): boolean;
  98473. /**
  98474. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98475. * @param attachUp defines if you want to attach events to pointerup
  98476. * @param attachDown defines if you want to attach events to pointerdown
  98477. * @param attachMove defines if you want to attach events to pointermove
  98478. */
  98479. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98480. /**
  98481. * Detaches all event handlers
  98482. */
  98483. detachControl(): void;
  98484. /**
  98485. * Force the value of meshUnderPointer
  98486. * @param mesh defines the mesh to use
  98487. */
  98488. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98489. /**
  98490. * Gets the mesh under the pointer
  98491. * @returns a Mesh or null if no mesh is under the pointer
  98492. */
  98493. getPointerOverMesh(): Nullable<AbstractMesh>;
  98494. }
  98495. }
  98496. declare module BABYLON {
  98497. /**
  98498. * Helper class used to generate session unique ID
  98499. */
  98500. export class UniqueIdGenerator {
  98501. private static _UniqueIdCounter;
  98502. /**
  98503. * Gets an unique (relatively to the current scene) Id
  98504. */
  98505. static readonly UniqueId: number;
  98506. }
  98507. }
  98508. declare module BABYLON {
  98509. /**
  98510. * This class defines the direct association between an animation and a target
  98511. */
  98512. export class TargetedAnimation {
  98513. /**
  98514. * Animation to perform
  98515. */
  98516. animation: Animation;
  98517. /**
  98518. * Target to animate
  98519. */
  98520. target: any;
  98521. /**
  98522. * Serialize the object
  98523. * @returns the JSON object representing the current entity
  98524. */
  98525. serialize(): any;
  98526. }
  98527. /**
  98528. * Use this class to create coordinated animations on multiple targets
  98529. */
  98530. export class AnimationGroup implements IDisposable {
  98531. /** The name of the animation group */
  98532. name: string;
  98533. private _scene;
  98534. private _targetedAnimations;
  98535. private _animatables;
  98536. private _from;
  98537. private _to;
  98538. private _isStarted;
  98539. private _isPaused;
  98540. private _speedRatio;
  98541. private _loopAnimation;
  98542. /**
  98543. * Gets or sets the unique id of the node
  98544. */
  98545. uniqueId: number;
  98546. /**
  98547. * This observable will notify when one animation have ended
  98548. */
  98549. onAnimationEndObservable: Observable<TargetedAnimation>;
  98550. /**
  98551. * Observer raised when one animation loops
  98552. */
  98553. onAnimationLoopObservable: Observable<TargetedAnimation>;
  98554. /**
  98555. * This observable will notify when all animations have ended.
  98556. */
  98557. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  98558. /**
  98559. * This observable will notify when all animations have paused.
  98560. */
  98561. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  98562. /**
  98563. * This observable will notify when all animations are playing.
  98564. */
  98565. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  98566. /**
  98567. * Gets the first frame
  98568. */
  98569. readonly from: number;
  98570. /**
  98571. * Gets the last frame
  98572. */
  98573. readonly to: number;
  98574. /**
  98575. * Define if the animations are started
  98576. */
  98577. readonly isStarted: boolean;
  98578. /**
  98579. * Gets a value indicating that the current group is playing
  98580. */
  98581. readonly isPlaying: boolean;
  98582. /**
  98583. * Gets or sets the speed ratio to use for all animations
  98584. */
  98585. /**
  98586. * Gets or sets the speed ratio to use for all animations
  98587. */
  98588. speedRatio: number;
  98589. /**
  98590. * Gets or sets if all animations should loop or not
  98591. */
  98592. loopAnimation: boolean;
  98593. /**
  98594. * Gets the targeted animations for this animation group
  98595. */
  98596. readonly targetedAnimations: Array<TargetedAnimation>;
  98597. /**
  98598. * returning the list of animatables controlled by this animation group.
  98599. */
  98600. readonly animatables: Array<Animatable>;
  98601. /**
  98602. * Instantiates a new Animation Group.
  98603. * This helps managing several animations at once.
  98604. * @see http://doc.babylonjs.com/how_to/group
  98605. * @param name Defines the name of the group
  98606. * @param scene Defines the scene the group belongs to
  98607. */
  98608. constructor(
  98609. /** The name of the animation group */
  98610. name: string, scene?: Nullable<Scene>);
  98611. /**
  98612. * Add an animation (with its target) in the group
  98613. * @param animation defines the animation we want to add
  98614. * @param target defines the target of the animation
  98615. * @returns the TargetedAnimation object
  98616. */
  98617. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  98618. /**
  98619. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  98620. * It can add constant keys at begin or end
  98621. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  98622. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  98623. * @returns the animation group
  98624. */
  98625. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  98626. /**
  98627. * Start all animations on given targets
  98628. * @param loop defines if animations must loop
  98629. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  98630. * @param from defines the from key (optional)
  98631. * @param to defines the to key (optional)
  98632. * @returns the current animation group
  98633. */
  98634. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  98635. /**
  98636. * Pause all animations
  98637. * @returns the animation group
  98638. */
  98639. pause(): AnimationGroup;
  98640. /**
  98641. * Play all animations to initial state
  98642. * This function will start() the animations if they were not started or will restart() them if they were paused
  98643. * @param loop defines if animations must loop
  98644. * @returns the animation group
  98645. */
  98646. play(loop?: boolean): AnimationGroup;
  98647. /**
  98648. * Reset all animations to initial state
  98649. * @returns the animation group
  98650. */
  98651. reset(): AnimationGroup;
  98652. /**
  98653. * Restart animations from key 0
  98654. * @returns the animation group
  98655. */
  98656. restart(): AnimationGroup;
  98657. /**
  98658. * Stop all animations
  98659. * @returns the animation group
  98660. */
  98661. stop(): AnimationGroup;
  98662. /**
  98663. * Set animation weight for all animatables
  98664. * @param weight defines the weight to use
  98665. * @return the animationGroup
  98666. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98667. */
  98668. setWeightForAllAnimatables(weight: number): AnimationGroup;
  98669. /**
  98670. * Synchronize and normalize all animatables with a source animatable
  98671. * @param root defines the root animatable to synchronize with
  98672. * @return the animationGroup
  98673. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98674. */
  98675. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  98676. /**
  98677. * Goes to a specific frame in this animation group
  98678. * @param frame the frame number to go to
  98679. * @return the animationGroup
  98680. */
  98681. goToFrame(frame: number): AnimationGroup;
  98682. /**
  98683. * Dispose all associated resources
  98684. */
  98685. dispose(): void;
  98686. private _checkAnimationGroupEnded;
  98687. /**
  98688. * Clone the current animation group and returns a copy
  98689. * @param newName defines the name of the new group
  98690. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  98691. * @returns the new aniamtion group
  98692. */
  98693. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  98694. /**
  98695. * Serializes the animationGroup to an object
  98696. * @returns Serialized object
  98697. */
  98698. serialize(): any;
  98699. /**
  98700. * Returns a new AnimationGroup object parsed from the source provided.
  98701. * @param parsedAnimationGroup defines the source
  98702. * @param scene defines the scene that will receive the animationGroup
  98703. * @returns a new AnimationGroup
  98704. */
  98705. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  98706. /**
  98707. * Returns the string "AnimationGroup"
  98708. * @returns "AnimationGroup"
  98709. */
  98710. getClassName(): string;
  98711. /**
  98712. * Creates a detailled string about the object
  98713. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  98714. * @returns a string representing the object
  98715. */
  98716. toString(fullDetails?: boolean): string;
  98717. }
  98718. }
  98719. declare module BABYLON {
  98720. /**
  98721. * Define an interface for all classes that will hold resources
  98722. */
  98723. export interface IDisposable {
  98724. /**
  98725. * Releases all held resources
  98726. */
  98727. dispose(): void;
  98728. }
  98729. /** Interface defining initialization parameters for Scene class */
  98730. export interface SceneOptions {
  98731. /**
  98732. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  98733. * It will improve performance when the number of geometries becomes important.
  98734. */
  98735. useGeometryUniqueIdsMap?: boolean;
  98736. /**
  98737. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  98738. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98739. */
  98740. useMaterialMeshMap?: boolean;
  98741. /**
  98742. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  98743. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98744. */
  98745. useClonedMeshhMap?: boolean;
  98746. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  98747. virtual?: boolean;
  98748. }
  98749. /**
  98750. * Represents a scene to be rendered by the engine.
  98751. * @see http://doc.babylonjs.com/features/scene
  98752. */
  98753. export class Scene extends AbstractScene implements IAnimatable {
  98754. /** The fog is deactivated */
  98755. static readonly FOGMODE_NONE: number;
  98756. /** The fog density is following an exponential function */
  98757. static readonly FOGMODE_EXP: number;
  98758. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  98759. static readonly FOGMODE_EXP2: number;
  98760. /** The fog density is following a linear function. */
  98761. static readonly FOGMODE_LINEAR: number;
  98762. /**
  98763. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  98764. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98765. */
  98766. static MinDeltaTime: number;
  98767. /**
  98768. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  98769. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98770. */
  98771. static MaxDeltaTime: number;
  98772. /**
  98773. * Factory used to create the default material.
  98774. * @param name The name of the material to create
  98775. * @param scene The scene to create the material for
  98776. * @returns The default material
  98777. */
  98778. static DefaultMaterialFactory(scene: Scene): Material;
  98779. /**
  98780. * Factory used to create the a collision coordinator.
  98781. * @returns The collision coordinator
  98782. */
  98783. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  98784. /** @hidden */
  98785. _inputManager: InputManager;
  98786. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  98787. cameraToUseForPointers: Nullable<Camera>;
  98788. /** @hidden */
  98789. readonly _isScene: boolean;
  98790. /**
  98791. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  98792. */
  98793. autoClear: boolean;
  98794. /**
  98795. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  98796. */
  98797. autoClearDepthAndStencil: boolean;
  98798. /**
  98799. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  98800. */
  98801. clearColor: Color4;
  98802. /**
  98803. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  98804. */
  98805. ambientColor: Color3;
  98806. /**
  98807. * This is use to store the default BRDF lookup for PBR materials in your scene.
  98808. * It should only be one of the following (if not the default embedded one):
  98809. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  98810. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  98811. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  98812. * The material properties need to be setup according to the type of texture in use.
  98813. */
  98814. environmentBRDFTexture: BaseTexture;
  98815. /** @hidden */
  98816. protected _environmentTexture: Nullable<BaseTexture>;
  98817. /**
  98818. * Texture used in all pbr material as the reflection texture.
  98819. * As in the majority of the scene they are the same (exception for multi room and so on),
  98820. * this is easier to reference from here than from all the materials.
  98821. */
  98822. /**
  98823. * Texture used in all pbr material as the reflection texture.
  98824. * As in the majority of the scene they are the same (exception for multi room and so on),
  98825. * this is easier to set here than in all the materials.
  98826. */
  98827. environmentTexture: Nullable<BaseTexture>;
  98828. /** @hidden */
  98829. protected _environmentIntensity: number;
  98830. /**
  98831. * Intensity of the environment in all pbr material.
  98832. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98833. * As in the majority of the scene they are the same (exception for multi room and so on),
  98834. * this is easier to reference from here than from all the materials.
  98835. */
  98836. /**
  98837. * Intensity of the environment in all pbr material.
  98838. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98839. * As in the majority of the scene they are the same (exception for multi room and so on),
  98840. * this is easier to set here than in all the materials.
  98841. */
  98842. environmentIntensity: number;
  98843. /** @hidden */
  98844. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98845. /**
  98846. * Default image processing configuration used either in the rendering
  98847. * Forward main pass or through the imageProcessingPostProcess if present.
  98848. * As in the majority of the scene they are the same (exception for multi camera),
  98849. * this is easier to reference from here than from all the materials and post process.
  98850. *
  98851. * No setter as we it is a shared configuration, you can set the values instead.
  98852. */
  98853. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  98854. private _forceWireframe;
  98855. /**
  98856. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  98857. */
  98858. forceWireframe: boolean;
  98859. private _forcePointsCloud;
  98860. /**
  98861. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  98862. */
  98863. forcePointsCloud: boolean;
  98864. /**
  98865. * Gets or sets the active clipplane 1
  98866. */
  98867. clipPlane: Nullable<Plane>;
  98868. /**
  98869. * Gets or sets the active clipplane 2
  98870. */
  98871. clipPlane2: Nullable<Plane>;
  98872. /**
  98873. * Gets or sets the active clipplane 3
  98874. */
  98875. clipPlane3: Nullable<Plane>;
  98876. /**
  98877. * Gets or sets the active clipplane 4
  98878. */
  98879. clipPlane4: Nullable<Plane>;
  98880. /**
  98881. * Gets or sets a boolean indicating if animations are enabled
  98882. */
  98883. animationsEnabled: boolean;
  98884. private _animationPropertiesOverride;
  98885. /**
  98886. * Gets or sets the animation properties override
  98887. */
  98888. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  98889. /**
  98890. * Gets or sets a boolean indicating if a constant deltatime has to be used
  98891. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  98892. */
  98893. useConstantAnimationDeltaTime: boolean;
  98894. /**
  98895. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  98896. * Please note that it requires to run a ray cast through the scene on every frame
  98897. */
  98898. constantlyUpdateMeshUnderPointer: boolean;
  98899. /**
  98900. * Defines the HTML cursor to use when hovering over interactive elements
  98901. */
  98902. hoverCursor: string;
  98903. /**
  98904. * Defines the HTML default cursor to use (empty by default)
  98905. */
  98906. defaultCursor: string;
  98907. /**
  98908. * This is used to call preventDefault() on pointer down
  98909. * in order to block unwanted artifacts like system double clicks
  98910. */
  98911. preventDefaultOnPointerDown: boolean;
  98912. /**
  98913. * This is used to call preventDefault() on pointer up
  98914. * in order to block unwanted artifacts like system double clicks
  98915. */
  98916. preventDefaultOnPointerUp: boolean;
  98917. /**
  98918. * Gets or sets user defined metadata
  98919. */
  98920. metadata: any;
  98921. /**
  98922. * For internal use only. Please do not use.
  98923. */
  98924. reservedDataStore: any;
  98925. /**
  98926. * Gets the name of the plugin used to load this scene (null by default)
  98927. */
  98928. loadingPluginName: string;
  98929. /**
  98930. * Use this array to add regular expressions used to disable offline support for specific urls
  98931. */
  98932. disableOfflineSupportExceptionRules: RegExp[];
  98933. /**
  98934. * An event triggered when the scene is disposed.
  98935. */
  98936. onDisposeObservable: Observable<Scene>;
  98937. private _onDisposeObserver;
  98938. /** Sets a function to be executed when this scene is disposed. */
  98939. onDispose: () => void;
  98940. /**
  98941. * An event triggered before rendering the scene (right after animations and physics)
  98942. */
  98943. onBeforeRenderObservable: Observable<Scene>;
  98944. private _onBeforeRenderObserver;
  98945. /** Sets a function to be executed before rendering this scene */
  98946. beforeRender: Nullable<() => void>;
  98947. /**
  98948. * An event triggered after rendering the scene
  98949. */
  98950. onAfterRenderObservable: Observable<Scene>;
  98951. /**
  98952. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  98953. */
  98954. onAfterRenderCameraObservable: Observable<Camera>;
  98955. private _onAfterRenderObserver;
  98956. /** Sets a function to be executed after rendering this scene */
  98957. afterRender: Nullable<() => void>;
  98958. /**
  98959. * An event triggered before animating the scene
  98960. */
  98961. onBeforeAnimationsObservable: Observable<Scene>;
  98962. /**
  98963. * An event triggered after animations processing
  98964. */
  98965. onAfterAnimationsObservable: Observable<Scene>;
  98966. /**
  98967. * An event triggered before draw calls are ready to be sent
  98968. */
  98969. onBeforeDrawPhaseObservable: Observable<Scene>;
  98970. /**
  98971. * An event triggered after draw calls have been sent
  98972. */
  98973. onAfterDrawPhaseObservable: Observable<Scene>;
  98974. /**
  98975. * An event triggered when the scene is ready
  98976. */
  98977. onReadyObservable: Observable<Scene>;
  98978. /**
  98979. * An event triggered before rendering a camera
  98980. */
  98981. onBeforeCameraRenderObservable: Observable<Camera>;
  98982. private _onBeforeCameraRenderObserver;
  98983. /** Sets a function to be executed before rendering a camera*/
  98984. beforeCameraRender: () => void;
  98985. /**
  98986. * An event triggered after rendering a camera
  98987. */
  98988. onAfterCameraRenderObservable: Observable<Camera>;
  98989. private _onAfterCameraRenderObserver;
  98990. /** Sets a function to be executed after rendering a camera*/
  98991. afterCameraRender: () => void;
  98992. /**
  98993. * An event triggered when active meshes evaluation is about to start
  98994. */
  98995. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  98996. /**
  98997. * An event triggered when active meshes evaluation is done
  98998. */
  98999. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  99000. /**
  99001. * An event triggered when particles rendering is about to start
  99002. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99003. */
  99004. onBeforeParticlesRenderingObservable: Observable<Scene>;
  99005. /**
  99006. * An event triggered when particles rendering is done
  99007. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99008. */
  99009. onAfterParticlesRenderingObservable: Observable<Scene>;
  99010. /**
  99011. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  99012. */
  99013. onDataLoadedObservable: Observable<Scene>;
  99014. /**
  99015. * An event triggered when a camera is created
  99016. */
  99017. onNewCameraAddedObservable: Observable<Camera>;
  99018. /**
  99019. * An event triggered when a camera is removed
  99020. */
  99021. onCameraRemovedObservable: Observable<Camera>;
  99022. /**
  99023. * An event triggered when a light is created
  99024. */
  99025. onNewLightAddedObservable: Observable<Light>;
  99026. /**
  99027. * An event triggered when a light is removed
  99028. */
  99029. onLightRemovedObservable: Observable<Light>;
  99030. /**
  99031. * An event triggered when a geometry is created
  99032. */
  99033. onNewGeometryAddedObservable: Observable<Geometry>;
  99034. /**
  99035. * An event triggered when a geometry is removed
  99036. */
  99037. onGeometryRemovedObservable: Observable<Geometry>;
  99038. /**
  99039. * An event triggered when a transform node is created
  99040. */
  99041. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  99042. /**
  99043. * An event triggered when a transform node is removed
  99044. */
  99045. onTransformNodeRemovedObservable: Observable<TransformNode>;
  99046. /**
  99047. * An event triggered when a mesh is created
  99048. */
  99049. onNewMeshAddedObservable: Observable<AbstractMesh>;
  99050. /**
  99051. * An event triggered when a mesh is removed
  99052. */
  99053. onMeshRemovedObservable: Observable<AbstractMesh>;
  99054. /**
  99055. * An event triggered when a skeleton is created
  99056. */
  99057. onNewSkeletonAddedObservable: Observable<Skeleton>;
  99058. /**
  99059. * An event triggered when a skeleton is removed
  99060. */
  99061. onSkeletonRemovedObservable: Observable<Skeleton>;
  99062. /**
  99063. * An event triggered when a material is created
  99064. */
  99065. onNewMaterialAddedObservable: Observable<Material>;
  99066. /**
  99067. * An event triggered when a material is removed
  99068. */
  99069. onMaterialRemovedObservable: Observable<Material>;
  99070. /**
  99071. * An event triggered when a texture is created
  99072. */
  99073. onNewTextureAddedObservable: Observable<BaseTexture>;
  99074. /**
  99075. * An event triggered when a texture is removed
  99076. */
  99077. onTextureRemovedObservable: Observable<BaseTexture>;
  99078. /**
  99079. * An event triggered when render targets are about to be rendered
  99080. * Can happen multiple times per frame.
  99081. */
  99082. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  99083. /**
  99084. * An event triggered when render targets were rendered.
  99085. * Can happen multiple times per frame.
  99086. */
  99087. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  99088. /**
  99089. * An event triggered before calculating deterministic simulation step
  99090. */
  99091. onBeforeStepObservable: Observable<Scene>;
  99092. /**
  99093. * An event triggered after calculating deterministic simulation step
  99094. */
  99095. onAfterStepObservable: Observable<Scene>;
  99096. /**
  99097. * An event triggered when the activeCamera property is updated
  99098. */
  99099. onActiveCameraChanged: Observable<Scene>;
  99100. /**
  99101. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  99102. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99103. * 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)
  99104. */
  99105. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99106. /**
  99107. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  99108. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99109. * 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)
  99110. */
  99111. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99112. /**
  99113. * This Observable will when a mesh has been imported into the scene.
  99114. */
  99115. onMeshImportedObservable: Observable<AbstractMesh>;
  99116. /**
  99117. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  99118. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  99119. */
  99120. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  99121. /** @hidden */
  99122. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  99123. /**
  99124. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  99125. */
  99126. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  99127. /**
  99128. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  99129. */
  99130. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  99131. /**
  99132. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  99133. */
  99134. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  99135. /** Callback called when a pointer move is detected */
  99136. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99137. /** Callback called when a pointer down is detected */
  99138. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99139. /** Callback called when a pointer up is detected */
  99140. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  99141. /** Callback called when a pointer pick is detected */
  99142. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  99143. /**
  99144. * 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).
  99145. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  99146. */
  99147. onPrePointerObservable: Observable<PointerInfoPre>;
  99148. /**
  99149. * Observable event triggered each time an input event is received from the rendering canvas
  99150. */
  99151. onPointerObservable: Observable<PointerInfo>;
  99152. /**
  99153. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  99154. */
  99155. readonly unTranslatedPointer: Vector2;
  99156. /**
  99157. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  99158. */
  99159. static DragMovementThreshold: number;
  99160. /**
  99161. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  99162. */
  99163. static LongPressDelay: number;
  99164. /**
  99165. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  99166. */
  99167. static DoubleClickDelay: number;
  99168. /** If you need to check double click without raising a single click at first click, enable this flag */
  99169. static ExclusiveDoubleClickMode: boolean;
  99170. /** @hidden */
  99171. _mirroredCameraPosition: Nullable<Vector3>;
  99172. /**
  99173. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  99174. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  99175. */
  99176. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  99177. /**
  99178. * Observable event triggered each time an keyboard event is received from the hosting window
  99179. */
  99180. onKeyboardObservable: Observable<KeyboardInfo>;
  99181. private _useRightHandedSystem;
  99182. /**
  99183. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  99184. */
  99185. useRightHandedSystem: boolean;
  99186. private _timeAccumulator;
  99187. private _currentStepId;
  99188. private _currentInternalStep;
  99189. /**
  99190. * Sets the step Id used by deterministic lock step
  99191. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99192. * @param newStepId defines the step Id
  99193. */
  99194. setStepId(newStepId: number): void;
  99195. /**
  99196. * Gets the step Id used by deterministic lock step
  99197. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99198. * @returns the step Id
  99199. */
  99200. getStepId(): number;
  99201. /**
  99202. * Gets the internal step used by deterministic lock step
  99203. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99204. * @returns the internal step
  99205. */
  99206. getInternalStep(): number;
  99207. private _fogEnabled;
  99208. /**
  99209. * Gets or sets a boolean indicating if fog is enabled on this scene
  99210. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99211. * (Default is true)
  99212. */
  99213. fogEnabled: boolean;
  99214. private _fogMode;
  99215. /**
  99216. * Gets or sets the fog mode to use
  99217. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99218. * | mode | value |
  99219. * | --- | --- |
  99220. * | FOGMODE_NONE | 0 |
  99221. * | FOGMODE_EXP | 1 |
  99222. * | FOGMODE_EXP2 | 2 |
  99223. * | FOGMODE_LINEAR | 3 |
  99224. */
  99225. fogMode: number;
  99226. /**
  99227. * Gets or sets the fog color to use
  99228. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99229. * (Default is Color3(0.2, 0.2, 0.3))
  99230. */
  99231. fogColor: Color3;
  99232. /**
  99233. * Gets or sets the fog density to use
  99234. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99235. * (Default is 0.1)
  99236. */
  99237. fogDensity: number;
  99238. /**
  99239. * Gets or sets the fog start distance to use
  99240. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99241. * (Default is 0)
  99242. */
  99243. fogStart: number;
  99244. /**
  99245. * Gets or sets the fog end distance to use
  99246. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99247. * (Default is 1000)
  99248. */
  99249. fogEnd: number;
  99250. private _shadowsEnabled;
  99251. /**
  99252. * Gets or sets a boolean indicating if shadows are enabled on this scene
  99253. */
  99254. shadowsEnabled: boolean;
  99255. private _lightsEnabled;
  99256. /**
  99257. * Gets or sets a boolean indicating if lights are enabled on this scene
  99258. */
  99259. lightsEnabled: boolean;
  99260. /** All of the active cameras added to this scene. */
  99261. activeCameras: Camera[];
  99262. /** @hidden */
  99263. _activeCamera: Nullable<Camera>;
  99264. /** Gets or sets the current active camera */
  99265. activeCamera: Nullable<Camera>;
  99266. private _defaultMaterial;
  99267. /** The default material used on meshes when no material is affected */
  99268. /** The default material used on meshes when no material is affected */
  99269. defaultMaterial: Material;
  99270. private _texturesEnabled;
  99271. /**
  99272. * Gets or sets a boolean indicating if textures are enabled on this scene
  99273. */
  99274. texturesEnabled: boolean;
  99275. /**
  99276. * Gets or sets a boolean indicating if particles are enabled on this scene
  99277. */
  99278. particlesEnabled: boolean;
  99279. /**
  99280. * Gets or sets a boolean indicating if sprites are enabled on this scene
  99281. */
  99282. spritesEnabled: boolean;
  99283. private _skeletonsEnabled;
  99284. /**
  99285. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  99286. */
  99287. skeletonsEnabled: boolean;
  99288. /**
  99289. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  99290. */
  99291. lensFlaresEnabled: boolean;
  99292. /**
  99293. * Gets or sets a boolean indicating if collisions are enabled on this scene
  99294. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99295. */
  99296. collisionsEnabled: boolean;
  99297. private _collisionCoordinator;
  99298. /** @hidden */
  99299. readonly collisionCoordinator: ICollisionCoordinator;
  99300. /**
  99301. * Defines the gravity applied to this scene (used only for collisions)
  99302. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99303. */
  99304. gravity: Vector3;
  99305. /**
  99306. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  99307. */
  99308. postProcessesEnabled: boolean;
  99309. /**
  99310. * The list of postprocesses added to the scene
  99311. */
  99312. postProcesses: PostProcess[];
  99313. /**
  99314. * Gets the current postprocess manager
  99315. */
  99316. postProcessManager: PostProcessManager;
  99317. /**
  99318. * Gets or sets a boolean indicating if render targets are enabled on this scene
  99319. */
  99320. renderTargetsEnabled: boolean;
  99321. /**
  99322. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  99323. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  99324. */
  99325. dumpNextRenderTargets: boolean;
  99326. /**
  99327. * The list of user defined render targets added to the scene
  99328. */
  99329. customRenderTargets: RenderTargetTexture[];
  99330. /**
  99331. * Defines if texture loading must be delayed
  99332. * If true, textures will only be loaded when they need to be rendered
  99333. */
  99334. useDelayedTextureLoading: boolean;
  99335. /**
  99336. * Gets the list of meshes imported to the scene through SceneLoader
  99337. */
  99338. importedMeshesFiles: String[];
  99339. /**
  99340. * Gets or sets a boolean indicating if probes are enabled on this scene
  99341. */
  99342. probesEnabled: boolean;
  99343. /**
  99344. * Gets or sets the current offline provider to use to store scene data
  99345. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  99346. */
  99347. offlineProvider: IOfflineProvider;
  99348. /**
  99349. * Gets or sets the action manager associated with the scene
  99350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99351. */
  99352. actionManager: AbstractActionManager;
  99353. private _meshesForIntersections;
  99354. /**
  99355. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  99356. */
  99357. proceduralTexturesEnabled: boolean;
  99358. private _engine;
  99359. private _totalVertices;
  99360. /** @hidden */
  99361. _activeIndices: PerfCounter;
  99362. /** @hidden */
  99363. _activeParticles: PerfCounter;
  99364. /** @hidden */
  99365. _activeBones: PerfCounter;
  99366. private _animationRatio;
  99367. /** @hidden */
  99368. _animationTimeLast: number;
  99369. /** @hidden */
  99370. _animationTime: number;
  99371. /**
  99372. * Gets or sets a general scale for animation speed
  99373. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  99374. */
  99375. animationTimeScale: number;
  99376. /** @hidden */
  99377. _cachedMaterial: Nullable<Material>;
  99378. /** @hidden */
  99379. _cachedEffect: Nullable<Effect>;
  99380. /** @hidden */
  99381. _cachedVisibility: Nullable<number>;
  99382. private _renderId;
  99383. private _frameId;
  99384. private _executeWhenReadyTimeoutId;
  99385. private _intermediateRendering;
  99386. private _viewUpdateFlag;
  99387. private _projectionUpdateFlag;
  99388. /** @hidden */
  99389. _toBeDisposed: Nullable<IDisposable>[];
  99390. private _activeRequests;
  99391. /** @hidden */
  99392. _pendingData: any[];
  99393. private _isDisposed;
  99394. /**
  99395. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  99396. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  99397. */
  99398. dispatchAllSubMeshesOfActiveMeshes: boolean;
  99399. private _activeMeshes;
  99400. private _processedMaterials;
  99401. private _renderTargets;
  99402. /** @hidden */
  99403. _activeParticleSystems: SmartArray<IParticleSystem>;
  99404. private _activeSkeletons;
  99405. private _softwareSkinnedMeshes;
  99406. private _renderingManager;
  99407. /** @hidden */
  99408. _activeAnimatables: Animatable[];
  99409. private _transformMatrix;
  99410. private _sceneUbo;
  99411. /** @hidden */
  99412. _viewMatrix: Matrix;
  99413. private _projectionMatrix;
  99414. /** @hidden */
  99415. _forcedViewPosition: Nullable<Vector3>;
  99416. /** @hidden */
  99417. _frustumPlanes: Plane[];
  99418. /**
  99419. * Gets the list of frustum planes (built from the active camera)
  99420. */
  99421. readonly frustumPlanes: Plane[];
  99422. /**
  99423. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  99424. * This is useful if there are more lights that the maximum simulteanous authorized
  99425. */
  99426. requireLightSorting: boolean;
  99427. /** @hidden */
  99428. readonly useMaterialMeshMap: boolean;
  99429. /** @hidden */
  99430. readonly useClonedMeshhMap: boolean;
  99431. private _externalData;
  99432. private _uid;
  99433. /**
  99434. * @hidden
  99435. * Backing store of defined scene components.
  99436. */
  99437. _components: ISceneComponent[];
  99438. /**
  99439. * @hidden
  99440. * Backing store of defined scene components.
  99441. */
  99442. _serializableComponents: ISceneSerializableComponent[];
  99443. /**
  99444. * List of components to register on the next registration step.
  99445. */
  99446. private _transientComponents;
  99447. /**
  99448. * Registers the transient components if needed.
  99449. */
  99450. private _registerTransientComponents;
  99451. /**
  99452. * @hidden
  99453. * Add a component to the scene.
  99454. * Note that the ccomponent could be registered on th next frame if this is called after
  99455. * the register component stage.
  99456. * @param component Defines the component to add to the scene
  99457. */
  99458. _addComponent(component: ISceneComponent): void;
  99459. /**
  99460. * @hidden
  99461. * Gets a component from the scene.
  99462. * @param name defines the name of the component to retrieve
  99463. * @returns the component or null if not present
  99464. */
  99465. _getComponent(name: string): Nullable<ISceneComponent>;
  99466. /**
  99467. * @hidden
  99468. * Defines the actions happening before camera updates.
  99469. */
  99470. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  99471. /**
  99472. * @hidden
  99473. * Defines the actions happening before clear the canvas.
  99474. */
  99475. _beforeClearStage: Stage<SimpleStageAction>;
  99476. /**
  99477. * @hidden
  99478. * Defines the actions when collecting render targets for the frame.
  99479. */
  99480. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99481. /**
  99482. * @hidden
  99483. * Defines the actions happening for one camera in the frame.
  99484. */
  99485. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99486. /**
  99487. * @hidden
  99488. * Defines the actions happening during the per mesh ready checks.
  99489. */
  99490. _isReadyForMeshStage: Stage<MeshStageAction>;
  99491. /**
  99492. * @hidden
  99493. * Defines the actions happening before evaluate active mesh checks.
  99494. */
  99495. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  99496. /**
  99497. * @hidden
  99498. * Defines the actions happening during the evaluate sub mesh checks.
  99499. */
  99500. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  99501. /**
  99502. * @hidden
  99503. * Defines the actions happening during the active mesh stage.
  99504. */
  99505. _activeMeshStage: Stage<ActiveMeshStageAction>;
  99506. /**
  99507. * @hidden
  99508. * Defines the actions happening during the per camera render target step.
  99509. */
  99510. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  99511. /**
  99512. * @hidden
  99513. * Defines the actions happening just before the active camera is drawing.
  99514. */
  99515. _beforeCameraDrawStage: Stage<CameraStageAction>;
  99516. /**
  99517. * @hidden
  99518. * Defines the actions happening just before a render target is drawing.
  99519. */
  99520. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99521. /**
  99522. * @hidden
  99523. * Defines the actions happening just before a rendering group is drawing.
  99524. */
  99525. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99526. /**
  99527. * @hidden
  99528. * Defines the actions happening just before a mesh is drawing.
  99529. */
  99530. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99531. /**
  99532. * @hidden
  99533. * Defines the actions happening just after a mesh has been drawn.
  99534. */
  99535. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99536. /**
  99537. * @hidden
  99538. * Defines the actions happening just after a rendering group has been drawn.
  99539. */
  99540. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99541. /**
  99542. * @hidden
  99543. * Defines the actions happening just after the active camera has been drawn.
  99544. */
  99545. _afterCameraDrawStage: Stage<CameraStageAction>;
  99546. /**
  99547. * @hidden
  99548. * Defines the actions happening just after a render target has been drawn.
  99549. */
  99550. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99551. /**
  99552. * @hidden
  99553. * Defines the actions happening just after rendering all cameras and computing intersections.
  99554. */
  99555. _afterRenderStage: Stage<SimpleStageAction>;
  99556. /**
  99557. * @hidden
  99558. * Defines the actions happening when a pointer move event happens.
  99559. */
  99560. _pointerMoveStage: Stage<PointerMoveStageAction>;
  99561. /**
  99562. * @hidden
  99563. * Defines the actions happening when a pointer down event happens.
  99564. */
  99565. _pointerDownStage: Stage<PointerUpDownStageAction>;
  99566. /**
  99567. * @hidden
  99568. * Defines the actions happening when a pointer up event happens.
  99569. */
  99570. _pointerUpStage: Stage<PointerUpDownStageAction>;
  99571. /**
  99572. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  99573. */
  99574. private geometriesByUniqueId;
  99575. /**
  99576. * Creates a new Scene
  99577. * @param engine defines the engine to use to render this scene
  99578. * @param options defines the scene options
  99579. */
  99580. constructor(engine: Engine, options?: SceneOptions);
  99581. /**
  99582. * Gets a string idenfifying the name of the class
  99583. * @returns "Scene" string
  99584. */
  99585. getClassName(): string;
  99586. private _defaultMeshCandidates;
  99587. /**
  99588. * @hidden
  99589. */
  99590. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99591. private _defaultSubMeshCandidates;
  99592. /**
  99593. * @hidden
  99594. */
  99595. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99596. /**
  99597. * Sets the default candidate providers for the scene.
  99598. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  99599. * and getCollidingSubMeshCandidates to their default function
  99600. */
  99601. setDefaultCandidateProviders(): void;
  99602. /**
  99603. * Gets the mesh that is currently under the pointer
  99604. */
  99605. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99606. /**
  99607. * Gets or sets the current on-screen X position of the pointer
  99608. */
  99609. pointerX: number;
  99610. /**
  99611. * Gets or sets the current on-screen Y position of the pointer
  99612. */
  99613. pointerY: number;
  99614. /**
  99615. * Gets the cached material (ie. the latest rendered one)
  99616. * @returns the cached material
  99617. */
  99618. getCachedMaterial(): Nullable<Material>;
  99619. /**
  99620. * Gets the cached effect (ie. the latest rendered one)
  99621. * @returns the cached effect
  99622. */
  99623. getCachedEffect(): Nullable<Effect>;
  99624. /**
  99625. * Gets the cached visibility state (ie. the latest rendered one)
  99626. * @returns the cached visibility state
  99627. */
  99628. getCachedVisibility(): Nullable<number>;
  99629. /**
  99630. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  99631. * @param material defines the current material
  99632. * @param effect defines the current effect
  99633. * @param visibility defines the current visibility state
  99634. * @returns true if one parameter is not cached
  99635. */
  99636. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  99637. /**
  99638. * Gets the engine associated with the scene
  99639. * @returns an Engine
  99640. */
  99641. getEngine(): Engine;
  99642. /**
  99643. * Gets the total number of vertices rendered per frame
  99644. * @returns the total number of vertices rendered per frame
  99645. */
  99646. getTotalVertices(): number;
  99647. /**
  99648. * Gets the performance counter for total vertices
  99649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99650. */
  99651. readonly totalVerticesPerfCounter: PerfCounter;
  99652. /**
  99653. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  99654. * @returns the total number of active indices rendered per frame
  99655. */
  99656. getActiveIndices(): number;
  99657. /**
  99658. * Gets the performance counter for active indices
  99659. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99660. */
  99661. readonly totalActiveIndicesPerfCounter: PerfCounter;
  99662. /**
  99663. * Gets the total number of active particles rendered per frame
  99664. * @returns the total number of active particles rendered per frame
  99665. */
  99666. getActiveParticles(): number;
  99667. /**
  99668. * Gets the performance counter for active particles
  99669. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99670. */
  99671. readonly activeParticlesPerfCounter: PerfCounter;
  99672. /**
  99673. * Gets the total number of active bones rendered per frame
  99674. * @returns the total number of active bones rendered per frame
  99675. */
  99676. getActiveBones(): number;
  99677. /**
  99678. * Gets the performance counter for active bones
  99679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99680. */
  99681. readonly activeBonesPerfCounter: PerfCounter;
  99682. /**
  99683. * Gets the array of active meshes
  99684. * @returns an array of AbstractMesh
  99685. */
  99686. getActiveMeshes(): SmartArray<AbstractMesh>;
  99687. /**
  99688. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  99689. * @returns a number
  99690. */
  99691. getAnimationRatio(): number;
  99692. /**
  99693. * Gets an unique Id for the current render phase
  99694. * @returns a number
  99695. */
  99696. getRenderId(): number;
  99697. /**
  99698. * Gets an unique Id for the current frame
  99699. * @returns a number
  99700. */
  99701. getFrameId(): number;
  99702. /** Call this function if you want to manually increment the render Id*/
  99703. incrementRenderId(): void;
  99704. private _createUbo;
  99705. /**
  99706. * Use this method to simulate a pointer move on a mesh
  99707. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99708. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99709. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99710. * @returns the current scene
  99711. */
  99712. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99713. /**
  99714. * Use this method to simulate a pointer down on a mesh
  99715. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99716. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99717. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99718. * @returns the current scene
  99719. */
  99720. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99721. /**
  99722. * Use this method to simulate a pointer up on a mesh
  99723. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99724. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99725. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99726. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99727. * @returns the current scene
  99728. */
  99729. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  99730. /**
  99731. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99732. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99733. * @returns true if the pointer was captured
  99734. */
  99735. isPointerCaptured(pointerId?: number): boolean;
  99736. /**
  99737. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99738. * @param attachUp defines if you want to attach events to pointerup
  99739. * @param attachDown defines if you want to attach events to pointerdown
  99740. * @param attachMove defines if you want to attach events to pointermove
  99741. */
  99742. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99743. /** Detaches all event handlers*/
  99744. detachControl(): void;
  99745. /**
  99746. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  99747. * Delay loaded resources are not taking in account
  99748. * @return true if all required resources are ready
  99749. */
  99750. isReady(): boolean;
  99751. /** Resets all cached information relative to material (including effect and visibility) */
  99752. resetCachedMaterial(): void;
  99753. /**
  99754. * Registers a function to be called before every frame render
  99755. * @param func defines the function to register
  99756. */
  99757. registerBeforeRender(func: () => void): void;
  99758. /**
  99759. * Unregisters a function called before every frame render
  99760. * @param func defines the function to unregister
  99761. */
  99762. unregisterBeforeRender(func: () => void): void;
  99763. /**
  99764. * Registers a function to be called after every frame render
  99765. * @param func defines the function to register
  99766. */
  99767. registerAfterRender(func: () => void): void;
  99768. /**
  99769. * Unregisters a function called after every frame render
  99770. * @param func defines the function to unregister
  99771. */
  99772. unregisterAfterRender(func: () => void): void;
  99773. private _executeOnceBeforeRender;
  99774. /**
  99775. * The provided function will run before render once and will be disposed afterwards.
  99776. * A timeout delay can be provided so that the function will be executed in N ms.
  99777. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  99778. * @param func The function to be executed.
  99779. * @param timeout optional delay in ms
  99780. */
  99781. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  99782. /** @hidden */
  99783. _addPendingData(data: any): void;
  99784. /** @hidden */
  99785. _removePendingData(data: any): void;
  99786. /**
  99787. * Returns the number of items waiting to be loaded
  99788. * @returns the number of items waiting to be loaded
  99789. */
  99790. getWaitingItemsCount(): number;
  99791. /**
  99792. * Returns a boolean indicating if the scene is still loading data
  99793. */
  99794. readonly isLoading: boolean;
  99795. /**
  99796. * Registers a function to be executed when the scene is ready
  99797. * @param {Function} func - the function to be executed
  99798. */
  99799. executeWhenReady(func: () => void): void;
  99800. /**
  99801. * Returns a promise that resolves when the scene is ready
  99802. * @returns A promise that resolves when the scene is ready
  99803. */
  99804. whenReadyAsync(): Promise<void>;
  99805. /** @hidden */
  99806. _checkIsReady(): void;
  99807. /**
  99808. * Gets all animatable attached to the scene
  99809. */
  99810. readonly animatables: Animatable[];
  99811. /**
  99812. * Resets the last animation time frame.
  99813. * Useful to override when animations start running when loading a scene for the first time.
  99814. */
  99815. resetLastAnimationTimeFrame(): void;
  99816. /**
  99817. * Gets the current view matrix
  99818. * @returns a Matrix
  99819. */
  99820. getViewMatrix(): Matrix;
  99821. /**
  99822. * Gets the current projection matrix
  99823. * @returns a Matrix
  99824. */
  99825. getProjectionMatrix(): Matrix;
  99826. /**
  99827. * Gets the current transform matrix
  99828. * @returns a Matrix made of View * Projection
  99829. */
  99830. getTransformMatrix(): Matrix;
  99831. /**
  99832. * Sets the current transform matrix
  99833. * @param viewL defines the View matrix to use
  99834. * @param projectionL defines the Projection matrix to use
  99835. * @param viewR defines the right View matrix to use (if provided)
  99836. * @param projectionR defines the right Projection matrix to use (if provided)
  99837. */
  99838. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  99839. /**
  99840. * Gets the uniform buffer used to store scene data
  99841. * @returns a UniformBuffer
  99842. */
  99843. getSceneUniformBuffer(): UniformBuffer;
  99844. /**
  99845. * Gets an unique (relatively to the current scene) Id
  99846. * @returns an unique number for the scene
  99847. */
  99848. getUniqueId(): number;
  99849. /**
  99850. * Add a mesh to the list of scene's meshes
  99851. * @param newMesh defines the mesh to add
  99852. * @param recursive if all child meshes should also be added to the scene
  99853. */
  99854. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  99855. /**
  99856. * Remove a mesh for the list of scene's meshes
  99857. * @param toRemove defines the mesh to remove
  99858. * @param recursive if all child meshes should also be removed from the scene
  99859. * @returns the index where the mesh was in the mesh list
  99860. */
  99861. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  99862. /**
  99863. * Add a transform node to the list of scene's transform nodes
  99864. * @param newTransformNode defines the transform node to add
  99865. */
  99866. addTransformNode(newTransformNode: TransformNode): void;
  99867. /**
  99868. * Remove a transform node for the list of scene's transform nodes
  99869. * @param toRemove defines the transform node to remove
  99870. * @returns the index where the transform node was in the transform node list
  99871. */
  99872. removeTransformNode(toRemove: TransformNode): number;
  99873. /**
  99874. * Remove a skeleton for the list of scene's skeletons
  99875. * @param toRemove defines the skeleton to remove
  99876. * @returns the index where the skeleton was in the skeleton list
  99877. */
  99878. removeSkeleton(toRemove: Skeleton): number;
  99879. /**
  99880. * Remove a morph target for the list of scene's morph targets
  99881. * @param toRemove defines the morph target to remove
  99882. * @returns the index where the morph target was in the morph target list
  99883. */
  99884. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  99885. /**
  99886. * Remove a light for the list of scene's lights
  99887. * @param toRemove defines the light to remove
  99888. * @returns the index where the light was in the light list
  99889. */
  99890. removeLight(toRemove: Light): number;
  99891. /**
  99892. * Remove a camera for the list of scene's cameras
  99893. * @param toRemove defines the camera to remove
  99894. * @returns the index where the camera was in the camera list
  99895. */
  99896. removeCamera(toRemove: Camera): number;
  99897. /**
  99898. * Remove a particle system for the list of scene's particle systems
  99899. * @param toRemove defines the particle system to remove
  99900. * @returns the index where the particle system was in the particle system list
  99901. */
  99902. removeParticleSystem(toRemove: IParticleSystem): number;
  99903. /**
  99904. * Remove a animation for the list of scene's animations
  99905. * @param toRemove defines the animation to remove
  99906. * @returns the index where the animation was in the animation list
  99907. */
  99908. removeAnimation(toRemove: Animation): number;
  99909. /**
  99910. * Will stop the animation of the given target
  99911. * @param target - the target
  99912. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  99913. * @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)
  99914. */
  99915. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  99916. /**
  99917. * Removes the given animation group from this scene.
  99918. * @param toRemove The animation group to remove
  99919. * @returns The index of the removed animation group
  99920. */
  99921. removeAnimationGroup(toRemove: AnimationGroup): number;
  99922. /**
  99923. * Removes the given multi-material from this scene.
  99924. * @param toRemove The multi-material to remove
  99925. * @returns The index of the removed multi-material
  99926. */
  99927. removeMultiMaterial(toRemove: MultiMaterial): number;
  99928. /**
  99929. * Removes the given material from this scene.
  99930. * @param toRemove The material to remove
  99931. * @returns The index of the removed material
  99932. */
  99933. removeMaterial(toRemove: Material): number;
  99934. /**
  99935. * Removes the given action manager from this scene.
  99936. * @param toRemove The action manager to remove
  99937. * @returns The index of the removed action manager
  99938. */
  99939. removeActionManager(toRemove: AbstractActionManager): number;
  99940. /**
  99941. * Removes the given texture from this scene.
  99942. * @param toRemove The texture to remove
  99943. * @returns The index of the removed texture
  99944. */
  99945. removeTexture(toRemove: BaseTexture): number;
  99946. /**
  99947. * Adds the given light to this scene
  99948. * @param newLight The light to add
  99949. */
  99950. addLight(newLight: Light): void;
  99951. /**
  99952. * Sorts the list list based on light priorities
  99953. */
  99954. sortLightsByPriority(): void;
  99955. /**
  99956. * Adds the given camera to this scene
  99957. * @param newCamera The camera to add
  99958. */
  99959. addCamera(newCamera: Camera): void;
  99960. /**
  99961. * Adds the given skeleton to this scene
  99962. * @param newSkeleton The skeleton to add
  99963. */
  99964. addSkeleton(newSkeleton: Skeleton): void;
  99965. /**
  99966. * Adds the given particle system to this scene
  99967. * @param newParticleSystem The particle system to add
  99968. */
  99969. addParticleSystem(newParticleSystem: IParticleSystem): void;
  99970. /**
  99971. * Adds the given animation to this scene
  99972. * @param newAnimation The animation to add
  99973. */
  99974. addAnimation(newAnimation: Animation): void;
  99975. /**
  99976. * Adds the given animation group to this scene.
  99977. * @param newAnimationGroup The animation group to add
  99978. */
  99979. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  99980. /**
  99981. * Adds the given multi-material to this scene
  99982. * @param newMultiMaterial The multi-material to add
  99983. */
  99984. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  99985. /**
  99986. * Adds the given material to this scene
  99987. * @param newMaterial The material to add
  99988. */
  99989. addMaterial(newMaterial: Material): void;
  99990. /**
  99991. * Adds the given morph target to this scene
  99992. * @param newMorphTargetManager The morph target to add
  99993. */
  99994. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  99995. /**
  99996. * Adds the given geometry to this scene
  99997. * @param newGeometry The geometry to add
  99998. */
  99999. addGeometry(newGeometry: Geometry): void;
  100000. /**
  100001. * Adds the given action manager to this scene
  100002. * @param newActionManager The action manager to add
  100003. */
  100004. addActionManager(newActionManager: AbstractActionManager): void;
  100005. /**
  100006. * Adds the given texture to this scene.
  100007. * @param newTexture The texture to add
  100008. */
  100009. addTexture(newTexture: BaseTexture): void;
  100010. /**
  100011. * Switch active camera
  100012. * @param newCamera defines the new active camera
  100013. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  100014. */
  100015. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  100016. /**
  100017. * sets the active camera of the scene using its ID
  100018. * @param id defines the camera's ID
  100019. * @return the new active camera or null if none found.
  100020. */
  100021. setActiveCameraByID(id: string): Nullable<Camera>;
  100022. /**
  100023. * sets the active camera of the scene using its name
  100024. * @param name defines the camera's name
  100025. * @returns the new active camera or null if none found.
  100026. */
  100027. setActiveCameraByName(name: string): Nullable<Camera>;
  100028. /**
  100029. * get an animation group using its name
  100030. * @param name defines the material's name
  100031. * @return the animation group or null if none found.
  100032. */
  100033. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  100034. /**
  100035. * Get a material using its unique id
  100036. * @param uniqueId defines the material's unique id
  100037. * @return the material or null if none found.
  100038. */
  100039. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  100040. /**
  100041. * get a material using its id
  100042. * @param id defines the material's ID
  100043. * @return the material or null if none found.
  100044. */
  100045. getMaterialByID(id: string): Nullable<Material>;
  100046. /**
  100047. * Gets a the last added material using a given id
  100048. * @param id defines the material's ID
  100049. * @return the last material with the given id or null if none found.
  100050. */
  100051. getLastMaterialByID(id: string): Nullable<Material>;
  100052. /**
  100053. * Gets a material using its name
  100054. * @param name defines the material's name
  100055. * @return the material or null if none found.
  100056. */
  100057. getMaterialByName(name: string): Nullable<Material>;
  100058. /**
  100059. * Get a texture using its unique id
  100060. * @param uniqueId defines the texture's unique id
  100061. * @return the texture or null if none found.
  100062. */
  100063. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  100064. /**
  100065. * Gets a camera using its id
  100066. * @param id defines the id to look for
  100067. * @returns the camera or null if not found
  100068. */
  100069. getCameraByID(id: string): Nullable<Camera>;
  100070. /**
  100071. * Gets a camera using its unique id
  100072. * @param uniqueId defines the unique id to look for
  100073. * @returns the camera or null if not found
  100074. */
  100075. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  100076. /**
  100077. * Gets a camera using its name
  100078. * @param name defines the camera's name
  100079. * @return the camera or null if none found.
  100080. */
  100081. getCameraByName(name: string): Nullable<Camera>;
  100082. /**
  100083. * Gets a bone using its id
  100084. * @param id defines the bone's id
  100085. * @return the bone or null if not found
  100086. */
  100087. getBoneByID(id: string): Nullable<Bone>;
  100088. /**
  100089. * Gets a bone using its id
  100090. * @param name defines the bone's name
  100091. * @return the bone or null if not found
  100092. */
  100093. getBoneByName(name: string): Nullable<Bone>;
  100094. /**
  100095. * Gets a light node using its name
  100096. * @param name defines the the light's name
  100097. * @return the light or null if none found.
  100098. */
  100099. getLightByName(name: string): Nullable<Light>;
  100100. /**
  100101. * Gets a light node using its id
  100102. * @param id defines the light's id
  100103. * @return the light or null if none found.
  100104. */
  100105. getLightByID(id: string): Nullable<Light>;
  100106. /**
  100107. * Gets a light node using its scene-generated unique ID
  100108. * @param uniqueId defines the light's unique id
  100109. * @return the light or null if none found.
  100110. */
  100111. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  100112. /**
  100113. * Gets a particle system by id
  100114. * @param id defines the particle system id
  100115. * @return the corresponding system or null if none found
  100116. */
  100117. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  100118. /**
  100119. * Gets a geometry using its ID
  100120. * @param id defines the geometry's id
  100121. * @return the geometry or null if none found.
  100122. */
  100123. getGeometryByID(id: string): Nullable<Geometry>;
  100124. private _getGeometryByUniqueID;
  100125. /**
  100126. * Add a new geometry to this scene
  100127. * @param geometry defines the geometry to be added to the scene.
  100128. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  100129. * @return a boolean defining if the geometry was added or not
  100130. */
  100131. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  100132. /**
  100133. * Removes an existing geometry
  100134. * @param geometry defines the geometry to be removed from the scene
  100135. * @return a boolean defining if the geometry was removed or not
  100136. */
  100137. removeGeometry(geometry: Geometry): boolean;
  100138. /**
  100139. * Gets the list of geometries attached to the scene
  100140. * @returns an array of Geometry
  100141. */
  100142. getGeometries(): Geometry[];
  100143. /**
  100144. * Gets the first added mesh found of a given ID
  100145. * @param id defines the id to search for
  100146. * @return the mesh found or null if not found at all
  100147. */
  100148. getMeshByID(id: string): Nullable<AbstractMesh>;
  100149. /**
  100150. * Gets a list of meshes using their id
  100151. * @param id defines the id to search for
  100152. * @returns a list of meshes
  100153. */
  100154. getMeshesByID(id: string): Array<AbstractMesh>;
  100155. /**
  100156. * Gets the first added transform node found of a given ID
  100157. * @param id defines the id to search for
  100158. * @return the found transform node or null if not found at all.
  100159. */
  100160. getTransformNodeByID(id: string): Nullable<TransformNode>;
  100161. /**
  100162. * Gets a transform node with its auto-generated unique id
  100163. * @param uniqueId efines the unique id to search for
  100164. * @return the found transform node or null if not found at all.
  100165. */
  100166. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  100167. /**
  100168. * Gets a list of transform nodes using their id
  100169. * @param id defines the id to search for
  100170. * @returns a list of transform nodes
  100171. */
  100172. getTransformNodesByID(id: string): Array<TransformNode>;
  100173. /**
  100174. * Gets a mesh with its auto-generated unique id
  100175. * @param uniqueId defines the unique id to search for
  100176. * @return the found mesh or null if not found at all.
  100177. */
  100178. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  100179. /**
  100180. * Gets a the last added mesh using a given id
  100181. * @param id defines the id to search for
  100182. * @return the found mesh or null if not found at all.
  100183. */
  100184. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  100185. /**
  100186. * Gets a the last added node (Mesh, Camera, Light) using a given id
  100187. * @param id defines the id to search for
  100188. * @return the found node or null if not found at all
  100189. */
  100190. getLastEntryByID(id: string): Nullable<Node>;
  100191. /**
  100192. * Gets a node (Mesh, Camera, Light) using a given id
  100193. * @param id defines the id to search for
  100194. * @return the found node or null if not found at all
  100195. */
  100196. getNodeByID(id: string): Nullable<Node>;
  100197. /**
  100198. * Gets a node (Mesh, Camera, Light) using a given name
  100199. * @param name defines the name to search for
  100200. * @return the found node or null if not found at all.
  100201. */
  100202. getNodeByName(name: string): Nullable<Node>;
  100203. /**
  100204. * Gets a mesh using a given name
  100205. * @param name defines the name to search for
  100206. * @return the found mesh or null if not found at all.
  100207. */
  100208. getMeshByName(name: string): Nullable<AbstractMesh>;
  100209. /**
  100210. * Gets a transform node using a given name
  100211. * @param name defines the name to search for
  100212. * @return the found transform node or null if not found at all.
  100213. */
  100214. getTransformNodeByName(name: string): Nullable<TransformNode>;
  100215. /**
  100216. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  100217. * @param id defines the id to search for
  100218. * @return the found skeleton or null if not found at all.
  100219. */
  100220. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  100221. /**
  100222. * Gets a skeleton using a given auto generated unique id
  100223. * @param uniqueId defines the unique id to search for
  100224. * @return the found skeleton or null if not found at all.
  100225. */
  100226. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  100227. /**
  100228. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  100229. * @param id defines the id to search for
  100230. * @return the found skeleton or null if not found at all.
  100231. */
  100232. getSkeletonById(id: string): Nullable<Skeleton>;
  100233. /**
  100234. * Gets a skeleton using a given name
  100235. * @param name defines the name to search for
  100236. * @return the found skeleton or null if not found at all.
  100237. */
  100238. getSkeletonByName(name: string): Nullable<Skeleton>;
  100239. /**
  100240. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  100241. * @param id defines the id to search for
  100242. * @return the found morph target manager or null if not found at all.
  100243. */
  100244. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  100245. /**
  100246. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  100247. * @param id defines the id to search for
  100248. * @return the found morph target or null if not found at all.
  100249. */
  100250. getMorphTargetById(id: string): Nullable<MorphTarget>;
  100251. /**
  100252. * Gets a boolean indicating if the given mesh is active
  100253. * @param mesh defines the mesh to look for
  100254. * @returns true if the mesh is in the active list
  100255. */
  100256. isActiveMesh(mesh: AbstractMesh): boolean;
  100257. /**
  100258. * Return a unique id as a string which can serve as an identifier for the scene
  100259. */
  100260. readonly uid: string;
  100261. /**
  100262. * Add an externaly attached data from its key.
  100263. * This method call will fail and return false, if such key already exists.
  100264. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  100265. * @param key the unique key that identifies the data
  100266. * @param data the data object to associate to the key for this Engine instance
  100267. * @return true if no such key were already present and the data was added successfully, false otherwise
  100268. */
  100269. addExternalData<T>(key: string, data: T): boolean;
  100270. /**
  100271. * Get an externaly attached data from its key
  100272. * @param key the unique key that identifies the data
  100273. * @return the associated data, if present (can be null), or undefined if not present
  100274. */
  100275. getExternalData<T>(key: string): Nullable<T>;
  100276. /**
  100277. * Get an externaly attached data from its key, create it using a factory if it's not already present
  100278. * @param key the unique key that identifies the data
  100279. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  100280. * @return the associated data, can be null if the factory returned null.
  100281. */
  100282. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  100283. /**
  100284. * Remove an externaly attached data from the Engine instance
  100285. * @param key the unique key that identifies the data
  100286. * @return true if the data was successfully removed, false if it doesn't exist
  100287. */
  100288. removeExternalData(key: string): boolean;
  100289. private _evaluateSubMesh;
  100290. /**
  100291. * Clear the processed materials smart array preventing retention point in material dispose.
  100292. */
  100293. freeProcessedMaterials(): void;
  100294. private _preventFreeActiveMeshesAndRenderingGroups;
  100295. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  100296. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  100297. * when disposing several meshes in a row or a hierarchy of meshes.
  100298. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  100299. */
  100300. blockfreeActiveMeshesAndRenderingGroups: boolean;
  100301. /**
  100302. * Clear the active meshes smart array preventing retention point in mesh dispose.
  100303. */
  100304. freeActiveMeshes(): void;
  100305. /**
  100306. * Clear the info related to rendering groups preventing retention points during dispose.
  100307. */
  100308. freeRenderingGroups(): void;
  100309. /** @hidden */
  100310. _isInIntermediateRendering(): boolean;
  100311. /**
  100312. * Lambda returning the list of potentially active meshes.
  100313. */
  100314. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  100315. /**
  100316. * Lambda returning the list of potentially active sub meshes.
  100317. */
  100318. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  100319. /**
  100320. * Lambda returning the list of potentially intersecting sub meshes.
  100321. */
  100322. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  100323. /**
  100324. * Lambda returning the list of potentially colliding sub meshes.
  100325. */
  100326. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  100327. private _activeMeshesFrozen;
  100328. /**
  100329. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  100330. * @returns the current scene
  100331. */
  100332. freezeActiveMeshes(): Scene;
  100333. /**
  100334. * Use this function to restart evaluating active meshes on every frame
  100335. * @returns the current scene
  100336. */
  100337. unfreezeActiveMeshes(): Scene;
  100338. private _evaluateActiveMeshes;
  100339. private _activeMesh;
  100340. /**
  100341. * Update the transform matrix to update from the current active camera
  100342. * @param force defines a boolean used to force the update even if cache is up to date
  100343. */
  100344. updateTransformMatrix(force?: boolean): void;
  100345. private _bindFrameBuffer;
  100346. /** @hidden */
  100347. _allowPostProcessClearColor: boolean;
  100348. /** @hidden */
  100349. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  100350. private _processSubCameras;
  100351. private _checkIntersections;
  100352. /** @hidden */
  100353. _advancePhysicsEngineStep(step: number): void;
  100354. /**
  100355. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  100356. */
  100357. getDeterministicFrameTime: () => number;
  100358. /** @hidden */
  100359. _animate(): void;
  100360. /** Execute all animations (for a frame) */
  100361. animate(): void;
  100362. /**
  100363. * Render the scene
  100364. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  100365. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  100366. */
  100367. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  100368. /**
  100369. * Freeze all materials
  100370. * A frozen material will not be updatable but should be faster to render
  100371. */
  100372. freezeMaterials(): void;
  100373. /**
  100374. * Unfreeze all materials
  100375. * A frozen material will not be updatable but should be faster to render
  100376. */
  100377. unfreezeMaterials(): void;
  100378. /**
  100379. * Releases all held ressources
  100380. */
  100381. dispose(): void;
  100382. /**
  100383. * Gets if the scene is already disposed
  100384. */
  100385. readonly isDisposed: boolean;
  100386. /**
  100387. * Call this function to reduce memory footprint of the scene.
  100388. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  100389. */
  100390. clearCachedVertexData(): void;
  100391. /**
  100392. * This function will remove the local cached buffer data from texture.
  100393. * It will save memory but will prevent the texture from being rebuilt
  100394. */
  100395. cleanCachedTextureBuffer(): void;
  100396. /**
  100397. * Get the world extend vectors with an optional filter
  100398. *
  100399. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  100400. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  100401. */
  100402. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  100403. min: Vector3;
  100404. max: Vector3;
  100405. };
  100406. /**
  100407. * Creates a ray that can be used to pick in the scene
  100408. * @param x defines the x coordinate of the origin (on-screen)
  100409. * @param y defines the y coordinate of the origin (on-screen)
  100410. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100411. * @param camera defines the camera to use for the picking
  100412. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100413. * @returns a Ray
  100414. */
  100415. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  100416. /**
  100417. * Creates a ray that can be used to pick in the scene
  100418. * @param x defines the x coordinate of the origin (on-screen)
  100419. * @param y defines the y coordinate of the origin (on-screen)
  100420. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100421. * @param result defines the ray where to store the picking ray
  100422. * @param camera defines the camera to use for the picking
  100423. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100424. * @returns the current scene
  100425. */
  100426. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  100427. /**
  100428. * Creates a ray that can be used to pick in the scene
  100429. * @param x defines the x coordinate of the origin (on-screen)
  100430. * @param y defines the y coordinate of the origin (on-screen)
  100431. * @param camera defines the camera to use for the picking
  100432. * @returns a Ray
  100433. */
  100434. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  100435. /**
  100436. * Creates a ray that can be used to pick in the scene
  100437. * @param x defines the x coordinate of the origin (on-screen)
  100438. * @param y defines the y coordinate of the origin (on-screen)
  100439. * @param result defines the ray where to store the picking ray
  100440. * @param camera defines the camera to use for the picking
  100441. * @returns the current scene
  100442. */
  100443. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  100444. /** Launch a ray to try to pick a mesh in the scene
  100445. * @param x position on screen
  100446. * @param y position on screen
  100447. * @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
  100448. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  100449. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100450. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100451. * @returns a PickingInfo
  100452. */
  100453. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100454. /** Use the given ray to pick a mesh in the scene
  100455. * @param ray The ray to use to pick meshes
  100456. * @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
  100457. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  100458. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100459. * @returns a PickingInfo
  100460. */
  100461. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100462. /**
  100463. * Launch a ray to try to pick a mesh in the scene
  100464. * @param x X position on screen
  100465. * @param y Y position on screen
  100466. * @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
  100467. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100469. * @returns an array of PickingInfo
  100470. */
  100471. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100472. /**
  100473. * Launch a ray to try to pick a mesh in the scene
  100474. * @param ray Ray to use
  100475. * @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
  100476. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100477. * @returns an array of PickingInfo
  100478. */
  100479. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100480. /**
  100481. * Force the value of meshUnderPointer
  100482. * @param mesh defines the mesh to use
  100483. */
  100484. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100485. /**
  100486. * Gets the mesh under the pointer
  100487. * @returns a Mesh or null if no mesh is under the pointer
  100488. */
  100489. getPointerOverMesh(): Nullable<AbstractMesh>;
  100490. /** @hidden */
  100491. _rebuildGeometries(): void;
  100492. /** @hidden */
  100493. _rebuildTextures(): void;
  100494. private _getByTags;
  100495. /**
  100496. * Get a list of meshes by tags
  100497. * @param tagsQuery defines the tags query to use
  100498. * @param forEach defines a predicate used to filter results
  100499. * @returns an array of Mesh
  100500. */
  100501. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  100502. /**
  100503. * Get a list of cameras by tags
  100504. * @param tagsQuery defines the tags query to use
  100505. * @param forEach defines a predicate used to filter results
  100506. * @returns an array of Camera
  100507. */
  100508. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  100509. /**
  100510. * Get a list of lights by tags
  100511. * @param tagsQuery defines the tags query to use
  100512. * @param forEach defines a predicate used to filter results
  100513. * @returns an array of Light
  100514. */
  100515. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  100516. /**
  100517. * Get a list of materials by tags
  100518. * @param tagsQuery defines the tags query to use
  100519. * @param forEach defines a predicate used to filter results
  100520. * @returns an array of Material
  100521. */
  100522. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  100523. /**
  100524. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100525. * This allowed control for front to back rendering or reversly depending of the special needs.
  100526. *
  100527. * @param renderingGroupId The rendering group id corresponding to its index
  100528. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100529. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100530. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100531. */
  100532. 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;
  100533. /**
  100534. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100535. *
  100536. * @param renderingGroupId The rendering group id corresponding to its index
  100537. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100538. * @param depth Automatically clears depth between groups if true and autoClear is true.
  100539. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  100540. */
  100541. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  100542. /**
  100543. * Gets the current auto clear configuration for one rendering group of the rendering
  100544. * manager.
  100545. * @param index the rendering group index to get the information for
  100546. * @returns The auto clear setup for the requested rendering group
  100547. */
  100548. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  100549. private _blockMaterialDirtyMechanism;
  100550. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  100551. blockMaterialDirtyMechanism: boolean;
  100552. /**
  100553. * Will flag all materials as dirty to trigger new shader compilation
  100554. * @param flag defines the flag used to specify which material part must be marked as dirty
  100555. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  100556. */
  100557. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  100558. /** @hidden */
  100559. _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;
  100560. /** @hidden */
  100561. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100562. }
  100563. }
  100564. declare module BABYLON {
  100565. /**
  100566. * Set of assets to keep when moving a scene into an asset container.
  100567. */
  100568. export class KeepAssets extends AbstractScene {
  100569. }
  100570. /**
  100571. * Container with a set of assets that can be added or removed from a scene.
  100572. */
  100573. export class AssetContainer extends AbstractScene {
  100574. /**
  100575. * The scene the AssetContainer belongs to.
  100576. */
  100577. scene: Scene;
  100578. /**
  100579. * Instantiates an AssetContainer.
  100580. * @param scene The scene the AssetContainer belongs to.
  100581. */
  100582. constructor(scene: Scene);
  100583. /**
  100584. * Adds all the assets from the container to the scene.
  100585. */
  100586. addAllToScene(): void;
  100587. /**
  100588. * Removes all the assets in the container from the scene
  100589. */
  100590. removeAllFromScene(): void;
  100591. /**
  100592. * Disposes all the assets in the container
  100593. */
  100594. dispose(): void;
  100595. private _moveAssets;
  100596. /**
  100597. * Removes all the assets contained in the scene and adds them to the container.
  100598. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  100599. */
  100600. moveAllFromScene(keepAssets?: KeepAssets): void;
  100601. /**
  100602. * 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.
  100603. * @returns the root mesh
  100604. */
  100605. createRootMesh(): Mesh;
  100606. }
  100607. }
  100608. declare module BABYLON {
  100609. /**
  100610. * Defines how the parser contract is defined.
  100611. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  100612. */
  100613. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  100614. /**
  100615. * Defines how the individual parser contract is defined.
  100616. * These parser can parse an individual asset
  100617. */
  100618. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  100619. /**
  100620. * Base class of the scene acting as a container for the different elements composing a scene.
  100621. * This class is dynamically extended by the different components of the scene increasing
  100622. * flexibility and reducing coupling
  100623. */
  100624. export abstract class AbstractScene {
  100625. /**
  100626. * Stores the list of available parsers in the application.
  100627. */
  100628. private static _BabylonFileParsers;
  100629. /**
  100630. * Stores the list of available individual parsers in the application.
  100631. */
  100632. private static _IndividualBabylonFileParsers;
  100633. /**
  100634. * Adds a parser in the list of available ones
  100635. * @param name Defines the name of the parser
  100636. * @param parser Defines the parser to add
  100637. */
  100638. static AddParser(name: string, parser: BabylonFileParser): void;
  100639. /**
  100640. * Gets a general parser from the list of avaialble ones
  100641. * @param name Defines the name of the parser
  100642. * @returns the requested parser or null
  100643. */
  100644. static GetParser(name: string): Nullable<BabylonFileParser>;
  100645. /**
  100646. * Adds n individual parser in the list of available ones
  100647. * @param name Defines the name of the parser
  100648. * @param parser Defines the parser to add
  100649. */
  100650. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  100651. /**
  100652. * Gets an individual parser from the list of avaialble ones
  100653. * @param name Defines the name of the parser
  100654. * @returns the requested parser or null
  100655. */
  100656. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  100657. /**
  100658. * Parser json data and populate both a scene and its associated container object
  100659. * @param jsonData Defines the data to parse
  100660. * @param scene Defines the scene to parse the data for
  100661. * @param container Defines the container attached to the parsing sequence
  100662. * @param rootUrl Defines the root url of the data
  100663. */
  100664. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  100665. /**
  100666. * Gets the list of root nodes (ie. nodes with no parent)
  100667. */
  100668. rootNodes: Node[];
  100669. /** All of the cameras added to this scene
  100670. * @see http://doc.babylonjs.com/babylon101/cameras
  100671. */
  100672. cameras: Camera[];
  100673. /**
  100674. * All of the lights added to this scene
  100675. * @see http://doc.babylonjs.com/babylon101/lights
  100676. */
  100677. lights: Light[];
  100678. /**
  100679. * All of the (abstract) meshes added to this scene
  100680. */
  100681. meshes: AbstractMesh[];
  100682. /**
  100683. * The list of skeletons added to the scene
  100684. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100685. */
  100686. skeletons: Skeleton[];
  100687. /**
  100688. * All of the particle systems added to this scene
  100689. * @see http://doc.babylonjs.com/babylon101/particles
  100690. */
  100691. particleSystems: IParticleSystem[];
  100692. /**
  100693. * Gets a list of Animations associated with the scene
  100694. */
  100695. animations: Animation[];
  100696. /**
  100697. * All of the animation groups added to this scene
  100698. * @see http://doc.babylonjs.com/how_to/group
  100699. */
  100700. animationGroups: AnimationGroup[];
  100701. /**
  100702. * All of the multi-materials added to this scene
  100703. * @see http://doc.babylonjs.com/how_to/multi_materials
  100704. */
  100705. multiMaterials: MultiMaterial[];
  100706. /**
  100707. * All of the materials added to this scene
  100708. * In the context of a Scene, it is not supposed to be modified manually.
  100709. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  100710. * Note also that the order of the Material wihin the array is not significant and might change.
  100711. * @see http://doc.babylonjs.com/babylon101/materials
  100712. */
  100713. materials: Material[];
  100714. /**
  100715. * The list of morph target managers added to the scene
  100716. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  100717. */
  100718. morphTargetManagers: MorphTargetManager[];
  100719. /**
  100720. * The list of geometries used in the scene.
  100721. */
  100722. geometries: Geometry[];
  100723. /**
  100724. * All of the tranform nodes added to this scene
  100725. * In the context of a Scene, it is not supposed to be modified manually.
  100726. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  100727. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  100728. * @see http://doc.babylonjs.com/how_to/transformnode
  100729. */
  100730. transformNodes: TransformNode[];
  100731. /**
  100732. * ActionManagers available on the scene.
  100733. */
  100734. actionManagers: AbstractActionManager[];
  100735. /**
  100736. * Textures to keep.
  100737. */
  100738. textures: BaseTexture[];
  100739. /**
  100740. * Environment texture for the scene
  100741. */
  100742. environmentTexture: Nullable<BaseTexture>;
  100743. }
  100744. }
  100745. declare module BABYLON {
  100746. /**
  100747. * Interface used to define options for Sound class
  100748. */
  100749. export interface ISoundOptions {
  100750. /**
  100751. * Does the sound autoplay once loaded.
  100752. */
  100753. autoplay?: boolean;
  100754. /**
  100755. * Does the sound loop after it finishes playing once.
  100756. */
  100757. loop?: boolean;
  100758. /**
  100759. * Sound's volume
  100760. */
  100761. volume?: number;
  100762. /**
  100763. * Is it a spatial sound?
  100764. */
  100765. spatialSound?: boolean;
  100766. /**
  100767. * Maximum distance to hear that sound
  100768. */
  100769. maxDistance?: number;
  100770. /**
  100771. * Uses user defined attenuation function
  100772. */
  100773. useCustomAttenuation?: boolean;
  100774. /**
  100775. * Define the roll off factor of spatial sounds.
  100776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100777. */
  100778. rolloffFactor?: number;
  100779. /**
  100780. * Define the reference distance the sound should be heard perfectly.
  100781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100782. */
  100783. refDistance?: number;
  100784. /**
  100785. * Define the distance attenuation model the sound will follow.
  100786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100787. */
  100788. distanceModel?: string;
  100789. /**
  100790. * Defines the playback speed (1 by default)
  100791. */
  100792. playbackRate?: number;
  100793. /**
  100794. * Defines if the sound is from a streaming source
  100795. */
  100796. streaming?: boolean;
  100797. /**
  100798. * Defines an optional length (in seconds) inside the sound file
  100799. */
  100800. length?: number;
  100801. /**
  100802. * Defines an optional offset (in seconds) inside the sound file
  100803. */
  100804. offset?: number;
  100805. /**
  100806. * If true, URLs will not be required to state the audio file codec to use.
  100807. */
  100808. skipCodecCheck?: boolean;
  100809. }
  100810. /**
  100811. * Defines a sound that can be played in the application.
  100812. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  100813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100814. */
  100815. export class Sound {
  100816. /**
  100817. * The name of the sound in the scene.
  100818. */
  100819. name: string;
  100820. /**
  100821. * Does the sound autoplay once loaded.
  100822. */
  100823. autoplay: boolean;
  100824. /**
  100825. * Does the sound loop after it finishes playing once.
  100826. */
  100827. loop: boolean;
  100828. /**
  100829. * Does the sound use a custom attenuation curve to simulate the falloff
  100830. * happening when the source gets further away from the camera.
  100831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100832. */
  100833. useCustomAttenuation: boolean;
  100834. /**
  100835. * The sound track id this sound belongs to.
  100836. */
  100837. soundTrackId: number;
  100838. /**
  100839. * Is this sound currently played.
  100840. */
  100841. isPlaying: boolean;
  100842. /**
  100843. * Is this sound currently paused.
  100844. */
  100845. isPaused: boolean;
  100846. /**
  100847. * Does this sound enables spatial sound.
  100848. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100849. */
  100850. spatialSound: boolean;
  100851. /**
  100852. * Define the reference distance the sound should be heard perfectly.
  100853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100854. */
  100855. refDistance: number;
  100856. /**
  100857. * Define the roll off factor of spatial sounds.
  100858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100859. */
  100860. rolloffFactor: number;
  100861. /**
  100862. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  100863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100864. */
  100865. maxDistance: number;
  100866. /**
  100867. * Define the distance attenuation model the sound will follow.
  100868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100869. */
  100870. distanceModel: string;
  100871. /**
  100872. * @hidden
  100873. * Back Compat
  100874. **/
  100875. onended: () => any;
  100876. /**
  100877. * Observable event when the current playing sound finishes.
  100878. */
  100879. onEndedObservable: Observable<Sound>;
  100880. private _panningModel;
  100881. private _playbackRate;
  100882. private _streaming;
  100883. private _startTime;
  100884. private _startOffset;
  100885. private _position;
  100886. /** @hidden */
  100887. _positionInEmitterSpace: boolean;
  100888. private _localDirection;
  100889. private _volume;
  100890. private _isReadyToPlay;
  100891. private _isDirectional;
  100892. private _readyToPlayCallback;
  100893. private _audioBuffer;
  100894. private _soundSource;
  100895. private _streamingSource;
  100896. private _soundPanner;
  100897. private _soundGain;
  100898. private _inputAudioNode;
  100899. private _outputAudioNode;
  100900. private _coneInnerAngle;
  100901. private _coneOuterAngle;
  100902. private _coneOuterGain;
  100903. private _scene;
  100904. private _connectedTransformNode;
  100905. private _customAttenuationFunction;
  100906. private _registerFunc;
  100907. private _isOutputConnected;
  100908. private _htmlAudioElement;
  100909. private _urlType;
  100910. private _length?;
  100911. private _offset?;
  100912. /** @hidden */
  100913. static _SceneComponentInitialization: (scene: Scene) => void;
  100914. /**
  100915. * Create a sound and attach it to a scene
  100916. * @param name Name of your sound
  100917. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  100918. * @param scene defines the scene the sound belongs to
  100919. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  100920. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  100921. */
  100922. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  100923. /**
  100924. * Release the sound and its associated resources
  100925. */
  100926. dispose(): void;
  100927. /**
  100928. * Gets if the sounds is ready to be played or not.
  100929. * @returns true if ready, otherwise false
  100930. */
  100931. isReady(): boolean;
  100932. private _soundLoaded;
  100933. /**
  100934. * Sets the data of the sound from an audiobuffer
  100935. * @param audioBuffer The audioBuffer containing the data
  100936. */
  100937. setAudioBuffer(audioBuffer: AudioBuffer): void;
  100938. /**
  100939. * Updates the current sounds options such as maxdistance, loop...
  100940. * @param options A JSON object containing values named as the object properties
  100941. */
  100942. updateOptions(options: ISoundOptions): void;
  100943. private _createSpatialParameters;
  100944. private _updateSpatialParameters;
  100945. /**
  100946. * Switch the panning model to HRTF:
  100947. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100949. */
  100950. switchPanningModelToHRTF(): void;
  100951. /**
  100952. * Switch the panning model to Equal Power:
  100953. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100955. */
  100956. switchPanningModelToEqualPower(): void;
  100957. private _switchPanningModel;
  100958. /**
  100959. * Connect this sound to a sound track audio node like gain...
  100960. * @param soundTrackAudioNode the sound track audio node to connect to
  100961. */
  100962. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  100963. /**
  100964. * Transform this sound into a directional source
  100965. * @param coneInnerAngle Size of the inner cone in degree
  100966. * @param coneOuterAngle Size of the outer cone in degree
  100967. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  100968. */
  100969. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  100970. /**
  100971. * Gets or sets the inner angle for the directional cone.
  100972. */
  100973. /**
  100974. * Gets or sets the inner angle for the directional cone.
  100975. */
  100976. directionalConeInnerAngle: number;
  100977. /**
  100978. * Gets or sets the outer angle for the directional cone.
  100979. */
  100980. /**
  100981. * Gets or sets the outer angle for the directional cone.
  100982. */
  100983. directionalConeOuterAngle: number;
  100984. /**
  100985. * Sets the position of the emitter if spatial sound is enabled
  100986. * @param newPosition Defines the new posisiton
  100987. */
  100988. setPosition(newPosition: Vector3): void;
  100989. /**
  100990. * Sets the local direction of the emitter if spatial sound is enabled
  100991. * @param newLocalDirection Defines the new local direction
  100992. */
  100993. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  100994. private _updateDirection;
  100995. /** @hidden */
  100996. updateDistanceFromListener(): void;
  100997. /**
  100998. * Sets a new custom attenuation function for the sound.
  100999. * @param callback Defines the function used for the attenuation
  101000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101001. */
  101002. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  101003. /**
  101004. * Play the sound
  101005. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  101006. * @param offset (optional) Start the sound at a specific time in seconds
  101007. * @param length (optional) Sound duration (in seconds)
  101008. */
  101009. play(time?: number, offset?: number, length?: number): void;
  101010. private _onended;
  101011. /**
  101012. * Stop the sound
  101013. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  101014. */
  101015. stop(time?: number): void;
  101016. /**
  101017. * Put the sound in pause
  101018. */
  101019. pause(): void;
  101020. /**
  101021. * Sets a dedicated volume for this sounds
  101022. * @param newVolume Define the new volume of the sound
  101023. * @param time Define time for gradual change to new volume
  101024. */
  101025. setVolume(newVolume: number, time?: number): void;
  101026. /**
  101027. * Set the sound play back rate
  101028. * @param newPlaybackRate Define the playback rate the sound should be played at
  101029. */
  101030. setPlaybackRate(newPlaybackRate: number): void;
  101031. /**
  101032. * Gets the volume of the sound.
  101033. * @returns the volume of the sound
  101034. */
  101035. getVolume(): number;
  101036. /**
  101037. * Attach the sound to a dedicated mesh
  101038. * @param transformNode The transform node to connect the sound with
  101039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101040. */
  101041. attachToMesh(transformNode: TransformNode): void;
  101042. /**
  101043. * Detach the sound from the previously attached mesh
  101044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101045. */
  101046. detachFromMesh(): void;
  101047. private _onRegisterAfterWorldMatrixUpdate;
  101048. /**
  101049. * Clone the current sound in the scene.
  101050. * @returns the new sound clone
  101051. */
  101052. clone(): Nullable<Sound>;
  101053. /**
  101054. * Gets the current underlying audio buffer containing the data
  101055. * @returns the audio buffer
  101056. */
  101057. getAudioBuffer(): Nullable<AudioBuffer>;
  101058. /**
  101059. * Serializes the Sound in a JSON representation
  101060. * @returns the JSON representation of the sound
  101061. */
  101062. serialize(): any;
  101063. /**
  101064. * Parse a JSON representation of a sound to innstantiate in a given scene
  101065. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  101066. * @param scene Define the scene the new parsed sound should be created in
  101067. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  101068. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  101069. * @returns the newly parsed sound
  101070. */
  101071. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  101072. }
  101073. }
  101074. declare module BABYLON {
  101075. /**
  101076. * This defines an action helpful to play a defined sound on a triggered action.
  101077. */
  101078. export class PlaySoundAction extends Action {
  101079. private _sound;
  101080. /**
  101081. * Instantiate the action
  101082. * @param triggerOptions defines the trigger options
  101083. * @param sound defines the sound to play
  101084. * @param condition defines the trigger related conditions
  101085. */
  101086. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101087. /** @hidden */
  101088. _prepare(): void;
  101089. /**
  101090. * Execute the action and play the sound.
  101091. */
  101092. execute(): void;
  101093. /**
  101094. * Serializes the actions and its related information.
  101095. * @param parent defines the object to serialize in
  101096. * @returns the serialized object
  101097. */
  101098. serialize(parent: any): any;
  101099. }
  101100. /**
  101101. * This defines an action helpful to stop a defined sound on a triggered action.
  101102. */
  101103. export class StopSoundAction extends Action {
  101104. private _sound;
  101105. /**
  101106. * Instantiate the action
  101107. * @param triggerOptions defines the trigger options
  101108. * @param sound defines the sound to stop
  101109. * @param condition defines the trigger related conditions
  101110. */
  101111. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101112. /** @hidden */
  101113. _prepare(): void;
  101114. /**
  101115. * Execute the action and stop the sound.
  101116. */
  101117. execute(): void;
  101118. /**
  101119. * Serializes the actions and its related information.
  101120. * @param parent defines the object to serialize in
  101121. * @returns the serialized object
  101122. */
  101123. serialize(parent: any): any;
  101124. }
  101125. }
  101126. declare module BABYLON {
  101127. /**
  101128. * This defines an action responsible to change the value of a property
  101129. * by interpolating between its current value and the newly set one once triggered.
  101130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101131. */
  101132. export class InterpolateValueAction extends Action {
  101133. /**
  101134. * Defines the path of the property where the value should be interpolated
  101135. */
  101136. propertyPath: string;
  101137. /**
  101138. * Defines the target value at the end of the interpolation.
  101139. */
  101140. value: any;
  101141. /**
  101142. * Defines the time it will take for the property to interpolate to the value.
  101143. */
  101144. duration: number;
  101145. /**
  101146. * Defines if the other scene animations should be stopped when the action has been triggered
  101147. */
  101148. stopOtherAnimations?: boolean;
  101149. /**
  101150. * Defines a callback raised once the interpolation animation has been done.
  101151. */
  101152. onInterpolationDone?: () => void;
  101153. /**
  101154. * Observable triggered once the interpolation animation has been done.
  101155. */
  101156. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  101157. private _target;
  101158. private _effectiveTarget;
  101159. private _property;
  101160. /**
  101161. * Instantiate the action
  101162. * @param triggerOptions defines the trigger options
  101163. * @param target defines the object containing the value to interpolate
  101164. * @param propertyPath defines the path to the property in the target object
  101165. * @param value defines the target value at the end of the interpolation
  101166. * @param duration deines the time it will take for the property to interpolate to the value.
  101167. * @param condition defines the trigger related conditions
  101168. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  101169. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  101170. */
  101171. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  101172. /** @hidden */
  101173. _prepare(): void;
  101174. /**
  101175. * Execute the action starts the value interpolation.
  101176. */
  101177. execute(): void;
  101178. /**
  101179. * Serializes the actions and its related information.
  101180. * @param parent defines the object to serialize in
  101181. * @returns the serialized object
  101182. */
  101183. serialize(parent: any): any;
  101184. }
  101185. }
  101186. declare module BABYLON {
  101187. /**
  101188. * Options allowed during the creation of a sound track.
  101189. */
  101190. export interface ISoundTrackOptions {
  101191. /**
  101192. * The volume the sound track should take during creation
  101193. */
  101194. volume?: number;
  101195. /**
  101196. * Define if the sound track is the main sound track of the scene
  101197. */
  101198. mainTrack?: boolean;
  101199. }
  101200. /**
  101201. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  101202. * It will be also used in a future release to apply effects on a specific track.
  101203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101204. */
  101205. export class SoundTrack {
  101206. /**
  101207. * The unique identifier of the sound track in the scene.
  101208. */
  101209. id: number;
  101210. /**
  101211. * The list of sounds included in the sound track.
  101212. */
  101213. soundCollection: Array<Sound>;
  101214. private _outputAudioNode;
  101215. private _scene;
  101216. private _isMainTrack;
  101217. private _connectedAnalyser;
  101218. private _options;
  101219. private _isInitialized;
  101220. /**
  101221. * Creates a new sound track.
  101222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101223. * @param scene Define the scene the sound track belongs to
  101224. * @param options
  101225. */
  101226. constructor(scene: Scene, options?: ISoundTrackOptions);
  101227. private _initializeSoundTrackAudioGraph;
  101228. /**
  101229. * Release the sound track and its associated resources
  101230. */
  101231. dispose(): void;
  101232. /**
  101233. * Adds a sound to this sound track
  101234. * @param sound define the cound to add
  101235. * @ignoreNaming
  101236. */
  101237. AddSound(sound: Sound): void;
  101238. /**
  101239. * Removes a sound to this sound track
  101240. * @param sound define the cound to remove
  101241. * @ignoreNaming
  101242. */
  101243. RemoveSound(sound: Sound): void;
  101244. /**
  101245. * Set a global volume for the full sound track.
  101246. * @param newVolume Define the new volume of the sound track
  101247. */
  101248. setVolume(newVolume: number): void;
  101249. /**
  101250. * Switch the panning model to HRTF:
  101251. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101253. */
  101254. switchPanningModelToHRTF(): void;
  101255. /**
  101256. * Switch the panning model to Equal Power:
  101257. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101259. */
  101260. switchPanningModelToEqualPower(): void;
  101261. /**
  101262. * Connect the sound track to an audio analyser allowing some amazing
  101263. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101265. * @param analyser The analyser to connect to the engine
  101266. */
  101267. connectToAnalyser(analyser: Analyser): void;
  101268. }
  101269. }
  101270. declare module BABYLON {
  101271. interface AbstractScene {
  101272. /**
  101273. * The list of sounds used in the scene.
  101274. */
  101275. sounds: Nullable<Array<Sound>>;
  101276. }
  101277. interface Scene {
  101278. /**
  101279. * @hidden
  101280. * Backing field
  101281. */
  101282. _mainSoundTrack: SoundTrack;
  101283. /**
  101284. * The main sound track played by the scene.
  101285. * It cotains your primary collection of sounds.
  101286. */
  101287. mainSoundTrack: SoundTrack;
  101288. /**
  101289. * The list of sound tracks added to the scene
  101290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101291. */
  101292. soundTracks: Nullable<Array<SoundTrack>>;
  101293. /**
  101294. * Gets a sound using a given name
  101295. * @param name defines the name to search for
  101296. * @return the found sound or null if not found at all.
  101297. */
  101298. getSoundByName(name: string): Nullable<Sound>;
  101299. /**
  101300. * Gets or sets if audio support is enabled
  101301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101302. */
  101303. audioEnabled: boolean;
  101304. /**
  101305. * Gets or sets if audio will be output to headphones
  101306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101307. */
  101308. headphone: boolean;
  101309. /**
  101310. * Gets or sets custom audio listener position provider
  101311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101312. */
  101313. audioListenerPositionProvider: Nullable<() => Vector3>;
  101314. }
  101315. /**
  101316. * Defines the sound scene component responsible to manage any sounds
  101317. * in a given scene.
  101318. */
  101319. export class AudioSceneComponent implements ISceneSerializableComponent {
  101320. /**
  101321. * The component name helpfull to identify the component in the list of scene components.
  101322. */
  101323. readonly name: string;
  101324. /**
  101325. * The scene the component belongs to.
  101326. */
  101327. scene: Scene;
  101328. private _audioEnabled;
  101329. /**
  101330. * Gets whether audio is enabled or not.
  101331. * Please use related enable/disable method to switch state.
  101332. */
  101333. readonly audioEnabled: boolean;
  101334. private _headphone;
  101335. /**
  101336. * Gets whether audio is outputing to headphone or not.
  101337. * Please use the according Switch methods to change output.
  101338. */
  101339. readonly headphone: boolean;
  101340. private _audioListenerPositionProvider;
  101341. /**
  101342. * Gets the current audio listener position provider
  101343. */
  101344. /**
  101345. * Sets a custom listener position for all sounds in the scene
  101346. * By default, this is the position of the first active camera
  101347. */
  101348. audioListenerPositionProvider: Nullable<() => Vector3>;
  101349. /**
  101350. * Creates a new instance of the component for the given scene
  101351. * @param scene Defines the scene to register the component in
  101352. */
  101353. constructor(scene: Scene);
  101354. /**
  101355. * Registers the component in a given scene
  101356. */
  101357. register(): void;
  101358. /**
  101359. * Rebuilds the elements related to this component in case of
  101360. * context lost for instance.
  101361. */
  101362. rebuild(): void;
  101363. /**
  101364. * Serializes the component data to the specified json object
  101365. * @param serializationObject The object to serialize to
  101366. */
  101367. serialize(serializationObject: any): void;
  101368. /**
  101369. * Adds all the elements from the container to the scene
  101370. * @param container the container holding the elements
  101371. */
  101372. addFromContainer(container: AbstractScene): void;
  101373. /**
  101374. * Removes all the elements in the container from the scene
  101375. * @param container contains the elements to remove
  101376. * @param dispose if the removed element should be disposed (default: false)
  101377. */
  101378. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  101379. /**
  101380. * Disposes the component and the associated ressources.
  101381. */
  101382. dispose(): void;
  101383. /**
  101384. * Disables audio in the associated scene.
  101385. */
  101386. disableAudio(): void;
  101387. /**
  101388. * Enables audio in the associated scene.
  101389. */
  101390. enableAudio(): void;
  101391. /**
  101392. * Switch audio to headphone output.
  101393. */
  101394. switchAudioModeForHeadphones(): void;
  101395. /**
  101396. * Switch audio to normal speakers.
  101397. */
  101398. switchAudioModeForNormalSpeakers(): void;
  101399. private _afterRender;
  101400. }
  101401. }
  101402. declare module BABYLON {
  101403. /**
  101404. * Wraps one or more Sound objects and selects one with random weight for playback.
  101405. */
  101406. export class WeightedSound {
  101407. /** When true a Sound will be selected and played when the current playing Sound completes. */
  101408. loop: boolean;
  101409. private _coneInnerAngle;
  101410. private _coneOuterAngle;
  101411. private _volume;
  101412. /** A Sound is currently playing. */
  101413. isPlaying: boolean;
  101414. /** A Sound is currently paused. */
  101415. isPaused: boolean;
  101416. private _sounds;
  101417. private _weights;
  101418. private _currentIndex?;
  101419. /**
  101420. * Creates a new WeightedSound from the list of sounds given.
  101421. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  101422. * @param sounds Array of Sounds that will be selected from.
  101423. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  101424. */
  101425. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  101426. /**
  101427. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  101428. */
  101429. /**
  101430. * The size of cone in degress for a directional sound in which there will be no attenuation.
  101431. */
  101432. directionalConeInnerAngle: number;
  101433. /**
  101434. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101435. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101436. */
  101437. /**
  101438. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101439. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101440. */
  101441. directionalConeOuterAngle: number;
  101442. /**
  101443. * Playback volume.
  101444. */
  101445. /**
  101446. * Playback volume.
  101447. */
  101448. volume: number;
  101449. private _onended;
  101450. /**
  101451. * Suspend playback
  101452. */
  101453. pause(): void;
  101454. /**
  101455. * Stop playback
  101456. */
  101457. stop(): void;
  101458. /**
  101459. * Start playback.
  101460. * @param startOffset Position the clip head at a specific time in seconds.
  101461. */
  101462. play(startOffset?: number): void;
  101463. }
  101464. }
  101465. declare module BABYLON {
  101466. /**
  101467. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  101468. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101469. */
  101470. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  101471. /**
  101472. * Gets the name of the behavior.
  101473. */
  101474. readonly name: string;
  101475. /**
  101476. * The easing function used by animations
  101477. */
  101478. static EasingFunction: BackEase;
  101479. /**
  101480. * The easing mode used by animations
  101481. */
  101482. static EasingMode: number;
  101483. /**
  101484. * The duration of the animation, in milliseconds
  101485. */
  101486. transitionDuration: number;
  101487. /**
  101488. * Length of the distance animated by the transition when lower radius is reached
  101489. */
  101490. lowerRadiusTransitionRange: number;
  101491. /**
  101492. * Length of the distance animated by the transition when upper radius is reached
  101493. */
  101494. upperRadiusTransitionRange: number;
  101495. private _autoTransitionRange;
  101496. /**
  101497. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101498. */
  101499. /**
  101500. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101501. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  101502. */
  101503. autoTransitionRange: boolean;
  101504. private _attachedCamera;
  101505. private _onAfterCheckInputsObserver;
  101506. private _onMeshTargetChangedObserver;
  101507. /**
  101508. * Initializes the behavior.
  101509. */
  101510. init(): void;
  101511. /**
  101512. * Attaches the behavior to its arc rotate camera.
  101513. * @param camera Defines the camera to attach the behavior to
  101514. */
  101515. attach(camera: ArcRotateCamera): void;
  101516. /**
  101517. * Detaches the behavior from its current arc rotate camera.
  101518. */
  101519. detach(): void;
  101520. private _radiusIsAnimating;
  101521. private _radiusBounceTransition;
  101522. private _animatables;
  101523. private _cachedWheelPrecision;
  101524. /**
  101525. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  101526. * @param radiusLimit The limit to check against.
  101527. * @return Bool to indicate if at limit.
  101528. */
  101529. private _isRadiusAtLimit;
  101530. /**
  101531. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  101532. * @param radiusDelta The delta by which to animate to. Can be negative.
  101533. */
  101534. private _applyBoundRadiusAnimation;
  101535. /**
  101536. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  101537. */
  101538. protected _clearAnimationLocks(): void;
  101539. /**
  101540. * Stops and removes all animations that have been applied to the camera
  101541. */
  101542. stopAllAnimations(): void;
  101543. }
  101544. }
  101545. declare module BABYLON {
  101546. /**
  101547. * 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.
  101548. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101549. */
  101550. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  101551. /**
  101552. * Gets the name of the behavior.
  101553. */
  101554. readonly name: string;
  101555. private _mode;
  101556. private _radiusScale;
  101557. private _positionScale;
  101558. private _defaultElevation;
  101559. private _elevationReturnTime;
  101560. private _elevationReturnWaitTime;
  101561. private _zoomStopsAnimation;
  101562. private _framingTime;
  101563. /**
  101564. * The easing function used by animations
  101565. */
  101566. static EasingFunction: ExponentialEase;
  101567. /**
  101568. * The easing mode used by animations
  101569. */
  101570. static EasingMode: number;
  101571. /**
  101572. * Sets the current mode used by the behavior
  101573. */
  101574. /**
  101575. * Gets current mode used by the behavior.
  101576. */
  101577. mode: number;
  101578. /**
  101579. * Sets the scale applied to the radius (1 by default)
  101580. */
  101581. /**
  101582. * Gets the scale applied to the radius
  101583. */
  101584. radiusScale: number;
  101585. /**
  101586. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101587. */
  101588. /**
  101589. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101590. */
  101591. positionScale: number;
  101592. /**
  101593. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101594. * behaviour is triggered, in radians.
  101595. */
  101596. /**
  101597. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101598. * behaviour is triggered, in radians.
  101599. */
  101600. defaultElevation: number;
  101601. /**
  101602. * Sets the time (in milliseconds) taken to return to the default beta position.
  101603. * Negative value indicates camera should not return to default.
  101604. */
  101605. /**
  101606. * Gets the time (in milliseconds) taken to return to the default beta position.
  101607. * Negative value indicates camera should not return to default.
  101608. */
  101609. elevationReturnTime: number;
  101610. /**
  101611. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101612. */
  101613. /**
  101614. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101615. */
  101616. elevationReturnWaitTime: number;
  101617. /**
  101618. * Sets the flag that indicates if user zooming should stop animation.
  101619. */
  101620. /**
  101621. * Gets the flag that indicates if user zooming should stop animation.
  101622. */
  101623. zoomStopsAnimation: boolean;
  101624. /**
  101625. * Sets the transition time when framing the mesh, in milliseconds
  101626. */
  101627. /**
  101628. * Gets the transition time when framing the mesh, in milliseconds
  101629. */
  101630. framingTime: number;
  101631. /**
  101632. * Define if the behavior should automatically change the configured
  101633. * camera limits and sensibilities.
  101634. */
  101635. autoCorrectCameraLimitsAndSensibility: boolean;
  101636. private _onPrePointerObservableObserver;
  101637. private _onAfterCheckInputsObserver;
  101638. private _onMeshTargetChangedObserver;
  101639. private _attachedCamera;
  101640. private _isPointerDown;
  101641. private _lastInteractionTime;
  101642. /**
  101643. * Initializes the behavior.
  101644. */
  101645. init(): void;
  101646. /**
  101647. * Attaches the behavior to its arc rotate camera.
  101648. * @param camera Defines the camera to attach the behavior to
  101649. */
  101650. attach(camera: ArcRotateCamera): void;
  101651. /**
  101652. * Detaches the behavior from its current arc rotate camera.
  101653. */
  101654. detach(): void;
  101655. private _animatables;
  101656. private _betaIsAnimating;
  101657. private _betaTransition;
  101658. private _radiusTransition;
  101659. private _vectorTransition;
  101660. /**
  101661. * Targets the given mesh and updates zoom level accordingly.
  101662. * @param mesh The mesh to target.
  101663. * @param radius Optional. If a cached radius position already exists, overrides default.
  101664. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101665. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101666. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101667. */
  101668. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101669. /**
  101670. * Targets the given mesh with its children and updates zoom level accordingly.
  101671. * @param mesh The mesh to target.
  101672. * @param radius Optional. If a cached radius position already exists, overrides default.
  101673. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101674. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101675. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101676. */
  101677. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101678. /**
  101679. * Targets the given meshes with their children and updates zoom level accordingly.
  101680. * @param meshes The mesh to target.
  101681. * @param radius Optional. If a cached radius position already exists, overrides default.
  101682. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101683. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101684. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101685. */
  101686. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101687. /**
  101688. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  101689. * @param minimumWorld Determines the smaller position of the bounding box extend
  101690. * @param maximumWorld Determines the bigger position of the bounding box extend
  101691. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101692. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101693. */
  101694. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101695. /**
  101696. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  101697. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  101698. * frustum width.
  101699. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  101700. * to fully enclose the mesh in the viewing frustum.
  101701. */
  101702. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  101703. /**
  101704. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  101705. * is automatically returned to its default position (expected to be above ground plane).
  101706. */
  101707. private _maintainCameraAboveGround;
  101708. /**
  101709. * Returns the frustum slope based on the canvas ratio and camera FOV
  101710. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  101711. */
  101712. private _getFrustumSlope;
  101713. /**
  101714. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  101715. */
  101716. private _clearAnimationLocks;
  101717. /**
  101718. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101719. */
  101720. private _applyUserInteraction;
  101721. /**
  101722. * Stops and removes all animations that have been applied to the camera
  101723. */
  101724. stopAllAnimations(): void;
  101725. /**
  101726. * Gets a value indicating if the user is moving the camera
  101727. */
  101728. readonly isUserIsMoving: boolean;
  101729. /**
  101730. * The camera can move all the way towards the mesh.
  101731. */
  101732. static IgnoreBoundsSizeMode: number;
  101733. /**
  101734. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  101735. */
  101736. static FitFrustumSidesMode: number;
  101737. }
  101738. }
  101739. declare module BABYLON {
  101740. /**
  101741. * Base class for Camera Pointer Inputs.
  101742. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  101743. * for example usage.
  101744. */
  101745. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  101746. /**
  101747. * Defines the camera the input is attached to.
  101748. */
  101749. abstract camera: Camera;
  101750. /**
  101751. * Whether keyboard modifier keys are pressed at time of last mouse event.
  101752. */
  101753. protected _altKey: boolean;
  101754. protected _ctrlKey: boolean;
  101755. protected _metaKey: boolean;
  101756. protected _shiftKey: boolean;
  101757. /**
  101758. * Which mouse buttons were pressed at time of last mouse event.
  101759. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  101760. */
  101761. protected _buttonsPressed: number;
  101762. /**
  101763. * Defines the buttons associated with the input to handle camera move.
  101764. */
  101765. buttons: number[];
  101766. /**
  101767. * Attach the input controls to a specific dom element to get the input from.
  101768. * @param element Defines the element the controls should be listened from
  101769. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101770. */
  101771. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101772. /**
  101773. * Detach the current controls from the specified dom element.
  101774. * @param element Defines the element to stop listening the inputs from
  101775. */
  101776. detachControl(element: Nullable<HTMLElement>): void;
  101777. /**
  101778. * Gets the class name of the current input.
  101779. * @returns the class name
  101780. */
  101781. getClassName(): string;
  101782. /**
  101783. * Get the friendly name associated with the input class.
  101784. * @returns the input friendly name
  101785. */
  101786. getSimpleName(): string;
  101787. /**
  101788. * Called on pointer POINTERDOUBLETAP event.
  101789. * Override this method to provide functionality on POINTERDOUBLETAP event.
  101790. */
  101791. protected onDoubleTap(type: string): void;
  101792. /**
  101793. * Called on pointer POINTERMOVE event if only a single touch is active.
  101794. * Override this method to provide functionality.
  101795. */
  101796. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101797. /**
  101798. * Called on pointer POINTERMOVE event if multiple touches are active.
  101799. * Override this method to provide functionality.
  101800. */
  101801. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101802. /**
  101803. * Called on JS contextmenu event.
  101804. * Override this method to provide functionality.
  101805. */
  101806. protected onContextMenu(evt: PointerEvent): void;
  101807. /**
  101808. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101809. * press.
  101810. * Override this method to provide functionality.
  101811. */
  101812. protected onButtonDown(evt: PointerEvent): void;
  101813. /**
  101814. * Called each time a new POINTERUP event occurs. Ie, for each button
  101815. * release.
  101816. * Override this method to provide functionality.
  101817. */
  101818. protected onButtonUp(evt: PointerEvent): void;
  101819. /**
  101820. * Called when window becomes inactive.
  101821. * Override this method to provide functionality.
  101822. */
  101823. protected onLostFocus(): void;
  101824. private _pointerInput;
  101825. private _observer;
  101826. private _onLostFocus;
  101827. private pointA;
  101828. private pointB;
  101829. }
  101830. }
  101831. declare module BABYLON {
  101832. /**
  101833. * Manage the pointers inputs to control an arc rotate camera.
  101834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101835. */
  101836. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  101837. /**
  101838. * Defines the camera the input is attached to.
  101839. */
  101840. camera: ArcRotateCamera;
  101841. /**
  101842. * Gets the class name of the current input.
  101843. * @returns the class name
  101844. */
  101845. getClassName(): string;
  101846. /**
  101847. * Defines the buttons associated with the input to handle camera move.
  101848. */
  101849. buttons: number[];
  101850. /**
  101851. * Defines the pointer angular sensibility along the X axis or how fast is
  101852. * the camera rotating.
  101853. */
  101854. angularSensibilityX: number;
  101855. /**
  101856. * Defines the pointer angular sensibility along the Y axis or how fast is
  101857. * the camera rotating.
  101858. */
  101859. angularSensibilityY: number;
  101860. /**
  101861. * Defines the pointer pinch precision or how fast is the camera zooming.
  101862. */
  101863. pinchPrecision: number;
  101864. /**
  101865. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101866. * from 0.
  101867. * It defines the percentage of current camera.radius to use as delta when
  101868. * pinch zoom is used.
  101869. */
  101870. pinchDeltaPercentage: number;
  101871. /**
  101872. * Defines the pointer panning sensibility or how fast is the camera moving.
  101873. */
  101874. panningSensibility: number;
  101875. /**
  101876. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  101877. */
  101878. multiTouchPanning: boolean;
  101879. /**
  101880. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  101881. * zoom (pinch) through multitouch.
  101882. */
  101883. multiTouchPanAndZoom: boolean;
  101884. /**
  101885. * Revers pinch action direction.
  101886. */
  101887. pinchInwards: boolean;
  101888. private _isPanClick;
  101889. private _twoFingerActivityCount;
  101890. private _isPinching;
  101891. /**
  101892. * Called on pointer POINTERMOVE event if only a single touch is active.
  101893. */
  101894. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101895. /**
  101896. * Called on pointer POINTERDOUBLETAP event.
  101897. */
  101898. protected onDoubleTap(type: string): void;
  101899. /**
  101900. * Called on pointer POINTERMOVE event if multiple touches are active.
  101901. */
  101902. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101903. /**
  101904. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101905. * press.
  101906. */
  101907. protected onButtonDown(evt: PointerEvent): void;
  101908. /**
  101909. * Called each time a new POINTERUP event occurs. Ie, for each button
  101910. * release.
  101911. */
  101912. protected onButtonUp(evt: PointerEvent): void;
  101913. /**
  101914. * Called when window becomes inactive.
  101915. */
  101916. protected onLostFocus(): void;
  101917. }
  101918. }
  101919. declare module BABYLON {
  101920. /**
  101921. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  101922. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101923. */
  101924. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  101925. /**
  101926. * Defines the camera the input is attached to.
  101927. */
  101928. camera: ArcRotateCamera;
  101929. /**
  101930. * Defines the list of key codes associated with the up action (increase alpha)
  101931. */
  101932. keysUp: number[];
  101933. /**
  101934. * Defines the list of key codes associated with the down action (decrease alpha)
  101935. */
  101936. keysDown: number[];
  101937. /**
  101938. * Defines the list of key codes associated with the left action (increase beta)
  101939. */
  101940. keysLeft: number[];
  101941. /**
  101942. * Defines the list of key codes associated with the right action (decrease beta)
  101943. */
  101944. keysRight: number[];
  101945. /**
  101946. * Defines the list of key codes associated with the reset action.
  101947. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  101948. */
  101949. keysReset: number[];
  101950. /**
  101951. * Defines the panning sensibility of the inputs.
  101952. * (How fast is the camera paning)
  101953. */
  101954. panningSensibility: number;
  101955. /**
  101956. * Defines the zooming sensibility of the inputs.
  101957. * (How fast is the camera zooming)
  101958. */
  101959. zoomingSensibility: number;
  101960. /**
  101961. * Defines wether maintaining the alt key down switch the movement mode from
  101962. * orientation to zoom.
  101963. */
  101964. useAltToZoom: boolean;
  101965. /**
  101966. * Rotation speed of the camera
  101967. */
  101968. angularSpeed: number;
  101969. private _keys;
  101970. private _ctrlPressed;
  101971. private _altPressed;
  101972. private _onCanvasBlurObserver;
  101973. private _onKeyboardObserver;
  101974. private _engine;
  101975. private _scene;
  101976. /**
  101977. * Attach the input controls to a specific dom element to get the input from.
  101978. * @param element Defines the element the controls should be listened from
  101979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101980. */
  101981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101982. /**
  101983. * Detach the current controls from the specified dom element.
  101984. * @param element Defines the element to stop listening the inputs from
  101985. */
  101986. detachControl(element: Nullable<HTMLElement>): void;
  101987. /**
  101988. * Update the current camera state depending on the inputs that have been used this frame.
  101989. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101990. */
  101991. checkInputs(): void;
  101992. /**
  101993. * Gets the class name of the current intput.
  101994. * @returns the class name
  101995. */
  101996. getClassName(): string;
  101997. /**
  101998. * Get the friendly name associated with the input class.
  101999. * @returns the input friendly name
  102000. */
  102001. getSimpleName(): string;
  102002. }
  102003. }
  102004. declare module BABYLON {
  102005. /**
  102006. * Manage the mouse wheel inputs to control an arc rotate camera.
  102007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102008. */
  102009. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  102010. /**
  102011. * Defines the camera the input is attached to.
  102012. */
  102013. camera: ArcRotateCamera;
  102014. /**
  102015. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102016. */
  102017. wheelPrecision: number;
  102018. /**
  102019. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102020. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102021. */
  102022. wheelDeltaPercentage: number;
  102023. private _wheel;
  102024. private _observer;
  102025. private computeDeltaFromMouseWheelLegacyEvent;
  102026. /**
  102027. * Attach the input controls to a specific dom element to get the input from.
  102028. * @param element Defines the element the controls should be listened from
  102029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102030. */
  102031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102032. /**
  102033. * Detach the current controls from the specified dom element.
  102034. * @param element Defines the element to stop listening the inputs from
  102035. */
  102036. detachControl(element: Nullable<HTMLElement>): void;
  102037. /**
  102038. * Gets the class name of the current intput.
  102039. * @returns the class name
  102040. */
  102041. getClassName(): string;
  102042. /**
  102043. * Get the friendly name associated with the input class.
  102044. * @returns the input friendly name
  102045. */
  102046. getSimpleName(): string;
  102047. }
  102048. }
  102049. declare module BABYLON {
  102050. /**
  102051. * Default Inputs manager for the ArcRotateCamera.
  102052. * It groups all the default supported inputs for ease of use.
  102053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102054. */
  102055. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  102056. /**
  102057. * Instantiates a new ArcRotateCameraInputsManager.
  102058. * @param camera Defines the camera the inputs belong to
  102059. */
  102060. constructor(camera: ArcRotateCamera);
  102061. /**
  102062. * Add mouse wheel input support to the input manager.
  102063. * @returns the current input manager
  102064. */
  102065. addMouseWheel(): ArcRotateCameraInputsManager;
  102066. /**
  102067. * Add pointers input support to the input manager.
  102068. * @returns the current input manager
  102069. */
  102070. addPointers(): ArcRotateCameraInputsManager;
  102071. /**
  102072. * Add keyboard input support to the input manager.
  102073. * @returns the current input manager
  102074. */
  102075. addKeyboard(): ArcRotateCameraInputsManager;
  102076. }
  102077. }
  102078. declare module BABYLON {
  102079. /**
  102080. * This represents an orbital type of camera.
  102081. *
  102082. * 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.
  102083. * 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.
  102084. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  102085. */
  102086. export class ArcRotateCamera extends TargetCamera {
  102087. /**
  102088. * Defines the rotation angle of the camera along the longitudinal axis.
  102089. */
  102090. alpha: number;
  102091. /**
  102092. * Defines the rotation angle of the camera along the latitudinal axis.
  102093. */
  102094. beta: number;
  102095. /**
  102096. * Defines the radius of the camera from it s target point.
  102097. */
  102098. radius: number;
  102099. protected _target: Vector3;
  102100. protected _targetHost: Nullable<AbstractMesh>;
  102101. /**
  102102. * Defines the target point of the camera.
  102103. * The camera looks towards it form the radius distance.
  102104. */
  102105. target: Vector3;
  102106. /**
  102107. * Define the current local position of the camera in the scene
  102108. */
  102109. position: Vector3;
  102110. protected _upVector: Vector3;
  102111. protected _upToYMatrix: Matrix;
  102112. protected _YToUpMatrix: Matrix;
  102113. /**
  102114. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  102115. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  102116. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  102117. */
  102118. upVector: Vector3;
  102119. /**
  102120. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  102121. */
  102122. setMatUp(): void;
  102123. /**
  102124. * Current inertia value on the longitudinal axis.
  102125. * The bigger this number the longer it will take for the camera to stop.
  102126. */
  102127. inertialAlphaOffset: number;
  102128. /**
  102129. * Current inertia value on the latitudinal axis.
  102130. * The bigger this number the longer it will take for the camera to stop.
  102131. */
  102132. inertialBetaOffset: number;
  102133. /**
  102134. * Current inertia value on the radius axis.
  102135. * The bigger this number the longer it will take for the camera to stop.
  102136. */
  102137. inertialRadiusOffset: number;
  102138. /**
  102139. * Minimum allowed angle on the longitudinal axis.
  102140. * This can help limiting how the Camera is able to move in the scene.
  102141. */
  102142. lowerAlphaLimit: Nullable<number>;
  102143. /**
  102144. * Maximum allowed angle on the longitudinal axis.
  102145. * This can help limiting how the Camera is able to move in the scene.
  102146. */
  102147. upperAlphaLimit: Nullable<number>;
  102148. /**
  102149. * Minimum allowed angle on the latitudinal axis.
  102150. * This can help limiting how the Camera is able to move in the scene.
  102151. */
  102152. lowerBetaLimit: number;
  102153. /**
  102154. * Maximum allowed angle on the latitudinal axis.
  102155. * This can help limiting how the Camera is able to move in the scene.
  102156. */
  102157. upperBetaLimit: number;
  102158. /**
  102159. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  102160. * This can help limiting how the Camera is able to move in the scene.
  102161. */
  102162. lowerRadiusLimit: Nullable<number>;
  102163. /**
  102164. * Maximum allowed distance of the camera to the target (The camera can not get further).
  102165. * This can help limiting how the Camera is able to move in the scene.
  102166. */
  102167. upperRadiusLimit: Nullable<number>;
  102168. /**
  102169. * Defines the current inertia value used during panning of the camera along the X axis.
  102170. */
  102171. inertialPanningX: number;
  102172. /**
  102173. * Defines the current inertia value used during panning of the camera along the Y axis.
  102174. */
  102175. inertialPanningY: number;
  102176. /**
  102177. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  102178. * Basically if your fingers moves away from more than this distance you will be considered
  102179. * in pinch mode.
  102180. */
  102181. pinchToPanMaxDistance: number;
  102182. /**
  102183. * Defines the maximum distance the camera can pan.
  102184. * This could help keeping the cammera always in your scene.
  102185. */
  102186. panningDistanceLimit: Nullable<number>;
  102187. /**
  102188. * Defines the target of the camera before paning.
  102189. */
  102190. panningOriginTarget: Vector3;
  102191. /**
  102192. * Defines the value of the inertia used during panning.
  102193. * 0 would mean stop inertia and one would mean no decelleration at all.
  102194. */
  102195. panningInertia: number;
  102196. /**
  102197. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  102198. */
  102199. angularSensibilityX: number;
  102200. /**
  102201. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  102202. */
  102203. angularSensibilityY: number;
  102204. /**
  102205. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  102206. */
  102207. pinchPrecision: number;
  102208. /**
  102209. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  102210. * It will be used instead of pinchDeltaPrecision if different from 0.
  102211. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102212. */
  102213. pinchDeltaPercentage: number;
  102214. /**
  102215. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  102216. */
  102217. panningSensibility: number;
  102218. /**
  102219. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  102220. */
  102221. keysUp: number[];
  102222. /**
  102223. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  102224. */
  102225. keysDown: number[];
  102226. /**
  102227. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  102228. */
  102229. keysLeft: number[];
  102230. /**
  102231. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  102232. */
  102233. keysRight: number[];
  102234. /**
  102235. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102236. */
  102237. wheelPrecision: number;
  102238. /**
  102239. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  102240. * It will be used instead of pinchDeltaPrecision if different from 0.
  102241. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102242. */
  102243. wheelDeltaPercentage: number;
  102244. /**
  102245. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  102246. */
  102247. zoomOnFactor: number;
  102248. /**
  102249. * Defines a screen offset for the camera position.
  102250. */
  102251. targetScreenOffset: Vector2;
  102252. /**
  102253. * Allows the camera to be completely reversed.
  102254. * If false the camera can not arrive upside down.
  102255. */
  102256. allowUpsideDown: boolean;
  102257. /**
  102258. * Define if double tap/click is used to restore the previously saved state of the camera.
  102259. */
  102260. useInputToRestoreState: boolean;
  102261. /** @hidden */
  102262. _viewMatrix: Matrix;
  102263. /** @hidden */
  102264. _useCtrlForPanning: boolean;
  102265. /** @hidden */
  102266. _panningMouseButton: number;
  102267. /**
  102268. * Defines the input associated to the camera.
  102269. */
  102270. inputs: ArcRotateCameraInputsManager;
  102271. /** @hidden */
  102272. _reset: () => void;
  102273. /**
  102274. * Defines the allowed panning axis.
  102275. */
  102276. panningAxis: Vector3;
  102277. protected _localDirection: Vector3;
  102278. protected _transformedDirection: Vector3;
  102279. private _bouncingBehavior;
  102280. /**
  102281. * Gets the bouncing behavior of the camera if it has been enabled.
  102282. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102283. */
  102284. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  102285. /**
  102286. * Defines if the bouncing behavior of the camera is enabled on the camera.
  102287. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102288. */
  102289. useBouncingBehavior: boolean;
  102290. private _framingBehavior;
  102291. /**
  102292. * Gets the framing behavior of the camera if it has been enabled.
  102293. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102294. */
  102295. readonly framingBehavior: Nullable<FramingBehavior>;
  102296. /**
  102297. * Defines if the framing behavior of the camera is enabled on the camera.
  102298. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102299. */
  102300. useFramingBehavior: boolean;
  102301. private _autoRotationBehavior;
  102302. /**
  102303. * Gets the auto rotation behavior of the camera if it has been enabled.
  102304. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102305. */
  102306. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  102307. /**
  102308. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  102309. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102310. */
  102311. useAutoRotationBehavior: boolean;
  102312. /**
  102313. * Observable triggered when the mesh target has been changed on the camera.
  102314. */
  102315. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  102316. /**
  102317. * Event raised when the camera is colliding with a mesh.
  102318. */
  102319. onCollide: (collidedMesh: AbstractMesh) => void;
  102320. /**
  102321. * Defines whether the camera should check collision with the objects oh the scene.
  102322. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  102323. */
  102324. checkCollisions: boolean;
  102325. /**
  102326. * Defines the collision radius of the camera.
  102327. * This simulates a sphere around the camera.
  102328. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102329. */
  102330. collisionRadius: Vector3;
  102331. protected _collider: Collider;
  102332. protected _previousPosition: Vector3;
  102333. protected _collisionVelocity: Vector3;
  102334. protected _newPosition: Vector3;
  102335. protected _previousAlpha: number;
  102336. protected _previousBeta: number;
  102337. protected _previousRadius: number;
  102338. protected _collisionTriggered: boolean;
  102339. protected _targetBoundingCenter: Nullable<Vector3>;
  102340. private _computationVector;
  102341. /**
  102342. * Instantiates a new ArcRotateCamera in a given scene
  102343. * @param name Defines the name of the camera
  102344. * @param alpha Defines the camera rotation along the logitudinal axis
  102345. * @param beta Defines the camera rotation along the latitudinal axis
  102346. * @param radius Defines the camera distance from its target
  102347. * @param target Defines the camera target
  102348. * @param scene Defines the scene the camera belongs to
  102349. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  102350. */
  102351. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102352. /** @hidden */
  102353. _initCache(): void;
  102354. /** @hidden */
  102355. _updateCache(ignoreParentClass?: boolean): void;
  102356. protected _getTargetPosition(): Vector3;
  102357. private _storedAlpha;
  102358. private _storedBeta;
  102359. private _storedRadius;
  102360. private _storedTarget;
  102361. private _storedTargetScreenOffset;
  102362. /**
  102363. * Stores the current state of the camera (alpha, beta, radius and target)
  102364. * @returns the camera itself
  102365. */
  102366. storeState(): Camera;
  102367. /**
  102368. * @hidden
  102369. * Restored camera state. You must call storeState() first
  102370. */
  102371. _restoreStateValues(): boolean;
  102372. /** @hidden */
  102373. _isSynchronizedViewMatrix(): boolean;
  102374. /**
  102375. * Attached controls to the current camera.
  102376. * @param element Defines the element the controls should be listened from
  102377. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102378. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  102379. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  102380. */
  102381. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  102382. /**
  102383. * Detach the current controls from the camera.
  102384. * The camera will stop reacting to inputs.
  102385. * @param element Defines the element to stop listening the inputs from
  102386. */
  102387. detachControl(element: HTMLElement): void;
  102388. /** @hidden */
  102389. _checkInputs(): void;
  102390. protected _checkLimits(): void;
  102391. /**
  102392. * Rebuilds angles (alpha, beta) and radius from the give position and target
  102393. */
  102394. rebuildAnglesAndRadius(): void;
  102395. /**
  102396. * Use a position to define the current camera related information like aplha, beta and radius
  102397. * @param position Defines the position to set the camera at
  102398. */
  102399. setPosition(position: Vector3): void;
  102400. /**
  102401. * Defines the target the camera should look at.
  102402. * This will automatically adapt alpha beta and radius to fit within the new target.
  102403. * @param target Defines the new target as a Vector or a mesh
  102404. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  102405. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  102406. */
  102407. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  102408. /** @hidden */
  102409. _getViewMatrix(): Matrix;
  102410. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  102411. /**
  102412. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  102413. * @param meshes Defines the mesh to zoom on
  102414. * @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)
  102415. */
  102416. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  102417. /**
  102418. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  102419. * The target will be changed but the radius
  102420. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  102421. * @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)
  102422. */
  102423. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  102424. min: Vector3;
  102425. max: Vector3;
  102426. distance: number;
  102427. }, doNotUpdateMaxZ?: boolean): void;
  102428. /**
  102429. * @override
  102430. * Override Camera.createRigCamera
  102431. */
  102432. createRigCamera(name: string, cameraIndex: number): Camera;
  102433. /**
  102434. * @hidden
  102435. * @override
  102436. * Override Camera._updateRigCameras
  102437. */
  102438. _updateRigCameras(): void;
  102439. /**
  102440. * Destroy the camera and release the current resources hold by it.
  102441. */
  102442. dispose(): void;
  102443. /**
  102444. * Gets the current object class name.
  102445. * @return the class name
  102446. */
  102447. getClassName(): string;
  102448. }
  102449. }
  102450. declare module BABYLON {
  102451. /**
  102452. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  102453. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102454. */
  102455. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  102456. /**
  102457. * Gets the name of the behavior.
  102458. */
  102459. readonly name: string;
  102460. private _zoomStopsAnimation;
  102461. private _idleRotationSpeed;
  102462. private _idleRotationWaitTime;
  102463. private _idleRotationSpinupTime;
  102464. /**
  102465. * Sets the flag that indicates if user zooming should stop animation.
  102466. */
  102467. /**
  102468. * Gets the flag that indicates if user zooming should stop animation.
  102469. */
  102470. zoomStopsAnimation: boolean;
  102471. /**
  102472. * Sets the default speed at which the camera rotates around the model.
  102473. */
  102474. /**
  102475. * Gets the default speed at which the camera rotates around the model.
  102476. */
  102477. idleRotationSpeed: number;
  102478. /**
  102479. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  102480. */
  102481. /**
  102482. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  102483. */
  102484. idleRotationWaitTime: number;
  102485. /**
  102486. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102487. */
  102488. /**
  102489. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102490. */
  102491. idleRotationSpinupTime: number;
  102492. /**
  102493. * Gets a value indicating if the camera is currently rotating because of this behavior
  102494. */
  102495. readonly rotationInProgress: boolean;
  102496. private _onPrePointerObservableObserver;
  102497. private _onAfterCheckInputsObserver;
  102498. private _attachedCamera;
  102499. private _isPointerDown;
  102500. private _lastFrameTime;
  102501. private _lastInteractionTime;
  102502. private _cameraRotationSpeed;
  102503. /**
  102504. * Initializes the behavior.
  102505. */
  102506. init(): void;
  102507. /**
  102508. * Attaches the behavior to its arc rotate camera.
  102509. * @param camera Defines the camera to attach the behavior to
  102510. */
  102511. attach(camera: ArcRotateCamera): void;
  102512. /**
  102513. * Detaches the behavior from its current arc rotate camera.
  102514. */
  102515. detach(): void;
  102516. /**
  102517. * Returns true if user is scrolling.
  102518. * @return true if user is scrolling.
  102519. */
  102520. private _userIsZooming;
  102521. private _lastFrameRadius;
  102522. private _shouldAnimationStopForInteraction;
  102523. /**
  102524. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102525. */
  102526. private _applyUserInteraction;
  102527. private _userIsMoving;
  102528. }
  102529. }
  102530. declare module BABYLON {
  102531. /**
  102532. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  102533. */
  102534. export class AttachToBoxBehavior implements Behavior<Mesh> {
  102535. private ui;
  102536. /**
  102537. * The name of the behavior
  102538. */
  102539. name: string;
  102540. /**
  102541. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  102542. */
  102543. distanceAwayFromFace: number;
  102544. /**
  102545. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  102546. */
  102547. distanceAwayFromBottomOfFace: number;
  102548. private _faceVectors;
  102549. private _target;
  102550. private _scene;
  102551. private _onRenderObserver;
  102552. private _tmpMatrix;
  102553. private _tmpVector;
  102554. /**
  102555. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  102556. * @param ui The transform node that should be attched to the mesh
  102557. */
  102558. constructor(ui: TransformNode);
  102559. /**
  102560. * Initializes the behavior
  102561. */
  102562. init(): void;
  102563. private _closestFace;
  102564. private _zeroVector;
  102565. private _lookAtTmpMatrix;
  102566. private _lookAtToRef;
  102567. /**
  102568. * Attaches the AttachToBoxBehavior to the passed in mesh
  102569. * @param target The mesh that the specified node will be attached to
  102570. */
  102571. attach(target: Mesh): void;
  102572. /**
  102573. * Detaches the behavior from the mesh
  102574. */
  102575. detach(): void;
  102576. }
  102577. }
  102578. declare module BABYLON {
  102579. /**
  102580. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  102581. */
  102582. export class FadeInOutBehavior implements Behavior<Mesh> {
  102583. /**
  102584. * Time in milliseconds to delay before fading in (Default: 0)
  102585. */
  102586. delay: number;
  102587. /**
  102588. * Time in milliseconds for the mesh to fade in (Default: 300)
  102589. */
  102590. fadeInTime: number;
  102591. private _millisecondsPerFrame;
  102592. private _hovered;
  102593. private _hoverValue;
  102594. private _ownerNode;
  102595. /**
  102596. * Instatiates the FadeInOutBehavior
  102597. */
  102598. constructor();
  102599. /**
  102600. * The name of the behavior
  102601. */
  102602. readonly name: string;
  102603. /**
  102604. * Initializes the behavior
  102605. */
  102606. init(): void;
  102607. /**
  102608. * Attaches the fade behavior on the passed in mesh
  102609. * @param ownerNode The mesh that will be faded in/out once attached
  102610. */
  102611. attach(ownerNode: Mesh): void;
  102612. /**
  102613. * Detaches the behavior from the mesh
  102614. */
  102615. detach(): void;
  102616. /**
  102617. * Triggers the mesh to begin fading in or out
  102618. * @param value if the object should fade in or out (true to fade in)
  102619. */
  102620. fadeIn(value: boolean): void;
  102621. private _update;
  102622. private _setAllVisibility;
  102623. }
  102624. }
  102625. declare module BABYLON {
  102626. /**
  102627. * Class containing a set of static utilities functions for managing Pivots
  102628. * @hidden
  102629. */
  102630. export class PivotTools {
  102631. private static _PivotCached;
  102632. private static _OldPivotPoint;
  102633. private static _PivotTranslation;
  102634. private static _PivotTmpVector;
  102635. /** @hidden */
  102636. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  102637. /** @hidden */
  102638. static _RestorePivotPoint(mesh: AbstractMesh): void;
  102639. }
  102640. }
  102641. declare module BABYLON {
  102642. /**
  102643. * Class containing static functions to help procedurally build meshes
  102644. */
  102645. export class PlaneBuilder {
  102646. /**
  102647. * Creates a plane mesh
  102648. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  102649. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  102650. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  102651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102652. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102654. * @param name defines the name of the mesh
  102655. * @param options defines the options used to create the mesh
  102656. * @param scene defines the hosting scene
  102657. * @returns the plane mesh
  102658. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  102659. */
  102660. static CreatePlane(name: string, options: {
  102661. size?: number;
  102662. width?: number;
  102663. height?: number;
  102664. sideOrientation?: number;
  102665. frontUVs?: Vector4;
  102666. backUVs?: Vector4;
  102667. updatable?: boolean;
  102668. sourcePlane?: Plane;
  102669. }, scene?: Nullable<Scene>): Mesh;
  102670. }
  102671. }
  102672. declare module BABYLON {
  102673. /**
  102674. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  102675. */
  102676. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  102677. private static _AnyMouseID;
  102678. /**
  102679. * Abstract mesh the behavior is set on
  102680. */
  102681. attachedNode: AbstractMesh;
  102682. private _dragPlane;
  102683. private _scene;
  102684. private _pointerObserver;
  102685. private _beforeRenderObserver;
  102686. private static _planeScene;
  102687. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  102688. /**
  102689. * 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)
  102690. */
  102691. maxDragAngle: number;
  102692. /**
  102693. * @hidden
  102694. */
  102695. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  102696. /**
  102697. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102698. */
  102699. currentDraggingPointerID: number;
  102700. /**
  102701. * The last position where the pointer hit the drag plane in world space
  102702. */
  102703. lastDragPosition: Vector3;
  102704. /**
  102705. * If the behavior is currently in a dragging state
  102706. */
  102707. dragging: boolean;
  102708. /**
  102709. * 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)
  102710. */
  102711. dragDeltaRatio: number;
  102712. /**
  102713. * If the drag plane orientation should be updated during the dragging (Default: true)
  102714. */
  102715. updateDragPlane: boolean;
  102716. private _debugMode;
  102717. private _moving;
  102718. /**
  102719. * Fires each time the attached mesh is dragged with the pointer
  102720. * * delta between last drag position and current drag position in world space
  102721. * * dragDistance along the drag axis
  102722. * * dragPlaneNormal normal of the current drag plane used during the drag
  102723. * * dragPlanePoint in world space where the drag intersects the drag plane
  102724. */
  102725. onDragObservable: Observable<{
  102726. delta: Vector3;
  102727. dragPlanePoint: Vector3;
  102728. dragPlaneNormal: Vector3;
  102729. dragDistance: number;
  102730. pointerId: number;
  102731. }>;
  102732. /**
  102733. * Fires each time a drag begins (eg. mouse down on mesh)
  102734. */
  102735. onDragStartObservable: Observable<{
  102736. dragPlanePoint: Vector3;
  102737. pointerId: number;
  102738. }>;
  102739. /**
  102740. * Fires each time a drag ends (eg. mouse release after drag)
  102741. */
  102742. onDragEndObservable: Observable<{
  102743. dragPlanePoint: Vector3;
  102744. pointerId: number;
  102745. }>;
  102746. /**
  102747. * If the attached mesh should be moved when dragged
  102748. */
  102749. moveAttached: boolean;
  102750. /**
  102751. * If the drag behavior will react to drag events (Default: true)
  102752. */
  102753. enabled: boolean;
  102754. /**
  102755. * If pointer events should start and release the drag (Default: true)
  102756. */
  102757. startAndReleaseDragOnPointerEvents: boolean;
  102758. /**
  102759. * If camera controls should be detached during the drag
  102760. */
  102761. detachCameraControls: boolean;
  102762. /**
  102763. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  102764. */
  102765. useObjectOrienationForDragging: boolean;
  102766. private _options;
  102767. /**
  102768. * Creates a pointer drag behavior that can be attached to a mesh
  102769. * @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)
  102770. */
  102771. constructor(options?: {
  102772. dragAxis?: Vector3;
  102773. dragPlaneNormal?: Vector3;
  102774. });
  102775. /**
  102776. * Predicate to determine if it is valid to move the object to a new position when it is moved
  102777. */
  102778. validateDrag: (targetPosition: Vector3) => boolean;
  102779. /**
  102780. * The name of the behavior
  102781. */
  102782. readonly name: string;
  102783. /**
  102784. * Initializes the behavior
  102785. */
  102786. init(): void;
  102787. private _tmpVector;
  102788. private _alternatePickedPoint;
  102789. private _worldDragAxis;
  102790. private _targetPosition;
  102791. private _attachedElement;
  102792. /**
  102793. * Attaches the drag behavior the passed in mesh
  102794. * @param ownerNode The mesh that will be dragged around once attached
  102795. * @param predicate Predicate to use for pick filtering
  102796. */
  102797. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  102798. /**
  102799. * Force relase the drag action by code.
  102800. */
  102801. releaseDrag(): void;
  102802. private _startDragRay;
  102803. private _lastPointerRay;
  102804. /**
  102805. * Simulates the start of a pointer drag event on the behavior
  102806. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  102807. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  102808. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  102809. */
  102810. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  102811. private _startDrag;
  102812. private _dragDelta;
  102813. private _moveDrag;
  102814. private _pickWithRayOnDragPlane;
  102815. private _pointA;
  102816. private _pointB;
  102817. private _pointC;
  102818. private _lineA;
  102819. private _lineB;
  102820. private _localAxis;
  102821. private _lookAt;
  102822. private _updateDragPlanePosition;
  102823. /**
  102824. * Detaches the behavior from the mesh
  102825. */
  102826. detach(): void;
  102827. }
  102828. }
  102829. declare module BABYLON {
  102830. /**
  102831. * A behavior that when attached to a mesh will allow the mesh to be scaled
  102832. */
  102833. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  102834. private _dragBehaviorA;
  102835. private _dragBehaviorB;
  102836. private _startDistance;
  102837. private _initialScale;
  102838. private _targetScale;
  102839. private _ownerNode;
  102840. private _sceneRenderObserver;
  102841. /**
  102842. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  102843. */
  102844. constructor();
  102845. /**
  102846. * The name of the behavior
  102847. */
  102848. readonly name: string;
  102849. /**
  102850. * Initializes the behavior
  102851. */
  102852. init(): void;
  102853. private _getCurrentDistance;
  102854. /**
  102855. * Attaches the scale behavior the passed in mesh
  102856. * @param ownerNode The mesh that will be scaled around once attached
  102857. */
  102858. attach(ownerNode: Mesh): void;
  102859. /**
  102860. * Detaches the behavior from the mesh
  102861. */
  102862. detach(): void;
  102863. }
  102864. }
  102865. declare module BABYLON {
  102866. /**
  102867. * 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
  102868. */
  102869. export class SixDofDragBehavior implements Behavior<Mesh> {
  102870. private static _virtualScene;
  102871. private _ownerNode;
  102872. private _sceneRenderObserver;
  102873. private _scene;
  102874. private _targetPosition;
  102875. private _virtualOriginMesh;
  102876. private _virtualDragMesh;
  102877. private _pointerObserver;
  102878. private _moving;
  102879. private _startingOrientation;
  102880. /**
  102881. * 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)
  102882. */
  102883. private zDragFactor;
  102884. /**
  102885. * If the object should rotate to face the drag origin
  102886. */
  102887. rotateDraggedObject: boolean;
  102888. /**
  102889. * If the behavior is currently in a dragging state
  102890. */
  102891. dragging: boolean;
  102892. /**
  102893. * 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)
  102894. */
  102895. dragDeltaRatio: number;
  102896. /**
  102897. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102898. */
  102899. currentDraggingPointerID: number;
  102900. /**
  102901. * If camera controls should be detached during the drag
  102902. */
  102903. detachCameraControls: boolean;
  102904. /**
  102905. * Fires each time a drag starts
  102906. */
  102907. onDragStartObservable: Observable<{}>;
  102908. /**
  102909. * Fires each time a drag ends (eg. mouse release after drag)
  102910. */
  102911. onDragEndObservable: Observable<{}>;
  102912. /**
  102913. * 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
  102914. */
  102915. constructor();
  102916. /**
  102917. * The name of the behavior
  102918. */
  102919. readonly name: string;
  102920. /**
  102921. * Initializes the behavior
  102922. */
  102923. init(): void;
  102924. /**
  102925. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  102926. */
  102927. private readonly _pointerCamera;
  102928. /**
  102929. * Attaches the scale behavior the passed in mesh
  102930. * @param ownerNode The mesh that will be scaled around once attached
  102931. */
  102932. attach(ownerNode: Mesh): void;
  102933. /**
  102934. * Detaches the behavior from the mesh
  102935. */
  102936. detach(): void;
  102937. }
  102938. }
  102939. declare module BABYLON {
  102940. /**
  102941. * Class used to apply inverse kinematics to bones
  102942. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  102943. */
  102944. export class BoneIKController {
  102945. private static _tmpVecs;
  102946. private static _tmpQuat;
  102947. private static _tmpMats;
  102948. /**
  102949. * Gets or sets the target mesh
  102950. */
  102951. targetMesh: AbstractMesh;
  102952. /** Gets or sets the mesh used as pole */
  102953. poleTargetMesh: AbstractMesh;
  102954. /**
  102955. * Gets or sets the bone used as pole
  102956. */
  102957. poleTargetBone: Nullable<Bone>;
  102958. /**
  102959. * Gets or sets the target position
  102960. */
  102961. targetPosition: Vector3;
  102962. /**
  102963. * Gets or sets the pole target position
  102964. */
  102965. poleTargetPosition: Vector3;
  102966. /**
  102967. * Gets or sets the pole target local offset
  102968. */
  102969. poleTargetLocalOffset: Vector3;
  102970. /**
  102971. * Gets or sets the pole angle
  102972. */
  102973. poleAngle: number;
  102974. /**
  102975. * Gets or sets the mesh associated with the controller
  102976. */
  102977. mesh: AbstractMesh;
  102978. /**
  102979. * 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)
  102980. */
  102981. slerpAmount: number;
  102982. private _bone1Quat;
  102983. private _bone1Mat;
  102984. private _bone2Ang;
  102985. private _bone1;
  102986. private _bone2;
  102987. private _bone1Length;
  102988. private _bone2Length;
  102989. private _maxAngle;
  102990. private _maxReach;
  102991. private _rightHandedSystem;
  102992. private _bendAxis;
  102993. private _slerping;
  102994. private _adjustRoll;
  102995. /**
  102996. * Gets or sets maximum allowed angle
  102997. */
  102998. maxAngle: number;
  102999. /**
  103000. * Creates a new BoneIKController
  103001. * @param mesh defines the mesh to control
  103002. * @param bone defines the bone to control
  103003. * @param options defines options to set up the controller
  103004. */
  103005. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  103006. targetMesh?: AbstractMesh;
  103007. poleTargetMesh?: AbstractMesh;
  103008. poleTargetBone?: Bone;
  103009. poleTargetLocalOffset?: Vector3;
  103010. poleAngle?: number;
  103011. bendAxis?: Vector3;
  103012. maxAngle?: number;
  103013. slerpAmount?: number;
  103014. });
  103015. private _setMaxAngle;
  103016. /**
  103017. * Force the controller to update the bones
  103018. */
  103019. update(): void;
  103020. }
  103021. }
  103022. declare module BABYLON {
  103023. /**
  103024. * Class used to make a bone look toward a point in space
  103025. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  103026. */
  103027. export class BoneLookController {
  103028. private static _tmpVecs;
  103029. private static _tmpQuat;
  103030. private static _tmpMats;
  103031. /**
  103032. * The target Vector3 that the bone will look at
  103033. */
  103034. target: Vector3;
  103035. /**
  103036. * The mesh that the bone is attached to
  103037. */
  103038. mesh: AbstractMesh;
  103039. /**
  103040. * The bone that will be looking to the target
  103041. */
  103042. bone: Bone;
  103043. /**
  103044. * The up axis of the coordinate system that is used when the bone is rotated
  103045. */
  103046. upAxis: Vector3;
  103047. /**
  103048. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  103049. */
  103050. upAxisSpace: Space;
  103051. /**
  103052. * Used to make an adjustment to the yaw of the bone
  103053. */
  103054. adjustYaw: number;
  103055. /**
  103056. * Used to make an adjustment to the pitch of the bone
  103057. */
  103058. adjustPitch: number;
  103059. /**
  103060. * Used to make an adjustment to the roll of the bone
  103061. */
  103062. adjustRoll: number;
  103063. /**
  103064. * 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)
  103065. */
  103066. slerpAmount: number;
  103067. private _minYaw;
  103068. private _maxYaw;
  103069. private _minPitch;
  103070. private _maxPitch;
  103071. private _minYawSin;
  103072. private _minYawCos;
  103073. private _maxYawSin;
  103074. private _maxYawCos;
  103075. private _midYawConstraint;
  103076. private _minPitchTan;
  103077. private _maxPitchTan;
  103078. private _boneQuat;
  103079. private _slerping;
  103080. private _transformYawPitch;
  103081. private _transformYawPitchInv;
  103082. private _firstFrameSkipped;
  103083. private _yawRange;
  103084. private _fowardAxis;
  103085. /**
  103086. * Gets or sets the minimum yaw angle that the bone can look to
  103087. */
  103088. minYaw: number;
  103089. /**
  103090. * Gets or sets the maximum yaw angle that the bone can look to
  103091. */
  103092. maxYaw: number;
  103093. /**
  103094. * Gets or sets the minimum pitch angle that the bone can look to
  103095. */
  103096. minPitch: number;
  103097. /**
  103098. * Gets or sets the maximum pitch angle that the bone can look to
  103099. */
  103100. maxPitch: number;
  103101. /**
  103102. * Create a BoneLookController
  103103. * @param mesh the mesh that the bone belongs to
  103104. * @param bone the bone that will be looking to the target
  103105. * @param target the target Vector3 to look at
  103106. * @param options optional settings:
  103107. * * maxYaw: the maximum angle the bone will yaw to
  103108. * * minYaw: the minimum angle the bone will yaw to
  103109. * * maxPitch: the maximum angle the bone will pitch to
  103110. * * minPitch: the minimum angle the bone will yaw to
  103111. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  103112. * * upAxis: the up axis of the coordinate system
  103113. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  103114. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  103115. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  103116. * * adjustYaw: used to make an adjustment to the yaw of the bone
  103117. * * adjustPitch: used to make an adjustment to the pitch of the bone
  103118. * * adjustRoll: used to make an adjustment to the roll of the bone
  103119. **/
  103120. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  103121. maxYaw?: number;
  103122. minYaw?: number;
  103123. maxPitch?: number;
  103124. minPitch?: number;
  103125. slerpAmount?: number;
  103126. upAxis?: Vector3;
  103127. upAxisSpace?: Space;
  103128. yawAxis?: Vector3;
  103129. pitchAxis?: Vector3;
  103130. adjustYaw?: number;
  103131. adjustPitch?: number;
  103132. adjustRoll?: number;
  103133. });
  103134. /**
  103135. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  103136. */
  103137. update(): void;
  103138. private _getAngleDiff;
  103139. private _getAngleBetween;
  103140. private _isAngleBetween;
  103141. }
  103142. }
  103143. declare module BABYLON {
  103144. /**
  103145. * Manage the gamepad inputs to control an arc rotate camera.
  103146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103147. */
  103148. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  103149. /**
  103150. * Defines the camera the input is attached to.
  103151. */
  103152. camera: ArcRotateCamera;
  103153. /**
  103154. * Defines the gamepad the input is gathering event from.
  103155. */
  103156. gamepad: Nullable<Gamepad>;
  103157. /**
  103158. * Defines the gamepad rotation sensiblity.
  103159. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103160. */
  103161. gamepadRotationSensibility: number;
  103162. /**
  103163. * Defines the gamepad move sensiblity.
  103164. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103165. */
  103166. gamepadMoveSensibility: number;
  103167. private _onGamepadConnectedObserver;
  103168. private _onGamepadDisconnectedObserver;
  103169. /**
  103170. * Attach the input controls to a specific dom element to get the input from.
  103171. * @param element Defines the element the controls should be listened from
  103172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103173. */
  103174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103175. /**
  103176. * Detach the current controls from the specified dom element.
  103177. * @param element Defines the element to stop listening the inputs from
  103178. */
  103179. detachControl(element: Nullable<HTMLElement>): void;
  103180. /**
  103181. * Update the current camera state depending on the inputs that have been used this frame.
  103182. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103183. */
  103184. checkInputs(): void;
  103185. /**
  103186. * Gets the class name of the current intput.
  103187. * @returns the class name
  103188. */
  103189. getClassName(): string;
  103190. /**
  103191. * Get the friendly name associated with the input class.
  103192. * @returns the input friendly name
  103193. */
  103194. getSimpleName(): string;
  103195. }
  103196. }
  103197. declare module BABYLON {
  103198. interface ArcRotateCameraInputsManager {
  103199. /**
  103200. * Add orientation input support to the input manager.
  103201. * @returns the current input manager
  103202. */
  103203. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  103204. }
  103205. /**
  103206. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  103207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103208. */
  103209. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  103210. /**
  103211. * Defines the camera the input is attached to.
  103212. */
  103213. camera: ArcRotateCamera;
  103214. /**
  103215. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  103216. */
  103217. alphaCorrection: number;
  103218. /**
  103219. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  103220. */
  103221. gammaCorrection: number;
  103222. private _alpha;
  103223. private _gamma;
  103224. private _dirty;
  103225. private _deviceOrientationHandler;
  103226. /**
  103227. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  103228. */
  103229. constructor();
  103230. /**
  103231. * Attach the input controls to a specific dom element to get the input from.
  103232. * @param element Defines the element the controls should be listened from
  103233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103234. */
  103235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103236. /** @hidden */
  103237. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  103238. /**
  103239. * Update the current camera state depending on the inputs that have been used this frame.
  103240. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103241. */
  103242. checkInputs(): void;
  103243. /**
  103244. * Detach the current controls from the specified dom element.
  103245. * @param element Defines the element to stop listening the inputs from
  103246. */
  103247. detachControl(element: Nullable<HTMLElement>): void;
  103248. /**
  103249. * Gets the class name of the current intput.
  103250. * @returns the class name
  103251. */
  103252. getClassName(): string;
  103253. /**
  103254. * Get the friendly name associated with the input class.
  103255. * @returns the input friendly name
  103256. */
  103257. getSimpleName(): string;
  103258. }
  103259. }
  103260. declare module BABYLON {
  103261. /**
  103262. * Listen to mouse events to control the camera.
  103263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103264. */
  103265. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  103266. /**
  103267. * Defines the camera the input is attached to.
  103268. */
  103269. camera: FlyCamera;
  103270. /**
  103271. * Defines if touch is enabled. (Default is true.)
  103272. */
  103273. touchEnabled: boolean;
  103274. /**
  103275. * Defines the buttons associated with the input to handle camera rotation.
  103276. */
  103277. buttons: number[];
  103278. /**
  103279. * Assign buttons for Yaw control.
  103280. */
  103281. buttonsYaw: number[];
  103282. /**
  103283. * Assign buttons for Pitch control.
  103284. */
  103285. buttonsPitch: number[];
  103286. /**
  103287. * Assign buttons for Roll control.
  103288. */
  103289. buttonsRoll: number[];
  103290. /**
  103291. * Detect if any button is being pressed while mouse is moved.
  103292. * -1 = Mouse locked.
  103293. * 0 = Left button.
  103294. * 1 = Middle Button.
  103295. * 2 = Right Button.
  103296. */
  103297. activeButton: number;
  103298. /**
  103299. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  103300. * Higher values reduce its sensitivity.
  103301. */
  103302. angularSensibility: number;
  103303. private _mousemoveCallback;
  103304. private _observer;
  103305. private _rollObserver;
  103306. private previousPosition;
  103307. private noPreventDefault;
  103308. private element;
  103309. /**
  103310. * Listen to mouse events to control the camera.
  103311. * @param touchEnabled Define if touch is enabled. (Default is true.)
  103312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103313. */
  103314. constructor(touchEnabled?: boolean);
  103315. /**
  103316. * Attach the mouse control to the HTML DOM element.
  103317. * @param element Defines the element that listens to the input events.
  103318. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  103319. */
  103320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103321. /**
  103322. * Detach the current controls from the specified dom element.
  103323. * @param element Defines the element to stop listening the inputs from
  103324. */
  103325. detachControl(element: Nullable<HTMLElement>): void;
  103326. /**
  103327. * Gets the class name of the current input.
  103328. * @returns the class name.
  103329. */
  103330. getClassName(): string;
  103331. /**
  103332. * Get the friendly name associated with the input class.
  103333. * @returns the input's friendly name.
  103334. */
  103335. getSimpleName(): string;
  103336. private _pointerInput;
  103337. private _onMouseMove;
  103338. /**
  103339. * Rotate camera by mouse offset.
  103340. */
  103341. private rotateCamera;
  103342. }
  103343. }
  103344. declare module BABYLON {
  103345. /**
  103346. * Default Inputs manager for the FlyCamera.
  103347. * It groups all the default supported inputs for ease of use.
  103348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103349. */
  103350. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  103351. /**
  103352. * Instantiates a new FlyCameraInputsManager.
  103353. * @param camera Defines the camera the inputs belong to.
  103354. */
  103355. constructor(camera: FlyCamera);
  103356. /**
  103357. * Add keyboard input support to the input manager.
  103358. * @returns the new FlyCameraKeyboardMoveInput().
  103359. */
  103360. addKeyboard(): FlyCameraInputsManager;
  103361. /**
  103362. * Add mouse input support to the input manager.
  103363. * @param touchEnabled Enable touch screen support.
  103364. * @returns the new FlyCameraMouseInput().
  103365. */
  103366. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  103367. }
  103368. }
  103369. declare module BABYLON {
  103370. /**
  103371. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103372. * such as in a 3D Space Shooter or a Flight Simulator.
  103373. */
  103374. export class FlyCamera extends TargetCamera {
  103375. /**
  103376. * Define the collision ellipsoid of the camera.
  103377. * This is helpful for simulating a camera body, like a player's body.
  103378. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103379. */
  103380. ellipsoid: Vector3;
  103381. /**
  103382. * Define an offset for the position of the ellipsoid around the camera.
  103383. * This can be helpful if the camera is attached away from the player's body center,
  103384. * such as at its head.
  103385. */
  103386. ellipsoidOffset: Vector3;
  103387. /**
  103388. * Enable or disable collisions of the camera with the rest of the scene objects.
  103389. */
  103390. checkCollisions: boolean;
  103391. /**
  103392. * Enable or disable gravity on the camera.
  103393. */
  103394. applyGravity: boolean;
  103395. /**
  103396. * Define the current direction the camera is moving to.
  103397. */
  103398. cameraDirection: Vector3;
  103399. /**
  103400. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  103401. * This overrides and empties cameraRotation.
  103402. */
  103403. rotationQuaternion: Quaternion;
  103404. /**
  103405. * Track Roll to maintain the wanted Rolling when looking around.
  103406. */
  103407. _trackRoll: number;
  103408. /**
  103409. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  103410. */
  103411. rollCorrect: number;
  103412. /**
  103413. * Mimic a banked turn, Rolling the camera when Yawing.
  103414. * It's recommended to use rollCorrect = 10 for faster banking correction.
  103415. */
  103416. bankedTurn: boolean;
  103417. /**
  103418. * Limit in radians for how much Roll banking will add. (Default: 90°)
  103419. */
  103420. bankedTurnLimit: number;
  103421. /**
  103422. * Value of 0 disables the banked Roll.
  103423. * Value of 1 is equal to the Yaw angle in radians.
  103424. */
  103425. bankedTurnMultiplier: number;
  103426. /**
  103427. * The inputs manager loads all the input sources, such as keyboard and mouse.
  103428. */
  103429. inputs: FlyCameraInputsManager;
  103430. /**
  103431. * Gets the input sensibility for mouse input.
  103432. * Higher values reduce sensitivity.
  103433. */
  103434. /**
  103435. * Sets the input sensibility for a mouse input.
  103436. * Higher values reduce sensitivity.
  103437. */
  103438. angularSensibility: number;
  103439. /**
  103440. * Get the keys for camera movement forward.
  103441. */
  103442. /**
  103443. * Set the keys for camera movement forward.
  103444. */
  103445. keysForward: number[];
  103446. /**
  103447. * Get the keys for camera movement backward.
  103448. */
  103449. keysBackward: number[];
  103450. /**
  103451. * Get the keys for camera movement up.
  103452. */
  103453. /**
  103454. * Set the keys for camera movement up.
  103455. */
  103456. keysUp: number[];
  103457. /**
  103458. * Get the keys for camera movement down.
  103459. */
  103460. /**
  103461. * Set the keys for camera movement down.
  103462. */
  103463. keysDown: number[];
  103464. /**
  103465. * Get the keys for camera movement left.
  103466. */
  103467. /**
  103468. * Set the keys for camera movement left.
  103469. */
  103470. keysLeft: number[];
  103471. /**
  103472. * Set the keys for camera movement right.
  103473. */
  103474. /**
  103475. * Set the keys for camera movement right.
  103476. */
  103477. keysRight: number[];
  103478. /**
  103479. * Event raised when the camera collides with a mesh in the scene.
  103480. */
  103481. onCollide: (collidedMesh: AbstractMesh) => void;
  103482. private _collider;
  103483. private _needMoveForGravity;
  103484. private _oldPosition;
  103485. private _diffPosition;
  103486. private _newPosition;
  103487. /** @hidden */
  103488. _localDirection: Vector3;
  103489. /** @hidden */
  103490. _transformedDirection: Vector3;
  103491. /**
  103492. * Instantiates a FlyCamera.
  103493. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103494. * such as in a 3D Space Shooter or a Flight Simulator.
  103495. * @param name Define the name of the camera in the scene.
  103496. * @param position Define the starting position of the camera in the scene.
  103497. * @param scene Define the scene the camera belongs to.
  103498. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  103499. */
  103500. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103501. /**
  103502. * Attach a control to the HTML DOM element.
  103503. * @param element Defines the element that listens to the input events.
  103504. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  103505. */
  103506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103507. /**
  103508. * Detach a control from the HTML DOM element.
  103509. * The camera will stop reacting to that input.
  103510. * @param element Defines the element that listens to the input events.
  103511. */
  103512. detachControl(element: HTMLElement): void;
  103513. private _collisionMask;
  103514. /**
  103515. * Get the mask that the camera ignores in collision events.
  103516. */
  103517. /**
  103518. * Set the mask that the camera ignores in collision events.
  103519. */
  103520. collisionMask: number;
  103521. /** @hidden */
  103522. _collideWithWorld(displacement: Vector3): void;
  103523. /** @hidden */
  103524. private _onCollisionPositionChange;
  103525. /** @hidden */
  103526. _checkInputs(): void;
  103527. /** @hidden */
  103528. _decideIfNeedsToMove(): boolean;
  103529. /** @hidden */
  103530. _updatePosition(): void;
  103531. /**
  103532. * Restore the Roll to its target value at the rate specified.
  103533. * @param rate - Higher means slower restoring.
  103534. * @hidden
  103535. */
  103536. restoreRoll(rate: number): void;
  103537. /**
  103538. * Destroy the camera and release the current resources held by it.
  103539. */
  103540. dispose(): void;
  103541. /**
  103542. * Get the current object class name.
  103543. * @returns the class name.
  103544. */
  103545. getClassName(): string;
  103546. }
  103547. }
  103548. declare module BABYLON {
  103549. /**
  103550. * Listen to keyboard events to control the camera.
  103551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103552. */
  103553. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  103554. /**
  103555. * Defines the camera the input is attached to.
  103556. */
  103557. camera: FlyCamera;
  103558. /**
  103559. * The list of keyboard keys used to control the forward move of the camera.
  103560. */
  103561. keysForward: number[];
  103562. /**
  103563. * The list of keyboard keys used to control the backward move of the camera.
  103564. */
  103565. keysBackward: number[];
  103566. /**
  103567. * The list of keyboard keys used to control the forward move of the camera.
  103568. */
  103569. keysUp: number[];
  103570. /**
  103571. * The list of keyboard keys used to control the backward move of the camera.
  103572. */
  103573. keysDown: number[];
  103574. /**
  103575. * The list of keyboard keys used to control the right strafe move of the camera.
  103576. */
  103577. keysRight: number[];
  103578. /**
  103579. * The list of keyboard keys used to control the left strafe move of the camera.
  103580. */
  103581. keysLeft: number[];
  103582. private _keys;
  103583. private _onCanvasBlurObserver;
  103584. private _onKeyboardObserver;
  103585. private _engine;
  103586. private _scene;
  103587. /**
  103588. * Attach the input controls to a specific dom element to get the input from.
  103589. * @param element Defines the element the controls should be listened from
  103590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103591. */
  103592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103593. /**
  103594. * Detach the current controls from the specified dom element.
  103595. * @param element Defines the element to stop listening the inputs from
  103596. */
  103597. detachControl(element: Nullable<HTMLElement>): void;
  103598. /**
  103599. * Gets the class name of the current intput.
  103600. * @returns the class name
  103601. */
  103602. getClassName(): string;
  103603. /** @hidden */
  103604. _onLostFocus(e: FocusEvent): void;
  103605. /**
  103606. * Get the friendly name associated with the input class.
  103607. * @returns the input friendly name
  103608. */
  103609. getSimpleName(): string;
  103610. /**
  103611. * Update the current camera state depending on the inputs that have been used this frame.
  103612. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103613. */
  103614. checkInputs(): void;
  103615. }
  103616. }
  103617. declare module BABYLON {
  103618. /**
  103619. * Manage the mouse wheel inputs to control a follow camera.
  103620. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103621. */
  103622. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  103623. /**
  103624. * Defines the camera the input is attached to.
  103625. */
  103626. camera: FollowCamera;
  103627. /**
  103628. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  103629. */
  103630. axisControlRadius: boolean;
  103631. /**
  103632. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  103633. */
  103634. axisControlHeight: boolean;
  103635. /**
  103636. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  103637. */
  103638. axisControlRotation: boolean;
  103639. /**
  103640. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  103641. * relation to mouseWheel events.
  103642. */
  103643. wheelPrecision: number;
  103644. /**
  103645. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103646. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103647. */
  103648. wheelDeltaPercentage: number;
  103649. private _wheel;
  103650. private _observer;
  103651. /**
  103652. * Attach the input controls to a specific dom element to get the input from.
  103653. * @param element Defines the element the controls should be listened from
  103654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103655. */
  103656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103657. /**
  103658. * Detach the current controls from the specified dom element.
  103659. * @param element Defines the element to stop listening the inputs from
  103660. */
  103661. detachControl(element: Nullable<HTMLElement>): void;
  103662. /**
  103663. * Gets the class name of the current intput.
  103664. * @returns the class name
  103665. */
  103666. getClassName(): string;
  103667. /**
  103668. * Get the friendly name associated with the input class.
  103669. * @returns the input friendly name
  103670. */
  103671. getSimpleName(): string;
  103672. }
  103673. }
  103674. declare module BABYLON {
  103675. /**
  103676. * Manage the pointers inputs to control an follow camera.
  103677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103678. */
  103679. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  103680. /**
  103681. * Defines the camera the input is attached to.
  103682. */
  103683. camera: FollowCamera;
  103684. /**
  103685. * Gets the class name of the current input.
  103686. * @returns the class name
  103687. */
  103688. getClassName(): string;
  103689. /**
  103690. * Defines the pointer angular sensibility along the X axis or how fast is
  103691. * the camera rotating.
  103692. * A negative number will reverse the axis direction.
  103693. */
  103694. angularSensibilityX: number;
  103695. /**
  103696. * Defines the pointer angular sensibility along the Y axis or how fast is
  103697. * the camera rotating.
  103698. * A negative number will reverse the axis direction.
  103699. */
  103700. angularSensibilityY: number;
  103701. /**
  103702. * Defines the pointer pinch precision or how fast is the camera zooming.
  103703. * A negative number will reverse the axis direction.
  103704. */
  103705. pinchPrecision: number;
  103706. /**
  103707. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103708. * from 0.
  103709. * It defines the percentage of current camera.radius to use as delta when
  103710. * pinch zoom is used.
  103711. */
  103712. pinchDeltaPercentage: number;
  103713. /**
  103714. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  103715. */
  103716. axisXControlRadius: boolean;
  103717. /**
  103718. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  103719. */
  103720. axisXControlHeight: boolean;
  103721. /**
  103722. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  103723. */
  103724. axisXControlRotation: boolean;
  103725. /**
  103726. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  103727. */
  103728. axisYControlRadius: boolean;
  103729. /**
  103730. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  103731. */
  103732. axisYControlHeight: boolean;
  103733. /**
  103734. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  103735. */
  103736. axisYControlRotation: boolean;
  103737. /**
  103738. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  103739. */
  103740. axisPinchControlRadius: boolean;
  103741. /**
  103742. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  103743. */
  103744. axisPinchControlHeight: boolean;
  103745. /**
  103746. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  103747. */
  103748. axisPinchControlRotation: boolean;
  103749. /**
  103750. * Log error messages if basic misconfiguration has occurred.
  103751. */
  103752. warningEnable: boolean;
  103753. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103754. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103755. private _warningCounter;
  103756. private _warning;
  103757. }
  103758. }
  103759. declare module BABYLON {
  103760. /**
  103761. * Default Inputs manager for the FollowCamera.
  103762. * It groups all the default supported inputs for ease of use.
  103763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103764. */
  103765. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  103766. /**
  103767. * Instantiates a new FollowCameraInputsManager.
  103768. * @param camera Defines the camera the inputs belong to
  103769. */
  103770. constructor(camera: FollowCamera);
  103771. /**
  103772. * Add keyboard input support to the input manager.
  103773. * @returns the current input manager
  103774. */
  103775. addKeyboard(): FollowCameraInputsManager;
  103776. /**
  103777. * Add mouse wheel input support to the input manager.
  103778. * @returns the current input manager
  103779. */
  103780. addMouseWheel(): FollowCameraInputsManager;
  103781. /**
  103782. * Add pointers input support to the input manager.
  103783. * @returns the current input manager
  103784. */
  103785. addPointers(): FollowCameraInputsManager;
  103786. /**
  103787. * Add orientation input support to the input manager.
  103788. * @returns the current input manager
  103789. */
  103790. addVRDeviceOrientation(): FollowCameraInputsManager;
  103791. }
  103792. }
  103793. declare module BABYLON {
  103794. /**
  103795. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  103796. * an arc rotate version arcFollowCamera are available.
  103797. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103798. */
  103799. export class FollowCamera extends TargetCamera {
  103800. /**
  103801. * Distance the follow camera should follow an object at
  103802. */
  103803. radius: number;
  103804. /**
  103805. * Minimum allowed distance of the camera to the axis of rotation
  103806. * (The camera can not get closer).
  103807. * This can help limiting how the Camera is able to move in the scene.
  103808. */
  103809. lowerRadiusLimit: Nullable<number>;
  103810. /**
  103811. * Maximum allowed distance of the camera to the axis of rotation
  103812. * (The camera can not get further).
  103813. * This can help limiting how the Camera is able to move in the scene.
  103814. */
  103815. upperRadiusLimit: Nullable<number>;
  103816. /**
  103817. * Define a rotation offset between the camera and the object it follows
  103818. */
  103819. rotationOffset: number;
  103820. /**
  103821. * Minimum allowed angle to camera position relative to target object.
  103822. * This can help limiting how the Camera is able to move in the scene.
  103823. */
  103824. lowerRotationOffsetLimit: Nullable<number>;
  103825. /**
  103826. * Maximum allowed angle to camera position relative to target object.
  103827. * This can help limiting how the Camera is able to move in the scene.
  103828. */
  103829. upperRotationOffsetLimit: Nullable<number>;
  103830. /**
  103831. * Define a height offset between the camera and the object it follows.
  103832. * It can help following an object from the top (like a car chaing a plane)
  103833. */
  103834. heightOffset: number;
  103835. /**
  103836. * Minimum allowed height of camera position relative to target object.
  103837. * This can help limiting how the Camera is able to move in the scene.
  103838. */
  103839. lowerHeightOffsetLimit: Nullable<number>;
  103840. /**
  103841. * Maximum allowed height of camera position relative to target object.
  103842. * This can help limiting how the Camera is able to move in the scene.
  103843. */
  103844. upperHeightOffsetLimit: Nullable<number>;
  103845. /**
  103846. * Define how fast the camera can accelerate to follow it s target.
  103847. */
  103848. cameraAcceleration: number;
  103849. /**
  103850. * Define the speed limit of the camera following an object.
  103851. */
  103852. maxCameraSpeed: number;
  103853. /**
  103854. * Define the target of the camera.
  103855. */
  103856. lockedTarget: Nullable<AbstractMesh>;
  103857. /**
  103858. * Defines the input associated with the camera.
  103859. */
  103860. inputs: FollowCameraInputsManager;
  103861. /**
  103862. * Instantiates the follow camera.
  103863. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103864. * @param name Define the name of the camera in the scene
  103865. * @param position Define the position of the camera
  103866. * @param scene Define the scene the camera belong to
  103867. * @param lockedTarget Define the target of the camera
  103868. */
  103869. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  103870. private _follow;
  103871. /**
  103872. * Attached controls to the current camera.
  103873. * @param element Defines the element the controls should be listened from
  103874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103875. */
  103876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103877. /**
  103878. * Detach the current controls from the camera.
  103879. * The camera will stop reacting to inputs.
  103880. * @param element Defines the element to stop listening the inputs from
  103881. */
  103882. detachControl(element: HTMLElement): void;
  103883. /** @hidden */
  103884. _checkInputs(): void;
  103885. private _checkLimits;
  103886. /**
  103887. * Gets the camera class name.
  103888. * @returns the class name
  103889. */
  103890. getClassName(): string;
  103891. }
  103892. /**
  103893. * Arc Rotate version of the follow camera.
  103894. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  103895. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103896. */
  103897. export class ArcFollowCamera extends TargetCamera {
  103898. /** The longitudinal angle of the camera */
  103899. alpha: number;
  103900. /** The latitudinal angle of the camera */
  103901. beta: number;
  103902. /** The radius of the camera from its target */
  103903. radius: number;
  103904. /** Define the camera target (the messh it should follow) */
  103905. target: Nullable<AbstractMesh>;
  103906. private _cartesianCoordinates;
  103907. /**
  103908. * Instantiates a new ArcFollowCamera
  103909. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103910. * @param name Define the name of the camera
  103911. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  103912. * @param beta Define the rotation angle of the camera around the elevation axis
  103913. * @param radius Define the radius of the camera from its target point
  103914. * @param target Define the target of the camera
  103915. * @param scene Define the scene the camera belongs to
  103916. */
  103917. constructor(name: string,
  103918. /** The longitudinal angle of the camera */
  103919. alpha: number,
  103920. /** The latitudinal angle of the camera */
  103921. beta: number,
  103922. /** The radius of the camera from its target */
  103923. radius: number,
  103924. /** Define the camera target (the messh it should follow) */
  103925. target: Nullable<AbstractMesh>, scene: Scene);
  103926. private _follow;
  103927. /** @hidden */
  103928. _checkInputs(): void;
  103929. /**
  103930. * Returns the class name of the object.
  103931. * It is mostly used internally for serialization purposes.
  103932. */
  103933. getClassName(): string;
  103934. }
  103935. }
  103936. declare module BABYLON {
  103937. /**
  103938. * Manage the keyboard inputs to control the movement of a follow camera.
  103939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103940. */
  103941. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  103942. /**
  103943. * Defines the camera the input is attached to.
  103944. */
  103945. camera: FollowCamera;
  103946. /**
  103947. * Defines the list of key codes associated with the up action (increase heightOffset)
  103948. */
  103949. keysHeightOffsetIncr: number[];
  103950. /**
  103951. * Defines the list of key codes associated with the down action (decrease heightOffset)
  103952. */
  103953. keysHeightOffsetDecr: number[];
  103954. /**
  103955. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  103956. */
  103957. keysHeightOffsetModifierAlt: boolean;
  103958. /**
  103959. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  103960. */
  103961. keysHeightOffsetModifierCtrl: boolean;
  103962. /**
  103963. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  103964. */
  103965. keysHeightOffsetModifierShift: boolean;
  103966. /**
  103967. * Defines the list of key codes associated with the left action (increase rotationOffset)
  103968. */
  103969. keysRotationOffsetIncr: number[];
  103970. /**
  103971. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  103972. */
  103973. keysRotationOffsetDecr: number[];
  103974. /**
  103975. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  103976. */
  103977. keysRotationOffsetModifierAlt: boolean;
  103978. /**
  103979. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  103980. */
  103981. keysRotationOffsetModifierCtrl: boolean;
  103982. /**
  103983. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  103984. */
  103985. keysRotationOffsetModifierShift: boolean;
  103986. /**
  103987. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  103988. */
  103989. keysRadiusIncr: number[];
  103990. /**
  103991. * Defines the list of key codes associated with the zoom-out action (increase radius)
  103992. */
  103993. keysRadiusDecr: number[];
  103994. /**
  103995. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  103996. */
  103997. keysRadiusModifierAlt: boolean;
  103998. /**
  103999. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  104000. */
  104001. keysRadiusModifierCtrl: boolean;
  104002. /**
  104003. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  104004. */
  104005. keysRadiusModifierShift: boolean;
  104006. /**
  104007. * Defines the rate of change of heightOffset.
  104008. */
  104009. heightSensibility: number;
  104010. /**
  104011. * Defines the rate of change of rotationOffset.
  104012. */
  104013. rotationSensibility: number;
  104014. /**
  104015. * Defines the rate of change of radius.
  104016. */
  104017. radiusSensibility: number;
  104018. private _keys;
  104019. private _ctrlPressed;
  104020. private _altPressed;
  104021. private _shiftPressed;
  104022. private _onCanvasBlurObserver;
  104023. private _onKeyboardObserver;
  104024. private _engine;
  104025. private _scene;
  104026. /**
  104027. * Attach the input controls to a specific dom element to get the input from.
  104028. * @param element Defines the element the controls should be listened from
  104029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104030. */
  104031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104032. /**
  104033. * Detach the current controls from the specified dom element.
  104034. * @param element Defines the element to stop listening the inputs from
  104035. */
  104036. detachControl(element: Nullable<HTMLElement>): void;
  104037. /**
  104038. * Update the current camera state depending on the inputs that have been used this frame.
  104039. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104040. */
  104041. checkInputs(): void;
  104042. /**
  104043. * Gets the class name of the current input.
  104044. * @returns the class name
  104045. */
  104046. getClassName(): string;
  104047. /**
  104048. * Get the friendly name associated with the input class.
  104049. * @returns the input friendly name
  104050. */
  104051. getSimpleName(): string;
  104052. /**
  104053. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104054. * allow modification of the heightOffset value.
  104055. */
  104056. private _modifierHeightOffset;
  104057. /**
  104058. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104059. * allow modification of the rotationOffset value.
  104060. */
  104061. private _modifierRotationOffset;
  104062. /**
  104063. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104064. * allow modification of the radius value.
  104065. */
  104066. private _modifierRadius;
  104067. }
  104068. }
  104069. declare module BABYLON {
  104070. interface FreeCameraInputsManager {
  104071. /**
  104072. * @hidden
  104073. */
  104074. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  104075. /**
  104076. * Add orientation input support to the input manager.
  104077. * @returns the current input manager
  104078. */
  104079. addDeviceOrientation(): FreeCameraInputsManager;
  104080. }
  104081. /**
  104082. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  104083. * Screen rotation is taken into account.
  104084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104085. */
  104086. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  104087. private _camera;
  104088. private _screenOrientationAngle;
  104089. private _constantTranform;
  104090. private _screenQuaternion;
  104091. private _alpha;
  104092. private _beta;
  104093. private _gamma;
  104094. /**
  104095. * Can be used to detect if a device orientation sensor is availible on a device
  104096. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  104097. * @returns a promise that will resolve on orientation change
  104098. */
  104099. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  104100. /**
  104101. * @hidden
  104102. */
  104103. _onDeviceOrientationChangedObservable: Observable<void>;
  104104. /**
  104105. * Instantiates a new input
  104106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104107. */
  104108. constructor();
  104109. /**
  104110. * Define the camera controlled by the input.
  104111. */
  104112. camera: FreeCamera;
  104113. /**
  104114. * Attach the input controls to a specific dom element to get the input from.
  104115. * @param element Defines the element the controls should be listened from
  104116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104117. */
  104118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104119. private _orientationChanged;
  104120. private _deviceOrientation;
  104121. /**
  104122. * Detach the current controls from the specified dom element.
  104123. * @param element Defines the element to stop listening the inputs from
  104124. */
  104125. detachControl(element: Nullable<HTMLElement>): void;
  104126. /**
  104127. * Update the current camera state depending on the inputs that have been used this frame.
  104128. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104129. */
  104130. checkInputs(): void;
  104131. /**
  104132. * Gets the class name of the current intput.
  104133. * @returns the class name
  104134. */
  104135. getClassName(): string;
  104136. /**
  104137. * Get the friendly name associated with the input class.
  104138. * @returns the input friendly name
  104139. */
  104140. getSimpleName(): string;
  104141. }
  104142. }
  104143. declare module BABYLON {
  104144. /**
  104145. * Manage the gamepad inputs to control a free camera.
  104146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104147. */
  104148. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  104149. /**
  104150. * Define the camera the input is attached to.
  104151. */
  104152. camera: FreeCamera;
  104153. /**
  104154. * Define the Gamepad controlling the input
  104155. */
  104156. gamepad: Nullable<Gamepad>;
  104157. /**
  104158. * Defines the gamepad rotation sensiblity.
  104159. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104160. */
  104161. gamepadAngularSensibility: number;
  104162. /**
  104163. * Defines the gamepad move sensiblity.
  104164. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104165. */
  104166. gamepadMoveSensibility: number;
  104167. private _onGamepadConnectedObserver;
  104168. private _onGamepadDisconnectedObserver;
  104169. private _cameraTransform;
  104170. private _deltaTransform;
  104171. private _vector3;
  104172. private _vector2;
  104173. /**
  104174. * Attach the input controls to a specific dom element to get the input from.
  104175. * @param element Defines the element the controls should be listened from
  104176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104177. */
  104178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104179. /**
  104180. * Detach the current controls from the specified dom element.
  104181. * @param element Defines the element to stop listening the inputs from
  104182. */
  104183. detachControl(element: Nullable<HTMLElement>): void;
  104184. /**
  104185. * Update the current camera state depending on the inputs that have been used this frame.
  104186. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104187. */
  104188. checkInputs(): void;
  104189. /**
  104190. * Gets the class name of the current intput.
  104191. * @returns the class name
  104192. */
  104193. getClassName(): string;
  104194. /**
  104195. * Get the friendly name associated with the input class.
  104196. * @returns the input friendly name
  104197. */
  104198. getSimpleName(): string;
  104199. }
  104200. }
  104201. declare module BABYLON {
  104202. /**
  104203. * Defines the potential axis of a Joystick
  104204. */
  104205. export enum JoystickAxis {
  104206. /** X axis */
  104207. X = 0,
  104208. /** Y axis */
  104209. Y = 1,
  104210. /** Z axis */
  104211. Z = 2
  104212. }
  104213. /**
  104214. * Class used to define virtual joystick (used in touch mode)
  104215. */
  104216. export class VirtualJoystick {
  104217. /**
  104218. * Gets or sets a boolean indicating that left and right values must be inverted
  104219. */
  104220. reverseLeftRight: boolean;
  104221. /**
  104222. * Gets or sets a boolean indicating that up and down values must be inverted
  104223. */
  104224. reverseUpDown: boolean;
  104225. /**
  104226. * Gets the offset value for the position (ie. the change of the position value)
  104227. */
  104228. deltaPosition: Vector3;
  104229. /**
  104230. * Gets a boolean indicating if the virtual joystick was pressed
  104231. */
  104232. pressed: boolean;
  104233. /**
  104234. * Canvas the virtual joystick will render onto, default z-index of this is 5
  104235. */
  104236. static Canvas: Nullable<HTMLCanvasElement>;
  104237. private static _globalJoystickIndex;
  104238. private static vjCanvasContext;
  104239. private static vjCanvasWidth;
  104240. private static vjCanvasHeight;
  104241. private static halfWidth;
  104242. private _action;
  104243. private _axisTargetedByLeftAndRight;
  104244. private _axisTargetedByUpAndDown;
  104245. private _joystickSensibility;
  104246. private _inversedSensibility;
  104247. private _joystickPointerID;
  104248. private _joystickColor;
  104249. private _joystickPointerPos;
  104250. private _joystickPreviousPointerPos;
  104251. private _joystickPointerStartPos;
  104252. private _deltaJoystickVector;
  104253. private _leftJoystick;
  104254. private _touches;
  104255. private _onPointerDownHandlerRef;
  104256. private _onPointerMoveHandlerRef;
  104257. private _onPointerUpHandlerRef;
  104258. private _onResize;
  104259. /**
  104260. * Creates a new virtual joystick
  104261. * @param leftJoystick defines that the joystick is for left hand (false by default)
  104262. */
  104263. constructor(leftJoystick?: boolean);
  104264. /**
  104265. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104266. * @param newJoystickSensibility defines the new sensibility
  104267. */
  104268. setJoystickSensibility(newJoystickSensibility: number): void;
  104269. private _onPointerDown;
  104270. private _onPointerMove;
  104271. private _onPointerUp;
  104272. /**
  104273. * Change the color of the virtual joystick
  104274. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104275. */
  104276. setJoystickColor(newColor: string): void;
  104277. /**
  104278. * Defines a callback to call when the joystick is touched
  104279. * @param action defines the callback
  104280. */
  104281. setActionOnTouch(action: () => any): void;
  104282. /**
  104283. * Defines which axis you'd like to control for left & right
  104284. * @param axis defines the axis to use
  104285. */
  104286. setAxisForLeftRight(axis: JoystickAxis): void;
  104287. /**
  104288. * Defines which axis you'd like to control for up & down
  104289. * @param axis defines the axis to use
  104290. */
  104291. setAxisForUpDown(axis: JoystickAxis): void;
  104292. private _drawVirtualJoystick;
  104293. /**
  104294. * Release internal HTML canvas
  104295. */
  104296. releaseCanvas(): void;
  104297. }
  104298. }
  104299. declare module BABYLON {
  104300. interface FreeCameraInputsManager {
  104301. /**
  104302. * Add virtual joystick input support to the input manager.
  104303. * @returns the current input manager
  104304. */
  104305. addVirtualJoystick(): FreeCameraInputsManager;
  104306. }
  104307. /**
  104308. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  104309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104310. */
  104311. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  104312. /**
  104313. * Defines the camera the input is attached to.
  104314. */
  104315. camera: FreeCamera;
  104316. private _leftjoystick;
  104317. private _rightjoystick;
  104318. /**
  104319. * Gets the left stick of the virtual joystick.
  104320. * @returns The virtual Joystick
  104321. */
  104322. getLeftJoystick(): VirtualJoystick;
  104323. /**
  104324. * Gets the right stick of the virtual joystick.
  104325. * @returns The virtual Joystick
  104326. */
  104327. getRightJoystick(): VirtualJoystick;
  104328. /**
  104329. * Update the current camera state depending on the inputs that have been used this frame.
  104330. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104331. */
  104332. checkInputs(): void;
  104333. /**
  104334. * Attach the input controls to a specific dom element to get the input from.
  104335. * @param element Defines the element the controls should be listened from
  104336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104337. */
  104338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104339. /**
  104340. * Detach the current controls from the specified dom element.
  104341. * @param element Defines the element to stop listening the inputs from
  104342. */
  104343. detachControl(element: Nullable<HTMLElement>): void;
  104344. /**
  104345. * Gets the class name of the current intput.
  104346. * @returns the class name
  104347. */
  104348. getClassName(): string;
  104349. /**
  104350. * Get the friendly name associated with the input class.
  104351. * @returns the input friendly name
  104352. */
  104353. getSimpleName(): string;
  104354. }
  104355. }
  104356. declare module BABYLON {
  104357. /**
  104358. * This represents a FPS type of camera controlled by touch.
  104359. * This is like a universal camera minus the Gamepad controls.
  104360. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104361. */
  104362. export class TouchCamera extends FreeCamera {
  104363. /**
  104364. * Defines the touch sensibility for rotation.
  104365. * The higher the faster.
  104366. */
  104367. touchAngularSensibility: number;
  104368. /**
  104369. * Defines the touch sensibility for move.
  104370. * The higher the faster.
  104371. */
  104372. touchMoveSensibility: number;
  104373. /**
  104374. * Instantiates a new touch camera.
  104375. * This represents a FPS type of camera controlled by touch.
  104376. * This is like a universal camera minus the Gamepad controls.
  104377. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104378. * @param name Define the name of the camera in the scene
  104379. * @param position Define the start position of the camera in the scene
  104380. * @param scene Define the scene the camera belongs to
  104381. */
  104382. constructor(name: string, position: Vector3, scene: Scene);
  104383. /**
  104384. * Gets the current object class name.
  104385. * @return the class name
  104386. */
  104387. getClassName(): string;
  104388. /** @hidden */
  104389. _setupInputs(): void;
  104390. }
  104391. }
  104392. declare module BABYLON {
  104393. /**
  104394. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  104395. * being tilted forward or back and left or right.
  104396. */
  104397. export class DeviceOrientationCamera extends FreeCamera {
  104398. private _initialQuaternion;
  104399. private _quaternionCache;
  104400. private _tmpDragQuaternion;
  104401. private _disablePointerInputWhenUsingDeviceOrientation;
  104402. /**
  104403. * Creates a new device orientation camera
  104404. * @param name The name of the camera
  104405. * @param position The start position camera
  104406. * @param scene The scene the camera belongs to
  104407. */
  104408. constructor(name: string, position: Vector3, scene: Scene);
  104409. /**
  104410. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  104411. */
  104412. disablePointerInputWhenUsingDeviceOrientation: boolean;
  104413. private _dragFactor;
  104414. /**
  104415. * Enabled turning on the y axis when the orientation sensor is active
  104416. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  104417. */
  104418. enableHorizontalDragging(dragFactor?: number): void;
  104419. /**
  104420. * Gets the current instance class name ("DeviceOrientationCamera").
  104421. * This helps avoiding instanceof at run time.
  104422. * @returns the class name
  104423. */
  104424. getClassName(): string;
  104425. /**
  104426. * @hidden
  104427. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  104428. */
  104429. _checkInputs(): void;
  104430. /**
  104431. * Reset the camera to its default orientation on the specified axis only.
  104432. * @param axis The axis to reset
  104433. */
  104434. resetToCurrentRotation(axis?: Axis): void;
  104435. }
  104436. }
  104437. declare module BABYLON {
  104438. /**
  104439. * Defines supported buttons for XBox360 compatible gamepads
  104440. */
  104441. export enum Xbox360Button {
  104442. /** A */
  104443. A = 0,
  104444. /** B */
  104445. B = 1,
  104446. /** X */
  104447. X = 2,
  104448. /** Y */
  104449. Y = 3,
  104450. /** Start */
  104451. Start = 4,
  104452. /** Back */
  104453. Back = 5,
  104454. /** Left button */
  104455. LB = 6,
  104456. /** Right button */
  104457. RB = 7,
  104458. /** Left stick */
  104459. LeftStick = 8,
  104460. /** Right stick */
  104461. RightStick = 9
  104462. }
  104463. /** Defines values for XBox360 DPad */
  104464. export enum Xbox360Dpad {
  104465. /** Up */
  104466. Up = 0,
  104467. /** Down */
  104468. Down = 1,
  104469. /** Left */
  104470. Left = 2,
  104471. /** Right */
  104472. Right = 3
  104473. }
  104474. /**
  104475. * Defines a XBox360 gamepad
  104476. */
  104477. export class Xbox360Pad extends Gamepad {
  104478. private _leftTrigger;
  104479. private _rightTrigger;
  104480. private _onlefttriggerchanged;
  104481. private _onrighttriggerchanged;
  104482. private _onbuttondown;
  104483. private _onbuttonup;
  104484. private _ondpaddown;
  104485. private _ondpadup;
  104486. /** Observable raised when a button is pressed */
  104487. onButtonDownObservable: Observable<Xbox360Button>;
  104488. /** Observable raised when a button is released */
  104489. onButtonUpObservable: Observable<Xbox360Button>;
  104490. /** Observable raised when a pad is pressed */
  104491. onPadDownObservable: Observable<Xbox360Dpad>;
  104492. /** Observable raised when a pad is released */
  104493. onPadUpObservable: Observable<Xbox360Dpad>;
  104494. private _buttonA;
  104495. private _buttonB;
  104496. private _buttonX;
  104497. private _buttonY;
  104498. private _buttonBack;
  104499. private _buttonStart;
  104500. private _buttonLB;
  104501. private _buttonRB;
  104502. private _buttonLeftStick;
  104503. private _buttonRightStick;
  104504. private _dPadUp;
  104505. private _dPadDown;
  104506. private _dPadLeft;
  104507. private _dPadRight;
  104508. private _isXboxOnePad;
  104509. /**
  104510. * Creates a new XBox360 gamepad object
  104511. * @param id defines the id of this gamepad
  104512. * @param index defines its index
  104513. * @param gamepad defines the internal HTML gamepad object
  104514. * @param xboxOne defines if it is a XBox One gamepad
  104515. */
  104516. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  104517. /**
  104518. * Defines the callback to call when left trigger is pressed
  104519. * @param callback defines the callback to use
  104520. */
  104521. onlefttriggerchanged(callback: (value: number) => void): void;
  104522. /**
  104523. * Defines the callback to call when right trigger is pressed
  104524. * @param callback defines the callback to use
  104525. */
  104526. onrighttriggerchanged(callback: (value: number) => void): void;
  104527. /**
  104528. * Gets the left trigger value
  104529. */
  104530. /**
  104531. * Sets the left trigger value
  104532. */
  104533. leftTrigger: number;
  104534. /**
  104535. * Gets the right trigger value
  104536. */
  104537. /**
  104538. * Sets the right trigger value
  104539. */
  104540. rightTrigger: number;
  104541. /**
  104542. * Defines the callback to call when a button is pressed
  104543. * @param callback defines the callback to use
  104544. */
  104545. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  104546. /**
  104547. * Defines the callback to call when a button is released
  104548. * @param callback defines the callback to use
  104549. */
  104550. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  104551. /**
  104552. * Defines the callback to call when a pad is pressed
  104553. * @param callback defines the callback to use
  104554. */
  104555. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  104556. /**
  104557. * Defines the callback to call when a pad is released
  104558. * @param callback defines the callback to use
  104559. */
  104560. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  104561. private _setButtonValue;
  104562. private _setDPadValue;
  104563. /**
  104564. * Gets the value of the `A` button
  104565. */
  104566. /**
  104567. * Sets the value of the `A` button
  104568. */
  104569. buttonA: number;
  104570. /**
  104571. * Gets the value of the `B` button
  104572. */
  104573. /**
  104574. * Sets the value of the `B` button
  104575. */
  104576. buttonB: number;
  104577. /**
  104578. * Gets the value of the `X` button
  104579. */
  104580. /**
  104581. * Sets the value of the `X` button
  104582. */
  104583. buttonX: number;
  104584. /**
  104585. * Gets the value of the `Y` button
  104586. */
  104587. /**
  104588. * Sets the value of the `Y` button
  104589. */
  104590. buttonY: number;
  104591. /**
  104592. * Gets the value of the `Start` button
  104593. */
  104594. /**
  104595. * Sets the value of the `Start` button
  104596. */
  104597. buttonStart: number;
  104598. /**
  104599. * Gets the value of the `Back` button
  104600. */
  104601. /**
  104602. * Sets the value of the `Back` button
  104603. */
  104604. buttonBack: number;
  104605. /**
  104606. * Gets the value of the `Left` button
  104607. */
  104608. /**
  104609. * Sets the value of the `Left` button
  104610. */
  104611. buttonLB: number;
  104612. /**
  104613. * Gets the value of the `Right` button
  104614. */
  104615. /**
  104616. * Sets the value of the `Right` button
  104617. */
  104618. buttonRB: number;
  104619. /**
  104620. * Gets the value of the Left joystick
  104621. */
  104622. /**
  104623. * Sets the value of the Left joystick
  104624. */
  104625. buttonLeftStick: number;
  104626. /**
  104627. * Gets the value of the Right joystick
  104628. */
  104629. /**
  104630. * Sets the value of the Right joystick
  104631. */
  104632. buttonRightStick: number;
  104633. /**
  104634. * Gets the value of D-pad up
  104635. */
  104636. /**
  104637. * Sets the value of D-pad up
  104638. */
  104639. dPadUp: number;
  104640. /**
  104641. * Gets the value of D-pad down
  104642. */
  104643. /**
  104644. * Sets the value of D-pad down
  104645. */
  104646. dPadDown: number;
  104647. /**
  104648. * Gets the value of D-pad left
  104649. */
  104650. /**
  104651. * Sets the value of D-pad left
  104652. */
  104653. dPadLeft: number;
  104654. /**
  104655. * Gets the value of D-pad right
  104656. */
  104657. /**
  104658. * Sets the value of D-pad right
  104659. */
  104660. dPadRight: number;
  104661. /**
  104662. * Force the gamepad to synchronize with device values
  104663. */
  104664. update(): void;
  104665. /**
  104666. * Disposes the gamepad
  104667. */
  104668. dispose(): void;
  104669. }
  104670. }
  104671. declare module BABYLON {
  104672. /**
  104673. * Defines supported buttons for DualShock compatible gamepads
  104674. */
  104675. export enum DualShockButton {
  104676. /** Cross */
  104677. Cross = 0,
  104678. /** Circle */
  104679. Circle = 1,
  104680. /** Square */
  104681. Square = 2,
  104682. /** Triangle */
  104683. Triangle = 3,
  104684. /** Options */
  104685. Options = 4,
  104686. /** Share */
  104687. Share = 5,
  104688. /** L1 */
  104689. L1 = 6,
  104690. /** R1 */
  104691. R1 = 7,
  104692. /** Left stick */
  104693. LeftStick = 8,
  104694. /** Right stick */
  104695. RightStick = 9
  104696. }
  104697. /** Defines values for DualShock DPad */
  104698. export enum DualShockDpad {
  104699. /** Up */
  104700. Up = 0,
  104701. /** Down */
  104702. Down = 1,
  104703. /** Left */
  104704. Left = 2,
  104705. /** Right */
  104706. Right = 3
  104707. }
  104708. /**
  104709. * Defines a DualShock gamepad
  104710. */
  104711. export class DualShockPad extends Gamepad {
  104712. private _leftTrigger;
  104713. private _rightTrigger;
  104714. private _onlefttriggerchanged;
  104715. private _onrighttriggerchanged;
  104716. private _onbuttondown;
  104717. private _onbuttonup;
  104718. private _ondpaddown;
  104719. private _ondpadup;
  104720. /** Observable raised when a button is pressed */
  104721. onButtonDownObservable: Observable<DualShockButton>;
  104722. /** Observable raised when a button is released */
  104723. onButtonUpObservable: Observable<DualShockButton>;
  104724. /** Observable raised when a pad is pressed */
  104725. onPadDownObservable: Observable<DualShockDpad>;
  104726. /** Observable raised when a pad is released */
  104727. onPadUpObservable: Observable<DualShockDpad>;
  104728. private _buttonCross;
  104729. private _buttonCircle;
  104730. private _buttonSquare;
  104731. private _buttonTriangle;
  104732. private _buttonShare;
  104733. private _buttonOptions;
  104734. private _buttonL1;
  104735. private _buttonR1;
  104736. private _buttonLeftStick;
  104737. private _buttonRightStick;
  104738. private _dPadUp;
  104739. private _dPadDown;
  104740. private _dPadLeft;
  104741. private _dPadRight;
  104742. /**
  104743. * Creates a new DualShock gamepad object
  104744. * @param id defines the id of this gamepad
  104745. * @param index defines its index
  104746. * @param gamepad defines the internal HTML gamepad object
  104747. */
  104748. constructor(id: string, index: number, gamepad: any);
  104749. /**
  104750. * Defines the callback to call when left trigger is pressed
  104751. * @param callback defines the callback to use
  104752. */
  104753. onlefttriggerchanged(callback: (value: number) => void): void;
  104754. /**
  104755. * Defines the callback to call when right trigger is pressed
  104756. * @param callback defines the callback to use
  104757. */
  104758. onrighttriggerchanged(callback: (value: number) => void): void;
  104759. /**
  104760. * Gets the left trigger value
  104761. */
  104762. /**
  104763. * Sets the left trigger value
  104764. */
  104765. leftTrigger: number;
  104766. /**
  104767. * Gets the right trigger value
  104768. */
  104769. /**
  104770. * Sets the right trigger value
  104771. */
  104772. rightTrigger: number;
  104773. /**
  104774. * Defines the callback to call when a button is pressed
  104775. * @param callback defines the callback to use
  104776. */
  104777. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  104778. /**
  104779. * Defines the callback to call when a button is released
  104780. * @param callback defines the callback to use
  104781. */
  104782. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  104783. /**
  104784. * Defines the callback to call when a pad is pressed
  104785. * @param callback defines the callback to use
  104786. */
  104787. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  104788. /**
  104789. * Defines the callback to call when a pad is released
  104790. * @param callback defines the callback to use
  104791. */
  104792. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  104793. private _setButtonValue;
  104794. private _setDPadValue;
  104795. /**
  104796. * Gets the value of the `Cross` button
  104797. */
  104798. /**
  104799. * Sets the value of the `Cross` button
  104800. */
  104801. buttonCross: number;
  104802. /**
  104803. * Gets the value of the `Circle` button
  104804. */
  104805. /**
  104806. * Sets the value of the `Circle` button
  104807. */
  104808. buttonCircle: number;
  104809. /**
  104810. * Gets the value of the `Square` button
  104811. */
  104812. /**
  104813. * Sets the value of the `Square` button
  104814. */
  104815. buttonSquare: number;
  104816. /**
  104817. * Gets the value of the `Triangle` button
  104818. */
  104819. /**
  104820. * Sets the value of the `Triangle` button
  104821. */
  104822. buttonTriangle: number;
  104823. /**
  104824. * Gets the value of the `Options` button
  104825. */
  104826. /**
  104827. * Sets the value of the `Options` button
  104828. */
  104829. buttonOptions: number;
  104830. /**
  104831. * Gets the value of the `Share` button
  104832. */
  104833. /**
  104834. * Sets the value of the `Share` button
  104835. */
  104836. buttonShare: number;
  104837. /**
  104838. * Gets the value of the `L1` button
  104839. */
  104840. /**
  104841. * Sets the value of the `L1` button
  104842. */
  104843. buttonL1: number;
  104844. /**
  104845. * Gets the value of the `R1` button
  104846. */
  104847. /**
  104848. * Sets the value of the `R1` button
  104849. */
  104850. buttonR1: number;
  104851. /**
  104852. * Gets the value of the Left joystick
  104853. */
  104854. /**
  104855. * Sets the value of the Left joystick
  104856. */
  104857. buttonLeftStick: number;
  104858. /**
  104859. * Gets the value of the Right joystick
  104860. */
  104861. /**
  104862. * Sets the value of the Right joystick
  104863. */
  104864. buttonRightStick: number;
  104865. /**
  104866. * Gets the value of D-pad up
  104867. */
  104868. /**
  104869. * Sets the value of D-pad up
  104870. */
  104871. dPadUp: number;
  104872. /**
  104873. * Gets the value of D-pad down
  104874. */
  104875. /**
  104876. * Sets the value of D-pad down
  104877. */
  104878. dPadDown: number;
  104879. /**
  104880. * Gets the value of D-pad left
  104881. */
  104882. /**
  104883. * Sets the value of D-pad left
  104884. */
  104885. dPadLeft: number;
  104886. /**
  104887. * Gets the value of D-pad right
  104888. */
  104889. /**
  104890. * Sets the value of D-pad right
  104891. */
  104892. dPadRight: number;
  104893. /**
  104894. * Force the gamepad to synchronize with device values
  104895. */
  104896. update(): void;
  104897. /**
  104898. * Disposes the gamepad
  104899. */
  104900. dispose(): void;
  104901. }
  104902. }
  104903. declare module BABYLON {
  104904. /**
  104905. * Manager for handling gamepads
  104906. */
  104907. export class GamepadManager {
  104908. private _scene?;
  104909. private _babylonGamepads;
  104910. private _oneGamepadConnected;
  104911. /** @hidden */
  104912. _isMonitoring: boolean;
  104913. private _gamepadEventSupported;
  104914. private _gamepadSupport;
  104915. /**
  104916. * observable to be triggered when the gamepad controller has been connected
  104917. */
  104918. onGamepadConnectedObservable: Observable<Gamepad>;
  104919. /**
  104920. * observable to be triggered when the gamepad controller has been disconnected
  104921. */
  104922. onGamepadDisconnectedObservable: Observable<Gamepad>;
  104923. private _onGamepadConnectedEvent;
  104924. private _onGamepadDisconnectedEvent;
  104925. /**
  104926. * Initializes the gamepad manager
  104927. * @param _scene BabylonJS scene
  104928. */
  104929. constructor(_scene?: Scene | undefined);
  104930. /**
  104931. * The gamepads in the game pad manager
  104932. */
  104933. readonly gamepads: Gamepad[];
  104934. /**
  104935. * Get the gamepad controllers based on type
  104936. * @param type The type of gamepad controller
  104937. * @returns Nullable gamepad
  104938. */
  104939. getGamepadByType(type?: number): Nullable<Gamepad>;
  104940. /**
  104941. * Disposes the gamepad manager
  104942. */
  104943. dispose(): void;
  104944. private _addNewGamepad;
  104945. private _startMonitoringGamepads;
  104946. private _stopMonitoringGamepads;
  104947. /** @hidden */
  104948. _checkGamepadsStatus(): void;
  104949. private _updateGamepadObjects;
  104950. }
  104951. }
  104952. declare module BABYLON {
  104953. interface Scene {
  104954. /** @hidden */
  104955. _gamepadManager: Nullable<GamepadManager>;
  104956. /**
  104957. * Gets the gamepad manager associated with the scene
  104958. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  104959. */
  104960. gamepadManager: GamepadManager;
  104961. }
  104962. /**
  104963. * Interface representing a free camera inputs manager
  104964. */
  104965. interface FreeCameraInputsManager {
  104966. /**
  104967. * Adds gamepad input support to the FreeCameraInputsManager.
  104968. * @returns the FreeCameraInputsManager
  104969. */
  104970. addGamepad(): FreeCameraInputsManager;
  104971. }
  104972. /**
  104973. * Interface representing an arc rotate camera inputs manager
  104974. */
  104975. interface ArcRotateCameraInputsManager {
  104976. /**
  104977. * Adds gamepad input support to the ArcRotateCamera InputManager.
  104978. * @returns the camera inputs manager
  104979. */
  104980. addGamepad(): ArcRotateCameraInputsManager;
  104981. }
  104982. /**
  104983. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  104984. */
  104985. export class GamepadSystemSceneComponent implements ISceneComponent {
  104986. /**
  104987. * The component name helpfull to identify the component in the list of scene components.
  104988. */
  104989. readonly name: string;
  104990. /**
  104991. * The scene the component belongs to.
  104992. */
  104993. scene: Scene;
  104994. /**
  104995. * Creates a new instance of the component for the given scene
  104996. * @param scene Defines the scene to register the component in
  104997. */
  104998. constructor(scene: Scene);
  104999. /**
  105000. * Registers the component in a given scene
  105001. */
  105002. register(): void;
  105003. /**
  105004. * Rebuilds the elements related to this component in case of
  105005. * context lost for instance.
  105006. */
  105007. rebuild(): void;
  105008. /**
  105009. * Disposes the component and the associated ressources
  105010. */
  105011. dispose(): void;
  105012. private _beforeCameraUpdate;
  105013. }
  105014. }
  105015. declare module BABYLON {
  105016. /**
  105017. * 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,
  105018. * which still works and will still be found in many Playgrounds.
  105019. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105020. */
  105021. export class UniversalCamera extends TouchCamera {
  105022. /**
  105023. * Defines the gamepad rotation sensiblity.
  105024. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105025. */
  105026. gamepadAngularSensibility: number;
  105027. /**
  105028. * Defines the gamepad move sensiblity.
  105029. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105030. */
  105031. gamepadMoveSensibility: number;
  105032. /**
  105033. * 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,
  105034. * which still works and will still be found in many Playgrounds.
  105035. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105036. * @param name Define the name of the camera in the scene
  105037. * @param position Define the start position of the camera in the scene
  105038. * @param scene Define the scene the camera belongs to
  105039. */
  105040. constructor(name: string, position: Vector3, scene: Scene);
  105041. /**
  105042. * Gets the current object class name.
  105043. * @return the class name
  105044. */
  105045. getClassName(): string;
  105046. }
  105047. }
  105048. declare module BABYLON {
  105049. /**
  105050. * This represents a FPS type of camera. This is only here for back compat purpose.
  105051. * Please use the UniversalCamera instead as both are identical.
  105052. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105053. */
  105054. export class GamepadCamera extends UniversalCamera {
  105055. /**
  105056. * Instantiates a new Gamepad Camera
  105057. * This represents a FPS type of camera. This is only here for back compat purpose.
  105058. * Please use the UniversalCamera instead as both are identical.
  105059. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105060. * @param name Define the name of the camera in the scene
  105061. * @param position Define the start position of the camera in the scene
  105062. * @param scene Define the scene the camera belongs to
  105063. */
  105064. constructor(name: string, position: Vector3, scene: Scene);
  105065. /**
  105066. * Gets the current object class name.
  105067. * @return the class name
  105068. */
  105069. getClassName(): string;
  105070. }
  105071. }
  105072. declare module BABYLON {
  105073. /** @hidden */
  105074. export var passPixelShader: {
  105075. name: string;
  105076. shader: string;
  105077. };
  105078. }
  105079. declare module BABYLON {
  105080. /** @hidden */
  105081. export var passCubePixelShader: {
  105082. name: string;
  105083. shader: string;
  105084. };
  105085. }
  105086. declare module BABYLON {
  105087. /**
  105088. * PassPostProcess which produces an output the same as it's input
  105089. */
  105090. export class PassPostProcess extends PostProcess {
  105091. /**
  105092. * Creates the PassPostProcess
  105093. * @param name The name of the effect.
  105094. * @param options The required width/height ratio to downsize to before computing the render pass.
  105095. * @param camera The camera to apply the render pass to.
  105096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105097. * @param engine The engine which the post process will be applied. (default: current engine)
  105098. * @param reusable If the post process can be reused on the same frame. (default: false)
  105099. * @param textureType The type of texture to be used when performing the post processing.
  105100. * @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)
  105101. */
  105102. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105103. }
  105104. /**
  105105. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  105106. */
  105107. export class PassCubePostProcess extends PostProcess {
  105108. private _face;
  105109. /**
  105110. * Gets or sets the cube face to display.
  105111. * * 0 is +X
  105112. * * 1 is -X
  105113. * * 2 is +Y
  105114. * * 3 is -Y
  105115. * * 4 is +Z
  105116. * * 5 is -Z
  105117. */
  105118. face: number;
  105119. /**
  105120. * Creates the PassCubePostProcess
  105121. * @param name The name of the effect.
  105122. * @param options The required width/height ratio to downsize to before computing the render pass.
  105123. * @param camera The camera to apply the render pass to.
  105124. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105125. * @param engine The engine which the post process will be applied. (default: current engine)
  105126. * @param reusable If the post process can be reused on the same frame. (default: false)
  105127. * @param textureType The type of texture to be used when performing the post processing.
  105128. * @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)
  105129. */
  105130. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105131. }
  105132. }
  105133. declare module BABYLON {
  105134. /** @hidden */
  105135. export var anaglyphPixelShader: {
  105136. name: string;
  105137. shader: string;
  105138. };
  105139. }
  105140. declare module BABYLON {
  105141. /**
  105142. * Postprocess used to generate anaglyphic rendering
  105143. */
  105144. export class AnaglyphPostProcess extends PostProcess {
  105145. private _passedProcess;
  105146. /**
  105147. * Creates a new AnaglyphPostProcess
  105148. * @param name defines postprocess name
  105149. * @param options defines creation options or target ratio scale
  105150. * @param rigCameras defines cameras using this postprocess
  105151. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  105152. * @param engine defines hosting engine
  105153. * @param reusable defines if the postprocess will be reused multiple times per frame
  105154. */
  105155. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  105156. }
  105157. }
  105158. declare module BABYLON {
  105159. /**
  105160. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  105161. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105162. */
  105163. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  105164. /**
  105165. * Creates a new AnaglyphArcRotateCamera
  105166. * @param name defines camera name
  105167. * @param alpha defines alpha angle (in radians)
  105168. * @param beta defines beta angle (in radians)
  105169. * @param radius defines radius
  105170. * @param target defines camera target
  105171. * @param interaxialDistance defines distance between each color axis
  105172. * @param scene defines the hosting scene
  105173. */
  105174. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  105175. /**
  105176. * Gets camera class name
  105177. * @returns AnaglyphArcRotateCamera
  105178. */
  105179. getClassName(): string;
  105180. }
  105181. }
  105182. declare module BABYLON {
  105183. /**
  105184. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  105185. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105186. */
  105187. export class AnaglyphFreeCamera extends FreeCamera {
  105188. /**
  105189. * Creates a new AnaglyphFreeCamera
  105190. * @param name defines camera name
  105191. * @param position defines initial position
  105192. * @param interaxialDistance defines distance between each color axis
  105193. * @param scene defines the hosting scene
  105194. */
  105195. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105196. /**
  105197. * Gets camera class name
  105198. * @returns AnaglyphFreeCamera
  105199. */
  105200. getClassName(): string;
  105201. }
  105202. }
  105203. declare module BABYLON {
  105204. /**
  105205. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  105206. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105207. */
  105208. export class AnaglyphGamepadCamera extends GamepadCamera {
  105209. /**
  105210. * Creates a new AnaglyphGamepadCamera
  105211. * @param name defines camera name
  105212. * @param position defines initial position
  105213. * @param interaxialDistance defines distance between each color axis
  105214. * @param scene defines the hosting scene
  105215. */
  105216. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105217. /**
  105218. * Gets camera class name
  105219. * @returns AnaglyphGamepadCamera
  105220. */
  105221. getClassName(): string;
  105222. }
  105223. }
  105224. declare module BABYLON {
  105225. /**
  105226. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  105227. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105228. */
  105229. export class AnaglyphUniversalCamera extends UniversalCamera {
  105230. /**
  105231. * Creates a new AnaglyphUniversalCamera
  105232. * @param name defines camera name
  105233. * @param position defines initial position
  105234. * @param interaxialDistance defines distance between each color axis
  105235. * @param scene defines the hosting scene
  105236. */
  105237. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105238. /**
  105239. * Gets camera class name
  105240. * @returns AnaglyphUniversalCamera
  105241. */
  105242. getClassName(): string;
  105243. }
  105244. }
  105245. declare module BABYLON {
  105246. /** @hidden */
  105247. export var stereoscopicInterlacePixelShader: {
  105248. name: string;
  105249. shader: string;
  105250. };
  105251. }
  105252. declare module BABYLON {
  105253. /**
  105254. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  105255. */
  105256. export class StereoscopicInterlacePostProcess extends PostProcess {
  105257. private _stepSize;
  105258. private _passedProcess;
  105259. /**
  105260. * Initializes a StereoscopicInterlacePostProcess
  105261. * @param name The name of the effect.
  105262. * @param rigCameras The rig cameras to be appled to the post process
  105263. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  105264. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105265. * @param engine The engine which the post process will be applied. (default: current engine)
  105266. * @param reusable If the post process can be reused on the same frame. (default: false)
  105267. */
  105268. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105269. }
  105270. }
  105271. declare module BABYLON {
  105272. /**
  105273. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  105274. * @see http://doc.babylonjs.com/features/cameras
  105275. */
  105276. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  105277. /**
  105278. * Creates a new StereoscopicArcRotateCamera
  105279. * @param name defines camera name
  105280. * @param alpha defines alpha angle (in radians)
  105281. * @param beta defines beta angle (in radians)
  105282. * @param radius defines radius
  105283. * @param target defines camera target
  105284. * @param interaxialDistance defines distance between each color axis
  105285. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105286. * @param scene defines the hosting scene
  105287. */
  105288. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105289. /**
  105290. * Gets camera class name
  105291. * @returns StereoscopicArcRotateCamera
  105292. */
  105293. getClassName(): string;
  105294. }
  105295. }
  105296. declare module BABYLON {
  105297. /**
  105298. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  105299. * @see http://doc.babylonjs.com/features/cameras
  105300. */
  105301. export class StereoscopicFreeCamera extends FreeCamera {
  105302. /**
  105303. * Creates a new StereoscopicFreeCamera
  105304. * @param name defines camera name
  105305. * @param position defines initial position
  105306. * @param interaxialDistance defines distance between each color axis
  105307. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105308. * @param scene defines the hosting scene
  105309. */
  105310. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105311. /**
  105312. * Gets camera class name
  105313. * @returns StereoscopicFreeCamera
  105314. */
  105315. getClassName(): string;
  105316. }
  105317. }
  105318. declare module BABYLON {
  105319. /**
  105320. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  105321. * @see http://doc.babylonjs.com/features/cameras
  105322. */
  105323. export class StereoscopicGamepadCamera extends GamepadCamera {
  105324. /**
  105325. * Creates a new StereoscopicGamepadCamera
  105326. * @param name defines camera name
  105327. * @param position defines initial position
  105328. * @param interaxialDistance defines distance between each color axis
  105329. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105330. * @param scene defines the hosting scene
  105331. */
  105332. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105333. /**
  105334. * Gets camera class name
  105335. * @returns StereoscopicGamepadCamera
  105336. */
  105337. getClassName(): string;
  105338. }
  105339. }
  105340. declare module BABYLON {
  105341. /**
  105342. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  105343. * @see http://doc.babylonjs.com/features/cameras
  105344. */
  105345. export class StereoscopicUniversalCamera extends UniversalCamera {
  105346. /**
  105347. * Creates a new StereoscopicUniversalCamera
  105348. * @param name defines camera name
  105349. * @param position defines initial position
  105350. * @param interaxialDistance defines distance between each color axis
  105351. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105352. * @param scene defines the hosting scene
  105353. */
  105354. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105355. /**
  105356. * Gets camera class name
  105357. * @returns StereoscopicUniversalCamera
  105358. */
  105359. getClassName(): string;
  105360. }
  105361. }
  105362. declare module BABYLON {
  105363. /**
  105364. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105365. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105366. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105367. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105368. */
  105369. export class VirtualJoysticksCamera extends FreeCamera {
  105370. /**
  105371. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  105372. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105373. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105374. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105375. * @param name Define the name of the camera in the scene
  105376. * @param position Define the start position of the camera in the scene
  105377. * @param scene Define the scene the camera belongs to
  105378. */
  105379. constructor(name: string, position: Vector3, scene: Scene);
  105380. /**
  105381. * Gets the current object class name.
  105382. * @return the class name
  105383. */
  105384. getClassName(): string;
  105385. }
  105386. }
  105387. declare module BABYLON {
  105388. /**
  105389. * This represents all the required metrics to create a VR camera.
  105390. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  105391. */
  105392. export class VRCameraMetrics {
  105393. /**
  105394. * Define the horizontal resolution off the screen.
  105395. */
  105396. hResolution: number;
  105397. /**
  105398. * Define the vertical resolution off the screen.
  105399. */
  105400. vResolution: number;
  105401. /**
  105402. * Define the horizontal screen size.
  105403. */
  105404. hScreenSize: number;
  105405. /**
  105406. * Define the vertical screen size.
  105407. */
  105408. vScreenSize: number;
  105409. /**
  105410. * Define the vertical screen center position.
  105411. */
  105412. vScreenCenter: number;
  105413. /**
  105414. * Define the distance of the eyes to the screen.
  105415. */
  105416. eyeToScreenDistance: number;
  105417. /**
  105418. * Define the distance between both lenses
  105419. */
  105420. lensSeparationDistance: number;
  105421. /**
  105422. * Define the distance between both viewer's eyes.
  105423. */
  105424. interpupillaryDistance: number;
  105425. /**
  105426. * Define the distortion factor of the VR postprocess.
  105427. * Please, touch with care.
  105428. */
  105429. distortionK: number[];
  105430. /**
  105431. * Define the chromatic aberration correction factors for the VR post process.
  105432. */
  105433. chromaAbCorrection: number[];
  105434. /**
  105435. * Define the scale factor of the post process.
  105436. * The smaller the better but the slower.
  105437. */
  105438. postProcessScaleFactor: number;
  105439. /**
  105440. * Define an offset for the lens center.
  105441. */
  105442. lensCenterOffset: number;
  105443. /**
  105444. * Define if the current vr camera should compensate the distortion of the lense or not.
  105445. */
  105446. compensateDistortion: boolean;
  105447. /**
  105448. * Defines if multiview should be enabled when rendering (Default: false)
  105449. */
  105450. multiviewEnabled: boolean;
  105451. /**
  105452. * Gets the rendering aspect ratio based on the provided resolutions.
  105453. */
  105454. readonly aspectRatio: number;
  105455. /**
  105456. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  105457. */
  105458. readonly aspectRatioFov: number;
  105459. /**
  105460. * @hidden
  105461. */
  105462. readonly leftHMatrix: Matrix;
  105463. /**
  105464. * @hidden
  105465. */
  105466. readonly rightHMatrix: Matrix;
  105467. /**
  105468. * @hidden
  105469. */
  105470. readonly leftPreViewMatrix: Matrix;
  105471. /**
  105472. * @hidden
  105473. */
  105474. readonly rightPreViewMatrix: Matrix;
  105475. /**
  105476. * Get the default VRMetrics based on the most generic setup.
  105477. * @returns the default vr metrics
  105478. */
  105479. static GetDefault(): VRCameraMetrics;
  105480. }
  105481. }
  105482. declare module BABYLON {
  105483. /** @hidden */
  105484. export var vrDistortionCorrectionPixelShader: {
  105485. name: string;
  105486. shader: string;
  105487. };
  105488. }
  105489. declare module BABYLON {
  105490. /**
  105491. * VRDistortionCorrectionPostProcess used for mobile VR
  105492. */
  105493. export class VRDistortionCorrectionPostProcess extends PostProcess {
  105494. private _isRightEye;
  105495. private _distortionFactors;
  105496. private _postProcessScaleFactor;
  105497. private _lensCenterOffset;
  105498. private _scaleIn;
  105499. private _scaleFactor;
  105500. private _lensCenter;
  105501. /**
  105502. * Initializes the VRDistortionCorrectionPostProcess
  105503. * @param name The name of the effect.
  105504. * @param camera The camera to apply the render pass to.
  105505. * @param isRightEye If this is for the right eye distortion
  105506. * @param vrMetrics All the required metrics for the VR camera
  105507. */
  105508. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  105509. }
  105510. }
  105511. declare module BABYLON {
  105512. /**
  105513. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  105514. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105515. */
  105516. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  105517. /**
  105518. * Creates a new VRDeviceOrientationArcRotateCamera
  105519. * @param name defines camera name
  105520. * @param alpha defines the camera rotation along the logitudinal axis
  105521. * @param beta defines the camera rotation along the latitudinal axis
  105522. * @param radius defines the camera distance from its target
  105523. * @param target defines the camera target
  105524. * @param scene defines the scene the camera belongs to
  105525. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105526. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105527. */
  105528. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105529. /**
  105530. * Gets camera class name
  105531. * @returns VRDeviceOrientationArcRotateCamera
  105532. */
  105533. getClassName(): string;
  105534. }
  105535. }
  105536. declare module BABYLON {
  105537. /**
  105538. * Camera used to simulate VR rendering (based on FreeCamera)
  105539. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105540. */
  105541. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  105542. /**
  105543. * Creates a new VRDeviceOrientationFreeCamera
  105544. * @param name defines camera name
  105545. * @param position defines the start position of the camera
  105546. * @param scene defines the scene the camera belongs to
  105547. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105548. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105549. */
  105550. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105551. /**
  105552. * Gets camera class name
  105553. * @returns VRDeviceOrientationFreeCamera
  105554. */
  105555. getClassName(): string;
  105556. }
  105557. }
  105558. declare module BABYLON {
  105559. /**
  105560. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  105561. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105562. */
  105563. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  105564. /**
  105565. * Creates a new VRDeviceOrientationGamepadCamera
  105566. * @param name defines camera name
  105567. * @param position defines the start position of the camera
  105568. * @param scene defines the scene the camera belongs to
  105569. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105570. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105571. */
  105572. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105573. /**
  105574. * Gets camera class name
  105575. * @returns VRDeviceOrientationGamepadCamera
  105576. */
  105577. getClassName(): string;
  105578. }
  105579. }
  105580. declare module BABYLON {
  105581. /**
  105582. * Base class of materials working in push mode in babylon JS
  105583. * @hidden
  105584. */
  105585. export class PushMaterial extends Material {
  105586. protected _activeEffect: Effect;
  105587. protected _normalMatrix: Matrix;
  105588. /**
  105589. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  105590. * This means that the material can keep using a previous shader while a new one is being compiled.
  105591. * This is mostly used when shader parallel compilation is supported (true by default)
  105592. */
  105593. allowShaderHotSwapping: boolean;
  105594. constructor(name: string, scene: Scene);
  105595. getEffect(): Effect;
  105596. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105597. /**
  105598. * Binds the given world matrix to the active effect
  105599. *
  105600. * @param world the matrix to bind
  105601. */
  105602. bindOnlyWorldMatrix(world: Matrix): void;
  105603. /**
  105604. * Binds the given normal matrix to the active effect
  105605. *
  105606. * @param normalMatrix the matrix to bind
  105607. */
  105608. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  105609. bind(world: Matrix, mesh?: Mesh): void;
  105610. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  105611. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  105612. }
  105613. }
  105614. declare module BABYLON {
  105615. /**
  105616. * This groups all the flags used to control the materials channel.
  105617. */
  105618. export class MaterialFlags {
  105619. private static _DiffuseTextureEnabled;
  105620. /**
  105621. * Are diffuse textures enabled in the application.
  105622. */
  105623. static DiffuseTextureEnabled: boolean;
  105624. private static _AmbientTextureEnabled;
  105625. /**
  105626. * Are ambient textures enabled in the application.
  105627. */
  105628. static AmbientTextureEnabled: boolean;
  105629. private static _OpacityTextureEnabled;
  105630. /**
  105631. * Are opacity textures enabled in the application.
  105632. */
  105633. static OpacityTextureEnabled: boolean;
  105634. private static _ReflectionTextureEnabled;
  105635. /**
  105636. * Are reflection textures enabled in the application.
  105637. */
  105638. static ReflectionTextureEnabled: boolean;
  105639. private static _EmissiveTextureEnabled;
  105640. /**
  105641. * Are emissive textures enabled in the application.
  105642. */
  105643. static EmissiveTextureEnabled: boolean;
  105644. private static _SpecularTextureEnabled;
  105645. /**
  105646. * Are specular textures enabled in the application.
  105647. */
  105648. static SpecularTextureEnabled: boolean;
  105649. private static _BumpTextureEnabled;
  105650. /**
  105651. * Are bump textures enabled in the application.
  105652. */
  105653. static BumpTextureEnabled: boolean;
  105654. private static _LightmapTextureEnabled;
  105655. /**
  105656. * Are lightmap textures enabled in the application.
  105657. */
  105658. static LightmapTextureEnabled: boolean;
  105659. private static _RefractionTextureEnabled;
  105660. /**
  105661. * Are refraction textures enabled in the application.
  105662. */
  105663. static RefractionTextureEnabled: boolean;
  105664. private static _ColorGradingTextureEnabled;
  105665. /**
  105666. * Are color grading textures enabled in the application.
  105667. */
  105668. static ColorGradingTextureEnabled: boolean;
  105669. private static _FresnelEnabled;
  105670. /**
  105671. * Are fresnels enabled in the application.
  105672. */
  105673. static FresnelEnabled: boolean;
  105674. private static _ClearCoatTextureEnabled;
  105675. /**
  105676. * Are clear coat textures enabled in the application.
  105677. */
  105678. static ClearCoatTextureEnabled: boolean;
  105679. private static _ClearCoatBumpTextureEnabled;
  105680. /**
  105681. * Are clear coat bump textures enabled in the application.
  105682. */
  105683. static ClearCoatBumpTextureEnabled: boolean;
  105684. private static _ClearCoatTintTextureEnabled;
  105685. /**
  105686. * Are clear coat tint textures enabled in the application.
  105687. */
  105688. static ClearCoatTintTextureEnabled: boolean;
  105689. private static _SheenTextureEnabled;
  105690. /**
  105691. * Are sheen textures enabled in the application.
  105692. */
  105693. static SheenTextureEnabled: boolean;
  105694. private static _AnisotropicTextureEnabled;
  105695. /**
  105696. * Are anisotropic textures enabled in the application.
  105697. */
  105698. static AnisotropicTextureEnabled: boolean;
  105699. private static _ThicknessTextureEnabled;
  105700. /**
  105701. * Are thickness textures enabled in the application.
  105702. */
  105703. static ThicknessTextureEnabled: boolean;
  105704. }
  105705. }
  105706. declare module BABYLON {
  105707. /** @hidden */
  105708. export var defaultFragmentDeclaration: {
  105709. name: string;
  105710. shader: string;
  105711. };
  105712. }
  105713. declare module BABYLON {
  105714. /** @hidden */
  105715. export var defaultUboDeclaration: {
  105716. name: string;
  105717. shader: string;
  105718. };
  105719. }
  105720. declare module BABYLON {
  105721. /** @hidden */
  105722. export var lightFragmentDeclaration: {
  105723. name: string;
  105724. shader: string;
  105725. };
  105726. }
  105727. declare module BABYLON {
  105728. /** @hidden */
  105729. export var lightUboDeclaration: {
  105730. name: string;
  105731. shader: string;
  105732. };
  105733. }
  105734. declare module BABYLON {
  105735. /** @hidden */
  105736. export var lightsFragmentFunctions: {
  105737. name: string;
  105738. shader: string;
  105739. };
  105740. }
  105741. declare module BABYLON {
  105742. /** @hidden */
  105743. export var shadowsFragmentFunctions: {
  105744. name: string;
  105745. shader: string;
  105746. };
  105747. }
  105748. declare module BABYLON {
  105749. /** @hidden */
  105750. export var fresnelFunction: {
  105751. name: string;
  105752. shader: string;
  105753. };
  105754. }
  105755. declare module BABYLON {
  105756. /** @hidden */
  105757. export var reflectionFunction: {
  105758. name: string;
  105759. shader: string;
  105760. };
  105761. }
  105762. declare module BABYLON {
  105763. /** @hidden */
  105764. export var bumpFragmentFunctions: {
  105765. name: string;
  105766. shader: string;
  105767. };
  105768. }
  105769. declare module BABYLON {
  105770. /** @hidden */
  105771. export var logDepthDeclaration: {
  105772. name: string;
  105773. shader: string;
  105774. };
  105775. }
  105776. declare module BABYLON {
  105777. /** @hidden */
  105778. export var bumpFragment: {
  105779. name: string;
  105780. shader: string;
  105781. };
  105782. }
  105783. declare module BABYLON {
  105784. /** @hidden */
  105785. export var depthPrePass: {
  105786. name: string;
  105787. shader: string;
  105788. };
  105789. }
  105790. declare module BABYLON {
  105791. /** @hidden */
  105792. export var lightFragment: {
  105793. name: string;
  105794. shader: string;
  105795. };
  105796. }
  105797. declare module BABYLON {
  105798. /** @hidden */
  105799. export var logDepthFragment: {
  105800. name: string;
  105801. shader: string;
  105802. };
  105803. }
  105804. declare module BABYLON {
  105805. /** @hidden */
  105806. export var defaultPixelShader: {
  105807. name: string;
  105808. shader: string;
  105809. };
  105810. }
  105811. declare module BABYLON {
  105812. /** @hidden */
  105813. export var defaultVertexDeclaration: {
  105814. name: string;
  105815. shader: string;
  105816. };
  105817. }
  105818. declare module BABYLON {
  105819. /** @hidden */
  105820. export var bumpVertexDeclaration: {
  105821. name: string;
  105822. shader: string;
  105823. };
  105824. }
  105825. declare module BABYLON {
  105826. /** @hidden */
  105827. export var bumpVertex: {
  105828. name: string;
  105829. shader: string;
  105830. };
  105831. }
  105832. declare module BABYLON {
  105833. /** @hidden */
  105834. export var fogVertex: {
  105835. name: string;
  105836. shader: string;
  105837. };
  105838. }
  105839. declare module BABYLON {
  105840. /** @hidden */
  105841. export var shadowsVertex: {
  105842. name: string;
  105843. shader: string;
  105844. };
  105845. }
  105846. declare module BABYLON {
  105847. /** @hidden */
  105848. export var pointCloudVertex: {
  105849. name: string;
  105850. shader: string;
  105851. };
  105852. }
  105853. declare module BABYLON {
  105854. /** @hidden */
  105855. export var logDepthVertex: {
  105856. name: string;
  105857. shader: string;
  105858. };
  105859. }
  105860. declare module BABYLON {
  105861. /** @hidden */
  105862. export var defaultVertexShader: {
  105863. name: string;
  105864. shader: string;
  105865. };
  105866. }
  105867. declare module BABYLON {
  105868. /** @hidden */
  105869. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  105870. MAINUV1: boolean;
  105871. MAINUV2: boolean;
  105872. DIFFUSE: boolean;
  105873. DIFFUSEDIRECTUV: number;
  105874. AMBIENT: boolean;
  105875. AMBIENTDIRECTUV: number;
  105876. OPACITY: boolean;
  105877. OPACITYDIRECTUV: number;
  105878. OPACITYRGB: boolean;
  105879. REFLECTION: boolean;
  105880. EMISSIVE: boolean;
  105881. EMISSIVEDIRECTUV: number;
  105882. SPECULAR: boolean;
  105883. SPECULARDIRECTUV: number;
  105884. BUMP: boolean;
  105885. BUMPDIRECTUV: number;
  105886. PARALLAX: boolean;
  105887. PARALLAXOCCLUSION: boolean;
  105888. SPECULAROVERALPHA: boolean;
  105889. CLIPPLANE: boolean;
  105890. CLIPPLANE2: boolean;
  105891. CLIPPLANE3: boolean;
  105892. CLIPPLANE4: boolean;
  105893. ALPHATEST: boolean;
  105894. DEPTHPREPASS: boolean;
  105895. ALPHAFROMDIFFUSE: boolean;
  105896. POINTSIZE: boolean;
  105897. FOG: boolean;
  105898. SPECULARTERM: boolean;
  105899. DIFFUSEFRESNEL: boolean;
  105900. OPACITYFRESNEL: boolean;
  105901. REFLECTIONFRESNEL: boolean;
  105902. REFRACTIONFRESNEL: boolean;
  105903. EMISSIVEFRESNEL: boolean;
  105904. FRESNEL: boolean;
  105905. NORMAL: boolean;
  105906. UV1: boolean;
  105907. UV2: boolean;
  105908. VERTEXCOLOR: boolean;
  105909. VERTEXALPHA: boolean;
  105910. NUM_BONE_INFLUENCERS: number;
  105911. BonesPerMesh: number;
  105912. BONETEXTURE: boolean;
  105913. INSTANCES: boolean;
  105914. GLOSSINESS: boolean;
  105915. ROUGHNESS: boolean;
  105916. EMISSIVEASILLUMINATION: boolean;
  105917. LINKEMISSIVEWITHDIFFUSE: boolean;
  105918. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105919. LIGHTMAP: boolean;
  105920. LIGHTMAPDIRECTUV: number;
  105921. OBJECTSPACE_NORMALMAP: boolean;
  105922. USELIGHTMAPASSHADOWMAP: boolean;
  105923. REFLECTIONMAP_3D: boolean;
  105924. REFLECTIONMAP_SPHERICAL: boolean;
  105925. REFLECTIONMAP_PLANAR: boolean;
  105926. REFLECTIONMAP_CUBIC: boolean;
  105927. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105928. REFLECTIONMAP_PROJECTION: boolean;
  105929. REFLECTIONMAP_SKYBOX: boolean;
  105930. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105931. REFLECTIONMAP_EXPLICIT: boolean;
  105932. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105933. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105934. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105935. INVERTCUBICMAP: boolean;
  105936. LOGARITHMICDEPTH: boolean;
  105937. REFRACTION: boolean;
  105938. REFRACTIONMAP_3D: boolean;
  105939. REFLECTIONOVERALPHA: boolean;
  105940. TWOSIDEDLIGHTING: boolean;
  105941. SHADOWFLOAT: boolean;
  105942. MORPHTARGETS: boolean;
  105943. MORPHTARGETS_NORMAL: boolean;
  105944. MORPHTARGETS_TANGENT: boolean;
  105945. MORPHTARGETS_UV: boolean;
  105946. NUM_MORPH_INFLUENCERS: number;
  105947. NONUNIFORMSCALING: boolean;
  105948. PREMULTIPLYALPHA: boolean;
  105949. IMAGEPROCESSING: boolean;
  105950. VIGNETTE: boolean;
  105951. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105952. VIGNETTEBLENDMODEOPAQUE: boolean;
  105953. TONEMAPPING: boolean;
  105954. TONEMAPPING_ACES: boolean;
  105955. CONTRAST: boolean;
  105956. COLORCURVES: boolean;
  105957. COLORGRADING: boolean;
  105958. COLORGRADING3D: boolean;
  105959. SAMPLER3DGREENDEPTH: boolean;
  105960. SAMPLER3DBGRMAP: boolean;
  105961. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105962. MULTIVIEW: boolean;
  105963. /**
  105964. * If the reflection texture on this material is in linear color space
  105965. * @hidden
  105966. */
  105967. IS_REFLECTION_LINEAR: boolean;
  105968. /**
  105969. * If the refraction texture on this material is in linear color space
  105970. * @hidden
  105971. */
  105972. IS_REFRACTION_LINEAR: boolean;
  105973. EXPOSURE: boolean;
  105974. constructor();
  105975. setReflectionMode(modeToEnable: string): void;
  105976. }
  105977. /**
  105978. * This is the default material used in Babylon. It is the best trade off between quality
  105979. * and performances.
  105980. * @see http://doc.babylonjs.com/babylon101/materials
  105981. */
  105982. export class StandardMaterial extends PushMaterial {
  105983. private _diffuseTexture;
  105984. /**
  105985. * The basic texture of the material as viewed under a light.
  105986. */
  105987. diffuseTexture: Nullable<BaseTexture>;
  105988. private _ambientTexture;
  105989. /**
  105990. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105991. */
  105992. ambientTexture: Nullable<BaseTexture>;
  105993. private _opacityTexture;
  105994. /**
  105995. * Define the transparency of the material from a texture.
  105996. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105997. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105998. */
  105999. opacityTexture: Nullable<BaseTexture>;
  106000. private _reflectionTexture;
  106001. /**
  106002. * Define the texture used to display the reflection.
  106003. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106004. */
  106005. reflectionTexture: Nullable<BaseTexture>;
  106006. private _emissiveTexture;
  106007. /**
  106008. * Define texture of the material as if self lit.
  106009. * This will be mixed in the final result even in the absence of light.
  106010. */
  106011. emissiveTexture: Nullable<BaseTexture>;
  106012. private _specularTexture;
  106013. /**
  106014. * Define how the color and intensity of the highlight given by the light in the material.
  106015. */
  106016. specularTexture: Nullable<BaseTexture>;
  106017. private _bumpTexture;
  106018. /**
  106019. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  106020. * 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.
  106021. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  106022. */
  106023. bumpTexture: Nullable<BaseTexture>;
  106024. private _lightmapTexture;
  106025. /**
  106026. * Complex lighting can be computationally expensive to compute at runtime.
  106027. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  106028. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  106029. */
  106030. lightmapTexture: Nullable<BaseTexture>;
  106031. private _refractionTexture;
  106032. /**
  106033. * Define the texture used to display the refraction.
  106034. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106035. */
  106036. refractionTexture: Nullable<BaseTexture>;
  106037. /**
  106038. * The color of the material lit by the environmental background lighting.
  106039. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106040. */
  106041. ambientColor: Color3;
  106042. /**
  106043. * The basic color of the material as viewed under a light.
  106044. */
  106045. diffuseColor: Color3;
  106046. /**
  106047. * Define how the color and intensity of the highlight given by the light in the material.
  106048. */
  106049. specularColor: Color3;
  106050. /**
  106051. * Define the color of the material as if self lit.
  106052. * This will be mixed in the final result even in the absence of light.
  106053. */
  106054. emissiveColor: Color3;
  106055. /**
  106056. * Defines how sharp are the highlights in the material.
  106057. * The bigger the value the sharper giving a more glossy feeling to the result.
  106058. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  106059. */
  106060. specularPower: number;
  106061. private _useAlphaFromDiffuseTexture;
  106062. /**
  106063. * Does the transparency come from the diffuse texture alpha channel.
  106064. */
  106065. useAlphaFromDiffuseTexture: boolean;
  106066. private _useEmissiveAsIllumination;
  106067. /**
  106068. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  106069. */
  106070. useEmissiveAsIllumination: boolean;
  106071. private _linkEmissiveWithDiffuse;
  106072. /**
  106073. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  106074. * the emissive level when the final color is close to one.
  106075. */
  106076. linkEmissiveWithDiffuse: boolean;
  106077. private _useSpecularOverAlpha;
  106078. /**
  106079. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106080. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106081. */
  106082. useSpecularOverAlpha: boolean;
  106083. private _useReflectionOverAlpha;
  106084. /**
  106085. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106086. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106087. */
  106088. useReflectionOverAlpha: boolean;
  106089. private _disableLighting;
  106090. /**
  106091. * Does lights from the scene impacts this material.
  106092. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  106093. */
  106094. disableLighting: boolean;
  106095. private _useObjectSpaceNormalMap;
  106096. /**
  106097. * Allows using an object space normal map (instead of tangent space).
  106098. */
  106099. useObjectSpaceNormalMap: boolean;
  106100. private _useParallax;
  106101. /**
  106102. * Is parallax enabled or not.
  106103. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106104. */
  106105. useParallax: boolean;
  106106. private _useParallaxOcclusion;
  106107. /**
  106108. * Is parallax occlusion enabled or not.
  106109. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  106110. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106111. */
  106112. useParallaxOcclusion: boolean;
  106113. /**
  106114. * 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.
  106115. */
  106116. parallaxScaleBias: number;
  106117. private _roughness;
  106118. /**
  106119. * Helps to define how blurry the reflections should appears in the material.
  106120. */
  106121. roughness: number;
  106122. /**
  106123. * In case of refraction, define the value of the index of refraction.
  106124. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106125. */
  106126. indexOfRefraction: number;
  106127. /**
  106128. * Invert the refraction texture alongside the y axis.
  106129. * It can be useful with procedural textures or probe for instance.
  106130. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106131. */
  106132. invertRefractionY: boolean;
  106133. /**
  106134. * Defines the alpha limits in alpha test mode.
  106135. */
  106136. alphaCutOff: number;
  106137. private _useLightmapAsShadowmap;
  106138. /**
  106139. * In case of light mapping, define whether the map contains light or shadow informations.
  106140. */
  106141. useLightmapAsShadowmap: boolean;
  106142. private _diffuseFresnelParameters;
  106143. /**
  106144. * Define the diffuse fresnel parameters of the material.
  106145. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106146. */
  106147. diffuseFresnelParameters: FresnelParameters;
  106148. private _opacityFresnelParameters;
  106149. /**
  106150. * Define the opacity fresnel parameters of the material.
  106151. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106152. */
  106153. opacityFresnelParameters: FresnelParameters;
  106154. private _reflectionFresnelParameters;
  106155. /**
  106156. * Define the reflection fresnel parameters of the material.
  106157. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106158. */
  106159. reflectionFresnelParameters: FresnelParameters;
  106160. private _refractionFresnelParameters;
  106161. /**
  106162. * Define the refraction fresnel parameters of the material.
  106163. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106164. */
  106165. refractionFresnelParameters: FresnelParameters;
  106166. private _emissiveFresnelParameters;
  106167. /**
  106168. * Define the emissive fresnel parameters of the material.
  106169. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106170. */
  106171. emissiveFresnelParameters: FresnelParameters;
  106172. private _useReflectionFresnelFromSpecular;
  106173. /**
  106174. * If true automatically deducts the fresnels values from the material specularity.
  106175. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106176. */
  106177. useReflectionFresnelFromSpecular: boolean;
  106178. private _useGlossinessFromSpecularMapAlpha;
  106179. /**
  106180. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106181. */
  106182. useGlossinessFromSpecularMapAlpha: boolean;
  106183. private _maxSimultaneousLights;
  106184. /**
  106185. * Defines the maximum number of lights that can be used in the material
  106186. */
  106187. maxSimultaneousLights: number;
  106188. private _invertNormalMapX;
  106189. /**
  106190. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106191. */
  106192. invertNormalMapX: boolean;
  106193. private _invertNormalMapY;
  106194. /**
  106195. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106196. */
  106197. invertNormalMapY: boolean;
  106198. private _twoSidedLighting;
  106199. /**
  106200. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106201. */
  106202. twoSidedLighting: boolean;
  106203. /**
  106204. * Default configuration related to image processing available in the standard Material.
  106205. */
  106206. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106207. /**
  106208. * Gets the image processing configuration used either in this material.
  106209. */
  106210. /**
  106211. * Sets the Default image processing configuration used either in the this material.
  106212. *
  106213. * If sets to null, the scene one is in use.
  106214. */
  106215. imageProcessingConfiguration: ImageProcessingConfiguration;
  106216. /**
  106217. * Keep track of the image processing observer to allow dispose and replace.
  106218. */
  106219. private _imageProcessingObserver;
  106220. /**
  106221. * Attaches a new image processing configuration to the Standard Material.
  106222. * @param configuration
  106223. */
  106224. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106225. /**
  106226. * Gets wether the color curves effect is enabled.
  106227. */
  106228. /**
  106229. * Sets wether the color curves effect is enabled.
  106230. */
  106231. cameraColorCurvesEnabled: boolean;
  106232. /**
  106233. * Gets wether the color grading effect is enabled.
  106234. */
  106235. /**
  106236. * Gets wether the color grading effect is enabled.
  106237. */
  106238. cameraColorGradingEnabled: boolean;
  106239. /**
  106240. * Gets wether tonemapping is enabled or not.
  106241. */
  106242. /**
  106243. * Sets wether tonemapping is enabled or not
  106244. */
  106245. cameraToneMappingEnabled: boolean;
  106246. /**
  106247. * The camera exposure used on this material.
  106248. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106249. * This corresponds to a photographic exposure.
  106250. */
  106251. /**
  106252. * The camera exposure used on this material.
  106253. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106254. * This corresponds to a photographic exposure.
  106255. */
  106256. cameraExposure: number;
  106257. /**
  106258. * Gets The camera contrast used on this material.
  106259. */
  106260. /**
  106261. * Sets The camera contrast used on this material.
  106262. */
  106263. cameraContrast: number;
  106264. /**
  106265. * Gets the Color Grading 2D Lookup Texture.
  106266. */
  106267. /**
  106268. * Sets the Color Grading 2D Lookup Texture.
  106269. */
  106270. cameraColorGradingTexture: Nullable<BaseTexture>;
  106271. /**
  106272. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106273. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106274. * 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;
  106275. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106276. */
  106277. /**
  106278. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106279. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106280. * 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;
  106281. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106282. */
  106283. cameraColorCurves: Nullable<ColorCurves>;
  106284. /**
  106285. * Custom callback helping to override the default shader used in the material.
  106286. */
  106287. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  106288. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106289. protected _worldViewProjectionMatrix: Matrix;
  106290. protected _globalAmbientColor: Color3;
  106291. protected _useLogarithmicDepth: boolean;
  106292. protected _rebuildInParallel: boolean;
  106293. /**
  106294. * Instantiates a new standard material.
  106295. * This is the default material used in Babylon. It is the best trade off between quality
  106296. * and performances.
  106297. * @see http://doc.babylonjs.com/babylon101/materials
  106298. * @param name Define the name of the material in the scene
  106299. * @param scene Define the scene the material belong to
  106300. */
  106301. constructor(name: string, scene: Scene);
  106302. /**
  106303. * Gets a boolean indicating that current material needs to register RTT
  106304. */
  106305. readonly hasRenderTargetTextures: boolean;
  106306. /**
  106307. * Gets the current class name of the material e.g. "StandardMaterial"
  106308. * Mainly use in serialization.
  106309. * @returns the class name
  106310. */
  106311. getClassName(): string;
  106312. /**
  106313. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106314. * You can try switching to logarithmic depth.
  106315. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106316. */
  106317. useLogarithmicDepth: boolean;
  106318. /**
  106319. * Specifies if the material will require alpha blending
  106320. * @returns a boolean specifying if alpha blending is needed
  106321. */
  106322. needAlphaBlending(): boolean;
  106323. /**
  106324. * Specifies if this material should be rendered in alpha test mode
  106325. * @returns a boolean specifying if an alpha test is needed.
  106326. */
  106327. needAlphaTesting(): boolean;
  106328. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106329. /**
  106330. * Get the texture used for alpha test purpose.
  106331. * @returns the diffuse texture in case of the standard material.
  106332. */
  106333. getAlphaTestTexture(): Nullable<BaseTexture>;
  106334. /**
  106335. * Get if the submesh is ready to be used and all its information available.
  106336. * Child classes can use it to update shaders
  106337. * @param mesh defines the mesh to check
  106338. * @param subMesh defines which submesh to check
  106339. * @param useInstances specifies that instances should be used
  106340. * @returns a boolean indicating that the submesh is ready or not
  106341. */
  106342. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106343. /**
  106344. * Builds the material UBO layouts.
  106345. * Used internally during the effect preparation.
  106346. */
  106347. buildUniformLayout(): void;
  106348. /**
  106349. * Unbinds the material from the mesh
  106350. */
  106351. unbind(): void;
  106352. /**
  106353. * Binds the submesh to this material by preparing the effect and shader to draw
  106354. * @param world defines the world transformation matrix
  106355. * @param mesh defines the mesh containing the submesh
  106356. * @param subMesh defines the submesh to bind the material to
  106357. */
  106358. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106359. /**
  106360. * Get the list of animatables in the material.
  106361. * @returns the list of animatables object used in the material
  106362. */
  106363. getAnimatables(): IAnimatable[];
  106364. /**
  106365. * Gets the active textures from the material
  106366. * @returns an array of textures
  106367. */
  106368. getActiveTextures(): BaseTexture[];
  106369. /**
  106370. * Specifies if the material uses a texture
  106371. * @param texture defines the texture to check against the material
  106372. * @returns a boolean specifying if the material uses the texture
  106373. */
  106374. hasTexture(texture: BaseTexture): boolean;
  106375. /**
  106376. * Disposes the material
  106377. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106378. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106379. */
  106380. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106381. /**
  106382. * Makes a duplicate of the material, and gives it a new name
  106383. * @param name defines the new name for the duplicated material
  106384. * @returns the cloned material
  106385. */
  106386. clone(name: string): StandardMaterial;
  106387. /**
  106388. * Serializes this material in a JSON representation
  106389. * @returns the serialized material object
  106390. */
  106391. serialize(): any;
  106392. /**
  106393. * Creates a standard material from parsed material data
  106394. * @param source defines the JSON representation of the material
  106395. * @param scene defines the hosting scene
  106396. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  106397. * @returns a new standard material
  106398. */
  106399. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  106400. /**
  106401. * Are diffuse textures enabled in the application.
  106402. */
  106403. static DiffuseTextureEnabled: boolean;
  106404. /**
  106405. * Are ambient textures enabled in the application.
  106406. */
  106407. static AmbientTextureEnabled: boolean;
  106408. /**
  106409. * Are opacity textures enabled in the application.
  106410. */
  106411. static OpacityTextureEnabled: boolean;
  106412. /**
  106413. * Are reflection textures enabled in the application.
  106414. */
  106415. static ReflectionTextureEnabled: boolean;
  106416. /**
  106417. * Are emissive textures enabled in the application.
  106418. */
  106419. static EmissiveTextureEnabled: boolean;
  106420. /**
  106421. * Are specular textures enabled in the application.
  106422. */
  106423. static SpecularTextureEnabled: boolean;
  106424. /**
  106425. * Are bump textures enabled in the application.
  106426. */
  106427. static BumpTextureEnabled: boolean;
  106428. /**
  106429. * Are lightmap textures enabled in the application.
  106430. */
  106431. static LightmapTextureEnabled: boolean;
  106432. /**
  106433. * Are refraction textures enabled in the application.
  106434. */
  106435. static RefractionTextureEnabled: boolean;
  106436. /**
  106437. * Are color grading textures enabled in the application.
  106438. */
  106439. static ColorGradingTextureEnabled: boolean;
  106440. /**
  106441. * Are fresnels enabled in the application.
  106442. */
  106443. static FresnelEnabled: boolean;
  106444. }
  106445. }
  106446. declare module BABYLON {
  106447. /** @hidden */
  106448. export var imageProcessingPixelShader: {
  106449. name: string;
  106450. shader: string;
  106451. };
  106452. }
  106453. declare module BABYLON {
  106454. /**
  106455. * ImageProcessingPostProcess
  106456. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  106457. */
  106458. export class ImageProcessingPostProcess extends PostProcess {
  106459. /**
  106460. * Default configuration related to image processing available in the PBR Material.
  106461. */
  106462. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106463. /**
  106464. * Gets the image processing configuration used either in this material.
  106465. */
  106466. /**
  106467. * Sets the Default image processing configuration used either in the this material.
  106468. *
  106469. * If sets to null, the scene one is in use.
  106470. */
  106471. imageProcessingConfiguration: ImageProcessingConfiguration;
  106472. /**
  106473. * Keep track of the image processing observer to allow dispose and replace.
  106474. */
  106475. private _imageProcessingObserver;
  106476. /**
  106477. * Attaches a new image processing configuration to the PBR Material.
  106478. * @param configuration
  106479. */
  106480. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  106481. /**
  106482. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106483. */
  106484. /**
  106485. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106486. */
  106487. colorCurves: Nullable<ColorCurves>;
  106488. /**
  106489. * Gets wether the color curves effect is enabled.
  106490. */
  106491. /**
  106492. * Sets wether the color curves effect is enabled.
  106493. */
  106494. colorCurvesEnabled: boolean;
  106495. /**
  106496. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106497. */
  106498. /**
  106499. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106500. */
  106501. colorGradingTexture: Nullable<BaseTexture>;
  106502. /**
  106503. * Gets wether the color grading effect is enabled.
  106504. */
  106505. /**
  106506. * Gets wether the color grading effect is enabled.
  106507. */
  106508. colorGradingEnabled: boolean;
  106509. /**
  106510. * Gets exposure used in the effect.
  106511. */
  106512. /**
  106513. * Sets exposure used in the effect.
  106514. */
  106515. exposure: number;
  106516. /**
  106517. * Gets wether tonemapping is enabled or not.
  106518. */
  106519. /**
  106520. * Sets wether tonemapping is enabled or not
  106521. */
  106522. toneMappingEnabled: boolean;
  106523. /**
  106524. * Gets the type of tone mapping effect.
  106525. */
  106526. /**
  106527. * Sets the type of tone mapping effect.
  106528. */
  106529. toneMappingType: number;
  106530. /**
  106531. * Gets contrast used in the effect.
  106532. */
  106533. /**
  106534. * Sets contrast used in the effect.
  106535. */
  106536. contrast: number;
  106537. /**
  106538. * Gets Vignette stretch size.
  106539. */
  106540. /**
  106541. * Sets Vignette stretch size.
  106542. */
  106543. vignetteStretch: number;
  106544. /**
  106545. * Gets Vignette centre X Offset.
  106546. */
  106547. /**
  106548. * Sets Vignette centre X Offset.
  106549. */
  106550. vignetteCentreX: number;
  106551. /**
  106552. * Gets Vignette centre Y Offset.
  106553. */
  106554. /**
  106555. * Sets Vignette centre Y Offset.
  106556. */
  106557. vignetteCentreY: number;
  106558. /**
  106559. * Gets Vignette weight or intensity of the vignette effect.
  106560. */
  106561. /**
  106562. * Sets Vignette weight or intensity of the vignette effect.
  106563. */
  106564. vignetteWeight: number;
  106565. /**
  106566. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106567. * if vignetteEnabled is set to true.
  106568. */
  106569. /**
  106570. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106571. * if vignetteEnabled is set to true.
  106572. */
  106573. vignetteColor: Color4;
  106574. /**
  106575. * Gets Camera field of view used by the Vignette effect.
  106576. */
  106577. /**
  106578. * Sets Camera field of view used by the Vignette effect.
  106579. */
  106580. vignetteCameraFov: number;
  106581. /**
  106582. * Gets the vignette blend mode allowing different kind of effect.
  106583. */
  106584. /**
  106585. * Sets the vignette blend mode allowing different kind of effect.
  106586. */
  106587. vignetteBlendMode: number;
  106588. /**
  106589. * Gets wether the vignette effect is enabled.
  106590. */
  106591. /**
  106592. * Sets wether the vignette effect is enabled.
  106593. */
  106594. vignetteEnabled: boolean;
  106595. private _fromLinearSpace;
  106596. /**
  106597. * Gets wether the input of the processing is in Gamma or Linear Space.
  106598. */
  106599. /**
  106600. * Sets wether the input of the processing is in Gamma or Linear Space.
  106601. */
  106602. fromLinearSpace: boolean;
  106603. /**
  106604. * Defines cache preventing GC.
  106605. */
  106606. private _defines;
  106607. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  106608. /**
  106609. * "ImageProcessingPostProcess"
  106610. * @returns "ImageProcessingPostProcess"
  106611. */
  106612. getClassName(): string;
  106613. protected _updateParameters(): void;
  106614. dispose(camera?: Camera): void;
  106615. }
  106616. }
  106617. declare module BABYLON {
  106618. /**
  106619. * Class containing static functions to help procedurally build meshes
  106620. */
  106621. export class GroundBuilder {
  106622. /**
  106623. * Creates a ground mesh
  106624. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106625. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106627. * @param name defines the name of the mesh
  106628. * @param options defines the options used to create the mesh
  106629. * @param scene defines the hosting scene
  106630. * @returns the ground mesh
  106631. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106632. */
  106633. static CreateGround(name: string, options: {
  106634. width?: number;
  106635. height?: number;
  106636. subdivisions?: number;
  106637. subdivisionsX?: number;
  106638. subdivisionsY?: number;
  106639. updatable?: boolean;
  106640. }, scene: any): Mesh;
  106641. /**
  106642. * Creates a tiled ground mesh
  106643. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106644. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106645. * * 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
  106646. * * 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
  106647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106648. * @param name defines the name of the mesh
  106649. * @param options defines the options used to create the mesh
  106650. * @param scene defines the hosting scene
  106651. * @returns the tiled ground mesh
  106652. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106653. */
  106654. static CreateTiledGround(name: string, options: {
  106655. xmin: number;
  106656. zmin: number;
  106657. xmax: number;
  106658. zmax: number;
  106659. subdivisions?: {
  106660. w: number;
  106661. h: number;
  106662. };
  106663. precision?: {
  106664. w: number;
  106665. h: number;
  106666. };
  106667. updatable?: boolean;
  106668. }, scene?: Nullable<Scene>): Mesh;
  106669. /**
  106670. * Creates a ground mesh from a height map
  106671. * * The parameter `url` sets the URL of the height map image resource.
  106672. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106673. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106674. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106675. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106676. * * 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.
  106677. * * 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).
  106678. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106680. * @param name defines the name of the mesh
  106681. * @param url defines the url to the height map
  106682. * @param options defines the options used to create the mesh
  106683. * @param scene defines the hosting scene
  106684. * @returns the ground mesh
  106685. * @see https://doc.babylonjs.com/babylon101/height_map
  106686. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106687. */
  106688. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106689. width?: number;
  106690. height?: number;
  106691. subdivisions?: number;
  106692. minHeight?: number;
  106693. maxHeight?: number;
  106694. colorFilter?: Color3;
  106695. alphaFilter?: number;
  106696. updatable?: boolean;
  106697. onReady?: (mesh: GroundMesh) => void;
  106698. }, scene?: Nullable<Scene>): GroundMesh;
  106699. }
  106700. }
  106701. declare module BABYLON {
  106702. /**
  106703. * Class containing static functions to help procedurally build meshes
  106704. */
  106705. export class TorusBuilder {
  106706. /**
  106707. * Creates a torus mesh
  106708. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106709. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106710. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106714. * @param name defines the name of the mesh
  106715. * @param options defines the options used to create the mesh
  106716. * @param scene defines the hosting scene
  106717. * @returns the torus mesh
  106718. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106719. */
  106720. static CreateTorus(name: string, options: {
  106721. diameter?: number;
  106722. thickness?: number;
  106723. tessellation?: number;
  106724. updatable?: boolean;
  106725. sideOrientation?: number;
  106726. frontUVs?: Vector4;
  106727. backUVs?: Vector4;
  106728. }, scene: any): Mesh;
  106729. }
  106730. }
  106731. declare module BABYLON {
  106732. /**
  106733. * Class containing static functions to help procedurally build meshes
  106734. */
  106735. export class CylinderBuilder {
  106736. /**
  106737. * Creates a cylinder or a cone mesh
  106738. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106739. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106740. * * 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.
  106741. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106742. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106743. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106744. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106745. * * 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).
  106746. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106747. * * 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).
  106748. * * 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
  106749. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106750. * * 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
  106751. * * 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.
  106752. * * If `enclose` is false, a ring surface is one element.
  106753. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106754. * * 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
  106755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106756. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106758. * @param name defines the name of the mesh
  106759. * @param options defines the options used to create the mesh
  106760. * @param scene defines the hosting scene
  106761. * @returns the cylinder mesh
  106762. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106763. */
  106764. static CreateCylinder(name: string, options: {
  106765. height?: number;
  106766. diameterTop?: number;
  106767. diameterBottom?: number;
  106768. diameter?: number;
  106769. tessellation?: number;
  106770. subdivisions?: number;
  106771. arc?: number;
  106772. faceColors?: Color4[];
  106773. faceUV?: Vector4[];
  106774. updatable?: boolean;
  106775. hasRings?: boolean;
  106776. enclose?: boolean;
  106777. cap?: number;
  106778. sideOrientation?: number;
  106779. frontUVs?: Vector4;
  106780. backUVs?: Vector4;
  106781. }, scene: any): Mesh;
  106782. }
  106783. }
  106784. declare module BABYLON {
  106785. /**
  106786. * Options to modify the vr teleportation behavior.
  106787. */
  106788. export interface VRTeleportationOptions {
  106789. /**
  106790. * The name of the mesh which should be used as the teleportation floor. (default: null)
  106791. */
  106792. floorMeshName?: string;
  106793. /**
  106794. * A list of meshes to be used as the teleportation floor. (default: empty)
  106795. */
  106796. floorMeshes?: Mesh[];
  106797. }
  106798. /**
  106799. * Options to modify the vr experience helper's behavior.
  106800. */
  106801. export interface VRExperienceHelperOptions extends WebVROptions {
  106802. /**
  106803. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  106804. */
  106805. createDeviceOrientationCamera?: boolean;
  106806. /**
  106807. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  106808. */
  106809. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  106810. /**
  106811. * Uses the main button on the controller to toggle the laser casted. (default: true)
  106812. */
  106813. laserToggle?: boolean;
  106814. /**
  106815. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  106816. */
  106817. floorMeshes?: Mesh[];
  106818. /**
  106819. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  106820. */
  106821. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  106822. }
  106823. /**
  106824. * Event containing information after VR has been entered
  106825. */
  106826. export class OnAfterEnteringVRObservableEvent {
  106827. /**
  106828. * If entering vr was successful
  106829. */
  106830. success: boolean;
  106831. }
  106832. /**
  106833. * Helps to quickly add VR support to an existing scene.
  106834. * See http://doc.babylonjs.com/how_to/webvr_helper
  106835. */
  106836. export class VRExperienceHelper {
  106837. /** Options to modify the vr experience helper's behavior. */
  106838. webVROptions: VRExperienceHelperOptions;
  106839. private _scene;
  106840. private _position;
  106841. private _btnVR;
  106842. private _btnVRDisplayed;
  106843. private _webVRsupported;
  106844. private _webVRready;
  106845. private _webVRrequesting;
  106846. private _webVRpresenting;
  106847. private _hasEnteredVR;
  106848. private _fullscreenVRpresenting;
  106849. private _canvas;
  106850. private _webVRCamera;
  106851. private _vrDeviceOrientationCamera;
  106852. private _deviceOrientationCamera;
  106853. private _existingCamera;
  106854. private _onKeyDown;
  106855. private _onVrDisplayPresentChange;
  106856. private _onVRDisplayChanged;
  106857. private _onVRRequestPresentStart;
  106858. private _onVRRequestPresentComplete;
  106859. /**
  106860. * 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)
  106861. */
  106862. enableGazeEvenWhenNoPointerLock: boolean;
  106863. /**
  106864. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  106865. */
  106866. exitVROnDoubleTap: boolean;
  106867. /**
  106868. * Observable raised right before entering VR.
  106869. */
  106870. onEnteringVRObservable: Observable<VRExperienceHelper>;
  106871. /**
  106872. * Observable raised when entering VR has completed.
  106873. */
  106874. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  106875. /**
  106876. * Observable raised when exiting VR.
  106877. */
  106878. onExitingVRObservable: Observable<VRExperienceHelper>;
  106879. /**
  106880. * Observable raised when controller mesh is loaded.
  106881. */
  106882. onControllerMeshLoadedObservable: Observable<WebVRController>;
  106883. /** Return this.onEnteringVRObservable
  106884. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  106885. */
  106886. readonly onEnteringVR: Observable<VRExperienceHelper>;
  106887. /** Return this.onExitingVRObservable
  106888. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  106889. */
  106890. readonly onExitingVR: Observable<VRExperienceHelper>;
  106891. /** Return this.onControllerMeshLoadedObservable
  106892. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  106893. */
  106894. readonly onControllerMeshLoaded: Observable<WebVRController>;
  106895. private _rayLength;
  106896. private _useCustomVRButton;
  106897. private _teleportationRequested;
  106898. private _teleportActive;
  106899. private _floorMeshName;
  106900. private _floorMeshesCollection;
  106901. private _rotationAllowed;
  106902. private _teleportBackwardsVector;
  106903. private _teleportationTarget;
  106904. private _isDefaultTeleportationTarget;
  106905. private _postProcessMove;
  106906. private _teleportationFillColor;
  106907. private _teleportationBorderColor;
  106908. private _rotationAngle;
  106909. private _haloCenter;
  106910. private _cameraGazer;
  106911. private _padSensibilityUp;
  106912. private _padSensibilityDown;
  106913. private _leftController;
  106914. private _rightController;
  106915. /**
  106916. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  106917. */
  106918. onNewMeshSelected: Observable<AbstractMesh>;
  106919. /**
  106920. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  106921. * This observable will provide the mesh and the controller used to select the mesh
  106922. */
  106923. onMeshSelectedWithController: Observable<{
  106924. mesh: AbstractMesh;
  106925. controller: WebVRController;
  106926. }>;
  106927. /**
  106928. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  106929. */
  106930. onNewMeshPicked: Observable<PickingInfo>;
  106931. private _circleEase;
  106932. /**
  106933. * Observable raised before camera teleportation
  106934. */
  106935. onBeforeCameraTeleport: Observable<Vector3>;
  106936. /**
  106937. * Observable raised after camera teleportation
  106938. */
  106939. onAfterCameraTeleport: Observable<Vector3>;
  106940. /**
  106941. * Observable raised when current selected mesh gets unselected
  106942. */
  106943. onSelectedMeshUnselected: Observable<AbstractMesh>;
  106944. private _raySelectionPredicate;
  106945. /**
  106946. * To be optionaly changed by user to define custom ray selection
  106947. */
  106948. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  106949. /**
  106950. * To be optionaly changed by user to define custom selection logic (after ray selection)
  106951. */
  106952. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106953. /**
  106954. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  106955. */
  106956. teleportationEnabled: boolean;
  106957. private _defaultHeight;
  106958. private _teleportationInitialized;
  106959. private _interactionsEnabled;
  106960. private _interactionsRequested;
  106961. private _displayGaze;
  106962. private _displayLaserPointer;
  106963. /**
  106964. * The mesh used to display where the user is going to teleport.
  106965. */
  106966. /**
  106967. * Sets the mesh to be used to display where the user is going to teleport.
  106968. */
  106969. teleportationTarget: Mesh;
  106970. /**
  106971. * 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
  106972. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  106973. * See http://doc.babylonjs.com/resources/baking_transformations
  106974. */
  106975. gazeTrackerMesh: Mesh;
  106976. /**
  106977. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  106978. */
  106979. updateGazeTrackerScale: boolean;
  106980. /**
  106981. * If the gaze trackers color should be updated when selecting meshes
  106982. */
  106983. updateGazeTrackerColor: boolean;
  106984. /**
  106985. * If the controller laser color should be updated when selecting meshes
  106986. */
  106987. updateControllerLaserColor: boolean;
  106988. /**
  106989. * The gaze tracking mesh corresponding to the left controller
  106990. */
  106991. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106992. /**
  106993. * The gaze tracking mesh corresponding to the right controller
  106994. */
  106995. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106996. /**
  106997. * If the ray of the gaze should be displayed.
  106998. */
  106999. /**
  107000. * Sets if the ray of the gaze should be displayed.
  107001. */
  107002. displayGaze: boolean;
  107003. /**
  107004. * If the ray of the LaserPointer should be displayed.
  107005. */
  107006. /**
  107007. * Sets if the ray of the LaserPointer should be displayed.
  107008. */
  107009. displayLaserPointer: boolean;
  107010. /**
  107011. * The deviceOrientationCamera used as the camera when not in VR.
  107012. */
  107013. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  107014. /**
  107015. * Based on the current WebVR support, returns the current VR camera used.
  107016. */
  107017. readonly currentVRCamera: Nullable<Camera>;
  107018. /**
  107019. * The webVRCamera which is used when in VR.
  107020. */
  107021. readonly webVRCamera: WebVRFreeCamera;
  107022. /**
  107023. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  107024. */
  107025. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  107026. /**
  107027. * The html button that is used to trigger entering into VR.
  107028. */
  107029. readonly vrButton: Nullable<HTMLButtonElement>;
  107030. private readonly _teleportationRequestInitiated;
  107031. /**
  107032. * Defines wether or not Pointer lock should be requested when switching to
  107033. * full screen.
  107034. */
  107035. requestPointerLockOnFullScreen: boolean;
  107036. /**
  107037. * Instantiates a VRExperienceHelper.
  107038. * Helps to quickly add VR support to an existing scene.
  107039. * @param scene The scene the VRExperienceHelper belongs to.
  107040. * @param webVROptions Options to modify the vr experience helper's behavior.
  107041. */
  107042. constructor(scene: Scene,
  107043. /** Options to modify the vr experience helper's behavior. */
  107044. webVROptions?: VRExperienceHelperOptions);
  107045. private _onDefaultMeshLoaded;
  107046. private _onResize;
  107047. private _onFullscreenChange;
  107048. /**
  107049. * Gets a value indicating if we are currently in VR mode.
  107050. */
  107051. readonly isInVRMode: boolean;
  107052. private onVrDisplayPresentChange;
  107053. private onVRDisplayChanged;
  107054. private moveButtonToBottomRight;
  107055. private displayVRButton;
  107056. private updateButtonVisibility;
  107057. private _cachedAngularSensibility;
  107058. /**
  107059. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  107060. * Otherwise, will use the fullscreen API.
  107061. */
  107062. enterVR(): void;
  107063. /**
  107064. * Attempt to exit VR, or fullscreen.
  107065. */
  107066. exitVR(): void;
  107067. /**
  107068. * The position of the vr experience helper.
  107069. */
  107070. /**
  107071. * Sets the position of the vr experience helper.
  107072. */
  107073. position: Vector3;
  107074. /**
  107075. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  107076. */
  107077. enableInteractions(): void;
  107078. private readonly _noControllerIsActive;
  107079. private beforeRender;
  107080. private _isTeleportationFloor;
  107081. /**
  107082. * Adds a floor mesh to be used for teleportation.
  107083. * @param floorMesh the mesh to be used for teleportation.
  107084. */
  107085. addFloorMesh(floorMesh: Mesh): void;
  107086. /**
  107087. * Removes a floor mesh from being used for teleportation.
  107088. * @param floorMesh the mesh to be removed.
  107089. */
  107090. removeFloorMesh(floorMesh: Mesh): void;
  107091. /**
  107092. * Enables interactions and teleportation using the VR controllers and gaze.
  107093. * @param vrTeleportationOptions options to modify teleportation behavior.
  107094. */
  107095. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  107096. private _onNewGamepadConnected;
  107097. private _tryEnableInteractionOnController;
  107098. private _onNewGamepadDisconnected;
  107099. private _enableInteractionOnController;
  107100. private _checkTeleportWithRay;
  107101. private _checkRotate;
  107102. private _checkTeleportBackwards;
  107103. private _enableTeleportationOnController;
  107104. private _createTeleportationCircles;
  107105. private _displayTeleportationTarget;
  107106. private _hideTeleportationTarget;
  107107. private _rotateCamera;
  107108. private _moveTeleportationSelectorTo;
  107109. private _workingVector;
  107110. private _workingQuaternion;
  107111. private _workingMatrix;
  107112. /**
  107113. * Teleports the users feet to the desired location
  107114. * @param location The location where the user's feet should be placed
  107115. */
  107116. teleportCamera(location: Vector3): void;
  107117. private _convertNormalToDirectionOfRay;
  107118. private _castRayAndSelectObject;
  107119. private _notifySelectedMeshUnselected;
  107120. /**
  107121. * Sets the color of the laser ray from the vr controllers.
  107122. * @param color new color for the ray.
  107123. */
  107124. changeLaserColor(color: Color3): void;
  107125. /**
  107126. * Sets the color of the ray from the vr headsets gaze.
  107127. * @param color new color for the ray.
  107128. */
  107129. changeGazeColor(color: Color3): void;
  107130. /**
  107131. * Exits VR and disposes of the vr experience helper
  107132. */
  107133. dispose(): void;
  107134. /**
  107135. * Gets the name of the VRExperienceHelper class
  107136. * @returns "VRExperienceHelper"
  107137. */
  107138. getClassName(): string;
  107139. }
  107140. }
  107141. declare module BABYLON {
  107142. /**
  107143. * Manages an XRSession to work with Babylon's engine
  107144. * @see https://doc.babylonjs.com/how_to/webxr
  107145. */
  107146. export class WebXRSessionManager implements IDisposable {
  107147. private scene;
  107148. /**
  107149. * Fires every time a new xrFrame arrives which can be used to update the camera
  107150. */
  107151. onXRFrameObservable: Observable<any>;
  107152. /**
  107153. * Fires when the xr session is ended either by the device or manually done
  107154. */
  107155. onXRSessionEnded: Observable<any>;
  107156. /**
  107157. * Underlying xr session
  107158. */
  107159. session: XRSession;
  107160. /**
  107161. * Type of reference space used when creating the session
  107162. */
  107163. referenceSpace: XRReferenceSpace;
  107164. /** @hidden */
  107165. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  107166. /**
  107167. * Current XR frame
  107168. */
  107169. currentFrame: Nullable<XRFrame>;
  107170. private _xrNavigator;
  107171. private baseLayer;
  107172. /**
  107173. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  107174. * @param scene The scene which the session should be created for
  107175. */
  107176. constructor(scene: Scene);
  107177. /**
  107178. * Initializes the manager
  107179. * After initialization enterXR can be called to start an XR session
  107180. * @returns Promise which resolves after it is initialized
  107181. */
  107182. initializeAsync(): Promise<void>;
  107183. /**
  107184. * Initializes an xr session
  107185. * @param xrSessionMode mode to initialize
  107186. * @returns a promise which will resolve once the session has been initialized
  107187. */
  107188. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  107189. /**
  107190. * Sets the reference space on the xr session
  107191. * @param referenceSpace space to set
  107192. * @returns a promise that will resolve once the reference space has been set
  107193. */
  107194. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  107195. /**
  107196. * Updates the render state of the session
  107197. * @param state state to set
  107198. * @returns a promise that resolves once the render state has been updated
  107199. */
  107200. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  107201. /**
  107202. * Starts rendering to the xr layer
  107203. * @returns a promise that will resolve once rendering has started
  107204. */
  107205. startRenderingToXRAsync(): Promise<void>;
  107206. /**
  107207. * Stops the xrSession and restores the renderloop
  107208. * @returns Promise which resolves after it exits XR
  107209. */
  107210. exitXRAsync(): Promise<unknown>;
  107211. /**
  107212. * Checks if a session would be supported for the creation options specified
  107213. * @param sessionMode session mode to check if supported eg. immersive-vr
  107214. * @returns true if supported
  107215. */
  107216. supportsSessionAsync(sessionMode: XRSessionMode): any;
  107217. /**
  107218. * @hidden
  107219. * Converts the render layer of xrSession to a render target
  107220. * @param session session to create render target for
  107221. * @param scene scene the new render target should be created for
  107222. */
  107223. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  107224. /**
  107225. * Disposes of the session manager
  107226. */
  107227. dispose(): void;
  107228. }
  107229. }
  107230. declare module BABYLON {
  107231. /**
  107232. * WebXR Camera which holds the views for the xrSession
  107233. * @see https://doc.babylonjs.com/how_to/webxr
  107234. */
  107235. export class WebXRCamera extends FreeCamera {
  107236. private static _TmpMatrix;
  107237. /**
  107238. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  107239. * @param name the name of the camera
  107240. * @param scene the scene to add the camera to
  107241. */
  107242. constructor(name: string, scene: Scene);
  107243. private _updateNumberOfRigCameras;
  107244. /** @hidden */
  107245. _updateForDualEyeDebugging(pupilDistance?: number): void;
  107246. /**
  107247. * Updates the cameras position from the current pose information of the XR session
  107248. * @param xrSessionManager the session containing pose information
  107249. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  107250. */
  107251. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  107252. }
  107253. }
  107254. declare module BABYLON {
  107255. /**
  107256. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  107257. */
  107258. export class WebXRManagedOutputCanvas implements IDisposable {
  107259. private helper;
  107260. private _canvas;
  107261. /**
  107262. * xrpresent context of the canvas which can be used to display/mirror xr content
  107263. */
  107264. canvasContext: WebGLRenderingContext;
  107265. /**
  107266. * xr layer for the canvas
  107267. */
  107268. xrLayer: Nullable<XRWebGLLayer>;
  107269. /**
  107270. * Initializes the xr layer for the session
  107271. * @param xrSession xr session
  107272. * @returns a promise that will resolve once the XR Layer has been created
  107273. */
  107274. initializeXRLayerAsync(xrSession: any): any;
  107275. /**
  107276. * Initializes the canvas to be added/removed upon entering/exiting xr
  107277. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  107278. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  107279. */
  107280. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  107281. /**
  107282. * Disposes of the object
  107283. */
  107284. dispose(): void;
  107285. private _setManagedOutputCanvas;
  107286. private _addCanvas;
  107287. private _removeCanvas;
  107288. }
  107289. }
  107290. declare module BABYLON {
  107291. /**
  107292. * States of the webXR experience
  107293. */
  107294. export enum WebXRState {
  107295. /**
  107296. * Transitioning to being in XR mode
  107297. */
  107298. ENTERING_XR = 0,
  107299. /**
  107300. * Transitioning to non XR mode
  107301. */
  107302. EXITING_XR = 1,
  107303. /**
  107304. * In XR mode and presenting
  107305. */
  107306. IN_XR = 2,
  107307. /**
  107308. * Not entered XR mode
  107309. */
  107310. NOT_IN_XR = 3
  107311. }
  107312. /**
  107313. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  107314. * @see https://doc.babylonjs.com/how_to/webxr
  107315. */
  107316. export class WebXRExperienceHelper implements IDisposable {
  107317. private scene;
  107318. /**
  107319. * 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
  107320. */
  107321. container: AbstractMesh;
  107322. /**
  107323. * Camera used to render xr content
  107324. */
  107325. camera: WebXRCamera;
  107326. /**
  107327. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  107328. */
  107329. state: WebXRState;
  107330. private _setState;
  107331. private static _TmpVector;
  107332. /**
  107333. * Fires when the state of the experience helper has changed
  107334. */
  107335. onStateChangedObservable: Observable<WebXRState>;
  107336. /** Session manager used to keep track of xr session */
  107337. sessionManager: WebXRSessionManager;
  107338. private _nonVRCamera;
  107339. private _originalSceneAutoClear;
  107340. private _supported;
  107341. /**
  107342. * Creates the experience helper
  107343. * @param scene the scene to attach the experience helper to
  107344. * @returns a promise for the experience helper
  107345. */
  107346. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  107347. /**
  107348. * Creates a WebXRExperienceHelper
  107349. * @param scene The scene the helper should be created in
  107350. */
  107351. private constructor();
  107352. /**
  107353. * Exits XR mode and returns the scene to its original state
  107354. * @returns promise that resolves after xr mode has exited
  107355. */
  107356. exitXRAsync(): Promise<unknown>;
  107357. /**
  107358. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  107359. * @param sessionCreationOptions options for the XR session
  107360. * @param referenceSpaceType frame of reference of the XR session
  107361. * @param outputCanvas the output canvas that will be used to enter XR mode
  107362. * @returns promise that resolves after xr mode has entered
  107363. */
  107364. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  107365. /**
  107366. * Updates the global position of the camera by moving the camera's container
  107367. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  107368. * @param position The desired global position of the camera
  107369. */
  107370. setPositionOfCameraUsingContainer(position: Vector3): void;
  107371. /**
  107372. * Rotates the xr camera by rotating the camera's container around the camera's position
  107373. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  107374. * @param rotation the desired quaternion rotation to apply to the camera
  107375. */
  107376. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  107377. /**
  107378. * Disposes of the experience helper
  107379. */
  107380. dispose(): void;
  107381. }
  107382. }
  107383. declare module BABYLON {
  107384. /**
  107385. * Button which can be used to enter a different mode of XR
  107386. */
  107387. export class WebXREnterExitUIButton {
  107388. /** button element */
  107389. element: HTMLElement;
  107390. /** XR initialization options for the button */
  107391. sessionMode: XRSessionMode;
  107392. /** Reference space type */
  107393. referenceSpaceType: XRReferenceSpaceType;
  107394. /**
  107395. * Creates a WebXREnterExitUIButton
  107396. * @param element button element
  107397. * @param sessionMode XR initialization session mode
  107398. * @param referenceSpaceType the type of reference space to be used
  107399. */
  107400. constructor(
  107401. /** button element */
  107402. element: HTMLElement,
  107403. /** XR initialization options for the button */
  107404. sessionMode: XRSessionMode,
  107405. /** Reference space type */
  107406. referenceSpaceType: XRReferenceSpaceType);
  107407. /**
  107408. * Overwritable function which can be used to update the button's visuals when the state changes
  107409. * @param activeButton the current active button in the UI
  107410. */
  107411. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  107412. }
  107413. /**
  107414. * Options to create the webXR UI
  107415. */
  107416. export class WebXREnterExitUIOptions {
  107417. /**
  107418. * Context to enter xr with
  107419. */
  107420. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  107421. /**
  107422. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  107423. */
  107424. customButtons?: Array<WebXREnterExitUIButton>;
  107425. }
  107426. /**
  107427. * UI to allow the user to enter/exit XR mode
  107428. */
  107429. export class WebXREnterExitUI implements IDisposable {
  107430. private scene;
  107431. private _overlay;
  107432. private _buttons;
  107433. private _activeButton;
  107434. /**
  107435. * Fired every time the active button is changed.
  107436. *
  107437. * When xr is entered via a button that launches xr that button will be the callback parameter
  107438. *
  107439. * When exiting xr the callback parameter will be null)
  107440. */
  107441. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  107442. /**
  107443. * Creates UI to allow the user to enter/exit XR mode
  107444. * @param scene the scene to add the ui to
  107445. * @param helper the xr experience helper to enter/exit xr with
  107446. * @param options options to configure the UI
  107447. * @returns the created ui
  107448. */
  107449. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  107450. private constructor();
  107451. private _updateButtons;
  107452. /**
  107453. * Disposes of the object
  107454. */
  107455. dispose(): void;
  107456. }
  107457. }
  107458. declare module BABYLON {
  107459. /**
  107460. * Represents an XR input
  107461. */
  107462. export class WebXRController {
  107463. private scene;
  107464. /** The underlying input source for the controller */
  107465. inputSource: XRInputSource;
  107466. private parentContainer;
  107467. /**
  107468. * 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
  107469. */
  107470. grip?: AbstractMesh;
  107471. /**
  107472. * Pointer which can be used to select objects or attach a visible laser to
  107473. */
  107474. pointer: AbstractMesh;
  107475. /**
  107476. * Event that fires when the controller is removed/disposed
  107477. */
  107478. onDisposeObservable: Observable<{}>;
  107479. private _tmpMatrix;
  107480. private _tmpQuaternion;
  107481. private _tmpVector;
  107482. /**
  107483. * Creates the controller
  107484. * @see https://doc.babylonjs.com/how_to/webxr
  107485. * @param scene the scene which the controller should be associated to
  107486. * @param inputSource the underlying input source for the controller
  107487. * @param parentContainer parent that the controller meshes should be children of
  107488. */
  107489. constructor(scene: Scene,
  107490. /** The underlying input source for the controller */
  107491. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  107492. /**
  107493. * Updates the controller pose based on the given XRFrame
  107494. * @param xrFrame xr frame to update the pose with
  107495. * @param referenceSpace reference space to use
  107496. */
  107497. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  107498. /**
  107499. * Gets a world space ray coming from the controller
  107500. * @param result the resulting ray
  107501. */
  107502. getWorldPointerRayToRef(result: Ray): void;
  107503. /**
  107504. * Disposes of the object
  107505. */
  107506. dispose(): void;
  107507. }
  107508. }
  107509. declare module BABYLON {
  107510. /**
  107511. * XR input used to track XR inputs such as controllers/rays
  107512. */
  107513. export class WebXRInput implements IDisposable {
  107514. /**
  107515. * Base experience the input listens to
  107516. */
  107517. baseExperience: WebXRExperienceHelper;
  107518. /**
  107519. * XR controllers being tracked
  107520. */
  107521. controllers: Array<WebXRController>;
  107522. private _frameObserver;
  107523. private _stateObserver;
  107524. /**
  107525. * Event when a controller has been connected/added
  107526. */
  107527. onControllerAddedObservable: Observable<WebXRController>;
  107528. /**
  107529. * Event when a controller has been removed/disconnected
  107530. */
  107531. onControllerRemovedObservable: Observable<WebXRController>;
  107532. /**
  107533. * Initializes the WebXRInput
  107534. * @param baseExperience experience helper which the input should be created for
  107535. */
  107536. constructor(
  107537. /**
  107538. * Base experience the input listens to
  107539. */
  107540. baseExperience: WebXRExperienceHelper);
  107541. private _onInputSourcesChange;
  107542. private _addAndRemoveControllers;
  107543. /**
  107544. * Disposes of the object
  107545. */
  107546. dispose(): void;
  107547. }
  107548. }
  107549. declare module BABYLON {
  107550. /**
  107551. * Enables teleportation
  107552. */
  107553. export class WebXRControllerTeleportation {
  107554. private _teleportationFillColor;
  107555. private _teleportationBorderColor;
  107556. private _tmpRay;
  107557. private _tmpVector;
  107558. /**
  107559. * Creates a WebXRControllerTeleportation
  107560. * @param input input manager to add teleportation to
  107561. * @param floorMeshes floormeshes which can be teleported to
  107562. */
  107563. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  107564. }
  107565. }
  107566. declare module BABYLON {
  107567. /**
  107568. * Handles pointer input automatically for the pointer of XR controllers
  107569. */
  107570. export class WebXRControllerPointerSelection {
  107571. private static _idCounter;
  107572. private _tmpRay;
  107573. /**
  107574. * Creates a WebXRControllerPointerSelection
  107575. * @param input input manager to setup pointer selection
  107576. */
  107577. constructor(input: WebXRInput);
  107578. private _convertNormalToDirectionOfRay;
  107579. private _updatePointerDistance;
  107580. }
  107581. }
  107582. declare module BABYLON {
  107583. /**
  107584. * Class used to represent data loading progression
  107585. */
  107586. export class SceneLoaderProgressEvent {
  107587. /** defines if data length to load can be evaluated */
  107588. readonly lengthComputable: boolean;
  107589. /** defines the loaded data length */
  107590. readonly loaded: number;
  107591. /** defines the data length to load */
  107592. readonly total: number;
  107593. /**
  107594. * Create a new progress event
  107595. * @param lengthComputable defines if data length to load can be evaluated
  107596. * @param loaded defines the loaded data length
  107597. * @param total defines the data length to load
  107598. */
  107599. constructor(
  107600. /** defines if data length to load can be evaluated */
  107601. lengthComputable: boolean,
  107602. /** defines the loaded data length */
  107603. loaded: number,
  107604. /** defines the data length to load */
  107605. total: number);
  107606. /**
  107607. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  107608. * @param event defines the source event
  107609. * @returns a new SceneLoaderProgressEvent
  107610. */
  107611. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  107612. }
  107613. /**
  107614. * Interface used by SceneLoader plugins to define supported file extensions
  107615. */
  107616. export interface ISceneLoaderPluginExtensions {
  107617. /**
  107618. * Defines the list of supported extensions
  107619. */
  107620. [extension: string]: {
  107621. isBinary: boolean;
  107622. };
  107623. }
  107624. /**
  107625. * Interface used by SceneLoader plugin factory
  107626. */
  107627. export interface ISceneLoaderPluginFactory {
  107628. /**
  107629. * Defines the name of the factory
  107630. */
  107631. name: string;
  107632. /**
  107633. * Function called to create a new plugin
  107634. * @return the new plugin
  107635. */
  107636. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  107637. /**
  107638. * Boolean indicating if the plugin can direct load specific data
  107639. */
  107640. canDirectLoad?: (data: string) => boolean;
  107641. }
  107642. /**
  107643. * Interface used to define a SceneLoader plugin
  107644. */
  107645. export interface ISceneLoaderPlugin {
  107646. /**
  107647. * The friendly name of this plugin.
  107648. */
  107649. name: string;
  107650. /**
  107651. * The file extensions supported by this plugin.
  107652. */
  107653. extensions: string | ISceneLoaderPluginExtensions;
  107654. /**
  107655. * Import meshes into a scene.
  107656. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107657. * @param scene The scene to import into
  107658. * @param data The data to import
  107659. * @param rootUrl The root url for scene and resources
  107660. * @param meshes The meshes array to import into
  107661. * @param particleSystems The particle systems array to import into
  107662. * @param skeletons The skeletons array to import into
  107663. * @param onError The callback when import fails
  107664. * @returns True if successful or false otherwise
  107665. */
  107666. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  107667. /**
  107668. * Load into a scene.
  107669. * @param scene The scene to load into
  107670. * @param data The data to import
  107671. * @param rootUrl The root url for scene and resources
  107672. * @param onError The callback when import fails
  107673. * @returns true if successful or false otherwise
  107674. */
  107675. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  107676. /**
  107677. * The callback that returns true if the data can be directly loaded.
  107678. */
  107679. canDirectLoad?: (data: string) => boolean;
  107680. /**
  107681. * The callback that allows custom handling of the root url based on the response url.
  107682. */
  107683. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107684. /**
  107685. * Load into an asset container.
  107686. * @param scene The scene to load into
  107687. * @param data The data to import
  107688. * @param rootUrl The root url for scene and resources
  107689. * @param onError The callback when import fails
  107690. * @returns The loaded asset container
  107691. */
  107692. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  107693. }
  107694. /**
  107695. * Interface used to define an async SceneLoader plugin
  107696. */
  107697. export interface ISceneLoaderPluginAsync {
  107698. /**
  107699. * The friendly name of this plugin.
  107700. */
  107701. name: string;
  107702. /**
  107703. * The file extensions supported by this plugin.
  107704. */
  107705. extensions: string | ISceneLoaderPluginExtensions;
  107706. /**
  107707. * Import meshes into a scene.
  107708. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107709. * @param scene The scene to import into
  107710. * @param data The data to import
  107711. * @param rootUrl The root url for scene and resources
  107712. * @param onProgress The callback when the load progresses
  107713. * @param fileName Defines the name of the file to load
  107714. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  107715. */
  107716. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  107717. meshes: AbstractMesh[];
  107718. particleSystems: IParticleSystem[];
  107719. skeletons: Skeleton[];
  107720. animationGroups: AnimationGroup[];
  107721. }>;
  107722. /**
  107723. * Load into a scene.
  107724. * @param scene The scene to load into
  107725. * @param data The data to import
  107726. * @param rootUrl The root url for scene and resources
  107727. * @param onProgress The callback when the load progresses
  107728. * @param fileName Defines the name of the file to load
  107729. * @returns Nothing
  107730. */
  107731. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  107732. /**
  107733. * The callback that returns true if the data can be directly loaded.
  107734. */
  107735. canDirectLoad?: (data: string) => boolean;
  107736. /**
  107737. * The callback that allows custom handling of the root url based on the response url.
  107738. */
  107739. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107740. /**
  107741. * Load into an asset container.
  107742. * @param scene The scene to load into
  107743. * @param data The data to import
  107744. * @param rootUrl The root url for scene and resources
  107745. * @param onProgress The callback when the load progresses
  107746. * @param fileName Defines the name of the file to load
  107747. * @returns The loaded asset container
  107748. */
  107749. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  107750. }
  107751. /**
  107752. * Class used to load scene from various file formats using registered plugins
  107753. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  107754. */
  107755. export class SceneLoader {
  107756. /**
  107757. * No logging while loading
  107758. */
  107759. static readonly NO_LOGGING: number;
  107760. /**
  107761. * Minimal logging while loading
  107762. */
  107763. static readonly MINIMAL_LOGGING: number;
  107764. /**
  107765. * Summary logging while loading
  107766. */
  107767. static readonly SUMMARY_LOGGING: number;
  107768. /**
  107769. * Detailled logging while loading
  107770. */
  107771. static readonly DETAILED_LOGGING: number;
  107772. /**
  107773. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  107774. */
  107775. static ForceFullSceneLoadingForIncremental: boolean;
  107776. /**
  107777. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  107778. */
  107779. static ShowLoadingScreen: boolean;
  107780. /**
  107781. * Defines the current logging level (while loading the scene)
  107782. * @ignorenaming
  107783. */
  107784. static loggingLevel: number;
  107785. /**
  107786. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  107787. */
  107788. static CleanBoneMatrixWeights: boolean;
  107789. /**
  107790. * Event raised when a plugin is used to load a scene
  107791. */
  107792. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  107793. private static _registeredPlugins;
  107794. private static _getDefaultPlugin;
  107795. private static _getPluginForExtension;
  107796. private static _getPluginForDirectLoad;
  107797. private static _getPluginForFilename;
  107798. private static _getDirectLoad;
  107799. private static _loadData;
  107800. private static _getFileInfo;
  107801. /**
  107802. * Gets a plugin that can load the given extension
  107803. * @param extension defines the extension to load
  107804. * @returns a plugin or null if none works
  107805. */
  107806. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  107807. /**
  107808. * Gets a boolean indicating that the given extension can be loaded
  107809. * @param extension defines the extension to load
  107810. * @returns true if the extension is supported
  107811. */
  107812. static IsPluginForExtensionAvailable(extension: string): boolean;
  107813. /**
  107814. * Adds a new plugin to the list of registered plugins
  107815. * @param plugin defines the plugin to add
  107816. */
  107817. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  107818. /**
  107819. * Import meshes into a scene
  107820. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107821. * @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)
  107822. * @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)
  107823. * @param scene the instance of BABYLON.Scene to append to
  107824. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  107825. * @param onProgress a callback with a progress event for each file being loaded
  107826. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107827. * @param pluginExtension the extension used to determine the plugin
  107828. * @returns The loaded plugin
  107829. */
  107830. 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>;
  107831. /**
  107832. * Import meshes into a scene
  107833. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107834. * @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)
  107835. * @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)
  107836. * @param scene the instance of BABYLON.Scene to append to
  107837. * @param onProgress a callback with a progress event for each file being loaded
  107838. * @param pluginExtension the extension used to determine the plugin
  107839. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  107840. */
  107841. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  107842. meshes: AbstractMesh[];
  107843. particleSystems: IParticleSystem[];
  107844. skeletons: Skeleton[];
  107845. animationGroups: AnimationGroup[];
  107846. }>;
  107847. /**
  107848. * Load a scene
  107849. * @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)
  107850. * @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)
  107851. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107852. * @param onSuccess a callback with the scene when import succeeds
  107853. * @param onProgress a callback with a progress event for each file being loaded
  107854. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107855. * @param pluginExtension the extension used to determine the plugin
  107856. * @returns The loaded plugin
  107857. */
  107858. 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>;
  107859. /**
  107860. * Load a scene
  107861. * @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)
  107862. * @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)
  107863. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107864. * @param onProgress a callback with a progress event for each file being loaded
  107865. * @param pluginExtension the extension used to determine the plugin
  107866. * @returns The loaded scene
  107867. */
  107868. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107869. /**
  107870. * Append a scene
  107871. * @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)
  107872. * @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)
  107873. * @param scene is the instance of BABYLON.Scene to append to
  107874. * @param onSuccess a callback with the scene when import succeeds
  107875. * @param onProgress a callback with a progress event for each file being loaded
  107876. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107877. * @param pluginExtension the extension used to determine the plugin
  107878. * @returns The loaded plugin
  107879. */
  107880. 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>;
  107881. /**
  107882. * Append a scene
  107883. * @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)
  107884. * @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)
  107885. * @param scene is the instance of BABYLON.Scene to append to
  107886. * @param onProgress a callback with a progress event for each file being loaded
  107887. * @param pluginExtension the extension used to determine the plugin
  107888. * @returns The given scene
  107889. */
  107890. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107891. /**
  107892. * Load a scene into an asset container
  107893. * @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)
  107894. * @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)
  107895. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107896. * @param onSuccess a callback with the scene when import succeeds
  107897. * @param onProgress a callback with a progress event for each file being loaded
  107898. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107899. * @param pluginExtension the extension used to determine the plugin
  107900. * @returns The loaded plugin
  107901. */
  107902. 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>;
  107903. /**
  107904. * Load a scene into an asset container
  107905. * @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)
  107906. * @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)
  107907. * @param scene is the instance of Scene to append to
  107908. * @param onProgress a callback with a progress event for each file being loaded
  107909. * @param pluginExtension the extension used to determine the plugin
  107910. * @returns The loaded asset container
  107911. */
  107912. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  107913. }
  107914. }
  107915. declare module BABYLON {
  107916. /**
  107917. * Generic Controller
  107918. */
  107919. export class GenericController extends WebVRController {
  107920. /**
  107921. * Base Url for the controller model.
  107922. */
  107923. static readonly MODEL_BASE_URL: string;
  107924. /**
  107925. * File name for the controller model.
  107926. */
  107927. static readonly MODEL_FILENAME: string;
  107928. /**
  107929. * Creates a new GenericController from a gamepad
  107930. * @param vrGamepad the gamepad that the controller should be created from
  107931. */
  107932. constructor(vrGamepad: any);
  107933. /**
  107934. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107935. * @param scene scene in which to add meshes
  107936. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107937. */
  107938. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107939. /**
  107940. * Called once for each button that changed state since the last frame
  107941. * @param buttonIdx Which button index changed
  107942. * @param state New state of the button
  107943. * @param changes Which properties on the state changed since last frame
  107944. */
  107945. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107946. }
  107947. }
  107948. declare module BABYLON {
  107949. /**
  107950. * Defines the WindowsMotionController object that the state of the windows motion controller
  107951. */
  107952. export class WindowsMotionController extends WebVRController {
  107953. /**
  107954. * The base url used to load the left and right controller models
  107955. */
  107956. static MODEL_BASE_URL: string;
  107957. /**
  107958. * The name of the left controller model file
  107959. */
  107960. static MODEL_LEFT_FILENAME: string;
  107961. /**
  107962. * The name of the right controller model file
  107963. */
  107964. static MODEL_RIGHT_FILENAME: string;
  107965. /**
  107966. * The controller name prefix for this controller type
  107967. */
  107968. static readonly GAMEPAD_ID_PREFIX: string;
  107969. /**
  107970. * The controller id pattern for this controller type
  107971. */
  107972. private static readonly GAMEPAD_ID_PATTERN;
  107973. private _loadedMeshInfo;
  107974. private readonly _mapping;
  107975. /**
  107976. * Fired when the trackpad on this controller is clicked
  107977. */
  107978. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  107979. /**
  107980. * Fired when the trackpad on this controller is modified
  107981. */
  107982. onTrackpadValuesChangedObservable: Observable<StickValues>;
  107983. /**
  107984. * The current x and y values of this controller's trackpad
  107985. */
  107986. trackpad: StickValues;
  107987. /**
  107988. * Creates a new WindowsMotionController from a gamepad
  107989. * @param vrGamepad the gamepad that the controller should be created from
  107990. */
  107991. constructor(vrGamepad: any);
  107992. /**
  107993. * Fired when the trigger on this controller is modified
  107994. */
  107995. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107996. /**
  107997. * Fired when the menu button on this controller is modified
  107998. */
  107999. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108000. /**
  108001. * Fired when the grip button on this controller is modified
  108002. */
  108003. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108004. /**
  108005. * Fired when the thumbstick button on this controller is modified
  108006. */
  108007. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108008. /**
  108009. * Fired when the touchpad button on this controller is modified
  108010. */
  108011. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108012. /**
  108013. * Fired when the touchpad values on this controller are modified
  108014. */
  108015. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  108016. private _updateTrackpad;
  108017. /**
  108018. * Called once per frame by the engine.
  108019. */
  108020. update(): void;
  108021. /**
  108022. * Called once for each button that changed state since the last frame
  108023. * @param buttonIdx Which button index changed
  108024. * @param state New state of the button
  108025. * @param changes Which properties on the state changed since last frame
  108026. */
  108027. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108028. /**
  108029. * Moves the buttons on the controller mesh based on their current state
  108030. * @param buttonName the name of the button to move
  108031. * @param buttonValue the value of the button which determines the buttons new position
  108032. */
  108033. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  108034. /**
  108035. * Moves the axis on the controller mesh based on its current state
  108036. * @param axis the index of the axis
  108037. * @param axisValue the value of the axis which determines the meshes new position
  108038. * @hidden
  108039. */
  108040. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  108041. /**
  108042. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108043. * @param scene scene in which to add meshes
  108044. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108045. */
  108046. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  108047. /**
  108048. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  108049. * can be transformed by button presses and axes values, based on this._mapping.
  108050. *
  108051. * @param scene scene in which the meshes exist
  108052. * @param meshes list of meshes that make up the controller model to process
  108053. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  108054. */
  108055. private processModel;
  108056. private createMeshInfo;
  108057. /**
  108058. * Gets the ray of the controller in the direction the controller is pointing
  108059. * @param length the length the resulting ray should be
  108060. * @returns a ray in the direction the controller is pointing
  108061. */
  108062. getForwardRay(length?: number): Ray;
  108063. /**
  108064. * Disposes of the controller
  108065. */
  108066. dispose(): void;
  108067. }
  108068. }
  108069. declare module BABYLON {
  108070. /**
  108071. * Oculus Touch Controller
  108072. */
  108073. export class OculusTouchController extends WebVRController {
  108074. /**
  108075. * Base Url for the controller model.
  108076. */
  108077. static MODEL_BASE_URL: string;
  108078. /**
  108079. * File name for the left controller model.
  108080. */
  108081. static MODEL_LEFT_FILENAME: string;
  108082. /**
  108083. * File name for the right controller model.
  108084. */
  108085. static MODEL_RIGHT_FILENAME: string;
  108086. /**
  108087. * Base Url for the Quest controller model.
  108088. */
  108089. static QUEST_MODEL_BASE_URL: string;
  108090. /**
  108091. * @hidden
  108092. * If the controllers are running on a device that needs the updated Quest controller models
  108093. */
  108094. static _IsQuest: boolean;
  108095. /**
  108096. * Fired when the secondary trigger on this controller is modified
  108097. */
  108098. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  108099. /**
  108100. * Fired when the thumb rest on this controller is modified
  108101. */
  108102. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  108103. /**
  108104. * Creates a new OculusTouchController from a gamepad
  108105. * @param vrGamepad the gamepad that the controller should be created from
  108106. */
  108107. constructor(vrGamepad: any);
  108108. /**
  108109. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108110. * @param scene scene in which to add meshes
  108111. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108112. */
  108113. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108114. /**
  108115. * Fired when the A button on this controller is modified
  108116. */
  108117. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108118. /**
  108119. * Fired when the B button on this controller is modified
  108120. */
  108121. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108122. /**
  108123. * Fired when the X button on this controller is modified
  108124. */
  108125. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108126. /**
  108127. * Fired when the Y button on this controller is modified
  108128. */
  108129. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108130. /**
  108131. * Called once for each button that changed state since the last frame
  108132. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  108133. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  108134. * 2) secondary trigger (same)
  108135. * 3) A (right) X (left), touch, pressed = value
  108136. * 4) B / Y
  108137. * 5) thumb rest
  108138. * @param buttonIdx Which button index changed
  108139. * @param state New state of the button
  108140. * @param changes Which properties on the state changed since last frame
  108141. */
  108142. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108143. }
  108144. }
  108145. declare module BABYLON {
  108146. /**
  108147. * Vive Controller
  108148. */
  108149. export class ViveController extends WebVRController {
  108150. /**
  108151. * Base Url for the controller model.
  108152. */
  108153. static MODEL_BASE_URL: string;
  108154. /**
  108155. * File name for the controller model.
  108156. */
  108157. static MODEL_FILENAME: string;
  108158. /**
  108159. * Creates a new ViveController from a gamepad
  108160. * @param vrGamepad the gamepad that the controller should be created from
  108161. */
  108162. constructor(vrGamepad: any);
  108163. /**
  108164. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108165. * @param scene scene in which to add meshes
  108166. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108167. */
  108168. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108169. /**
  108170. * Fired when the left button on this controller is modified
  108171. */
  108172. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108173. /**
  108174. * Fired when the right button on this controller is modified
  108175. */
  108176. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108177. /**
  108178. * Fired when the menu button on this controller is modified
  108179. */
  108180. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108181. /**
  108182. * Called once for each button that changed state since the last frame
  108183. * Vive mapping:
  108184. * 0: touchpad
  108185. * 1: trigger
  108186. * 2: left AND right buttons
  108187. * 3: menu button
  108188. * @param buttonIdx Which button index changed
  108189. * @param state New state of the button
  108190. * @param changes Which properties on the state changed since last frame
  108191. */
  108192. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108193. }
  108194. }
  108195. declare module BABYLON {
  108196. /**
  108197. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  108198. */
  108199. export class WebXRControllerModelLoader {
  108200. /**
  108201. * Creates the WebXRControllerModelLoader
  108202. * @param input xr input that creates the controllers
  108203. */
  108204. constructor(input: WebXRInput);
  108205. }
  108206. }
  108207. declare module BABYLON {
  108208. /**
  108209. * Contains an array of blocks representing the octree
  108210. */
  108211. export interface IOctreeContainer<T> {
  108212. /**
  108213. * Blocks within the octree
  108214. */
  108215. blocks: Array<OctreeBlock<T>>;
  108216. }
  108217. /**
  108218. * Class used to store a cell in an octree
  108219. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108220. */
  108221. export class OctreeBlock<T> {
  108222. /**
  108223. * Gets the content of the current block
  108224. */
  108225. entries: T[];
  108226. /**
  108227. * Gets the list of block children
  108228. */
  108229. blocks: Array<OctreeBlock<T>>;
  108230. private _depth;
  108231. private _maxDepth;
  108232. private _capacity;
  108233. private _minPoint;
  108234. private _maxPoint;
  108235. private _boundingVectors;
  108236. private _creationFunc;
  108237. /**
  108238. * Creates a new block
  108239. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  108240. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  108241. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108242. * @param depth defines the current depth of this block in the octree
  108243. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  108244. * @param creationFunc defines a callback to call when an element is added to the block
  108245. */
  108246. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  108247. /**
  108248. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108249. */
  108250. readonly capacity: number;
  108251. /**
  108252. * Gets the minimum vector (in world space) of the block's bounding box
  108253. */
  108254. readonly minPoint: Vector3;
  108255. /**
  108256. * Gets the maximum vector (in world space) of the block's bounding box
  108257. */
  108258. readonly maxPoint: Vector3;
  108259. /**
  108260. * Add a new element to this block
  108261. * @param entry defines the element to add
  108262. */
  108263. addEntry(entry: T): void;
  108264. /**
  108265. * Remove an element from this block
  108266. * @param entry defines the element to remove
  108267. */
  108268. removeEntry(entry: T): void;
  108269. /**
  108270. * Add an array of elements to this block
  108271. * @param entries defines the array of elements to add
  108272. */
  108273. addEntries(entries: T[]): void;
  108274. /**
  108275. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  108276. * @param frustumPlanes defines the frustum planes to test
  108277. * @param selection defines the array to store current content if selection is positive
  108278. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108279. */
  108280. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108281. /**
  108282. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  108283. * @param sphereCenter defines the bounding sphere center
  108284. * @param sphereRadius defines the bounding sphere radius
  108285. * @param selection defines the array to store current content if selection is positive
  108286. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108287. */
  108288. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108289. /**
  108290. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  108291. * @param ray defines the ray to test with
  108292. * @param selection defines the array to store current content if selection is positive
  108293. */
  108294. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  108295. /**
  108296. * Subdivide the content into child blocks (this block will then be empty)
  108297. */
  108298. createInnerBlocks(): void;
  108299. /**
  108300. * @hidden
  108301. */
  108302. 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;
  108303. }
  108304. }
  108305. declare module BABYLON {
  108306. /**
  108307. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  108308. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108309. */
  108310. export class Octree<T> {
  108311. /** 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.) */
  108312. maxDepth: number;
  108313. /**
  108314. * Blocks within the octree containing objects
  108315. */
  108316. blocks: Array<OctreeBlock<T>>;
  108317. /**
  108318. * Content stored in the octree
  108319. */
  108320. dynamicContent: T[];
  108321. private _maxBlockCapacity;
  108322. private _selectionContent;
  108323. private _creationFunc;
  108324. /**
  108325. * Creates a octree
  108326. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108327. * @param creationFunc function to be used to instatiate the octree
  108328. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  108329. * @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.)
  108330. */
  108331. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  108332. /** 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.) */
  108333. maxDepth?: number);
  108334. /**
  108335. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  108336. * @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);
  108337. * @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);
  108338. * @param entries meshes to be added to the octree blocks
  108339. */
  108340. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  108341. /**
  108342. * Adds a mesh to the octree
  108343. * @param entry Mesh to add to the octree
  108344. */
  108345. addMesh(entry: T): void;
  108346. /**
  108347. * Remove an element from the octree
  108348. * @param entry defines the element to remove
  108349. */
  108350. removeMesh(entry: T): void;
  108351. /**
  108352. * Selects an array of meshes within the frustum
  108353. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  108354. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  108355. * @returns array of meshes within the frustum
  108356. */
  108357. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  108358. /**
  108359. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  108360. * @param sphereCenter defines the bounding sphere center
  108361. * @param sphereRadius defines the bounding sphere radius
  108362. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108363. * @returns an array of objects that intersect the sphere
  108364. */
  108365. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  108366. /**
  108367. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  108368. * @param ray defines the ray to test with
  108369. * @returns array of intersected objects
  108370. */
  108371. intersectsRay(ray: Ray): SmartArray<T>;
  108372. /**
  108373. * Adds a mesh into the octree block if it intersects the block
  108374. */
  108375. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  108376. /**
  108377. * Adds a submesh into the octree block if it intersects the block
  108378. */
  108379. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  108380. }
  108381. }
  108382. declare module BABYLON {
  108383. interface Scene {
  108384. /**
  108385. * @hidden
  108386. * Backing Filed
  108387. */
  108388. _selectionOctree: Octree<AbstractMesh>;
  108389. /**
  108390. * Gets the octree used to boost mesh selection (picking)
  108391. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108392. */
  108393. selectionOctree: Octree<AbstractMesh>;
  108394. /**
  108395. * Creates or updates the octree used to boost selection (picking)
  108396. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108397. * @param maxCapacity defines the maximum capacity per leaf
  108398. * @param maxDepth defines the maximum depth of the octree
  108399. * @returns an octree of AbstractMesh
  108400. */
  108401. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  108402. }
  108403. interface AbstractMesh {
  108404. /**
  108405. * @hidden
  108406. * Backing Field
  108407. */
  108408. _submeshesOctree: Octree<SubMesh>;
  108409. /**
  108410. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  108411. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  108412. * @param maxCapacity defines the maximum size of each block (64 by default)
  108413. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  108414. * @returns the new octree
  108415. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  108416. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108417. */
  108418. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  108419. }
  108420. /**
  108421. * Defines the octree scene component responsible to manage any octrees
  108422. * in a given scene.
  108423. */
  108424. export class OctreeSceneComponent {
  108425. /**
  108426. * The component name help to identify the component in the list of scene components.
  108427. */
  108428. readonly name: string;
  108429. /**
  108430. * The scene the component belongs to.
  108431. */
  108432. scene: Scene;
  108433. /**
  108434. * Indicates if the meshes have been checked to make sure they are isEnabled()
  108435. */
  108436. readonly checksIsEnabled: boolean;
  108437. /**
  108438. * Creates a new instance of the component for the given scene
  108439. * @param scene Defines the scene to register the component in
  108440. */
  108441. constructor(scene: Scene);
  108442. /**
  108443. * Registers the component in a given scene
  108444. */
  108445. register(): void;
  108446. /**
  108447. * Return the list of active meshes
  108448. * @returns the list of active meshes
  108449. */
  108450. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108451. /**
  108452. * Return the list of active sub meshes
  108453. * @param mesh The mesh to get the candidates sub meshes from
  108454. * @returns the list of active sub meshes
  108455. */
  108456. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108457. private _tempRay;
  108458. /**
  108459. * Return the list of sub meshes intersecting with a given local ray
  108460. * @param mesh defines the mesh to find the submesh for
  108461. * @param localRay defines the ray in local space
  108462. * @returns the list of intersecting sub meshes
  108463. */
  108464. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  108465. /**
  108466. * Return the list of sub meshes colliding with a collider
  108467. * @param mesh defines the mesh to find the submesh for
  108468. * @param collider defines the collider to evaluate the collision against
  108469. * @returns the list of colliding sub meshes
  108470. */
  108471. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  108472. /**
  108473. * Rebuilds the elements related to this component in case of
  108474. * context lost for instance.
  108475. */
  108476. rebuild(): void;
  108477. /**
  108478. * Disposes the component and the associated ressources.
  108479. */
  108480. dispose(): void;
  108481. }
  108482. }
  108483. declare module BABYLON {
  108484. /**
  108485. * Renders a layer on top of an existing scene
  108486. */
  108487. export class UtilityLayerRenderer implements IDisposable {
  108488. /** the original scene that will be rendered on top of */
  108489. originalScene: Scene;
  108490. private _pointerCaptures;
  108491. private _lastPointerEvents;
  108492. private static _DefaultUtilityLayer;
  108493. private static _DefaultKeepDepthUtilityLayer;
  108494. private _sharedGizmoLight;
  108495. private _renderCamera;
  108496. /**
  108497. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  108498. * @returns the camera that is used when rendering the utility layer
  108499. */
  108500. getRenderCamera(): Nullable<Camera>;
  108501. /**
  108502. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  108503. * @param cam the camera that should be used when rendering the utility layer
  108504. */
  108505. setRenderCamera(cam: Nullable<Camera>): void;
  108506. /**
  108507. * @hidden
  108508. * Light which used by gizmos to get light shading
  108509. */
  108510. _getSharedGizmoLight(): HemisphericLight;
  108511. /**
  108512. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  108513. */
  108514. pickUtilitySceneFirst: boolean;
  108515. /**
  108516. * 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)
  108517. */
  108518. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  108519. /**
  108520. * 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)
  108521. */
  108522. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  108523. /**
  108524. * The scene that is rendered on top of the original scene
  108525. */
  108526. utilityLayerScene: Scene;
  108527. /**
  108528. * If the utility layer should automatically be rendered on top of existing scene
  108529. */
  108530. shouldRender: boolean;
  108531. /**
  108532. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  108533. */
  108534. onlyCheckPointerDownEvents: boolean;
  108535. /**
  108536. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  108537. */
  108538. processAllEvents: boolean;
  108539. /**
  108540. * Observable raised when the pointer move from the utility layer scene to the main scene
  108541. */
  108542. onPointerOutObservable: Observable<number>;
  108543. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  108544. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  108545. private _afterRenderObserver;
  108546. private _sceneDisposeObserver;
  108547. private _originalPointerObserver;
  108548. /**
  108549. * Instantiates a UtilityLayerRenderer
  108550. * @param originalScene the original scene that will be rendered on top of
  108551. * @param handleEvents boolean indicating if the utility layer should handle events
  108552. */
  108553. constructor(
  108554. /** the original scene that will be rendered on top of */
  108555. originalScene: Scene, handleEvents?: boolean);
  108556. private _notifyObservers;
  108557. /**
  108558. * Renders the utility layers scene on top of the original scene
  108559. */
  108560. render(): void;
  108561. /**
  108562. * Disposes of the renderer
  108563. */
  108564. dispose(): void;
  108565. private _updateCamera;
  108566. }
  108567. }
  108568. declare module BABYLON {
  108569. /**
  108570. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  108571. */
  108572. export class Gizmo implements IDisposable {
  108573. /** The utility layer the gizmo will be added to */
  108574. gizmoLayer: UtilityLayerRenderer;
  108575. /**
  108576. * The root mesh of the gizmo
  108577. */
  108578. _rootMesh: Mesh;
  108579. private _attachedMesh;
  108580. /**
  108581. * Ratio for the scale of the gizmo (Default: 1)
  108582. */
  108583. scaleRatio: number;
  108584. /**
  108585. * If a custom mesh has been set (Default: false)
  108586. */
  108587. protected _customMeshSet: boolean;
  108588. /**
  108589. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  108590. * * When set, interactions will be enabled
  108591. */
  108592. attachedMesh: Nullable<AbstractMesh>;
  108593. /**
  108594. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108595. * @param mesh The mesh to replace the default mesh of the gizmo
  108596. */
  108597. setCustomMesh(mesh: Mesh): void;
  108598. /**
  108599. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  108600. */
  108601. updateGizmoRotationToMatchAttachedMesh: boolean;
  108602. /**
  108603. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  108604. */
  108605. updateGizmoPositionToMatchAttachedMesh: boolean;
  108606. /**
  108607. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  108608. */
  108609. updateScale: boolean;
  108610. protected _interactionsEnabled: boolean;
  108611. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108612. private _beforeRenderObserver;
  108613. private _tempVector;
  108614. /**
  108615. * Creates a gizmo
  108616. * @param gizmoLayer The utility layer the gizmo will be added to
  108617. */
  108618. constructor(
  108619. /** The utility layer the gizmo will be added to */
  108620. gizmoLayer?: UtilityLayerRenderer);
  108621. /**
  108622. * Updates the gizmo to match the attached mesh's position/rotation
  108623. */
  108624. protected _update(): void;
  108625. /**
  108626. * Disposes of the gizmo
  108627. */
  108628. dispose(): void;
  108629. }
  108630. }
  108631. declare module BABYLON {
  108632. /**
  108633. * Single plane drag gizmo
  108634. */
  108635. export class PlaneDragGizmo extends Gizmo {
  108636. /**
  108637. * Drag behavior responsible for the gizmos dragging interactions
  108638. */
  108639. dragBehavior: PointerDragBehavior;
  108640. private _pointerObserver;
  108641. /**
  108642. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108643. */
  108644. snapDistance: number;
  108645. /**
  108646. * Event that fires each time the gizmo snaps to a new location.
  108647. * * snapDistance is the the change in distance
  108648. */
  108649. onSnapObservable: Observable<{
  108650. snapDistance: number;
  108651. }>;
  108652. private _plane;
  108653. private _coloredMaterial;
  108654. private _hoverMaterial;
  108655. private _isEnabled;
  108656. private _parent;
  108657. /** @hidden */
  108658. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  108659. /** @hidden */
  108660. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108661. /**
  108662. * Creates a PlaneDragGizmo
  108663. * @param gizmoLayer The utility layer the gizmo will be added to
  108664. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  108665. * @param color The color of the gizmo
  108666. */
  108667. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108668. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108669. /**
  108670. * If the gizmo is enabled
  108671. */
  108672. isEnabled: boolean;
  108673. /**
  108674. * Disposes of the gizmo
  108675. */
  108676. dispose(): void;
  108677. }
  108678. }
  108679. declare module BABYLON {
  108680. /**
  108681. * Gizmo that enables dragging a mesh along 3 axis
  108682. */
  108683. export class PositionGizmo extends Gizmo {
  108684. /**
  108685. * Internal gizmo used for interactions on the x axis
  108686. */
  108687. xGizmo: AxisDragGizmo;
  108688. /**
  108689. * Internal gizmo used for interactions on the y axis
  108690. */
  108691. yGizmo: AxisDragGizmo;
  108692. /**
  108693. * Internal gizmo used for interactions on the z axis
  108694. */
  108695. zGizmo: AxisDragGizmo;
  108696. /**
  108697. * Internal gizmo used for interactions on the yz plane
  108698. */
  108699. xPlaneGizmo: PlaneDragGizmo;
  108700. /**
  108701. * Internal gizmo used for interactions on the xz plane
  108702. */
  108703. yPlaneGizmo: PlaneDragGizmo;
  108704. /**
  108705. * Internal gizmo used for interactions on the xy plane
  108706. */
  108707. zPlaneGizmo: PlaneDragGizmo;
  108708. /**
  108709. * private variables
  108710. */
  108711. private _meshAttached;
  108712. private _updateGizmoRotationToMatchAttachedMesh;
  108713. private _snapDistance;
  108714. private _scaleRatio;
  108715. /** Fires an event when any of it's sub gizmos are dragged */
  108716. onDragStartObservable: Observable<unknown>;
  108717. /** Fires an event when any of it's sub gizmos are released from dragging */
  108718. onDragEndObservable: Observable<unknown>;
  108719. /**
  108720. * If set to true, planar drag is enabled
  108721. */
  108722. private _planarGizmoEnabled;
  108723. attachedMesh: Nullable<AbstractMesh>;
  108724. /**
  108725. * Creates a PositionGizmo
  108726. * @param gizmoLayer The utility layer the gizmo will be added to
  108727. */
  108728. constructor(gizmoLayer?: UtilityLayerRenderer);
  108729. /**
  108730. * If the planar drag gizmo is enabled
  108731. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  108732. */
  108733. planarGizmoEnabled: boolean;
  108734. updateGizmoRotationToMatchAttachedMesh: boolean;
  108735. /**
  108736. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108737. */
  108738. snapDistance: number;
  108739. /**
  108740. * Ratio for the scale of the gizmo (Default: 1)
  108741. */
  108742. scaleRatio: number;
  108743. /**
  108744. * Disposes of the gizmo
  108745. */
  108746. dispose(): void;
  108747. /**
  108748. * CustomMeshes are not supported by this gizmo
  108749. * @param mesh The mesh to replace the default mesh of the gizmo
  108750. */
  108751. setCustomMesh(mesh: Mesh): void;
  108752. }
  108753. }
  108754. declare module BABYLON {
  108755. /**
  108756. * Single axis drag gizmo
  108757. */
  108758. export class AxisDragGizmo extends Gizmo {
  108759. /**
  108760. * Drag behavior responsible for the gizmos dragging interactions
  108761. */
  108762. dragBehavior: PointerDragBehavior;
  108763. private _pointerObserver;
  108764. /**
  108765. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108766. */
  108767. snapDistance: number;
  108768. /**
  108769. * Event that fires each time the gizmo snaps to a new location.
  108770. * * snapDistance is the the change in distance
  108771. */
  108772. onSnapObservable: Observable<{
  108773. snapDistance: number;
  108774. }>;
  108775. private _isEnabled;
  108776. private _parent;
  108777. private _arrow;
  108778. private _coloredMaterial;
  108779. private _hoverMaterial;
  108780. /** @hidden */
  108781. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  108782. /** @hidden */
  108783. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108784. /**
  108785. * Creates an AxisDragGizmo
  108786. * @param gizmoLayer The utility layer the gizmo will be added to
  108787. * @param dragAxis The axis which the gizmo will be able to drag on
  108788. * @param color The color of the gizmo
  108789. */
  108790. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108791. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108792. /**
  108793. * If the gizmo is enabled
  108794. */
  108795. isEnabled: boolean;
  108796. /**
  108797. * Disposes of the gizmo
  108798. */
  108799. dispose(): void;
  108800. }
  108801. }
  108802. declare module BABYLON.Debug {
  108803. /**
  108804. * The Axes viewer will show 3 axes in a specific point in space
  108805. */
  108806. export class AxesViewer {
  108807. private _xAxis;
  108808. private _yAxis;
  108809. private _zAxis;
  108810. private _scaleLinesFactor;
  108811. private _instanced;
  108812. /**
  108813. * Gets the hosting scene
  108814. */
  108815. scene: Scene;
  108816. /**
  108817. * Gets or sets a number used to scale line length
  108818. */
  108819. scaleLines: number;
  108820. /** Gets the node hierarchy used to render x-axis */
  108821. readonly xAxis: TransformNode;
  108822. /** Gets the node hierarchy used to render y-axis */
  108823. readonly yAxis: TransformNode;
  108824. /** Gets the node hierarchy used to render z-axis */
  108825. readonly zAxis: TransformNode;
  108826. /**
  108827. * Creates a new AxesViewer
  108828. * @param scene defines the hosting scene
  108829. * @param scaleLines defines a number used to scale line length (1 by default)
  108830. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  108831. * @param xAxis defines the node hierarchy used to render the x-axis
  108832. * @param yAxis defines the node hierarchy used to render the y-axis
  108833. * @param zAxis defines the node hierarchy used to render the z-axis
  108834. */
  108835. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  108836. /**
  108837. * Force the viewer to update
  108838. * @param position defines the position of the viewer
  108839. * @param xaxis defines the x axis of the viewer
  108840. * @param yaxis defines the y axis of the viewer
  108841. * @param zaxis defines the z axis of the viewer
  108842. */
  108843. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  108844. /**
  108845. * Creates an instance of this axes viewer.
  108846. * @returns a new axes viewer with instanced meshes
  108847. */
  108848. createInstance(): AxesViewer;
  108849. /** Releases resources */
  108850. dispose(): void;
  108851. private static _SetRenderingGroupId;
  108852. }
  108853. }
  108854. declare module BABYLON.Debug {
  108855. /**
  108856. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  108857. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  108858. */
  108859. export class BoneAxesViewer extends AxesViewer {
  108860. /**
  108861. * Gets or sets the target mesh where to display the axes viewer
  108862. */
  108863. mesh: Nullable<Mesh>;
  108864. /**
  108865. * Gets or sets the target bone where to display the axes viewer
  108866. */
  108867. bone: Nullable<Bone>;
  108868. /** Gets current position */
  108869. pos: Vector3;
  108870. /** Gets direction of X axis */
  108871. xaxis: Vector3;
  108872. /** Gets direction of Y axis */
  108873. yaxis: Vector3;
  108874. /** Gets direction of Z axis */
  108875. zaxis: Vector3;
  108876. /**
  108877. * Creates a new BoneAxesViewer
  108878. * @param scene defines the hosting scene
  108879. * @param bone defines the target bone
  108880. * @param mesh defines the target mesh
  108881. * @param scaleLines defines a scaling factor for line length (1 by default)
  108882. */
  108883. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  108884. /**
  108885. * Force the viewer to update
  108886. */
  108887. update(): void;
  108888. /** Releases resources */
  108889. dispose(): void;
  108890. }
  108891. }
  108892. declare module BABYLON {
  108893. /**
  108894. * Interface used to define scene explorer extensibility option
  108895. */
  108896. export interface IExplorerExtensibilityOption {
  108897. /**
  108898. * Define the option label
  108899. */
  108900. label: string;
  108901. /**
  108902. * Defines the action to execute on click
  108903. */
  108904. action: (entity: any) => void;
  108905. }
  108906. /**
  108907. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  108908. */
  108909. export interface IExplorerExtensibilityGroup {
  108910. /**
  108911. * Defines a predicate to test if a given type mut be extended
  108912. */
  108913. predicate: (entity: any) => boolean;
  108914. /**
  108915. * Gets the list of options added to a type
  108916. */
  108917. entries: IExplorerExtensibilityOption[];
  108918. }
  108919. /**
  108920. * Interface used to define the options to use to create the Inspector
  108921. */
  108922. export interface IInspectorOptions {
  108923. /**
  108924. * Display in overlay mode (default: false)
  108925. */
  108926. overlay?: boolean;
  108927. /**
  108928. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  108929. */
  108930. globalRoot?: HTMLElement;
  108931. /**
  108932. * Display the Scene explorer
  108933. */
  108934. showExplorer?: boolean;
  108935. /**
  108936. * Display the property inspector
  108937. */
  108938. showInspector?: boolean;
  108939. /**
  108940. * Display in embed mode (both panes on the right)
  108941. */
  108942. embedMode?: boolean;
  108943. /**
  108944. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  108945. */
  108946. handleResize?: boolean;
  108947. /**
  108948. * Allow the panes to popup (default: true)
  108949. */
  108950. enablePopup?: boolean;
  108951. /**
  108952. * Allow the panes to be closed by users (default: true)
  108953. */
  108954. enableClose?: boolean;
  108955. /**
  108956. * Optional list of extensibility entries
  108957. */
  108958. explorerExtensibility?: IExplorerExtensibilityGroup[];
  108959. /**
  108960. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  108961. */
  108962. inspectorURL?: string;
  108963. }
  108964. interface Scene {
  108965. /**
  108966. * @hidden
  108967. * Backing field
  108968. */
  108969. _debugLayer: DebugLayer;
  108970. /**
  108971. * Gets the debug layer (aka Inspector) associated with the scene
  108972. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108973. */
  108974. debugLayer: DebugLayer;
  108975. }
  108976. /**
  108977. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108978. * what is happening in your scene
  108979. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108980. */
  108981. export class DebugLayer {
  108982. /**
  108983. * Define the url to get the inspector script from.
  108984. * By default it uses the babylonjs CDN.
  108985. * @ignoreNaming
  108986. */
  108987. static InspectorURL: string;
  108988. private _scene;
  108989. private BJSINSPECTOR;
  108990. private _onPropertyChangedObservable?;
  108991. /**
  108992. * Observable triggered when a property is changed through the inspector.
  108993. */
  108994. readonly onPropertyChangedObservable: any;
  108995. /**
  108996. * Instantiates a new debug layer.
  108997. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108998. * what is happening in your scene
  108999. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109000. * @param scene Defines the scene to inspect
  109001. */
  109002. constructor(scene: Scene);
  109003. /** Creates the inspector window. */
  109004. private _createInspector;
  109005. /**
  109006. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  109007. * @param entity defines the entity to select
  109008. * @param lineContainerTitle defines the specific block to highlight
  109009. */
  109010. select(entity: any, lineContainerTitle?: string): void;
  109011. /** Get the inspector from bundle or global */
  109012. private _getGlobalInspector;
  109013. /**
  109014. * Get if the inspector is visible or not.
  109015. * @returns true if visible otherwise, false
  109016. */
  109017. isVisible(): boolean;
  109018. /**
  109019. * Hide the inspector and close its window.
  109020. */
  109021. hide(): void;
  109022. /**
  109023. * Launch the debugLayer.
  109024. * @param config Define the configuration of the inspector
  109025. * @return a promise fulfilled when the debug layer is visible
  109026. */
  109027. show(config?: IInspectorOptions): Promise<DebugLayer>;
  109028. }
  109029. }
  109030. declare module BABYLON {
  109031. /**
  109032. * Class containing static functions to help procedurally build meshes
  109033. */
  109034. export class BoxBuilder {
  109035. /**
  109036. * Creates a box mesh
  109037. * * The parameter `size` sets the size (float) of each box side (default 1)
  109038. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109039. * * 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)
  109040. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109042. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109044. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109045. * @param name defines the name of the mesh
  109046. * @param options defines the options used to create the mesh
  109047. * @param scene defines the hosting scene
  109048. * @returns the box mesh
  109049. */
  109050. static CreateBox(name: string, options: {
  109051. size?: number;
  109052. width?: number;
  109053. height?: number;
  109054. depth?: number;
  109055. faceUV?: Vector4[];
  109056. faceColors?: Color4[];
  109057. sideOrientation?: number;
  109058. frontUVs?: Vector4;
  109059. backUVs?: Vector4;
  109060. wrap?: boolean;
  109061. topBaseAt?: number;
  109062. bottomBaseAt?: number;
  109063. updatable?: boolean;
  109064. }, scene?: Nullable<Scene>): Mesh;
  109065. }
  109066. }
  109067. declare module BABYLON {
  109068. /**
  109069. * Class containing static functions to help procedurally build meshes
  109070. */
  109071. export class SphereBuilder {
  109072. /**
  109073. * Creates a sphere mesh
  109074. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109075. * * 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`)
  109076. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109077. * * 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
  109078. * * 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)
  109079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109080. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109082. * @param name defines the name of the mesh
  109083. * @param options defines the options used to create the mesh
  109084. * @param scene defines the hosting scene
  109085. * @returns the sphere mesh
  109086. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109087. */
  109088. static CreateSphere(name: string, options: {
  109089. segments?: number;
  109090. diameter?: number;
  109091. diameterX?: number;
  109092. diameterY?: number;
  109093. diameterZ?: number;
  109094. arc?: number;
  109095. slice?: number;
  109096. sideOrientation?: number;
  109097. frontUVs?: Vector4;
  109098. backUVs?: Vector4;
  109099. updatable?: boolean;
  109100. }, scene?: Nullable<Scene>): Mesh;
  109101. }
  109102. }
  109103. declare module BABYLON.Debug {
  109104. /**
  109105. * Used to show the physics impostor around the specific mesh
  109106. */
  109107. export class PhysicsViewer {
  109108. /** @hidden */
  109109. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  109110. /** @hidden */
  109111. protected _meshes: Array<Nullable<AbstractMesh>>;
  109112. /** @hidden */
  109113. protected _scene: Nullable<Scene>;
  109114. /** @hidden */
  109115. protected _numMeshes: number;
  109116. /** @hidden */
  109117. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  109118. private _renderFunction;
  109119. private _utilityLayer;
  109120. private _debugBoxMesh;
  109121. private _debugSphereMesh;
  109122. private _debugCylinderMesh;
  109123. private _debugMaterial;
  109124. private _debugMeshMeshes;
  109125. /**
  109126. * Creates a new PhysicsViewer
  109127. * @param scene defines the hosting scene
  109128. */
  109129. constructor(scene: Scene);
  109130. /** @hidden */
  109131. protected _updateDebugMeshes(): void;
  109132. /**
  109133. * Renders a specified physic impostor
  109134. * @param impostor defines the impostor to render
  109135. * @param targetMesh defines the mesh represented by the impostor
  109136. * @returns the new debug mesh used to render the impostor
  109137. */
  109138. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  109139. /**
  109140. * Hides a specified physic impostor
  109141. * @param impostor defines the impostor to hide
  109142. */
  109143. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  109144. private _getDebugMaterial;
  109145. private _getDebugBoxMesh;
  109146. private _getDebugSphereMesh;
  109147. private _getDebugCylinderMesh;
  109148. private _getDebugMeshMesh;
  109149. private _getDebugMesh;
  109150. /** Releases all resources */
  109151. dispose(): void;
  109152. }
  109153. }
  109154. declare module BABYLON {
  109155. /**
  109156. * Class containing static functions to help procedurally build meshes
  109157. */
  109158. export class LinesBuilder {
  109159. /**
  109160. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109161. * * 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
  109162. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109163. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109164. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109165. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109166. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109167. * * 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
  109168. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109171. * @param name defines the name of the new line system
  109172. * @param options defines the options used to create the line system
  109173. * @param scene defines the hosting scene
  109174. * @returns a new line system mesh
  109175. */
  109176. static CreateLineSystem(name: string, options: {
  109177. lines: Vector3[][];
  109178. updatable?: boolean;
  109179. instance?: Nullable<LinesMesh>;
  109180. colors?: Nullable<Color4[][]>;
  109181. useVertexAlpha?: boolean;
  109182. }, scene: Nullable<Scene>): LinesMesh;
  109183. /**
  109184. * Creates a line mesh
  109185. * 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
  109186. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109187. * * The parameter `points` is an array successive Vector3
  109188. * * 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
  109189. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109190. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109191. * * When updating an instance, remember that only point positions can change, not the number of points
  109192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109193. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109194. * @param name defines the name of the new line system
  109195. * @param options defines the options used to create the line system
  109196. * @param scene defines the hosting scene
  109197. * @returns a new line mesh
  109198. */
  109199. static CreateLines(name: string, options: {
  109200. points: Vector3[];
  109201. updatable?: boolean;
  109202. instance?: Nullable<LinesMesh>;
  109203. colors?: Color4[];
  109204. useVertexAlpha?: boolean;
  109205. }, scene?: Nullable<Scene>): LinesMesh;
  109206. /**
  109207. * Creates a dashed line mesh
  109208. * * 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
  109209. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109210. * * The parameter `points` is an array successive Vector3
  109211. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109212. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109213. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109214. * * 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
  109215. * * When updating an instance, remember that only point positions can change, not the number of points
  109216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109217. * @param name defines the name of the mesh
  109218. * @param options defines the options used to create the mesh
  109219. * @param scene defines the hosting scene
  109220. * @returns the dashed line mesh
  109221. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109222. */
  109223. static CreateDashedLines(name: string, options: {
  109224. points: Vector3[];
  109225. dashSize?: number;
  109226. gapSize?: number;
  109227. dashNb?: number;
  109228. updatable?: boolean;
  109229. instance?: LinesMesh;
  109230. }, scene?: Nullable<Scene>): LinesMesh;
  109231. }
  109232. }
  109233. declare module BABYLON {
  109234. /**
  109235. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109236. * in order to better appreciate the issue one might have.
  109237. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109238. */
  109239. export class RayHelper {
  109240. /**
  109241. * Defines the ray we are currently tryin to visualize.
  109242. */
  109243. ray: Nullable<Ray>;
  109244. private _renderPoints;
  109245. private _renderLine;
  109246. private _renderFunction;
  109247. private _scene;
  109248. private _updateToMeshFunction;
  109249. private _attachedToMesh;
  109250. private _meshSpaceDirection;
  109251. private _meshSpaceOrigin;
  109252. /**
  109253. * Helper function to create a colored helper in a scene in one line.
  109254. * @param ray Defines the ray we are currently tryin to visualize
  109255. * @param scene Defines the scene the ray is used in
  109256. * @param color Defines the color we want to see the ray in
  109257. * @returns The newly created ray helper.
  109258. */
  109259. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  109260. /**
  109261. * Instantiate a new ray helper.
  109262. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109263. * in order to better appreciate the issue one might have.
  109264. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109265. * @param ray Defines the ray we are currently tryin to visualize
  109266. */
  109267. constructor(ray: Ray);
  109268. /**
  109269. * Shows the ray we are willing to debug.
  109270. * @param scene Defines the scene the ray needs to be rendered in
  109271. * @param color Defines the color the ray needs to be rendered in
  109272. */
  109273. show(scene: Scene, color?: Color3): void;
  109274. /**
  109275. * Hides the ray we are debugging.
  109276. */
  109277. hide(): void;
  109278. private _render;
  109279. /**
  109280. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  109281. * @param mesh Defines the mesh we want the helper attached to
  109282. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  109283. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  109284. * @param length Defines the length of the ray
  109285. */
  109286. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  109287. /**
  109288. * Detach the ray helper from the mesh it has previously been attached to.
  109289. */
  109290. detachFromMesh(): void;
  109291. private _updateToMesh;
  109292. /**
  109293. * Dispose the helper and release its associated resources.
  109294. */
  109295. dispose(): void;
  109296. }
  109297. }
  109298. declare module BABYLON.Debug {
  109299. /**
  109300. * Class used to render a debug view of a given skeleton
  109301. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  109302. */
  109303. export class SkeletonViewer {
  109304. /** defines the skeleton to render */
  109305. skeleton: Skeleton;
  109306. /** defines the mesh attached to the skeleton */
  109307. mesh: AbstractMesh;
  109308. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109309. autoUpdateBonesMatrices: boolean;
  109310. /** defines the rendering group id to use with the viewer */
  109311. renderingGroupId: number;
  109312. /** Gets or sets the color used to render the skeleton */
  109313. color: Color3;
  109314. private _scene;
  109315. private _debugLines;
  109316. private _debugMesh;
  109317. private _isEnabled;
  109318. private _renderFunction;
  109319. private _utilityLayer;
  109320. /**
  109321. * Returns the mesh used to render the bones
  109322. */
  109323. readonly debugMesh: Nullable<LinesMesh>;
  109324. /**
  109325. * Creates a new SkeletonViewer
  109326. * @param skeleton defines the skeleton to render
  109327. * @param mesh defines the mesh attached to the skeleton
  109328. * @param scene defines the hosting scene
  109329. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  109330. * @param renderingGroupId defines the rendering group id to use with the viewer
  109331. */
  109332. constructor(
  109333. /** defines the skeleton to render */
  109334. skeleton: Skeleton,
  109335. /** defines the mesh attached to the skeleton */
  109336. mesh: AbstractMesh, scene: Scene,
  109337. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109338. autoUpdateBonesMatrices?: boolean,
  109339. /** defines the rendering group id to use with the viewer */
  109340. renderingGroupId?: number);
  109341. /** Gets or sets a boolean indicating if the viewer is enabled */
  109342. isEnabled: boolean;
  109343. private _getBonePosition;
  109344. private _getLinesForBonesWithLength;
  109345. private _getLinesForBonesNoLength;
  109346. /** Update the viewer to sync with current skeleton state */
  109347. update(): void;
  109348. /** Release associated resources */
  109349. dispose(): void;
  109350. }
  109351. }
  109352. declare module BABYLON {
  109353. /**
  109354. * Options to create the null engine
  109355. */
  109356. export class NullEngineOptions {
  109357. /**
  109358. * Render width (Default: 512)
  109359. */
  109360. renderWidth: number;
  109361. /**
  109362. * Render height (Default: 256)
  109363. */
  109364. renderHeight: number;
  109365. /**
  109366. * Texture size (Default: 512)
  109367. */
  109368. textureSize: number;
  109369. /**
  109370. * If delta time between frames should be constant
  109371. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109372. */
  109373. deterministicLockstep: boolean;
  109374. /**
  109375. * Maximum about of steps between frames (Default: 4)
  109376. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109377. */
  109378. lockstepMaxSteps: number;
  109379. }
  109380. /**
  109381. * The null engine class provides support for headless version of babylon.js.
  109382. * This can be used in server side scenario or for testing purposes
  109383. */
  109384. export class NullEngine extends Engine {
  109385. private _options;
  109386. /**
  109387. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109388. */
  109389. isDeterministicLockStep(): boolean;
  109390. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  109391. getLockstepMaxSteps(): number;
  109392. /**
  109393. * Sets hardware scaling, used to save performance if needed
  109394. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109395. */
  109396. getHardwareScalingLevel(): number;
  109397. constructor(options?: NullEngineOptions);
  109398. createVertexBuffer(vertices: FloatArray): DataBuffer;
  109399. createIndexBuffer(indices: IndicesArray): DataBuffer;
  109400. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109401. getRenderWidth(useScreen?: boolean): number;
  109402. getRenderHeight(useScreen?: boolean): number;
  109403. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  109404. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  109405. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  109406. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109407. bindSamplers(effect: Effect): void;
  109408. enableEffect(effect: Effect): void;
  109409. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109410. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109411. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109412. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109413. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109414. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109415. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109416. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109417. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109418. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109419. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109420. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109421. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109422. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109423. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109424. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109425. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109426. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109427. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109428. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109429. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109430. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109431. bindBuffers(vertexBuffers: {
  109432. [key: string]: VertexBuffer;
  109433. }, indexBuffer: DataBuffer, effect: Effect): void;
  109434. wipeCaches(bruteForce?: boolean): void;
  109435. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  109436. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109437. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109438. /** @hidden */
  109439. _createTexture(): WebGLTexture;
  109440. /** @hidden */
  109441. _releaseTexture(texture: InternalTexture): void;
  109442. 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;
  109443. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  109444. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  109445. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  109446. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  109447. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  109448. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  109449. areAllEffectsReady(): boolean;
  109450. /**
  109451. * @hidden
  109452. * Get the current error code of the webGL context
  109453. * @returns the error code
  109454. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  109455. */
  109456. getError(): number;
  109457. /** @hidden */
  109458. _getUnpackAlignement(): number;
  109459. /** @hidden */
  109460. _unpackFlipY(value: boolean): void;
  109461. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  109462. /**
  109463. * Updates a dynamic vertex buffer.
  109464. * @param vertexBuffer the vertex buffer to update
  109465. * @param data the data used to update the vertex buffer
  109466. * @param byteOffset the byte offset of the data (optional)
  109467. * @param byteLength the byte length of the data (optional)
  109468. */
  109469. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  109470. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  109471. /** @hidden */
  109472. _bindTexture(channel: number, texture: InternalTexture): void;
  109473. protected _deleteBuffer(buffer: WebGLBuffer): void;
  109474. releaseEffects(): void;
  109475. displayLoadingUI(): void;
  109476. hideLoadingUI(): void;
  109477. /** @hidden */
  109478. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109479. /** @hidden */
  109480. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109481. /** @hidden */
  109482. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109483. /** @hidden */
  109484. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109485. }
  109486. }
  109487. declare module BABYLON {
  109488. /** @hidden */
  109489. export class _OcclusionDataStorage {
  109490. /** @hidden */
  109491. occlusionInternalRetryCounter: number;
  109492. /** @hidden */
  109493. isOcclusionQueryInProgress: boolean;
  109494. /** @hidden */
  109495. isOccluded: boolean;
  109496. /** @hidden */
  109497. occlusionRetryCount: number;
  109498. /** @hidden */
  109499. occlusionType: number;
  109500. /** @hidden */
  109501. occlusionQueryAlgorithmType: number;
  109502. }
  109503. interface Engine {
  109504. /**
  109505. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  109506. * @return the new query
  109507. */
  109508. createQuery(): WebGLQuery;
  109509. /**
  109510. * Delete and release a webGL query
  109511. * @param query defines the query to delete
  109512. * @return the current engine
  109513. */
  109514. deleteQuery(query: WebGLQuery): Engine;
  109515. /**
  109516. * Check if a given query has resolved and got its value
  109517. * @param query defines the query to check
  109518. * @returns true if the query got its value
  109519. */
  109520. isQueryResultAvailable(query: WebGLQuery): boolean;
  109521. /**
  109522. * Gets the value of a given query
  109523. * @param query defines the query to check
  109524. * @returns the value of the query
  109525. */
  109526. getQueryResult(query: WebGLQuery): number;
  109527. /**
  109528. * Initiates an occlusion query
  109529. * @param algorithmType defines the algorithm to use
  109530. * @param query defines the query to use
  109531. * @returns the current engine
  109532. * @see http://doc.babylonjs.com/features/occlusionquery
  109533. */
  109534. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  109535. /**
  109536. * Ends an occlusion query
  109537. * @see http://doc.babylonjs.com/features/occlusionquery
  109538. * @param algorithmType defines the algorithm to use
  109539. * @returns the current engine
  109540. */
  109541. endOcclusionQuery(algorithmType: number): Engine;
  109542. /**
  109543. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  109544. * Please note that only one query can be issued at a time
  109545. * @returns a time token used to track the time span
  109546. */
  109547. startTimeQuery(): Nullable<_TimeToken>;
  109548. /**
  109549. * Ends a time query
  109550. * @param token defines the token used to measure the time span
  109551. * @returns the time spent (in ns)
  109552. */
  109553. endTimeQuery(token: _TimeToken): int;
  109554. /** @hidden */
  109555. _currentNonTimestampToken: Nullable<_TimeToken>;
  109556. /** @hidden */
  109557. _createTimeQuery(): WebGLQuery;
  109558. /** @hidden */
  109559. _deleteTimeQuery(query: WebGLQuery): void;
  109560. /** @hidden */
  109561. _getGlAlgorithmType(algorithmType: number): number;
  109562. /** @hidden */
  109563. _getTimeQueryResult(query: WebGLQuery): any;
  109564. /** @hidden */
  109565. _getTimeQueryAvailability(query: WebGLQuery): any;
  109566. }
  109567. interface AbstractMesh {
  109568. /**
  109569. * Backing filed
  109570. * @hidden
  109571. */
  109572. __occlusionDataStorage: _OcclusionDataStorage;
  109573. /**
  109574. * Access property
  109575. * @hidden
  109576. */
  109577. _occlusionDataStorage: _OcclusionDataStorage;
  109578. /**
  109579. * 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.
  109580. * The default value is -1 which means don't break the query and wait till the result
  109581. * @see http://doc.babylonjs.com/features/occlusionquery
  109582. */
  109583. occlusionRetryCount: number;
  109584. /**
  109585. * 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:
  109586. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  109587. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  109588. * * 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.
  109589. * @see http://doc.babylonjs.com/features/occlusionquery
  109590. */
  109591. occlusionType: number;
  109592. /**
  109593. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  109594. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  109595. * * 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.
  109596. * @see http://doc.babylonjs.com/features/occlusionquery
  109597. */
  109598. occlusionQueryAlgorithmType: number;
  109599. /**
  109600. * 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
  109601. * @see http://doc.babylonjs.com/features/occlusionquery
  109602. */
  109603. isOccluded: boolean;
  109604. /**
  109605. * Flag to check the progress status of the query
  109606. * @see http://doc.babylonjs.com/features/occlusionquery
  109607. */
  109608. isOcclusionQueryInProgress: boolean;
  109609. }
  109610. }
  109611. declare module BABYLON {
  109612. /** @hidden */
  109613. export var _forceTransformFeedbackToBundle: boolean;
  109614. interface Engine {
  109615. /**
  109616. * Creates a webGL transform feedback object
  109617. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  109618. * @returns the webGL transform feedback object
  109619. */
  109620. createTransformFeedback(): WebGLTransformFeedback;
  109621. /**
  109622. * Delete a webGL transform feedback object
  109623. * @param value defines the webGL transform feedback object to delete
  109624. */
  109625. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  109626. /**
  109627. * Bind a webGL transform feedback object to the webgl context
  109628. * @param value defines the webGL transform feedback object to bind
  109629. */
  109630. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  109631. /**
  109632. * Begins a transform feedback operation
  109633. * @param usePoints defines if points or triangles must be used
  109634. */
  109635. beginTransformFeedback(usePoints: boolean): void;
  109636. /**
  109637. * Ends a transform feedback operation
  109638. */
  109639. endTransformFeedback(): void;
  109640. /**
  109641. * Specify the varyings to use with transform feedback
  109642. * @param program defines the associated webGL program
  109643. * @param value defines the list of strings representing the varying names
  109644. */
  109645. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  109646. /**
  109647. * Bind a webGL buffer for a transform feedback operation
  109648. * @param value defines the webGL buffer to bind
  109649. */
  109650. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  109651. }
  109652. }
  109653. declare module BABYLON {
  109654. /**
  109655. * Creation options of the multi render target texture.
  109656. */
  109657. export interface IMultiRenderTargetOptions {
  109658. /**
  109659. * Define if the texture needs to create mip maps after render.
  109660. */
  109661. generateMipMaps?: boolean;
  109662. /**
  109663. * Define the types of all the draw buffers we want to create
  109664. */
  109665. types?: number[];
  109666. /**
  109667. * Define the sampling modes of all the draw buffers we want to create
  109668. */
  109669. samplingModes?: number[];
  109670. /**
  109671. * Define if a depth buffer is required
  109672. */
  109673. generateDepthBuffer?: boolean;
  109674. /**
  109675. * Define if a stencil buffer is required
  109676. */
  109677. generateStencilBuffer?: boolean;
  109678. /**
  109679. * Define if a depth texture is required instead of a depth buffer
  109680. */
  109681. generateDepthTexture?: boolean;
  109682. /**
  109683. * Define the number of desired draw buffers
  109684. */
  109685. textureCount?: number;
  109686. /**
  109687. * Define if aspect ratio should be adapted to the texture or stay the scene one
  109688. */
  109689. doNotChangeAspectRatio?: boolean;
  109690. /**
  109691. * Define the default type of the buffers we are creating
  109692. */
  109693. defaultType?: number;
  109694. }
  109695. /**
  109696. * A multi render target, like a render target provides the ability to render to a texture.
  109697. * Unlike the render target, it can render to several draw buffers in one draw.
  109698. * This is specially interesting in deferred rendering or for any effects requiring more than
  109699. * just one color from a single pass.
  109700. */
  109701. export class MultiRenderTarget extends RenderTargetTexture {
  109702. private _internalTextures;
  109703. private _textures;
  109704. private _multiRenderTargetOptions;
  109705. /**
  109706. * Get if draw buffers are currently supported by the used hardware and browser.
  109707. */
  109708. readonly isSupported: boolean;
  109709. /**
  109710. * Get the list of textures generated by the multi render target.
  109711. */
  109712. readonly textures: Texture[];
  109713. /**
  109714. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  109715. */
  109716. readonly depthTexture: Texture;
  109717. /**
  109718. * Set the wrapping mode on U of all the textures we are rendering to.
  109719. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109720. */
  109721. wrapU: number;
  109722. /**
  109723. * Set the wrapping mode on V of all the textures we are rendering to.
  109724. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109725. */
  109726. wrapV: number;
  109727. /**
  109728. * Instantiate a new multi render target texture.
  109729. * A multi render target, like a render target provides the ability to render to a texture.
  109730. * Unlike the render target, it can render to several draw buffers in one draw.
  109731. * This is specially interesting in deferred rendering or for any effects requiring more than
  109732. * just one color from a single pass.
  109733. * @param name Define the name of the texture
  109734. * @param size Define the size of the buffers to render to
  109735. * @param count Define the number of target we are rendering into
  109736. * @param scene Define the scene the texture belongs to
  109737. * @param options Define the options used to create the multi render target
  109738. */
  109739. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  109740. /** @hidden */
  109741. _rebuild(): void;
  109742. private _createInternalTextures;
  109743. private _createTextures;
  109744. /**
  109745. * Define the number of samples used if MSAA is enabled.
  109746. */
  109747. samples: number;
  109748. /**
  109749. * Resize all the textures in the multi render target.
  109750. * Be carrefull as it will recreate all the data in the new texture.
  109751. * @param size Define the new size
  109752. */
  109753. resize(size: any): void;
  109754. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109755. /**
  109756. * Dispose the render targets and their associated resources
  109757. */
  109758. dispose(): void;
  109759. /**
  109760. * Release all the underlying texture used as draw buffers.
  109761. */
  109762. releaseInternalTextures(): void;
  109763. }
  109764. }
  109765. declare module BABYLON {
  109766. interface Engine {
  109767. /**
  109768. * Unbind a list of render target textures from the webGL context
  109769. * This is used only when drawBuffer extension or webGL2 are active
  109770. * @param textures defines the render target textures to unbind
  109771. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  109772. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  109773. */
  109774. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  109775. /**
  109776. * Create a multi render target texture
  109777. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  109778. * @param size defines the size of the texture
  109779. * @param options defines the creation options
  109780. * @returns the cube texture as an InternalTexture
  109781. */
  109782. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  109783. /**
  109784. * Update the sample count for a given multiple render target texture
  109785. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  109786. * @param textures defines the textures to update
  109787. * @param samples defines the sample count to set
  109788. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  109789. */
  109790. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  109791. }
  109792. }
  109793. declare module BABYLON {
  109794. /** @hidden */
  109795. export var rgbdEncodePixelShader: {
  109796. name: string;
  109797. shader: string;
  109798. };
  109799. }
  109800. declare module BABYLON {
  109801. /** @hidden */
  109802. export var rgbdDecodePixelShader: {
  109803. name: string;
  109804. shader: string;
  109805. };
  109806. }
  109807. declare module BABYLON {
  109808. /**
  109809. * Raw texture data and descriptor sufficient for WebGL texture upload
  109810. */
  109811. export interface EnvironmentTextureInfo {
  109812. /**
  109813. * Version of the environment map
  109814. */
  109815. version: number;
  109816. /**
  109817. * Width of image
  109818. */
  109819. width: number;
  109820. /**
  109821. * Irradiance information stored in the file.
  109822. */
  109823. irradiance: any;
  109824. /**
  109825. * Specular information stored in the file.
  109826. */
  109827. specular: any;
  109828. }
  109829. /**
  109830. * Defines One Image in the file. It requires only the position in the file
  109831. * as well as the length.
  109832. */
  109833. interface BufferImageData {
  109834. /**
  109835. * Length of the image data.
  109836. */
  109837. length: number;
  109838. /**
  109839. * Position of the data from the null terminator delimiting the end of the JSON.
  109840. */
  109841. position: number;
  109842. }
  109843. /**
  109844. * Defines the specular data enclosed in the file.
  109845. * This corresponds to the version 1 of the data.
  109846. */
  109847. export interface EnvironmentTextureSpecularInfoV1 {
  109848. /**
  109849. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  109850. */
  109851. specularDataPosition?: number;
  109852. /**
  109853. * This contains all the images data needed to reconstruct the cubemap.
  109854. */
  109855. mipmaps: Array<BufferImageData>;
  109856. /**
  109857. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  109858. */
  109859. lodGenerationScale: number;
  109860. }
  109861. /**
  109862. * Sets of helpers addressing the serialization and deserialization of environment texture
  109863. * stored in a BabylonJS env file.
  109864. * Those files are usually stored as .env files.
  109865. */
  109866. export class EnvironmentTextureTools {
  109867. /**
  109868. * Magic number identifying the env file.
  109869. */
  109870. private static _MagicBytes;
  109871. /**
  109872. * Gets the environment info from an env file.
  109873. * @param data The array buffer containing the .env bytes.
  109874. * @returns the environment file info (the json header) if successfully parsed.
  109875. */
  109876. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109877. /**
  109878. * Creates an environment texture from a loaded cube texture.
  109879. * @param texture defines the cube texture to convert in env file
  109880. * @return a promise containing the environment data if succesfull.
  109881. */
  109882. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109883. /**
  109884. * Creates a JSON representation of the spherical data.
  109885. * @param texture defines the texture containing the polynomials
  109886. * @return the JSON representation of the spherical info
  109887. */
  109888. private static _CreateEnvTextureIrradiance;
  109889. /**
  109890. * Creates the ArrayBufferViews used for initializing environment texture image data.
  109891. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  109892. * @param info parameters that determine what views will be created for accessing the underlying buffer
  109893. * @return the views described by info providing access to the underlying buffer
  109894. */
  109895. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  109896. /**
  109897. * Uploads the texture info contained in the env file to the GPU.
  109898. * @param texture defines the internal texture to upload to
  109899. * @param arrayBuffer defines the buffer cotaining the data to load
  109900. * @param info defines the texture info retrieved through the GetEnvInfo method
  109901. * @returns a promise
  109902. */
  109903. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109904. /**
  109905. * Uploads the levels of image data to the GPU.
  109906. * @param texture defines the internal texture to upload to
  109907. * @param imageData defines the array buffer views of image data [mipmap][face]
  109908. * @returns a promise
  109909. */
  109910. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109911. /**
  109912. * Uploads spherical polynomials information to the texture.
  109913. * @param texture defines the texture we are trying to upload the information to
  109914. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109915. */
  109916. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109917. /** @hidden */
  109918. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109919. }
  109920. }
  109921. declare module BABYLON {
  109922. /**
  109923. * Contains position and normal vectors for a vertex
  109924. */
  109925. export class PositionNormalVertex {
  109926. /** the position of the vertex (defaut: 0,0,0) */
  109927. position: Vector3;
  109928. /** the normal of the vertex (defaut: 0,1,0) */
  109929. normal: Vector3;
  109930. /**
  109931. * Creates a PositionNormalVertex
  109932. * @param position the position of the vertex (defaut: 0,0,0)
  109933. * @param normal the normal of the vertex (defaut: 0,1,0)
  109934. */
  109935. constructor(
  109936. /** the position of the vertex (defaut: 0,0,0) */
  109937. position?: Vector3,
  109938. /** the normal of the vertex (defaut: 0,1,0) */
  109939. normal?: Vector3);
  109940. /**
  109941. * Clones the PositionNormalVertex
  109942. * @returns the cloned PositionNormalVertex
  109943. */
  109944. clone(): PositionNormalVertex;
  109945. }
  109946. /**
  109947. * Contains position, normal and uv vectors for a vertex
  109948. */
  109949. export class PositionNormalTextureVertex {
  109950. /** the position of the vertex (defaut: 0,0,0) */
  109951. position: Vector3;
  109952. /** the normal of the vertex (defaut: 0,1,0) */
  109953. normal: Vector3;
  109954. /** the uv of the vertex (default: 0,0) */
  109955. uv: Vector2;
  109956. /**
  109957. * Creates a PositionNormalTextureVertex
  109958. * @param position the position of the vertex (defaut: 0,0,0)
  109959. * @param normal the normal of the vertex (defaut: 0,1,0)
  109960. * @param uv the uv of the vertex (default: 0,0)
  109961. */
  109962. constructor(
  109963. /** the position of the vertex (defaut: 0,0,0) */
  109964. position?: Vector3,
  109965. /** the normal of the vertex (defaut: 0,1,0) */
  109966. normal?: Vector3,
  109967. /** the uv of the vertex (default: 0,0) */
  109968. uv?: Vector2);
  109969. /**
  109970. * Clones the PositionNormalTextureVertex
  109971. * @returns the cloned PositionNormalTextureVertex
  109972. */
  109973. clone(): PositionNormalTextureVertex;
  109974. }
  109975. }
  109976. declare module BABYLON {
  109977. /** @hidden */
  109978. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  109979. private _genericAttributeLocation;
  109980. private _varyingLocationCount;
  109981. private _varyingLocationMap;
  109982. private _replacements;
  109983. private _textureCount;
  109984. private _uniforms;
  109985. lineProcessor(line: string): string;
  109986. attributeProcessor(attribute: string): string;
  109987. varyingProcessor(varying: string, isFragment: boolean): string;
  109988. uniformProcessor(uniform: string): string;
  109989. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  109990. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  109991. }
  109992. }
  109993. declare module BABYLON {
  109994. /**
  109995. * Container for accessors for natively-stored mesh data buffers.
  109996. */
  109997. class NativeDataBuffer extends DataBuffer {
  109998. /**
  109999. * Accessor value used to identify/retrieve a natively-stored index buffer.
  110000. */
  110001. nativeIndexBuffer?: any;
  110002. /**
  110003. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  110004. */
  110005. nativeVertexBuffer?: any;
  110006. }
  110007. /** @hidden */
  110008. export class NativeEngine extends Engine {
  110009. private readonly _native;
  110010. getHardwareScalingLevel(): number;
  110011. constructor();
  110012. /**
  110013. * Can be used to override the current requestAnimationFrame requester.
  110014. * @hidden
  110015. */
  110016. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  110017. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110018. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  110019. createVertexBuffer(data: DataArray): NativeDataBuffer;
  110020. recordVertexArrayObject(vertexBuffers: {
  110021. [key: string]: VertexBuffer;
  110022. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  110023. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  110024. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  110025. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110026. /**
  110027. * Draw a list of indexed primitives
  110028. * @param fillMode defines the primitive to use
  110029. * @param indexStart defines the starting index
  110030. * @param indexCount defines the number of index to draw
  110031. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110032. */
  110033. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110034. /**
  110035. * Draw a list of unindexed primitives
  110036. * @param fillMode defines the primitive to use
  110037. * @param verticesStart defines the index of first vertex to draw
  110038. * @param verticesCount defines the count of vertices to draw
  110039. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110040. */
  110041. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110042. createPipelineContext(): IPipelineContext;
  110043. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  110044. /** @hidden */
  110045. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  110046. /** @hidden */
  110047. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  110048. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  110049. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  110050. protected _setProgram(program: WebGLProgram): void;
  110051. _releaseEffect(effect: Effect): void;
  110052. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  110053. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  110054. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  110055. bindSamplers(effect: Effect): void;
  110056. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  110057. getRenderWidth(useScreen?: boolean): number;
  110058. getRenderHeight(useScreen?: boolean): number;
  110059. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  110060. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110061. /**
  110062. * Set the z offset to apply to current rendering
  110063. * @param value defines the offset to apply
  110064. */
  110065. setZOffset(value: number): void;
  110066. /**
  110067. * Gets the current value of the zOffset
  110068. * @returns the current zOffset state
  110069. */
  110070. getZOffset(): number;
  110071. /**
  110072. * Enable or disable depth buffering
  110073. * @param enable defines the state to set
  110074. */
  110075. setDepthBuffer(enable: boolean): void;
  110076. /**
  110077. * Gets a boolean indicating if depth writing is enabled
  110078. * @returns the current depth writing state
  110079. */
  110080. getDepthWrite(): boolean;
  110081. /**
  110082. * Enable or disable depth writing
  110083. * @param enable defines the state to set
  110084. */
  110085. setDepthWrite(enable: boolean): void;
  110086. /**
  110087. * Enable or disable color writing
  110088. * @param enable defines the state to set
  110089. */
  110090. setColorWrite(enable: boolean): void;
  110091. /**
  110092. * Gets a boolean indicating if color writing is enabled
  110093. * @returns the current color writing state
  110094. */
  110095. getColorWrite(): boolean;
  110096. /**
  110097. * Sets alpha constants used by some alpha blending modes
  110098. * @param r defines the red component
  110099. * @param g defines the green component
  110100. * @param b defines the blue component
  110101. * @param a defines the alpha component
  110102. */
  110103. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  110104. /**
  110105. * Sets the current alpha mode
  110106. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  110107. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110108. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110109. */
  110110. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110111. /**
  110112. * Gets the current alpha mode
  110113. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110114. * @returns the current alpha mode
  110115. */
  110116. getAlphaMode(): number;
  110117. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110118. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110119. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110120. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110121. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110122. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110123. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110124. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110125. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110126. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110127. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110128. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110129. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110130. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110131. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110132. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110133. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110134. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110135. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110136. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110137. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  110138. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  110139. wipeCaches(bruteForce?: boolean): void;
  110140. _createTexture(): WebGLTexture;
  110141. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  110142. /**
  110143. * Usually called from BABYLON.Texture.ts.
  110144. * Passed information to create a WebGLTexture
  110145. * @param urlArg defines a value which contains one of the following:
  110146. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110147. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110148. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110149. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110150. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  110151. * @param scene needed for loading to the correct scene
  110152. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  110153. * @param onLoad optional callback to be called upon successful completion
  110154. * @param onError optional callback to be called upon failure
  110155. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  110156. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110157. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110158. * @param forcedExtension defines the extension to use to pick the right loader
  110159. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110160. */
  110161. 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;
  110162. /**
  110163. * Creates a cube texture
  110164. * @param rootUrl defines the url where the files to load is located
  110165. * @param scene defines the current scene
  110166. * @param files defines the list of files to load (1 per face)
  110167. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  110168. * @param onLoad defines an optional callback raised when the texture is loaded
  110169. * @param onError defines an optional callback raised if there is an issue to load the texture
  110170. * @param format defines the format of the data
  110171. * @param forcedExtension defines the extension to use to pick the right loader
  110172. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  110173. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  110174. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  110175. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  110176. * @returns the cube texture as an InternalTexture
  110177. */
  110178. 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;
  110179. private _getSamplingFilter;
  110180. private static _GetNativeTextureFormat;
  110181. createRenderTargetTexture(size: number | {
  110182. width: number;
  110183. height: number;
  110184. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110185. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110186. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110187. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110188. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  110189. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110190. /**
  110191. * Updates a dynamic vertex buffer.
  110192. * @param vertexBuffer the vertex buffer to update
  110193. * @param data the data used to update the vertex buffer
  110194. * @param byteOffset the byte offset of the data (optional)
  110195. * @param byteLength the byte length of the data (optional)
  110196. */
  110197. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110198. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  110199. private _updateAnisotropicLevel;
  110200. private _getAddressMode;
  110201. /** @hidden */
  110202. _bindTexture(channel: number, texture: InternalTexture): void;
  110203. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  110204. releaseEffects(): void;
  110205. /** @hidden */
  110206. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110207. /** @hidden */
  110208. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110209. /** @hidden */
  110210. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110211. /** @hidden */
  110212. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110213. }
  110214. }
  110215. declare module BABYLON {
  110216. /**
  110217. * Gather the list of clipboard event types as constants.
  110218. */
  110219. export class ClipboardEventTypes {
  110220. /**
  110221. * The clipboard event is fired when a copy command is active (pressed).
  110222. */
  110223. static readonly COPY: number;
  110224. /**
  110225. * The clipboard event is fired when a cut command is active (pressed).
  110226. */
  110227. static readonly CUT: number;
  110228. /**
  110229. * The clipboard event is fired when a paste command is active (pressed).
  110230. */
  110231. static readonly PASTE: number;
  110232. }
  110233. /**
  110234. * This class is used to store clipboard related info for the onClipboardObservable event.
  110235. */
  110236. export class ClipboardInfo {
  110237. /**
  110238. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110239. */
  110240. type: number;
  110241. /**
  110242. * Defines the related dom event
  110243. */
  110244. event: ClipboardEvent;
  110245. /**
  110246. *Creates an instance of ClipboardInfo.
  110247. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  110248. * @param event Defines the related dom event
  110249. */
  110250. constructor(
  110251. /**
  110252. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110253. */
  110254. type: number,
  110255. /**
  110256. * Defines the related dom event
  110257. */
  110258. event: ClipboardEvent);
  110259. /**
  110260. * Get the clipboard event's type from the keycode.
  110261. * @param keyCode Defines the keyCode for the current keyboard event.
  110262. * @return {number}
  110263. */
  110264. static GetTypeFromCharacter(keyCode: number): number;
  110265. }
  110266. }
  110267. declare module BABYLON {
  110268. /**
  110269. * Google Daydream controller
  110270. */
  110271. export class DaydreamController extends WebVRController {
  110272. /**
  110273. * Base Url for the controller model.
  110274. */
  110275. static MODEL_BASE_URL: string;
  110276. /**
  110277. * File name for the controller model.
  110278. */
  110279. static MODEL_FILENAME: string;
  110280. /**
  110281. * Gamepad Id prefix used to identify Daydream Controller.
  110282. */
  110283. static readonly GAMEPAD_ID_PREFIX: string;
  110284. /**
  110285. * Creates a new DaydreamController from a gamepad
  110286. * @param vrGamepad the gamepad that the controller should be created from
  110287. */
  110288. constructor(vrGamepad: any);
  110289. /**
  110290. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110291. * @param scene scene in which to add meshes
  110292. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110293. */
  110294. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110295. /**
  110296. * Called once for each button that changed state since the last frame
  110297. * @param buttonIdx Which button index changed
  110298. * @param state New state of the button
  110299. * @param changes Which properties on the state changed since last frame
  110300. */
  110301. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110302. }
  110303. }
  110304. declare module BABYLON {
  110305. /**
  110306. * Gear VR Controller
  110307. */
  110308. export class GearVRController extends WebVRController {
  110309. /**
  110310. * Base Url for the controller model.
  110311. */
  110312. static MODEL_BASE_URL: string;
  110313. /**
  110314. * File name for the controller model.
  110315. */
  110316. static MODEL_FILENAME: string;
  110317. /**
  110318. * Gamepad Id prefix used to identify this controller.
  110319. */
  110320. static readonly GAMEPAD_ID_PREFIX: string;
  110321. private readonly _buttonIndexToObservableNameMap;
  110322. /**
  110323. * Creates a new GearVRController from a gamepad
  110324. * @param vrGamepad the gamepad that the controller should be created from
  110325. */
  110326. constructor(vrGamepad: any);
  110327. /**
  110328. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110329. * @param scene scene in which to add meshes
  110330. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110331. */
  110332. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110333. /**
  110334. * Called once for each button that changed state since the last frame
  110335. * @param buttonIdx Which button index changed
  110336. * @param state New state of the button
  110337. * @param changes Which properties on the state changed since last frame
  110338. */
  110339. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110340. }
  110341. }
  110342. declare module BABYLON {
  110343. /**
  110344. * Class containing static functions to help procedurally build meshes
  110345. */
  110346. export class PolyhedronBuilder {
  110347. /**
  110348. * Creates a polyhedron mesh
  110349. * * 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
  110350. * * The parameter `size` (positive float, default 1) sets the polygon size
  110351. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110352. * * 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`
  110353. * * 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
  110354. * * 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)`)
  110355. * * 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
  110356. * * 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
  110357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110360. * @param name defines the name of the mesh
  110361. * @param options defines the options used to create the mesh
  110362. * @param scene defines the hosting scene
  110363. * @returns the polyhedron mesh
  110364. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110365. */
  110366. static CreatePolyhedron(name: string, options: {
  110367. type?: number;
  110368. size?: number;
  110369. sizeX?: number;
  110370. sizeY?: number;
  110371. sizeZ?: number;
  110372. custom?: any;
  110373. faceUV?: Vector4[];
  110374. faceColors?: Color4[];
  110375. flat?: boolean;
  110376. updatable?: boolean;
  110377. sideOrientation?: number;
  110378. frontUVs?: Vector4;
  110379. backUVs?: Vector4;
  110380. }, scene?: Nullable<Scene>): Mesh;
  110381. }
  110382. }
  110383. declare module BABYLON {
  110384. /**
  110385. * Gizmo that enables scaling a mesh along 3 axis
  110386. */
  110387. export class ScaleGizmo extends Gizmo {
  110388. /**
  110389. * Internal gizmo used for interactions on the x axis
  110390. */
  110391. xGizmo: AxisScaleGizmo;
  110392. /**
  110393. * Internal gizmo used for interactions on the y axis
  110394. */
  110395. yGizmo: AxisScaleGizmo;
  110396. /**
  110397. * Internal gizmo used for interactions on the z axis
  110398. */
  110399. zGizmo: AxisScaleGizmo;
  110400. /**
  110401. * Internal gizmo used to scale all axis equally
  110402. */
  110403. uniformScaleGizmo: AxisScaleGizmo;
  110404. private _meshAttached;
  110405. private _updateGizmoRotationToMatchAttachedMesh;
  110406. private _snapDistance;
  110407. private _scaleRatio;
  110408. private _uniformScalingMesh;
  110409. private _octahedron;
  110410. /** Fires an event when any of it's sub gizmos are dragged */
  110411. onDragStartObservable: Observable<unknown>;
  110412. /** Fires an event when any of it's sub gizmos are released from dragging */
  110413. onDragEndObservable: Observable<unknown>;
  110414. attachedMesh: Nullable<AbstractMesh>;
  110415. /**
  110416. * Creates a ScaleGizmo
  110417. * @param gizmoLayer The utility layer the gizmo will be added to
  110418. */
  110419. constructor(gizmoLayer?: UtilityLayerRenderer);
  110420. updateGizmoRotationToMatchAttachedMesh: boolean;
  110421. /**
  110422. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110423. */
  110424. snapDistance: number;
  110425. /**
  110426. * Ratio for the scale of the gizmo (Default: 1)
  110427. */
  110428. scaleRatio: number;
  110429. /**
  110430. * Disposes of the gizmo
  110431. */
  110432. dispose(): void;
  110433. }
  110434. }
  110435. declare module BABYLON {
  110436. /**
  110437. * Single axis scale gizmo
  110438. */
  110439. export class AxisScaleGizmo extends Gizmo {
  110440. /**
  110441. * Drag behavior responsible for the gizmos dragging interactions
  110442. */
  110443. dragBehavior: PointerDragBehavior;
  110444. private _pointerObserver;
  110445. /**
  110446. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110447. */
  110448. snapDistance: number;
  110449. /**
  110450. * Event that fires each time the gizmo snaps to a new location.
  110451. * * snapDistance is the the change in distance
  110452. */
  110453. onSnapObservable: Observable<{
  110454. snapDistance: number;
  110455. }>;
  110456. /**
  110457. * If the scaling operation should be done on all axis (default: false)
  110458. */
  110459. uniformScaling: boolean;
  110460. private _isEnabled;
  110461. private _parent;
  110462. private _arrow;
  110463. private _coloredMaterial;
  110464. private _hoverMaterial;
  110465. /**
  110466. * Creates an AxisScaleGizmo
  110467. * @param gizmoLayer The utility layer the gizmo will be added to
  110468. * @param dragAxis The axis which the gizmo will be able to scale on
  110469. * @param color The color of the gizmo
  110470. */
  110471. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  110472. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110473. /**
  110474. * If the gizmo is enabled
  110475. */
  110476. isEnabled: boolean;
  110477. /**
  110478. * Disposes of the gizmo
  110479. */
  110480. dispose(): void;
  110481. /**
  110482. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110483. * @param mesh The mesh to replace the default mesh of the gizmo
  110484. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  110485. */
  110486. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  110487. }
  110488. }
  110489. declare module BABYLON {
  110490. /**
  110491. * Bounding box gizmo
  110492. */
  110493. export class BoundingBoxGizmo extends Gizmo {
  110494. private _lineBoundingBox;
  110495. private _rotateSpheresParent;
  110496. private _scaleBoxesParent;
  110497. private _boundingDimensions;
  110498. private _renderObserver;
  110499. private _pointerObserver;
  110500. private _scaleDragSpeed;
  110501. private _tmpQuaternion;
  110502. private _tmpVector;
  110503. private _tmpRotationMatrix;
  110504. /**
  110505. * 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)
  110506. */
  110507. ignoreChildren: boolean;
  110508. /**
  110509. * 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)
  110510. */
  110511. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  110512. /**
  110513. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  110514. */
  110515. rotationSphereSize: number;
  110516. /**
  110517. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  110518. */
  110519. scaleBoxSize: number;
  110520. /**
  110521. * 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)
  110522. */
  110523. fixedDragMeshScreenSize: boolean;
  110524. /**
  110525. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  110526. */
  110527. fixedDragMeshScreenSizeDistanceFactor: number;
  110528. /**
  110529. * Fired when a rotation sphere or scale box is dragged
  110530. */
  110531. onDragStartObservable: Observable<{}>;
  110532. /**
  110533. * Fired when a scale box is dragged
  110534. */
  110535. onScaleBoxDragObservable: Observable<{}>;
  110536. /**
  110537. * Fired when a scale box drag is ended
  110538. */
  110539. onScaleBoxDragEndObservable: Observable<{}>;
  110540. /**
  110541. * Fired when a rotation sphere is dragged
  110542. */
  110543. onRotationSphereDragObservable: Observable<{}>;
  110544. /**
  110545. * Fired when a rotation sphere drag is ended
  110546. */
  110547. onRotationSphereDragEndObservable: Observable<{}>;
  110548. /**
  110549. * 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)
  110550. */
  110551. scalePivot: Nullable<Vector3>;
  110552. /**
  110553. * Mesh used as a pivot to rotate the attached mesh
  110554. */
  110555. private _anchorMesh;
  110556. private _existingMeshScale;
  110557. private _dragMesh;
  110558. private pointerDragBehavior;
  110559. private coloredMaterial;
  110560. private hoverColoredMaterial;
  110561. /**
  110562. * Sets the color of the bounding box gizmo
  110563. * @param color the color to set
  110564. */
  110565. setColor(color: Color3): void;
  110566. /**
  110567. * Creates an BoundingBoxGizmo
  110568. * @param gizmoLayer The utility layer the gizmo will be added to
  110569. * @param color The color of the gizmo
  110570. */
  110571. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  110572. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110573. private _selectNode;
  110574. /**
  110575. * Updates the bounding box information for the Gizmo
  110576. */
  110577. updateBoundingBox(): void;
  110578. private _updateRotationSpheres;
  110579. private _updateScaleBoxes;
  110580. /**
  110581. * Enables rotation on the specified axis and disables rotation on the others
  110582. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  110583. */
  110584. setEnabledRotationAxis(axis: string): void;
  110585. /**
  110586. * Enables/disables scaling
  110587. * @param enable if scaling should be enabled
  110588. */
  110589. setEnabledScaling(enable: boolean): void;
  110590. private _updateDummy;
  110591. /**
  110592. * Enables a pointer drag behavior on the bounding box of the gizmo
  110593. */
  110594. enableDragBehavior(): void;
  110595. /**
  110596. * Disposes of the gizmo
  110597. */
  110598. dispose(): void;
  110599. /**
  110600. * 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)
  110601. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  110602. * @returns the bounding box mesh with the passed in mesh as a child
  110603. */
  110604. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  110605. /**
  110606. * CustomMeshes are not supported by this gizmo
  110607. * @param mesh The mesh to replace the default mesh of the gizmo
  110608. */
  110609. setCustomMesh(mesh: Mesh): void;
  110610. }
  110611. }
  110612. declare module BABYLON {
  110613. /**
  110614. * Single plane rotation gizmo
  110615. */
  110616. export class PlaneRotationGizmo extends Gizmo {
  110617. /**
  110618. * Drag behavior responsible for the gizmos dragging interactions
  110619. */
  110620. dragBehavior: PointerDragBehavior;
  110621. private _pointerObserver;
  110622. /**
  110623. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  110624. */
  110625. snapDistance: number;
  110626. /**
  110627. * Event that fires each time the gizmo snaps to a new location.
  110628. * * snapDistance is the the change in distance
  110629. */
  110630. onSnapObservable: Observable<{
  110631. snapDistance: number;
  110632. }>;
  110633. private _isEnabled;
  110634. private _parent;
  110635. /**
  110636. * Creates a PlaneRotationGizmo
  110637. * @param gizmoLayer The utility layer the gizmo will be added to
  110638. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  110639. * @param color The color of the gizmo
  110640. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110641. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110642. */
  110643. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  110644. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110645. /**
  110646. * If the gizmo is enabled
  110647. */
  110648. isEnabled: boolean;
  110649. /**
  110650. * Disposes of the gizmo
  110651. */
  110652. dispose(): void;
  110653. }
  110654. }
  110655. declare module BABYLON {
  110656. /**
  110657. * Gizmo that enables rotating a mesh along 3 axis
  110658. */
  110659. export class RotationGizmo extends Gizmo {
  110660. /**
  110661. * Internal gizmo used for interactions on the x axis
  110662. */
  110663. xGizmo: PlaneRotationGizmo;
  110664. /**
  110665. * Internal gizmo used for interactions on the y axis
  110666. */
  110667. yGizmo: PlaneRotationGizmo;
  110668. /**
  110669. * Internal gizmo used for interactions on the z axis
  110670. */
  110671. zGizmo: PlaneRotationGizmo;
  110672. /** Fires an event when any of it's sub gizmos are dragged */
  110673. onDragStartObservable: Observable<unknown>;
  110674. /** Fires an event when any of it's sub gizmos are released from dragging */
  110675. onDragEndObservable: Observable<unknown>;
  110676. private _meshAttached;
  110677. attachedMesh: Nullable<AbstractMesh>;
  110678. /**
  110679. * Creates a RotationGizmo
  110680. * @param gizmoLayer The utility layer the gizmo will be added to
  110681. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110682. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110683. */
  110684. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  110685. updateGizmoRotationToMatchAttachedMesh: boolean;
  110686. /**
  110687. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110688. */
  110689. snapDistance: number;
  110690. /**
  110691. * Ratio for the scale of the gizmo (Default: 1)
  110692. */
  110693. scaleRatio: number;
  110694. /**
  110695. * Disposes of the gizmo
  110696. */
  110697. dispose(): void;
  110698. /**
  110699. * CustomMeshes are not supported by this gizmo
  110700. * @param mesh The mesh to replace the default mesh of the gizmo
  110701. */
  110702. setCustomMesh(mesh: Mesh): void;
  110703. }
  110704. }
  110705. declare module BABYLON {
  110706. /**
  110707. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  110708. */
  110709. export class GizmoManager implements IDisposable {
  110710. private scene;
  110711. /**
  110712. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  110713. */
  110714. gizmos: {
  110715. positionGizmo: Nullable<PositionGizmo>;
  110716. rotationGizmo: Nullable<RotationGizmo>;
  110717. scaleGizmo: Nullable<ScaleGizmo>;
  110718. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  110719. };
  110720. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  110721. clearGizmoOnEmptyPointerEvent: boolean;
  110722. /** Fires an event when the manager is attached to a mesh */
  110723. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  110724. private _gizmosEnabled;
  110725. private _pointerObserver;
  110726. private _attachedMesh;
  110727. private _boundingBoxColor;
  110728. private _defaultUtilityLayer;
  110729. private _defaultKeepDepthUtilityLayer;
  110730. /**
  110731. * When bounding box gizmo is enabled, this can be used to track drag/end events
  110732. */
  110733. boundingBoxDragBehavior: SixDofDragBehavior;
  110734. /**
  110735. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  110736. */
  110737. attachableMeshes: Nullable<Array<AbstractMesh>>;
  110738. /**
  110739. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  110740. */
  110741. usePointerToAttachGizmos: boolean;
  110742. /**
  110743. * Utility layer that the bounding box gizmo belongs to
  110744. */
  110745. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  110746. /**
  110747. * Utility layer that all gizmos besides bounding box belong to
  110748. */
  110749. readonly utilityLayer: UtilityLayerRenderer;
  110750. /**
  110751. * Instatiates a gizmo manager
  110752. * @param scene the scene to overlay the gizmos on top of
  110753. */
  110754. constructor(scene: Scene);
  110755. /**
  110756. * Attaches a set of gizmos to the specified mesh
  110757. * @param mesh The mesh the gizmo's should be attached to
  110758. */
  110759. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  110760. /**
  110761. * If the position gizmo is enabled
  110762. */
  110763. positionGizmoEnabled: boolean;
  110764. /**
  110765. * If the rotation gizmo is enabled
  110766. */
  110767. rotationGizmoEnabled: boolean;
  110768. /**
  110769. * If the scale gizmo is enabled
  110770. */
  110771. scaleGizmoEnabled: boolean;
  110772. /**
  110773. * If the boundingBox gizmo is enabled
  110774. */
  110775. boundingBoxGizmoEnabled: boolean;
  110776. /**
  110777. * Disposes of the gizmo manager
  110778. */
  110779. dispose(): void;
  110780. }
  110781. }
  110782. declare module BABYLON {
  110783. /**
  110784. * A directional light is defined by a direction (what a surprise!).
  110785. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  110786. * 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.
  110787. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110788. */
  110789. export class DirectionalLight extends ShadowLight {
  110790. private _shadowFrustumSize;
  110791. /**
  110792. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  110793. */
  110794. /**
  110795. * Specifies a fix frustum size for the shadow generation.
  110796. */
  110797. shadowFrustumSize: number;
  110798. private _shadowOrthoScale;
  110799. /**
  110800. * Gets the shadow projection scale against the optimal computed one.
  110801. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110802. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110803. */
  110804. /**
  110805. * Sets the shadow projection scale against the optimal computed one.
  110806. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110807. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110808. */
  110809. shadowOrthoScale: number;
  110810. /**
  110811. * Automatically compute the projection matrix to best fit (including all the casters)
  110812. * on each frame.
  110813. */
  110814. autoUpdateExtends: boolean;
  110815. private _orthoLeft;
  110816. private _orthoRight;
  110817. private _orthoTop;
  110818. private _orthoBottom;
  110819. /**
  110820. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  110821. * The directional light is emitted from everywhere in the given direction.
  110822. * It can cast shadows.
  110823. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110824. * @param name The friendly name of the light
  110825. * @param direction The direction of the light
  110826. * @param scene The scene the light belongs to
  110827. */
  110828. constructor(name: string, direction: Vector3, scene: Scene);
  110829. /**
  110830. * Returns the string "DirectionalLight".
  110831. * @return The class name
  110832. */
  110833. getClassName(): string;
  110834. /**
  110835. * Returns the integer 1.
  110836. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110837. */
  110838. getTypeID(): number;
  110839. /**
  110840. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  110841. * Returns the DirectionalLight Shadow projection matrix.
  110842. */
  110843. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110844. /**
  110845. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  110846. * Returns the DirectionalLight Shadow projection matrix.
  110847. */
  110848. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  110849. /**
  110850. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  110851. * Returns the DirectionalLight Shadow projection matrix.
  110852. */
  110853. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110854. protected _buildUniformLayout(): void;
  110855. /**
  110856. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  110857. * @param effect The effect to update
  110858. * @param lightIndex The index of the light in the effect to update
  110859. * @returns The directional light
  110860. */
  110861. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  110862. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  110863. /**
  110864. * Gets the minZ used for shadow according to both the scene and the light.
  110865. *
  110866. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110867. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110868. * @param activeCamera The camera we are returning the min for
  110869. * @returns the depth min z
  110870. */
  110871. getDepthMinZ(activeCamera: Camera): number;
  110872. /**
  110873. * Gets the maxZ used for shadow according to both the scene and the light.
  110874. *
  110875. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110876. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110877. * @param activeCamera The camera we are returning the max for
  110878. * @returns the depth max z
  110879. */
  110880. getDepthMaxZ(activeCamera: Camera): number;
  110881. /**
  110882. * Prepares the list of defines specific to the light type.
  110883. * @param defines the list of defines
  110884. * @param lightIndex defines the index of the light for the effect
  110885. */
  110886. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110887. }
  110888. }
  110889. declare module BABYLON {
  110890. /**
  110891. * Class containing static functions to help procedurally build meshes
  110892. */
  110893. export class HemisphereBuilder {
  110894. /**
  110895. * Creates a hemisphere mesh
  110896. * @param name defines the name of the mesh
  110897. * @param options defines the options used to create the mesh
  110898. * @param scene defines the hosting scene
  110899. * @returns the hemisphere mesh
  110900. */
  110901. static CreateHemisphere(name: string, options: {
  110902. segments?: number;
  110903. diameter?: number;
  110904. sideOrientation?: number;
  110905. }, scene: any): Mesh;
  110906. }
  110907. }
  110908. declare module BABYLON {
  110909. /**
  110910. * A spot light is defined by a position, a direction, an angle, and an exponent.
  110911. * These values define a cone of light starting from the position, emitting toward the direction.
  110912. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  110913. * and the exponent defines the speed of the decay of the light with distance (reach).
  110914. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110915. */
  110916. export class SpotLight extends ShadowLight {
  110917. private _angle;
  110918. private _innerAngle;
  110919. private _cosHalfAngle;
  110920. private _lightAngleScale;
  110921. private _lightAngleOffset;
  110922. /**
  110923. * Gets the cone angle of the spot light in Radians.
  110924. */
  110925. /**
  110926. * Sets the cone angle of the spot light in Radians.
  110927. */
  110928. angle: number;
  110929. /**
  110930. * Only used in gltf falloff mode, this defines the angle where
  110931. * the directional falloff will start before cutting at angle which could be seen
  110932. * as outer angle.
  110933. */
  110934. /**
  110935. * Only used in gltf falloff mode, this defines the angle where
  110936. * the directional falloff will start before cutting at angle which could be seen
  110937. * as outer angle.
  110938. */
  110939. innerAngle: number;
  110940. private _shadowAngleScale;
  110941. /**
  110942. * Allows scaling the angle of the light for shadow generation only.
  110943. */
  110944. /**
  110945. * Allows scaling the angle of the light for shadow generation only.
  110946. */
  110947. shadowAngleScale: number;
  110948. /**
  110949. * The light decay speed with the distance from the emission spot.
  110950. */
  110951. exponent: number;
  110952. private _projectionTextureMatrix;
  110953. /**
  110954. * Allows reading the projecton texture
  110955. */
  110956. readonly projectionTextureMatrix: Matrix;
  110957. protected _projectionTextureLightNear: number;
  110958. /**
  110959. * Gets the near clip of the Spotlight for texture projection.
  110960. */
  110961. /**
  110962. * Sets the near clip of the Spotlight for texture projection.
  110963. */
  110964. projectionTextureLightNear: number;
  110965. protected _projectionTextureLightFar: number;
  110966. /**
  110967. * Gets the far clip of the Spotlight for texture projection.
  110968. */
  110969. /**
  110970. * Sets the far clip of the Spotlight for texture projection.
  110971. */
  110972. projectionTextureLightFar: number;
  110973. protected _projectionTextureUpDirection: Vector3;
  110974. /**
  110975. * Gets the Up vector of the Spotlight for texture projection.
  110976. */
  110977. /**
  110978. * Sets the Up vector of the Spotlight for texture projection.
  110979. */
  110980. projectionTextureUpDirection: Vector3;
  110981. private _projectionTexture;
  110982. /**
  110983. * Gets the projection texture of the light.
  110984. */
  110985. /**
  110986. * Sets the projection texture of the light.
  110987. */
  110988. projectionTexture: Nullable<BaseTexture>;
  110989. private _projectionTextureViewLightDirty;
  110990. private _projectionTextureProjectionLightDirty;
  110991. private _projectionTextureDirty;
  110992. private _projectionTextureViewTargetVector;
  110993. private _projectionTextureViewLightMatrix;
  110994. private _projectionTextureProjectionLightMatrix;
  110995. private _projectionTextureScalingMatrix;
  110996. /**
  110997. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  110998. * It can cast shadows.
  110999. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111000. * @param name The light friendly name
  111001. * @param position The position of the spot light in the scene
  111002. * @param direction The direction of the light in the scene
  111003. * @param angle The cone angle of the light in Radians
  111004. * @param exponent The light decay speed with the distance from the emission spot
  111005. * @param scene The scene the lights belongs to
  111006. */
  111007. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  111008. /**
  111009. * Returns the string "SpotLight".
  111010. * @returns the class name
  111011. */
  111012. getClassName(): string;
  111013. /**
  111014. * Returns the integer 2.
  111015. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111016. */
  111017. getTypeID(): number;
  111018. /**
  111019. * Overrides the direction setter to recompute the projection texture view light Matrix.
  111020. */
  111021. protected _setDirection(value: Vector3): void;
  111022. /**
  111023. * Overrides the position setter to recompute the projection texture view light Matrix.
  111024. */
  111025. protected _setPosition(value: Vector3): void;
  111026. /**
  111027. * 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.
  111028. * Returns the SpotLight.
  111029. */
  111030. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111031. protected _computeProjectionTextureViewLightMatrix(): void;
  111032. protected _computeProjectionTextureProjectionLightMatrix(): void;
  111033. /**
  111034. * Main function for light texture projection matrix computing.
  111035. */
  111036. protected _computeProjectionTextureMatrix(): void;
  111037. protected _buildUniformLayout(): void;
  111038. private _computeAngleValues;
  111039. /**
  111040. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  111041. * @param effect The effect to update
  111042. * @param lightIndex The index of the light in the effect to update
  111043. * @returns The spot light
  111044. */
  111045. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  111046. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  111047. /**
  111048. * Disposes the light and the associated resources.
  111049. */
  111050. dispose(): void;
  111051. /**
  111052. * Prepares the list of defines specific to the light type.
  111053. * @param defines the list of defines
  111054. * @param lightIndex defines the index of the light for the effect
  111055. */
  111056. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111057. }
  111058. }
  111059. declare module BABYLON {
  111060. /**
  111061. * Gizmo that enables viewing a light
  111062. */
  111063. export class LightGizmo extends Gizmo {
  111064. private _lightMesh;
  111065. private _material;
  111066. private cachedPosition;
  111067. private cachedForward;
  111068. /**
  111069. * Creates a LightGizmo
  111070. * @param gizmoLayer The utility layer the gizmo will be added to
  111071. */
  111072. constructor(gizmoLayer?: UtilityLayerRenderer);
  111073. private _light;
  111074. /**
  111075. * The light that the gizmo is attached to
  111076. */
  111077. light: Nullable<Light>;
  111078. /**
  111079. * Gets the material used to render the light gizmo
  111080. */
  111081. readonly material: StandardMaterial;
  111082. /**
  111083. * @hidden
  111084. * Updates the gizmo to match the attached mesh's position/rotation
  111085. */
  111086. protected _update(): void;
  111087. private static _Scale;
  111088. /**
  111089. * Creates the lines for a light mesh
  111090. */
  111091. private static _createLightLines;
  111092. /**
  111093. * Disposes of the light gizmo
  111094. */
  111095. dispose(): void;
  111096. private static _CreateHemisphericLightMesh;
  111097. private static _CreatePointLightMesh;
  111098. private static _CreateSpotLightMesh;
  111099. private static _CreateDirectionalLightMesh;
  111100. }
  111101. }
  111102. declare module BABYLON {
  111103. /** @hidden */
  111104. export var backgroundFragmentDeclaration: {
  111105. name: string;
  111106. shader: string;
  111107. };
  111108. }
  111109. declare module BABYLON {
  111110. /** @hidden */
  111111. export var backgroundUboDeclaration: {
  111112. name: string;
  111113. shader: string;
  111114. };
  111115. }
  111116. declare module BABYLON {
  111117. /** @hidden */
  111118. export var backgroundPixelShader: {
  111119. name: string;
  111120. shader: string;
  111121. };
  111122. }
  111123. declare module BABYLON {
  111124. /** @hidden */
  111125. export var backgroundVertexDeclaration: {
  111126. name: string;
  111127. shader: string;
  111128. };
  111129. }
  111130. declare module BABYLON {
  111131. /** @hidden */
  111132. export var backgroundVertexShader: {
  111133. name: string;
  111134. shader: string;
  111135. };
  111136. }
  111137. declare module BABYLON {
  111138. /**
  111139. * Background material used to create an efficient environement around your scene.
  111140. */
  111141. export class BackgroundMaterial extends PushMaterial {
  111142. /**
  111143. * Standard reflectance value at parallel view angle.
  111144. */
  111145. static StandardReflectance0: number;
  111146. /**
  111147. * Standard reflectance value at grazing angle.
  111148. */
  111149. static StandardReflectance90: number;
  111150. protected _primaryColor: Color3;
  111151. /**
  111152. * Key light Color (multiply against the environement texture)
  111153. */
  111154. primaryColor: Color3;
  111155. protected __perceptualColor: Nullable<Color3>;
  111156. /**
  111157. * Experimental Internal Use Only.
  111158. *
  111159. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  111160. * This acts as a helper to set the primary color to a more "human friendly" value.
  111161. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  111162. * output color as close as possible from the chosen value.
  111163. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  111164. * part of lighting setup.)
  111165. */
  111166. _perceptualColor: Nullable<Color3>;
  111167. protected _primaryColorShadowLevel: float;
  111168. /**
  111169. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  111170. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  111171. */
  111172. primaryColorShadowLevel: float;
  111173. protected _primaryColorHighlightLevel: float;
  111174. /**
  111175. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  111176. * The primary color is used at the level chosen to define what the white area would look.
  111177. */
  111178. primaryColorHighlightLevel: float;
  111179. protected _reflectionTexture: Nullable<BaseTexture>;
  111180. /**
  111181. * Reflection Texture used in the material.
  111182. * Should be author in a specific way for the best result (refer to the documentation).
  111183. */
  111184. reflectionTexture: Nullable<BaseTexture>;
  111185. protected _reflectionBlur: float;
  111186. /**
  111187. * Reflection Texture level of blur.
  111188. *
  111189. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  111190. * texture twice.
  111191. */
  111192. reflectionBlur: float;
  111193. protected _diffuseTexture: Nullable<BaseTexture>;
  111194. /**
  111195. * Diffuse Texture used in the material.
  111196. * Should be author in a specific way for the best result (refer to the documentation).
  111197. */
  111198. diffuseTexture: Nullable<BaseTexture>;
  111199. protected _shadowLights: Nullable<IShadowLight[]>;
  111200. /**
  111201. * Specify the list of lights casting shadow on the material.
  111202. * All scene shadow lights will be included if null.
  111203. */
  111204. shadowLights: Nullable<IShadowLight[]>;
  111205. protected _shadowLevel: float;
  111206. /**
  111207. * Helps adjusting the shadow to a softer level if required.
  111208. * 0 means black shadows and 1 means no shadows.
  111209. */
  111210. shadowLevel: float;
  111211. protected _sceneCenter: Vector3;
  111212. /**
  111213. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  111214. * It is usually zero but might be interesting to modify according to your setup.
  111215. */
  111216. sceneCenter: Vector3;
  111217. protected _opacityFresnel: boolean;
  111218. /**
  111219. * This helps specifying that the material is falling off to the sky box at grazing angle.
  111220. * This helps ensuring a nice transition when the camera goes under the ground.
  111221. */
  111222. opacityFresnel: boolean;
  111223. protected _reflectionFresnel: boolean;
  111224. /**
  111225. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  111226. * This helps adding a mirror texture on the ground.
  111227. */
  111228. reflectionFresnel: boolean;
  111229. protected _reflectionFalloffDistance: number;
  111230. /**
  111231. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  111232. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  111233. */
  111234. reflectionFalloffDistance: number;
  111235. protected _reflectionAmount: number;
  111236. /**
  111237. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  111238. */
  111239. reflectionAmount: number;
  111240. protected _reflectionReflectance0: number;
  111241. /**
  111242. * This specifies the weight of the reflection at grazing angle.
  111243. */
  111244. reflectionReflectance0: number;
  111245. protected _reflectionReflectance90: number;
  111246. /**
  111247. * This specifies the weight of the reflection at a perpendicular point of view.
  111248. */
  111249. reflectionReflectance90: number;
  111250. /**
  111251. * Sets the reflection reflectance fresnel values according to the default standard
  111252. * empirically know to work well :-)
  111253. */
  111254. reflectionStandardFresnelWeight: number;
  111255. protected _useRGBColor: boolean;
  111256. /**
  111257. * Helps to directly use the maps channels instead of their level.
  111258. */
  111259. useRGBColor: boolean;
  111260. protected _enableNoise: boolean;
  111261. /**
  111262. * This helps reducing the banding effect that could occur on the background.
  111263. */
  111264. enableNoise: boolean;
  111265. /**
  111266. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111267. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  111268. * Recommended to be keep at 1.0 except for special cases.
  111269. */
  111270. fovMultiplier: number;
  111271. private _fovMultiplier;
  111272. /**
  111273. * Enable the FOV adjustment feature controlled by fovMultiplier.
  111274. */
  111275. useEquirectangularFOV: boolean;
  111276. private _maxSimultaneousLights;
  111277. /**
  111278. * Number of Simultaneous lights allowed on the material.
  111279. */
  111280. maxSimultaneousLights: int;
  111281. /**
  111282. * Default configuration related to image processing available in the Background Material.
  111283. */
  111284. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111285. /**
  111286. * Keep track of the image processing observer to allow dispose and replace.
  111287. */
  111288. private _imageProcessingObserver;
  111289. /**
  111290. * Attaches a new image processing configuration to the PBR Material.
  111291. * @param configuration (if null the scene configuration will be use)
  111292. */
  111293. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111294. /**
  111295. * Gets the image processing configuration used either in this material.
  111296. */
  111297. /**
  111298. * Sets the Default image processing configuration used either in the this material.
  111299. *
  111300. * If sets to null, the scene one is in use.
  111301. */
  111302. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  111303. /**
  111304. * Gets wether the color curves effect is enabled.
  111305. */
  111306. /**
  111307. * Sets wether the color curves effect is enabled.
  111308. */
  111309. cameraColorCurvesEnabled: boolean;
  111310. /**
  111311. * Gets wether the color grading effect is enabled.
  111312. */
  111313. /**
  111314. * Gets wether the color grading effect is enabled.
  111315. */
  111316. cameraColorGradingEnabled: boolean;
  111317. /**
  111318. * Gets wether tonemapping is enabled or not.
  111319. */
  111320. /**
  111321. * Sets wether tonemapping is enabled or not
  111322. */
  111323. cameraToneMappingEnabled: boolean;
  111324. /**
  111325. * The camera exposure used on this material.
  111326. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111327. * This corresponds to a photographic exposure.
  111328. */
  111329. /**
  111330. * The camera exposure used on this material.
  111331. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111332. * This corresponds to a photographic exposure.
  111333. */
  111334. cameraExposure: float;
  111335. /**
  111336. * Gets The camera contrast used on this material.
  111337. */
  111338. /**
  111339. * Sets The camera contrast used on this material.
  111340. */
  111341. cameraContrast: float;
  111342. /**
  111343. * Gets the Color Grading 2D Lookup Texture.
  111344. */
  111345. /**
  111346. * Sets the Color Grading 2D Lookup Texture.
  111347. */
  111348. cameraColorGradingTexture: Nullable<BaseTexture>;
  111349. /**
  111350. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111351. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111352. * 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;
  111353. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111354. */
  111355. /**
  111356. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111357. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111358. * 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;
  111359. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111360. */
  111361. cameraColorCurves: Nullable<ColorCurves>;
  111362. /**
  111363. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  111364. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  111365. */
  111366. switchToBGR: boolean;
  111367. private _renderTargets;
  111368. private _reflectionControls;
  111369. private _white;
  111370. private _primaryShadowColor;
  111371. private _primaryHighlightColor;
  111372. /**
  111373. * Instantiates a Background Material in the given scene
  111374. * @param name The friendly name of the material
  111375. * @param scene The scene to add the material to
  111376. */
  111377. constructor(name: string, scene: Scene);
  111378. /**
  111379. * Gets a boolean indicating that current material needs to register RTT
  111380. */
  111381. readonly hasRenderTargetTextures: boolean;
  111382. /**
  111383. * The entire material has been created in order to prevent overdraw.
  111384. * @returns false
  111385. */
  111386. needAlphaTesting(): boolean;
  111387. /**
  111388. * The entire material has been created in order to prevent overdraw.
  111389. * @returns true if blending is enable
  111390. */
  111391. needAlphaBlending(): boolean;
  111392. /**
  111393. * Checks wether the material is ready to be rendered for a given mesh.
  111394. * @param mesh The mesh to render
  111395. * @param subMesh The submesh to check against
  111396. * @param useInstances Specify wether or not the material is used with instances
  111397. * @returns true if all the dependencies are ready (Textures, Effects...)
  111398. */
  111399. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111400. /**
  111401. * Compute the primary color according to the chosen perceptual color.
  111402. */
  111403. private _computePrimaryColorFromPerceptualColor;
  111404. /**
  111405. * Compute the highlights and shadow colors according to their chosen levels.
  111406. */
  111407. private _computePrimaryColors;
  111408. /**
  111409. * Build the uniform buffer used in the material.
  111410. */
  111411. buildUniformLayout(): void;
  111412. /**
  111413. * Unbind the material.
  111414. */
  111415. unbind(): void;
  111416. /**
  111417. * Bind only the world matrix to the material.
  111418. * @param world The world matrix to bind.
  111419. */
  111420. bindOnlyWorldMatrix(world: Matrix): void;
  111421. /**
  111422. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  111423. * @param world The world matrix to bind.
  111424. * @param subMesh The submesh to bind for.
  111425. */
  111426. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111427. /**
  111428. * Checks to see if a texture is used in the material.
  111429. * @param texture - Base texture to use.
  111430. * @returns - Boolean specifying if a texture is used in the material.
  111431. */
  111432. hasTexture(texture: BaseTexture): boolean;
  111433. /**
  111434. * Dispose the material.
  111435. * @param forceDisposeEffect Force disposal of the associated effect.
  111436. * @param forceDisposeTextures Force disposal of the associated textures.
  111437. */
  111438. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111439. /**
  111440. * Clones the material.
  111441. * @param name The cloned name.
  111442. * @returns The cloned material.
  111443. */
  111444. clone(name: string): BackgroundMaterial;
  111445. /**
  111446. * Serializes the current material to its JSON representation.
  111447. * @returns The JSON representation.
  111448. */
  111449. serialize(): any;
  111450. /**
  111451. * Gets the class name of the material
  111452. * @returns "BackgroundMaterial"
  111453. */
  111454. getClassName(): string;
  111455. /**
  111456. * Parse a JSON input to create back a background material.
  111457. * @param source The JSON data to parse
  111458. * @param scene The scene to create the parsed material in
  111459. * @param rootUrl The root url of the assets the material depends upon
  111460. * @returns the instantiated BackgroundMaterial.
  111461. */
  111462. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  111463. }
  111464. }
  111465. declare module BABYLON {
  111466. /**
  111467. * Represents the different options available during the creation of
  111468. * a Environment helper.
  111469. *
  111470. * This can control the default ground, skybox and image processing setup of your scene.
  111471. */
  111472. export interface IEnvironmentHelperOptions {
  111473. /**
  111474. * Specifies wether or not to create a ground.
  111475. * True by default.
  111476. */
  111477. createGround: boolean;
  111478. /**
  111479. * Specifies the ground size.
  111480. * 15 by default.
  111481. */
  111482. groundSize: number;
  111483. /**
  111484. * The texture used on the ground for the main color.
  111485. * Comes from the BabylonJS CDN by default.
  111486. *
  111487. * Remarks: Can be either a texture or a url.
  111488. */
  111489. groundTexture: string | BaseTexture;
  111490. /**
  111491. * The color mixed in the ground texture by default.
  111492. * BabylonJS clearColor by default.
  111493. */
  111494. groundColor: Color3;
  111495. /**
  111496. * Specifies the ground opacity.
  111497. * 1 by default.
  111498. */
  111499. groundOpacity: number;
  111500. /**
  111501. * Enables the ground to receive shadows.
  111502. * True by default.
  111503. */
  111504. enableGroundShadow: boolean;
  111505. /**
  111506. * Helps preventing the shadow to be fully black on the ground.
  111507. * 0.5 by default.
  111508. */
  111509. groundShadowLevel: number;
  111510. /**
  111511. * Creates a mirror texture attach to the ground.
  111512. * false by default.
  111513. */
  111514. enableGroundMirror: boolean;
  111515. /**
  111516. * Specifies the ground mirror size ratio.
  111517. * 0.3 by default as the default kernel is 64.
  111518. */
  111519. groundMirrorSizeRatio: number;
  111520. /**
  111521. * Specifies the ground mirror blur kernel size.
  111522. * 64 by default.
  111523. */
  111524. groundMirrorBlurKernel: number;
  111525. /**
  111526. * Specifies the ground mirror visibility amount.
  111527. * 1 by default
  111528. */
  111529. groundMirrorAmount: number;
  111530. /**
  111531. * Specifies the ground mirror reflectance weight.
  111532. * This uses the standard weight of the background material to setup the fresnel effect
  111533. * of the mirror.
  111534. * 1 by default.
  111535. */
  111536. groundMirrorFresnelWeight: number;
  111537. /**
  111538. * Specifies the ground mirror Falloff distance.
  111539. * This can helps reducing the size of the reflection.
  111540. * 0 by Default.
  111541. */
  111542. groundMirrorFallOffDistance: number;
  111543. /**
  111544. * Specifies the ground mirror texture type.
  111545. * Unsigned Int by Default.
  111546. */
  111547. groundMirrorTextureType: number;
  111548. /**
  111549. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  111550. * the shown objects.
  111551. */
  111552. groundYBias: number;
  111553. /**
  111554. * Specifies wether or not to create a skybox.
  111555. * True by default.
  111556. */
  111557. createSkybox: boolean;
  111558. /**
  111559. * Specifies the skybox size.
  111560. * 20 by default.
  111561. */
  111562. skyboxSize: number;
  111563. /**
  111564. * The texture used on the skybox for the main color.
  111565. * Comes from the BabylonJS CDN by default.
  111566. *
  111567. * Remarks: Can be either a texture or a url.
  111568. */
  111569. skyboxTexture: string | BaseTexture;
  111570. /**
  111571. * The color mixed in the skybox texture by default.
  111572. * BabylonJS clearColor by default.
  111573. */
  111574. skyboxColor: Color3;
  111575. /**
  111576. * The background rotation around the Y axis of the scene.
  111577. * This helps aligning the key lights of your scene with the background.
  111578. * 0 by default.
  111579. */
  111580. backgroundYRotation: number;
  111581. /**
  111582. * Compute automatically the size of the elements to best fit with the scene.
  111583. */
  111584. sizeAuto: boolean;
  111585. /**
  111586. * Default position of the rootMesh if autoSize is not true.
  111587. */
  111588. rootPosition: Vector3;
  111589. /**
  111590. * Sets up the image processing in the scene.
  111591. * true by default.
  111592. */
  111593. setupImageProcessing: boolean;
  111594. /**
  111595. * The texture used as your environment texture in the scene.
  111596. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  111597. *
  111598. * Remarks: Can be either a texture or a url.
  111599. */
  111600. environmentTexture: string | BaseTexture;
  111601. /**
  111602. * The value of the exposure to apply to the scene.
  111603. * 0.6 by default if setupImageProcessing is true.
  111604. */
  111605. cameraExposure: number;
  111606. /**
  111607. * The value of the contrast to apply to the scene.
  111608. * 1.6 by default if setupImageProcessing is true.
  111609. */
  111610. cameraContrast: number;
  111611. /**
  111612. * Specifies wether or not tonemapping should be enabled in the scene.
  111613. * true by default if setupImageProcessing is true.
  111614. */
  111615. toneMappingEnabled: boolean;
  111616. }
  111617. /**
  111618. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  111619. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  111620. * It also helps with the default setup of your imageProcessing configuration.
  111621. */
  111622. export class EnvironmentHelper {
  111623. /**
  111624. * Default ground texture URL.
  111625. */
  111626. private static _groundTextureCDNUrl;
  111627. /**
  111628. * Default skybox texture URL.
  111629. */
  111630. private static _skyboxTextureCDNUrl;
  111631. /**
  111632. * Default environment texture URL.
  111633. */
  111634. private static _environmentTextureCDNUrl;
  111635. /**
  111636. * Creates the default options for the helper.
  111637. */
  111638. private static _getDefaultOptions;
  111639. private _rootMesh;
  111640. /**
  111641. * Gets the root mesh created by the helper.
  111642. */
  111643. readonly rootMesh: Mesh;
  111644. private _skybox;
  111645. /**
  111646. * Gets the skybox created by the helper.
  111647. */
  111648. readonly skybox: Nullable<Mesh>;
  111649. private _skyboxTexture;
  111650. /**
  111651. * Gets the skybox texture created by the helper.
  111652. */
  111653. readonly skyboxTexture: Nullable<BaseTexture>;
  111654. private _skyboxMaterial;
  111655. /**
  111656. * Gets the skybox material created by the helper.
  111657. */
  111658. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  111659. private _ground;
  111660. /**
  111661. * Gets the ground mesh created by the helper.
  111662. */
  111663. readonly ground: Nullable<Mesh>;
  111664. private _groundTexture;
  111665. /**
  111666. * Gets the ground texture created by the helper.
  111667. */
  111668. readonly groundTexture: Nullable<BaseTexture>;
  111669. private _groundMirror;
  111670. /**
  111671. * Gets the ground mirror created by the helper.
  111672. */
  111673. readonly groundMirror: Nullable<MirrorTexture>;
  111674. /**
  111675. * Gets the ground mirror render list to helps pushing the meshes
  111676. * you wish in the ground reflection.
  111677. */
  111678. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  111679. private _groundMaterial;
  111680. /**
  111681. * Gets the ground material created by the helper.
  111682. */
  111683. readonly groundMaterial: Nullable<BackgroundMaterial>;
  111684. /**
  111685. * Stores the creation options.
  111686. */
  111687. private readonly _scene;
  111688. private _options;
  111689. /**
  111690. * This observable will be notified with any error during the creation of the environment,
  111691. * mainly texture creation errors.
  111692. */
  111693. onErrorObservable: Observable<{
  111694. message?: string;
  111695. exception?: any;
  111696. }>;
  111697. /**
  111698. * constructor
  111699. * @param options Defines the options we want to customize the helper
  111700. * @param scene The scene to add the material to
  111701. */
  111702. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  111703. /**
  111704. * Updates the background according to the new options
  111705. * @param options
  111706. */
  111707. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  111708. /**
  111709. * Sets the primary color of all the available elements.
  111710. * @param color the main color to affect to the ground and the background
  111711. */
  111712. setMainColor(color: Color3): void;
  111713. /**
  111714. * Setup the image processing according to the specified options.
  111715. */
  111716. private _setupImageProcessing;
  111717. /**
  111718. * Setup the environment texture according to the specified options.
  111719. */
  111720. private _setupEnvironmentTexture;
  111721. /**
  111722. * Setup the background according to the specified options.
  111723. */
  111724. private _setupBackground;
  111725. /**
  111726. * Get the scene sizes according to the setup.
  111727. */
  111728. private _getSceneSize;
  111729. /**
  111730. * Setup the ground according to the specified options.
  111731. */
  111732. private _setupGround;
  111733. /**
  111734. * Setup the ground material according to the specified options.
  111735. */
  111736. private _setupGroundMaterial;
  111737. /**
  111738. * Setup the ground diffuse texture according to the specified options.
  111739. */
  111740. private _setupGroundDiffuseTexture;
  111741. /**
  111742. * Setup the ground mirror texture according to the specified options.
  111743. */
  111744. private _setupGroundMirrorTexture;
  111745. /**
  111746. * Setup the ground to receive the mirror texture.
  111747. */
  111748. private _setupMirrorInGroundMaterial;
  111749. /**
  111750. * Setup the skybox according to the specified options.
  111751. */
  111752. private _setupSkybox;
  111753. /**
  111754. * Setup the skybox material according to the specified options.
  111755. */
  111756. private _setupSkyboxMaterial;
  111757. /**
  111758. * Setup the skybox reflection texture according to the specified options.
  111759. */
  111760. private _setupSkyboxReflectionTexture;
  111761. private _errorHandler;
  111762. /**
  111763. * Dispose all the elements created by the Helper.
  111764. */
  111765. dispose(): void;
  111766. }
  111767. }
  111768. declare module BABYLON {
  111769. /**
  111770. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  111771. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  111772. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  111773. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111774. */
  111775. export class PhotoDome extends TransformNode {
  111776. /**
  111777. * Define the image as a Monoscopic panoramic 360 image.
  111778. */
  111779. static readonly MODE_MONOSCOPIC: number;
  111780. /**
  111781. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111782. */
  111783. static readonly MODE_TOPBOTTOM: number;
  111784. /**
  111785. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111786. */
  111787. static readonly MODE_SIDEBYSIDE: number;
  111788. private _useDirectMapping;
  111789. /**
  111790. * The texture being displayed on the sphere
  111791. */
  111792. protected _photoTexture: Texture;
  111793. /**
  111794. * Gets or sets the texture being displayed on the sphere
  111795. */
  111796. photoTexture: Texture;
  111797. /**
  111798. * Observable raised when an error occured while loading the 360 image
  111799. */
  111800. onLoadErrorObservable: Observable<string>;
  111801. /**
  111802. * The skybox material
  111803. */
  111804. protected _material: BackgroundMaterial;
  111805. /**
  111806. * The surface used for the skybox
  111807. */
  111808. protected _mesh: Mesh;
  111809. /**
  111810. * Gets the mesh used for the skybox.
  111811. */
  111812. readonly mesh: Mesh;
  111813. /**
  111814. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111815. * Also see the options.resolution property.
  111816. */
  111817. fovMultiplier: number;
  111818. private _imageMode;
  111819. /**
  111820. * Gets or set the current video mode for the video. It can be:
  111821. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  111822. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111823. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111824. */
  111825. imageMode: number;
  111826. /**
  111827. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  111828. * @param name Element's name, child elements will append suffixes for their own names.
  111829. * @param urlsOfPhoto defines the url of the photo to display
  111830. * @param options defines an object containing optional or exposed sub element properties
  111831. * @param onError defines a callback called when an error occured while loading the texture
  111832. */
  111833. constructor(name: string, urlOfPhoto: string, options: {
  111834. resolution?: number;
  111835. size?: number;
  111836. useDirectMapping?: boolean;
  111837. faceForward?: boolean;
  111838. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  111839. private _onBeforeCameraRenderObserver;
  111840. private _changeImageMode;
  111841. /**
  111842. * Releases resources associated with this node.
  111843. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111844. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111845. */
  111846. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111847. }
  111848. }
  111849. declare module BABYLON {
  111850. /**
  111851. * Class used to host RGBD texture specific utilities
  111852. */
  111853. export class RGBDTextureTools {
  111854. /**
  111855. * Expand the RGBD Texture from RGBD to Half Float if possible.
  111856. * @param texture the texture to expand.
  111857. */
  111858. static ExpandRGBDTexture(texture: Texture): void;
  111859. }
  111860. }
  111861. declare module BABYLON {
  111862. /**
  111863. * Class used to host texture specific utilities
  111864. */
  111865. export class BRDFTextureTools {
  111866. /**
  111867. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  111868. * @param scene defines the hosting scene
  111869. * @returns the environment BRDF texture
  111870. */
  111871. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  111872. private static _environmentBRDFBase64Texture;
  111873. }
  111874. }
  111875. declare module BABYLON {
  111876. /**
  111877. * @hidden
  111878. */
  111879. export interface IMaterialClearCoatDefines {
  111880. CLEARCOAT: boolean;
  111881. CLEARCOAT_DEFAULTIOR: boolean;
  111882. CLEARCOAT_TEXTURE: boolean;
  111883. CLEARCOAT_TEXTUREDIRECTUV: number;
  111884. CLEARCOAT_BUMP: boolean;
  111885. CLEARCOAT_BUMPDIRECTUV: number;
  111886. CLEARCOAT_TINT: boolean;
  111887. CLEARCOAT_TINT_TEXTURE: boolean;
  111888. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111889. /** @hidden */
  111890. _areTexturesDirty: boolean;
  111891. }
  111892. /**
  111893. * Define the code related to the clear coat parameters of the pbr material.
  111894. */
  111895. export class PBRClearCoatConfiguration {
  111896. /**
  111897. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111898. * The default fits with a polyurethane material.
  111899. */
  111900. private static readonly _DefaultIndexOfRefraction;
  111901. private _isEnabled;
  111902. /**
  111903. * Defines if the clear coat is enabled in the material.
  111904. */
  111905. isEnabled: boolean;
  111906. /**
  111907. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  111908. */
  111909. intensity: number;
  111910. /**
  111911. * Defines the clear coat layer roughness.
  111912. */
  111913. roughness: number;
  111914. private _indexOfRefraction;
  111915. /**
  111916. * Defines the index of refraction of the clear coat.
  111917. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111918. * The default fits with a polyurethane material.
  111919. * Changing the default value is more performance intensive.
  111920. */
  111921. indexOfRefraction: number;
  111922. private _texture;
  111923. /**
  111924. * Stores the clear coat values in a texture.
  111925. */
  111926. texture: Nullable<BaseTexture>;
  111927. private _bumpTexture;
  111928. /**
  111929. * Define the clear coat specific bump texture.
  111930. */
  111931. bumpTexture: Nullable<BaseTexture>;
  111932. private _isTintEnabled;
  111933. /**
  111934. * Defines if the clear coat tint is enabled in the material.
  111935. */
  111936. isTintEnabled: boolean;
  111937. /**
  111938. * Defines the clear coat tint of the material.
  111939. * This is only use if tint is enabled
  111940. */
  111941. tintColor: Color3;
  111942. /**
  111943. * Defines the distance at which the tint color should be found in the
  111944. * clear coat media.
  111945. * This is only use if tint is enabled
  111946. */
  111947. tintColorAtDistance: number;
  111948. /**
  111949. * Defines the clear coat layer thickness.
  111950. * This is only use if tint is enabled
  111951. */
  111952. tintThickness: number;
  111953. private _tintTexture;
  111954. /**
  111955. * Stores the clear tint values in a texture.
  111956. * rgb is tint
  111957. * a is a thickness factor
  111958. */
  111959. tintTexture: Nullable<BaseTexture>;
  111960. /** @hidden */
  111961. private _internalMarkAllSubMeshesAsTexturesDirty;
  111962. /** @hidden */
  111963. _markAllSubMeshesAsTexturesDirty(): void;
  111964. /**
  111965. * Instantiate a new istance of clear coat configuration.
  111966. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111967. */
  111968. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111969. /**
  111970. * Gets wehter the submesh is ready to be used or not.
  111971. * @param defines the list of "defines" to update.
  111972. * @param scene defines the scene the material belongs to.
  111973. * @param engine defines the engine the material belongs to.
  111974. * @param disableBumpMap defines wether the material disables bump or not.
  111975. * @returns - boolean indicating that the submesh is ready or not.
  111976. */
  111977. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  111978. /**
  111979. * Checks to see if a texture is used in the material.
  111980. * @param defines the list of "defines" to update.
  111981. * @param scene defines the scene to the material belongs to.
  111982. */
  111983. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  111984. /**
  111985. * Binds the material data.
  111986. * @param uniformBuffer defines the Uniform buffer to fill in.
  111987. * @param scene defines the scene the material belongs to.
  111988. * @param engine defines the engine the material belongs to.
  111989. * @param disableBumpMap defines wether the material disables bump or not.
  111990. * @param isFrozen defines wether the material is frozen or not.
  111991. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111992. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111993. */
  111994. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  111995. /**
  111996. * Checks to see if a texture is used in the material.
  111997. * @param texture - Base texture to use.
  111998. * @returns - Boolean specifying if a texture is used in the material.
  111999. */
  112000. hasTexture(texture: BaseTexture): boolean;
  112001. /**
  112002. * Returns an array of the actively used textures.
  112003. * @param activeTextures Array of BaseTextures
  112004. */
  112005. getActiveTextures(activeTextures: BaseTexture[]): void;
  112006. /**
  112007. * Returns the animatable textures.
  112008. * @param animatables Array of animatable textures.
  112009. */
  112010. getAnimatables(animatables: IAnimatable[]): void;
  112011. /**
  112012. * Disposes the resources of the material.
  112013. * @param forceDisposeTextures - Forces the disposal of all textures.
  112014. */
  112015. dispose(forceDisposeTextures?: boolean): void;
  112016. /**
  112017. * Get the current class name of the texture useful for serialization or dynamic coding.
  112018. * @returns "PBRClearCoatConfiguration"
  112019. */
  112020. getClassName(): string;
  112021. /**
  112022. * Add fallbacks to the effect fallbacks list.
  112023. * @param defines defines the Base texture to use.
  112024. * @param fallbacks defines the current fallback list.
  112025. * @param currentRank defines the current fallback rank.
  112026. * @returns the new fallback rank.
  112027. */
  112028. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112029. /**
  112030. * Add the required uniforms to the current list.
  112031. * @param uniforms defines the current uniform list.
  112032. */
  112033. static AddUniforms(uniforms: string[]): void;
  112034. /**
  112035. * Add the required samplers to the current list.
  112036. * @param samplers defines the current sampler list.
  112037. */
  112038. static AddSamplers(samplers: string[]): void;
  112039. /**
  112040. * Add the required uniforms to the current buffer.
  112041. * @param uniformBuffer defines the current uniform buffer.
  112042. */
  112043. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112044. /**
  112045. * Makes a duplicate of the current configuration into another one.
  112046. * @param clearCoatConfiguration define the config where to copy the info
  112047. */
  112048. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  112049. /**
  112050. * Serializes this clear coat configuration.
  112051. * @returns - An object with the serialized config.
  112052. */
  112053. serialize(): any;
  112054. /**
  112055. * Parses a anisotropy Configuration from a serialized object.
  112056. * @param source - Serialized object.
  112057. * @param scene Defines the scene we are parsing for
  112058. * @param rootUrl Defines the rootUrl to load from
  112059. */
  112060. parse(source: any, scene: Scene, rootUrl: string): void;
  112061. }
  112062. }
  112063. declare module BABYLON {
  112064. /**
  112065. * @hidden
  112066. */
  112067. export interface IMaterialAnisotropicDefines {
  112068. ANISOTROPIC: boolean;
  112069. ANISOTROPIC_TEXTURE: boolean;
  112070. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112071. MAINUV1: boolean;
  112072. _areTexturesDirty: boolean;
  112073. _needUVs: boolean;
  112074. }
  112075. /**
  112076. * Define the code related to the anisotropic parameters of the pbr material.
  112077. */
  112078. export class PBRAnisotropicConfiguration {
  112079. private _isEnabled;
  112080. /**
  112081. * Defines if the anisotropy is enabled in the material.
  112082. */
  112083. isEnabled: boolean;
  112084. /**
  112085. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  112086. */
  112087. intensity: number;
  112088. /**
  112089. * Defines if the effect is along the tangents, bitangents or in between.
  112090. * By default, the effect is "strectching" the highlights along the tangents.
  112091. */
  112092. direction: Vector2;
  112093. private _texture;
  112094. /**
  112095. * Stores the anisotropy values in a texture.
  112096. * rg is direction (like normal from -1 to 1)
  112097. * b is a intensity
  112098. */
  112099. texture: Nullable<BaseTexture>;
  112100. /** @hidden */
  112101. private _internalMarkAllSubMeshesAsTexturesDirty;
  112102. /** @hidden */
  112103. _markAllSubMeshesAsTexturesDirty(): void;
  112104. /**
  112105. * Instantiate a new istance of anisotropy configuration.
  112106. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112107. */
  112108. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112109. /**
  112110. * Specifies that the submesh is ready to be used.
  112111. * @param defines the list of "defines" to update.
  112112. * @param scene defines the scene the material belongs to.
  112113. * @returns - boolean indicating that the submesh is ready or not.
  112114. */
  112115. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  112116. /**
  112117. * Checks to see if a texture is used in the material.
  112118. * @param defines the list of "defines" to update.
  112119. * @param mesh the mesh we are preparing the defines for.
  112120. * @param scene defines the scene the material belongs to.
  112121. */
  112122. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  112123. /**
  112124. * Binds the material data.
  112125. * @param uniformBuffer defines the Uniform buffer to fill in.
  112126. * @param scene defines the scene the material belongs to.
  112127. * @param isFrozen defines wether the material is frozen or not.
  112128. */
  112129. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112130. /**
  112131. * Checks to see if a texture is used in the material.
  112132. * @param texture - Base texture to use.
  112133. * @returns - Boolean specifying if a texture is used in the material.
  112134. */
  112135. hasTexture(texture: BaseTexture): boolean;
  112136. /**
  112137. * Returns an array of the actively used textures.
  112138. * @param activeTextures Array of BaseTextures
  112139. */
  112140. getActiveTextures(activeTextures: BaseTexture[]): void;
  112141. /**
  112142. * Returns the animatable textures.
  112143. * @param animatables Array of animatable textures.
  112144. */
  112145. getAnimatables(animatables: IAnimatable[]): void;
  112146. /**
  112147. * Disposes the resources of the material.
  112148. * @param forceDisposeTextures - Forces the disposal of all textures.
  112149. */
  112150. dispose(forceDisposeTextures?: boolean): void;
  112151. /**
  112152. * Get the current class name of the texture useful for serialization or dynamic coding.
  112153. * @returns "PBRAnisotropicConfiguration"
  112154. */
  112155. getClassName(): string;
  112156. /**
  112157. * Add fallbacks to the effect fallbacks list.
  112158. * @param defines defines the Base texture to use.
  112159. * @param fallbacks defines the current fallback list.
  112160. * @param currentRank defines the current fallback rank.
  112161. * @returns the new fallback rank.
  112162. */
  112163. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112164. /**
  112165. * Add the required uniforms to the current list.
  112166. * @param uniforms defines the current uniform list.
  112167. */
  112168. static AddUniforms(uniforms: string[]): void;
  112169. /**
  112170. * Add the required uniforms to the current buffer.
  112171. * @param uniformBuffer defines the current uniform buffer.
  112172. */
  112173. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112174. /**
  112175. * Add the required samplers to the current list.
  112176. * @param samplers defines the current sampler list.
  112177. */
  112178. static AddSamplers(samplers: string[]): void;
  112179. /**
  112180. * Makes a duplicate of the current configuration into another one.
  112181. * @param anisotropicConfiguration define the config where to copy the info
  112182. */
  112183. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  112184. /**
  112185. * Serializes this anisotropy configuration.
  112186. * @returns - An object with the serialized config.
  112187. */
  112188. serialize(): any;
  112189. /**
  112190. * Parses a anisotropy Configuration from a serialized object.
  112191. * @param source - Serialized object.
  112192. * @param scene Defines the scene we are parsing for
  112193. * @param rootUrl Defines the rootUrl to load from
  112194. */
  112195. parse(source: any, scene: Scene, rootUrl: string): void;
  112196. }
  112197. }
  112198. declare module BABYLON {
  112199. /**
  112200. * @hidden
  112201. */
  112202. export interface IMaterialBRDFDefines {
  112203. BRDF_V_HEIGHT_CORRELATED: boolean;
  112204. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112205. SPHERICAL_HARMONICS: boolean;
  112206. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112207. /** @hidden */
  112208. _areMiscDirty: boolean;
  112209. }
  112210. /**
  112211. * Define the code related to the BRDF parameters of the pbr material.
  112212. */
  112213. export class PBRBRDFConfiguration {
  112214. /**
  112215. * Default value used for the energy conservation.
  112216. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112217. */
  112218. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  112219. /**
  112220. * Default value used for the Smith Visibility Height Correlated mode.
  112221. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112222. */
  112223. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  112224. /**
  112225. * Default value used for the IBL diffuse part.
  112226. * This can help switching back to the polynomials mode globally which is a tiny bit
  112227. * less GPU intensive at the drawback of a lower quality.
  112228. */
  112229. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  112230. /**
  112231. * Default value used for activating energy conservation for the specular workflow.
  112232. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112233. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112234. */
  112235. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  112236. private _useEnergyConservation;
  112237. /**
  112238. * Defines if the material uses energy conservation.
  112239. */
  112240. useEnergyConservation: boolean;
  112241. private _useSmithVisibilityHeightCorrelated;
  112242. /**
  112243. * LEGACY Mode set to false
  112244. * Defines if the material uses height smith correlated visibility term.
  112245. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  112246. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  112247. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  112248. * Not relying on height correlated will also disable energy conservation.
  112249. */
  112250. useSmithVisibilityHeightCorrelated: boolean;
  112251. private _useSphericalHarmonics;
  112252. /**
  112253. * LEGACY Mode set to false
  112254. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  112255. * diffuse part of the IBL.
  112256. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  112257. * to the ground truth.
  112258. */
  112259. useSphericalHarmonics: boolean;
  112260. private _useSpecularGlossinessInputEnergyConservation;
  112261. /**
  112262. * Defines if the material uses energy conservation, when the specular workflow is active.
  112263. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112264. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112265. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  112266. */
  112267. useSpecularGlossinessInputEnergyConservation: boolean;
  112268. /** @hidden */
  112269. private _internalMarkAllSubMeshesAsMiscDirty;
  112270. /** @hidden */
  112271. _markAllSubMeshesAsMiscDirty(): void;
  112272. /**
  112273. * Instantiate a new istance of clear coat configuration.
  112274. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  112275. */
  112276. constructor(markAllSubMeshesAsMiscDirty: () => void);
  112277. /**
  112278. * Checks to see if a texture is used in the material.
  112279. * @param defines the list of "defines" to update.
  112280. */
  112281. prepareDefines(defines: IMaterialBRDFDefines): void;
  112282. /**
  112283. * Get the current class name of the texture useful for serialization or dynamic coding.
  112284. * @returns "PBRClearCoatConfiguration"
  112285. */
  112286. getClassName(): string;
  112287. /**
  112288. * Makes a duplicate of the current configuration into another one.
  112289. * @param brdfConfiguration define the config where to copy the info
  112290. */
  112291. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  112292. /**
  112293. * Serializes this BRDF configuration.
  112294. * @returns - An object with the serialized config.
  112295. */
  112296. serialize(): any;
  112297. /**
  112298. * Parses a anisotropy Configuration from a serialized object.
  112299. * @param source - Serialized object.
  112300. * @param scene Defines the scene we are parsing for
  112301. * @param rootUrl Defines the rootUrl to load from
  112302. */
  112303. parse(source: any, scene: Scene, rootUrl: string): void;
  112304. }
  112305. }
  112306. declare module BABYLON {
  112307. /**
  112308. * @hidden
  112309. */
  112310. export interface IMaterialSheenDefines {
  112311. SHEEN: boolean;
  112312. SHEEN_TEXTURE: boolean;
  112313. SHEEN_TEXTUREDIRECTUV: number;
  112314. SHEEN_LINKWITHALBEDO: boolean;
  112315. /** @hidden */
  112316. _areTexturesDirty: boolean;
  112317. }
  112318. /**
  112319. * Define the code related to the Sheen parameters of the pbr material.
  112320. */
  112321. export class PBRSheenConfiguration {
  112322. private _isEnabled;
  112323. /**
  112324. * Defines if the material uses sheen.
  112325. */
  112326. isEnabled: boolean;
  112327. private _linkSheenWithAlbedo;
  112328. /**
  112329. * Defines if the sheen is linked to the sheen color.
  112330. */
  112331. linkSheenWithAlbedo: boolean;
  112332. /**
  112333. * Defines the sheen intensity.
  112334. */
  112335. intensity: number;
  112336. /**
  112337. * Defines the sheen color.
  112338. */
  112339. color: Color3;
  112340. private _texture;
  112341. /**
  112342. * Stores the sheen tint values in a texture.
  112343. * rgb is tint
  112344. * a is a intensity
  112345. */
  112346. texture: Nullable<BaseTexture>;
  112347. /** @hidden */
  112348. private _internalMarkAllSubMeshesAsTexturesDirty;
  112349. /** @hidden */
  112350. _markAllSubMeshesAsTexturesDirty(): void;
  112351. /**
  112352. * Instantiate a new istance of clear coat configuration.
  112353. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112354. */
  112355. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112356. /**
  112357. * Specifies that the submesh is ready to be used.
  112358. * @param defines the list of "defines" to update.
  112359. * @param scene defines the scene the material belongs to.
  112360. * @returns - boolean indicating that the submesh is ready or not.
  112361. */
  112362. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  112363. /**
  112364. * Checks to see if a texture is used in the material.
  112365. * @param defines the list of "defines" to update.
  112366. * @param scene defines the scene the material belongs to.
  112367. */
  112368. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  112369. /**
  112370. * Binds the material data.
  112371. * @param uniformBuffer defines the Uniform buffer to fill in.
  112372. * @param scene defines the scene the material belongs to.
  112373. * @param isFrozen defines wether the material is frozen or not.
  112374. */
  112375. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112376. /**
  112377. * Checks to see if a texture is used in the material.
  112378. * @param texture - Base texture to use.
  112379. * @returns - Boolean specifying if a texture is used in the material.
  112380. */
  112381. hasTexture(texture: BaseTexture): boolean;
  112382. /**
  112383. * Returns an array of the actively used textures.
  112384. * @param activeTextures Array of BaseTextures
  112385. */
  112386. getActiveTextures(activeTextures: BaseTexture[]): void;
  112387. /**
  112388. * Returns the animatable textures.
  112389. * @param animatables Array of animatable textures.
  112390. */
  112391. getAnimatables(animatables: IAnimatable[]): void;
  112392. /**
  112393. * Disposes the resources of the material.
  112394. * @param forceDisposeTextures - Forces the disposal of all textures.
  112395. */
  112396. dispose(forceDisposeTextures?: boolean): void;
  112397. /**
  112398. * Get the current class name of the texture useful for serialization or dynamic coding.
  112399. * @returns "PBRSheenConfiguration"
  112400. */
  112401. getClassName(): string;
  112402. /**
  112403. * Add fallbacks to the effect fallbacks list.
  112404. * @param defines defines the Base texture to use.
  112405. * @param fallbacks defines the current fallback list.
  112406. * @param currentRank defines the current fallback rank.
  112407. * @returns the new fallback rank.
  112408. */
  112409. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112410. /**
  112411. * Add the required uniforms to the current list.
  112412. * @param uniforms defines the current uniform list.
  112413. */
  112414. static AddUniforms(uniforms: string[]): void;
  112415. /**
  112416. * Add the required uniforms to the current buffer.
  112417. * @param uniformBuffer defines the current uniform buffer.
  112418. */
  112419. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112420. /**
  112421. * Add the required samplers to the current list.
  112422. * @param samplers defines the current sampler list.
  112423. */
  112424. static AddSamplers(samplers: string[]): void;
  112425. /**
  112426. * Makes a duplicate of the current configuration into another one.
  112427. * @param sheenConfiguration define the config where to copy the info
  112428. */
  112429. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  112430. /**
  112431. * Serializes this BRDF configuration.
  112432. * @returns - An object with the serialized config.
  112433. */
  112434. serialize(): any;
  112435. /**
  112436. * Parses a anisotropy Configuration from a serialized object.
  112437. * @param source - Serialized object.
  112438. * @param scene Defines the scene we are parsing for
  112439. * @param rootUrl Defines the rootUrl to load from
  112440. */
  112441. parse(source: any, scene: Scene, rootUrl: string): void;
  112442. }
  112443. }
  112444. declare module BABYLON {
  112445. /**
  112446. * @hidden
  112447. */
  112448. export interface IMaterialSubSurfaceDefines {
  112449. SUBSURFACE: boolean;
  112450. SS_REFRACTION: boolean;
  112451. SS_TRANSLUCENCY: boolean;
  112452. SS_SCATERRING: boolean;
  112453. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112454. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112455. SS_REFRACTIONMAP_3D: boolean;
  112456. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112457. SS_LODINREFRACTIONALPHA: boolean;
  112458. SS_GAMMAREFRACTION: boolean;
  112459. SS_RGBDREFRACTION: boolean;
  112460. SS_LINEARSPECULARREFRACTION: boolean;
  112461. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112462. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112463. /** @hidden */
  112464. _areTexturesDirty: boolean;
  112465. }
  112466. /**
  112467. * Define the code related to the sub surface parameters of the pbr material.
  112468. */
  112469. export class PBRSubSurfaceConfiguration {
  112470. private _isRefractionEnabled;
  112471. /**
  112472. * Defines if the refraction is enabled in the material.
  112473. */
  112474. isRefractionEnabled: boolean;
  112475. private _isTranslucencyEnabled;
  112476. /**
  112477. * Defines if the translucency is enabled in the material.
  112478. */
  112479. isTranslucencyEnabled: boolean;
  112480. private _isScatteringEnabled;
  112481. /**
  112482. * Defines the refraction intensity of the material.
  112483. * The refraction when enabled replaces the Diffuse part of the material.
  112484. * The intensity helps transitionning between diffuse and refraction.
  112485. */
  112486. refractionIntensity: number;
  112487. /**
  112488. * Defines the translucency intensity of the material.
  112489. * When translucency has been enabled, this defines how much of the "translucency"
  112490. * is addded to the diffuse part of the material.
  112491. */
  112492. translucencyIntensity: number;
  112493. /**
  112494. * Defines the scattering intensity of the material.
  112495. * When scattering has been enabled, this defines how much of the "scattered light"
  112496. * is addded to the diffuse part of the material.
  112497. */
  112498. scatteringIntensity: number;
  112499. private _thicknessTexture;
  112500. /**
  112501. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  112502. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  112503. * 0 would mean minimumThickness
  112504. * 1 would mean maximumThickness
  112505. * The other channels might be use as a mask to vary the different effects intensity.
  112506. */
  112507. thicknessTexture: Nullable<BaseTexture>;
  112508. private _refractionTexture;
  112509. /**
  112510. * Defines the texture to use for refraction.
  112511. */
  112512. refractionTexture: Nullable<BaseTexture>;
  112513. private _indexOfRefraction;
  112514. /**
  112515. * Defines the index of refraction used in the material.
  112516. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  112517. */
  112518. indexOfRefraction: number;
  112519. private _invertRefractionY;
  112520. /**
  112521. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112522. */
  112523. invertRefractionY: boolean;
  112524. private _linkRefractionWithTransparency;
  112525. /**
  112526. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112527. * Materials half opaque for instance using refraction could benefit from this control.
  112528. */
  112529. linkRefractionWithTransparency: boolean;
  112530. /**
  112531. * Defines the minimum thickness stored in the thickness map.
  112532. * If no thickness map is defined, this value will be used to simulate thickness.
  112533. */
  112534. minimumThickness: number;
  112535. /**
  112536. * Defines the maximum thickness stored in the thickness map.
  112537. */
  112538. maximumThickness: number;
  112539. /**
  112540. * Defines the volume tint of the material.
  112541. * This is used for both translucency and scattering.
  112542. */
  112543. tintColor: Color3;
  112544. /**
  112545. * Defines the distance at which the tint color should be found in the media.
  112546. * This is used for refraction only.
  112547. */
  112548. tintColorAtDistance: number;
  112549. /**
  112550. * Defines how far each channel transmit through the media.
  112551. * It is defined as a color to simplify it selection.
  112552. */
  112553. diffusionDistance: Color3;
  112554. private _useMaskFromThicknessTexture;
  112555. /**
  112556. * Stores the intensity of the different subsurface effects in the thickness texture.
  112557. * * the green channel is the translucency intensity.
  112558. * * the blue channel is the scattering intensity.
  112559. * * the alpha channel is the refraction intensity.
  112560. */
  112561. useMaskFromThicknessTexture: boolean;
  112562. /** @hidden */
  112563. private _internalMarkAllSubMeshesAsTexturesDirty;
  112564. /** @hidden */
  112565. _markAllSubMeshesAsTexturesDirty(): void;
  112566. /**
  112567. * Instantiate a new istance of sub surface configuration.
  112568. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112569. */
  112570. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112571. /**
  112572. * Gets wehter the submesh is ready to be used or not.
  112573. * @param defines the list of "defines" to update.
  112574. * @param scene defines the scene the material belongs to.
  112575. * @returns - boolean indicating that the submesh is ready or not.
  112576. */
  112577. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  112578. /**
  112579. * Checks to see if a texture is used in the material.
  112580. * @param defines the list of "defines" to update.
  112581. * @param scene defines the scene to the material belongs to.
  112582. */
  112583. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  112584. /**
  112585. * Binds the material data.
  112586. * @param uniformBuffer defines the Uniform buffer to fill in.
  112587. * @param scene defines the scene the material belongs to.
  112588. * @param engine defines the engine the material belongs to.
  112589. * @param isFrozen defines wether the material is frozen or not.
  112590. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  112591. */
  112592. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  112593. /**
  112594. * Unbinds the material from the mesh.
  112595. * @param activeEffect defines the effect that should be unbound from.
  112596. * @returns true if unbound, otherwise false
  112597. */
  112598. unbind(activeEffect: Effect): boolean;
  112599. /**
  112600. * Returns the texture used for refraction or null if none is used.
  112601. * @param scene defines the scene the material belongs to.
  112602. * @returns - Refraction texture if present. If no refraction texture and refraction
  112603. * is linked with transparency, returns environment texture. Otherwise, returns null.
  112604. */
  112605. private _getRefractionTexture;
  112606. /**
  112607. * Returns true if alpha blending should be disabled.
  112608. */
  112609. readonly disableAlphaBlending: boolean;
  112610. /**
  112611. * Fills the list of render target textures.
  112612. * @param renderTargets the list of render targets to update
  112613. */
  112614. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  112615. /**
  112616. * Checks to see if a texture is used in the material.
  112617. * @param texture - Base texture to use.
  112618. * @returns - Boolean specifying if a texture is used in the material.
  112619. */
  112620. hasTexture(texture: BaseTexture): boolean;
  112621. /**
  112622. * Gets a boolean indicating that current material needs to register RTT
  112623. * @returns true if this uses a render target otherwise false.
  112624. */
  112625. hasRenderTargetTextures(): boolean;
  112626. /**
  112627. * Returns an array of the actively used textures.
  112628. * @param activeTextures Array of BaseTextures
  112629. */
  112630. getActiveTextures(activeTextures: BaseTexture[]): void;
  112631. /**
  112632. * Returns the animatable textures.
  112633. * @param animatables Array of animatable textures.
  112634. */
  112635. getAnimatables(animatables: IAnimatable[]): void;
  112636. /**
  112637. * Disposes the resources of the material.
  112638. * @param forceDisposeTextures - Forces the disposal of all textures.
  112639. */
  112640. dispose(forceDisposeTextures?: boolean): void;
  112641. /**
  112642. * Get the current class name of the texture useful for serialization or dynamic coding.
  112643. * @returns "PBRSubSurfaceConfiguration"
  112644. */
  112645. getClassName(): string;
  112646. /**
  112647. * Add fallbacks to the effect fallbacks list.
  112648. * @param defines defines the Base texture to use.
  112649. * @param fallbacks defines the current fallback list.
  112650. * @param currentRank defines the current fallback rank.
  112651. * @returns the new fallback rank.
  112652. */
  112653. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112654. /**
  112655. * Add the required uniforms to the current list.
  112656. * @param uniforms defines the current uniform list.
  112657. */
  112658. static AddUniforms(uniforms: string[]): void;
  112659. /**
  112660. * Add the required samplers to the current list.
  112661. * @param samplers defines the current sampler list.
  112662. */
  112663. static AddSamplers(samplers: string[]): void;
  112664. /**
  112665. * Add the required uniforms to the current buffer.
  112666. * @param uniformBuffer defines the current uniform buffer.
  112667. */
  112668. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112669. /**
  112670. * Makes a duplicate of the current configuration into another one.
  112671. * @param configuration define the config where to copy the info
  112672. */
  112673. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  112674. /**
  112675. * Serializes this Sub Surface configuration.
  112676. * @returns - An object with the serialized config.
  112677. */
  112678. serialize(): any;
  112679. /**
  112680. * Parses a anisotropy Configuration from a serialized object.
  112681. * @param source - Serialized object.
  112682. * @param scene Defines the scene we are parsing for
  112683. * @param rootUrl Defines the rootUrl to load from
  112684. */
  112685. parse(source: any, scene: Scene, rootUrl: string): void;
  112686. }
  112687. }
  112688. declare module BABYLON {
  112689. /** @hidden */
  112690. export var pbrFragmentDeclaration: {
  112691. name: string;
  112692. shader: string;
  112693. };
  112694. }
  112695. declare module BABYLON {
  112696. /** @hidden */
  112697. export var pbrUboDeclaration: {
  112698. name: string;
  112699. shader: string;
  112700. };
  112701. }
  112702. declare module BABYLON {
  112703. /** @hidden */
  112704. export var pbrFragmentExtraDeclaration: {
  112705. name: string;
  112706. shader: string;
  112707. };
  112708. }
  112709. declare module BABYLON {
  112710. /** @hidden */
  112711. export var pbrFragmentSamplersDeclaration: {
  112712. name: string;
  112713. shader: string;
  112714. };
  112715. }
  112716. declare module BABYLON {
  112717. /** @hidden */
  112718. export var pbrHelperFunctions: {
  112719. name: string;
  112720. shader: string;
  112721. };
  112722. }
  112723. declare module BABYLON {
  112724. /** @hidden */
  112725. export var harmonicsFunctions: {
  112726. name: string;
  112727. shader: string;
  112728. };
  112729. }
  112730. declare module BABYLON {
  112731. /** @hidden */
  112732. export var pbrDirectLightingSetupFunctions: {
  112733. name: string;
  112734. shader: string;
  112735. };
  112736. }
  112737. declare module BABYLON {
  112738. /** @hidden */
  112739. export var pbrDirectLightingFalloffFunctions: {
  112740. name: string;
  112741. shader: string;
  112742. };
  112743. }
  112744. declare module BABYLON {
  112745. /** @hidden */
  112746. export var pbrBRDFFunctions: {
  112747. name: string;
  112748. shader: string;
  112749. };
  112750. }
  112751. declare module BABYLON {
  112752. /** @hidden */
  112753. export var pbrDirectLightingFunctions: {
  112754. name: string;
  112755. shader: string;
  112756. };
  112757. }
  112758. declare module BABYLON {
  112759. /** @hidden */
  112760. export var pbrIBLFunctions: {
  112761. name: string;
  112762. shader: string;
  112763. };
  112764. }
  112765. declare module BABYLON {
  112766. /** @hidden */
  112767. export var pbrDebug: {
  112768. name: string;
  112769. shader: string;
  112770. };
  112771. }
  112772. declare module BABYLON {
  112773. /** @hidden */
  112774. export var pbrPixelShader: {
  112775. name: string;
  112776. shader: string;
  112777. };
  112778. }
  112779. declare module BABYLON {
  112780. /** @hidden */
  112781. export var pbrVertexDeclaration: {
  112782. name: string;
  112783. shader: string;
  112784. };
  112785. }
  112786. declare module BABYLON {
  112787. /** @hidden */
  112788. export var pbrVertexShader: {
  112789. name: string;
  112790. shader: string;
  112791. };
  112792. }
  112793. declare module BABYLON {
  112794. /**
  112795. * Manages the defines for the PBR Material.
  112796. * @hidden
  112797. */
  112798. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  112799. PBR: boolean;
  112800. MAINUV1: boolean;
  112801. MAINUV2: boolean;
  112802. UV1: boolean;
  112803. UV2: boolean;
  112804. ALBEDO: boolean;
  112805. ALBEDODIRECTUV: number;
  112806. VERTEXCOLOR: boolean;
  112807. AMBIENT: boolean;
  112808. AMBIENTDIRECTUV: number;
  112809. AMBIENTINGRAYSCALE: boolean;
  112810. OPACITY: boolean;
  112811. VERTEXALPHA: boolean;
  112812. OPACITYDIRECTUV: number;
  112813. OPACITYRGB: boolean;
  112814. ALPHATEST: boolean;
  112815. DEPTHPREPASS: boolean;
  112816. ALPHABLEND: boolean;
  112817. ALPHAFROMALBEDO: boolean;
  112818. ALPHATESTVALUE: string;
  112819. SPECULAROVERALPHA: boolean;
  112820. RADIANCEOVERALPHA: boolean;
  112821. ALPHAFRESNEL: boolean;
  112822. LINEARALPHAFRESNEL: boolean;
  112823. PREMULTIPLYALPHA: boolean;
  112824. EMISSIVE: boolean;
  112825. EMISSIVEDIRECTUV: number;
  112826. REFLECTIVITY: boolean;
  112827. REFLECTIVITYDIRECTUV: number;
  112828. SPECULARTERM: boolean;
  112829. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  112830. MICROSURFACEAUTOMATIC: boolean;
  112831. LODBASEDMICROSFURACE: boolean;
  112832. MICROSURFACEMAP: boolean;
  112833. MICROSURFACEMAPDIRECTUV: number;
  112834. METALLICWORKFLOW: boolean;
  112835. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  112836. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  112837. METALLNESSSTOREINMETALMAPBLUE: boolean;
  112838. AOSTOREINMETALMAPRED: boolean;
  112839. ENVIRONMENTBRDF: boolean;
  112840. ENVIRONMENTBRDF_RGBD: boolean;
  112841. NORMAL: boolean;
  112842. TANGENT: boolean;
  112843. BUMP: boolean;
  112844. BUMPDIRECTUV: number;
  112845. OBJECTSPACE_NORMALMAP: boolean;
  112846. PARALLAX: boolean;
  112847. PARALLAXOCCLUSION: boolean;
  112848. NORMALXYSCALE: boolean;
  112849. LIGHTMAP: boolean;
  112850. LIGHTMAPDIRECTUV: number;
  112851. USELIGHTMAPASSHADOWMAP: boolean;
  112852. GAMMALIGHTMAP: boolean;
  112853. RGBDLIGHTMAP: boolean;
  112854. REFLECTION: boolean;
  112855. REFLECTIONMAP_3D: boolean;
  112856. REFLECTIONMAP_SPHERICAL: boolean;
  112857. REFLECTIONMAP_PLANAR: boolean;
  112858. REFLECTIONMAP_CUBIC: boolean;
  112859. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  112860. REFLECTIONMAP_PROJECTION: boolean;
  112861. REFLECTIONMAP_SKYBOX: boolean;
  112862. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  112863. REFLECTIONMAP_EXPLICIT: boolean;
  112864. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  112865. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  112866. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  112867. INVERTCUBICMAP: boolean;
  112868. USESPHERICALFROMREFLECTIONMAP: boolean;
  112869. USEIRRADIANCEMAP: boolean;
  112870. SPHERICAL_HARMONICS: boolean;
  112871. USESPHERICALINVERTEX: boolean;
  112872. REFLECTIONMAP_OPPOSITEZ: boolean;
  112873. LODINREFLECTIONALPHA: boolean;
  112874. GAMMAREFLECTION: boolean;
  112875. RGBDREFLECTION: boolean;
  112876. LINEARSPECULARREFLECTION: boolean;
  112877. RADIANCEOCCLUSION: boolean;
  112878. HORIZONOCCLUSION: boolean;
  112879. INSTANCES: boolean;
  112880. NUM_BONE_INFLUENCERS: number;
  112881. BonesPerMesh: number;
  112882. BONETEXTURE: boolean;
  112883. NONUNIFORMSCALING: boolean;
  112884. MORPHTARGETS: boolean;
  112885. MORPHTARGETS_NORMAL: boolean;
  112886. MORPHTARGETS_TANGENT: boolean;
  112887. MORPHTARGETS_UV: boolean;
  112888. NUM_MORPH_INFLUENCERS: number;
  112889. IMAGEPROCESSING: boolean;
  112890. VIGNETTE: boolean;
  112891. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112892. VIGNETTEBLENDMODEOPAQUE: boolean;
  112893. TONEMAPPING: boolean;
  112894. TONEMAPPING_ACES: boolean;
  112895. CONTRAST: boolean;
  112896. COLORCURVES: boolean;
  112897. COLORGRADING: boolean;
  112898. COLORGRADING3D: boolean;
  112899. SAMPLER3DGREENDEPTH: boolean;
  112900. SAMPLER3DBGRMAP: boolean;
  112901. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112902. EXPOSURE: boolean;
  112903. MULTIVIEW: boolean;
  112904. USEPHYSICALLIGHTFALLOFF: boolean;
  112905. USEGLTFLIGHTFALLOFF: boolean;
  112906. TWOSIDEDLIGHTING: boolean;
  112907. SHADOWFLOAT: boolean;
  112908. CLIPPLANE: boolean;
  112909. CLIPPLANE2: boolean;
  112910. CLIPPLANE3: boolean;
  112911. CLIPPLANE4: boolean;
  112912. POINTSIZE: boolean;
  112913. FOG: boolean;
  112914. LOGARITHMICDEPTH: boolean;
  112915. FORCENORMALFORWARD: boolean;
  112916. SPECULARAA: boolean;
  112917. CLEARCOAT: boolean;
  112918. CLEARCOAT_DEFAULTIOR: boolean;
  112919. CLEARCOAT_TEXTURE: boolean;
  112920. CLEARCOAT_TEXTUREDIRECTUV: number;
  112921. CLEARCOAT_BUMP: boolean;
  112922. CLEARCOAT_BUMPDIRECTUV: number;
  112923. CLEARCOAT_TINT: boolean;
  112924. CLEARCOAT_TINT_TEXTURE: boolean;
  112925. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112926. ANISOTROPIC: boolean;
  112927. ANISOTROPIC_TEXTURE: boolean;
  112928. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112929. BRDF_V_HEIGHT_CORRELATED: boolean;
  112930. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112931. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112932. SHEEN: boolean;
  112933. SHEEN_TEXTURE: boolean;
  112934. SHEEN_TEXTUREDIRECTUV: number;
  112935. SHEEN_LINKWITHALBEDO: boolean;
  112936. SUBSURFACE: boolean;
  112937. SS_REFRACTION: boolean;
  112938. SS_TRANSLUCENCY: boolean;
  112939. SS_SCATERRING: boolean;
  112940. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112941. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112942. SS_REFRACTIONMAP_3D: boolean;
  112943. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112944. SS_LODINREFRACTIONALPHA: boolean;
  112945. SS_GAMMAREFRACTION: boolean;
  112946. SS_RGBDREFRACTION: boolean;
  112947. SS_LINEARSPECULARREFRACTION: boolean;
  112948. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112949. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112950. UNLIT: boolean;
  112951. DEBUGMODE: number;
  112952. /**
  112953. * Initializes the PBR Material defines.
  112954. */
  112955. constructor();
  112956. /**
  112957. * Resets the PBR Material defines.
  112958. */
  112959. reset(): void;
  112960. }
  112961. /**
  112962. * The Physically based material base class of BJS.
  112963. *
  112964. * This offers the main features of a standard PBR material.
  112965. * For more information, please refer to the documentation :
  112966. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112967. */
  112968. export abstract class PBRBaseMaterial extends PushMaterial {
  112969. /**
  112970. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112971. */
  112972. static readonly PBRMATERIAL_OPAQUE: number;
  112973. /**
  112974. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112975. */
  112976. static readonly PBRMATERIAL_ALPHATEST: number;
  112977. /**
  112978. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112979. */
  112980. static readonly PBRMATERIAL_ALPHABLEND: number;
  112981. /**
  112982. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112983. * They are also discarded below the alpha cutoff threshold to improve performances.
  112984. */
  112985. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112986. /**
  112987. * Defines the default value of how much AO map is occluding the analytical lights
  112988. * (point spot...).
  112989. */
  112990. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112991. /**
  112992. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  112993. */
  112994. static readonly LIGHTFALLOFF_PHYSICAL: number;
  112995. /**
  112996. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  112997. * to enhance interoperability with other engines.
  112998. */
  112999. static readonly LIGHTFALLOFF_GLTF: number;
  113000. /**
  113001. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  113002. * to enhance interoperability with other materials.
  113003. */
  113004. static readonly LIGHTFALLOFF_STANDARD: number;
  113005. /**
  113006. * Intensity of the direct lights e.g. the four lights available in your scene.
  113007. * This impacts both the direct diffuse and specular highlights.
  113008. */
  113009. protected _directIntensity: number;
  113010. /**
  113011. * Intensity of the emissive part of the material.
  113012. * This helps controlling the emissive effect without modifying the emissive color.
  113013. */
  113014. protected _emissiveIntensity: number;
  113015. /**
  113016. * Intensity of the environment e.g. how much the environment will light the object
  113017. * either through harmonics for rough material or through the refelction for shiny ones.
  113018. */
  113019. protected _environmentIntensity: number;
  113020. /**
  113021. * This is a special control allowing the reduction of the specular highlights coming from the
  113022. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113023. */
  113024. protected _specularIntensity: number;
  113025. /**
  113026. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  113027. */
  113028. private _lightingInfos;
  113029. /**
  113030. * Debug Control allowing disabling the bump map on this material.
  113031. */
  113032. protected _disableBumpMap: boolean;
  113033. /**
  113034. * AKA Diffuse Texture in standard nomenclature.
  113035. */
  113036. protected _albedoTexture: Nullable<BaseTexture>;
  113037. /**
  113038. * AKA Occlusion Texture in other nomenclature.
  113039. */
  113040. protected _ambientTexture: Nullable<BaseTexture>;
  113041. /**
  113042. * AKA Occlusion Texture Intensity in other nomenclature.
  113043. */
  113044. protected _ambientTextureStrength: number;
  113045. /**
  113046. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113047. * 1 means it completely occludes it
  113048. * 0 mean it has no impact
  113049. */
  113050. protected _ambientTextureImpactOnAnalyticalLights: number;
  113051. /**
  113052. * Stores the alpha values in a texture.
  113053. */
  113054. protected _opacityTexture: Nullable<BaseTexture>;
  113055. /**
  113056. * Stores the reflection values in a texture.
  113057. */
  113058. protected _reflectionTexture: Nullable<BaseTexture>;
  113059. /**
  113060. * Stores the emissive values in a texture.
  113061. */
  113062. protected _emissiveTexture: Nullable<BaseTexture>;
  113063. /**
  113064. * AKA Specular texture in other nomenclature.
  113065. */
  113066. protected _reflectivityTexture: Nullable<BaseTexture>;
  113067. /**
  113068. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113069. */
  113070. protected _metallicTexture: Nullable<BaseTexture>;
  113071. /**
  113072. * Specifies the metallic scalar of the metallic/roughness workflow.
  113073. * Can also be used to scale the metalness values of the metallic texture.
  113074. */
  113075. protected _metallic: Nullable<number>;
  113076. /**
  113077. * Specifies the roughness scalar of the metallic/roughness workflow.
  113078. * Can also be used to scale the roughness values of the metallic texture.
  113079. */
  113080. protected _roughness: Nullable<number>;
  113081. /**
  113082. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113083. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113084. */
  113085. protected _microSurfaceTexture: Nullable<BaseTexture>;
  113086. /**
  113087. * Stores surface normal data used to displace a mesh in a texture.
  113088. */
  113089. protected _bumpTexture: Nullable<BaseTexture>;
  113090. /**
  113091. * Stores the pre-calculated light information of a mesh in a texture.
  113092. */
  113093. protected _lightmapTexture: Nullable<BaseTexture>;
  113094. /**
  113095. * The color of a material in ambient lighting.
  113096. */
  113097. protected _ambientColor: Color3;
  113098. /**
  113099. * AKA Diffuse Color in other nomenclature.
  113100. */
  113101. protected _albedoColor: Color3;
  113102. /**
  113103. * AKA Specular Color in other nomenclature.
  113104. */
  113105. protected _reflectivityColor: Color3;
  113106. /**
  113107. * The color applied when light is reflected from a material.
  113108. */
  113109. protected _reflectionColor: Color3;
  113110. /**
  113111. * The color applied when light is emitted from a material.
  113112. */
  113113. protected _emissiveColor: Color3;
  113114. /**
  113115. * AKA Glossiness in other nomenclature.
  113116. */
  113117. protected _microSurface: number;
  113118. /**
  113119. * Specifies that the material will use the light map as a show map.
  113120. */
  113121. protected _useLightmapAsShadowmap: boolean;
  113122. /**
  113123. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113124. * makes the reflect vector face the model (under horizon).
  113125. */
  113126. protected _useHorizonOcclusion: boolean;
  113127. /**
  113128. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113129. * too much the area relying on ambient texture to define their ambient occlusion.
  113130. */
  113131. protected _useRadianceOcclusion: boolean;
  113132. /**
  113133. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113134. */
  113135. protected _useAlphaFromAlbedoTexture: boolean;
  113136. /**
  113137. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  113138. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113139. */
  113140. protected _useSpecularOverAlpha: boolean;
  113141. /**
  113142. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113143. */
  113144. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113145. /**
  113146. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113147. */
  113148. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  113149. /**
  113150. * Specifies if the metallic texture contains the roughness information in its green channel.
  113151. */
  113152. protected _useRoughnessFromMetallicTextureGreen: boolean;
  113153. /**
  113154. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113155. */
  113156. protected _useMetallnessFromMetallicTextureBlue: boolean;
  113157. /**
  113158. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113159. */
  113160. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  113161. /**
  113162. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113163. */
  113164. protected _useAmbientInGrayScale: boolean;
  113165. /**
  113166. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113167. * The material will try to infer what glossiness each pixel should be.
  113168. */
  113169. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  113170. /**
  113171. * Defines the falloff type used in this material.
  113172. * It by default is Physical.
  113173. */
  113174. protected _lightFalloff: number;
  113175. /**
  113176. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113177. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113178. */
  113179. protected _useRadianceOverAlpha: boolean;
  113180. /**
  113181. * Allows using an object space normal map (instead of tangent space).
  113182. */
  113183. protected _useObjectSpaceNormalMap: boolean;
  113184. /**
  113185. * Allows using the bump map in parallax mode.
  113186. */
  113187. protected _useParallax: boolean;
  113188. /**
  113189. * Allows using the bump map in parallax occlusion mode.
  113190. */
  113191. protected _useParallaxOcclusion: boolean;
  113192. /**
  113193. * Controls the scale bias of the parallax mode.
  113194. */
  113195. protected _parallaxScaleBias: number;
  113196. /**
  113197. * If sets to true, disables all the lights affecting the material.
  113198. */
  113199. protected _disableLighting: boolean;
  113200. /**
  113201. * Number of Simultaneous lights allowed on the material.
  113202. */
  113203. protected _maxSimultaneousLights: number;
  113204. /**
  113205. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113206. */
  113207. protected _invertNormalMapX: boolean;
  113208. /**
  113209. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113210. */
  113211. protected _invertNormalMapY: boolean;
  113212. /**
  113213. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113214. */
  113215. protected _twoSidedLighting: boolean;
  113216. /**
  113217. * Defines the alpha limits in alpha test mode.
  113218. */
  113219. protected _alphaCutOff: number;
  113220. /**
  113221. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113222. */
  113223. protected _forceAlphaTest: boolean;
  113224. /**
  113225. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113226. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113227. */
  113228. protected _useAlphaFresnel: boolean;
  113229. /**
  113230. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113231. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113232. */
  113233. protected _useLinearAlphaFresnel: boolean;
  113234. /**
  113235. * The transparency mode of the material.
  113236. */
  113237. protected _transparencyMode: Nullable<number>;
  113238. /**
  113239. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  113240. * from cos thetav and roughness:
  113241. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  113242. */
  113243. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  113244. /**
  113245. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113246. */
  113247. protected _forceIrradianceInFragment: boolean;
  113248. /**
  113249. * Force normal to face away from face.
  113250. */
  113251. protected _forceNormalForward: boolean;
  113252. /**
  113253. * Enables specular anti aliasing in the PBR shader.
  113254. * It will both interacts on the Geometry for analytical and IBL lighting.
  113255. * It also prefilter the roughness map based on the bump values.
  113256. */
  113257. protected _enableSpecularAntiAliasing: boolean;
  113258. /**
  113259. * Default configuration related to image processing available in the PBR Material.
  113260. */
  113261. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113262. /**
  113263. * Keep track of the image processing observer to allow dispose and replace.
  113264. */
  113265. private _imageProcessingObserver;
  113266. /**
  113267. * Attaches a new image processing configuration to the PBR Material.
  113268. * @param configuration
  113269. */
  113270. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113271. /**
  113272. * Stores the available render targets.
  113273. */
  113274. private _renderTargets;
  113275. /**
  113276. * Sets the global ambient color for the material used in lighting calculations.
  113277. */
  113278. private _globalAmbientColor;
  113279. /**
  113280. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  113281. */
  113282. private _useLogarithmicDepth;
  113283. /**
  113284. * If set to true, no lighting calculations will be applied.
  113285. */
  113286. private _unlit;
  113287. private _debugMode;
  113288. /**
  113289. * @hidden
  113290. * This is reserved for the inspector.
  113291. * Defines the material debug mode.
  113292. * It helps seeing only some components of the material while troubleshooting.
  113293. */
  113294. debugMode: number;
  113295. /**
  113296. * @hidden
  113297. * This is reserved for the inspector.
  113298. * Specify from where on screen the debug mode should start.
  113299. * The value goes from -1 (full screen) to 1 (not visible)
  113300. * It helps with side by side comparison against the final render
  113301. * This defaults to -1
  113302. */
  113303. private debugLimit;
  113304. /**
  113305. * @hidden
  113306. * This is reserved for the inspector.
  113307. * As the default viewing range might not be enough (if the ambient is really small for instance)
  113308. * You can use the factor to better multiply the final value.
  113309. */
  113310. private debugFactor;
  113311. /**
  113312. * Defines the clear coat layer parameters for the material.
  113313. */
  113314. readonly clearCoat: PBRClearCoatConfiguration;
  113315. /**
  113316. * Defines the anisotropic parameters for the material.
  113317. */
  113318. readonly anisotropy: PBRAnisotropicConfiguration;
  113319. /**
  113320. * Defines the BRDF parameters for the material.
  113321. */
  113322. readonly brdf: PBRBRDFConfiguration;
  113323. /**
  113324. * Defines the Sheen parameters for the material.
  113325. */
  113326. readonly sheen: PBRSheenConfiguration;
  113327. /**
  113328. * Defines the SubSurface parameters for the material.
  113329. */
  113330. readonly subSurface: PBRSubSurfaceConfiguration;
  113331. /**
  113332. * Custom callback helping to override the default shader used in the material.
  113333. */
  113334. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  113335. protected _rebuildInParallel: boolean;
  113336. /**
  113337. * Instantiates a new PBRMaterial instance.
  113338. *
  113339. * @param name The material name
  113340. * @param scene The scene the material will be use in.
  113341. */
  113342. constructor(name: string, scene: Scene);
  113343. /**
  113344. * Gets a boolean indicating that current material needs to register RTT
  113345. */
  113346. readonly hasRenderTargetTextures: boolean;
  113347. /**
  113348. * Gets the name of the material class.
  113349. */
  113350. getClassName(): string;
  113351. /**
  113352. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113353. */
  113354. /**
  113355. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113356. */
  113357. useLogarithmicDepth: boolean;
  113358. /**
  113359. * Gets the current transparency mode.
  113360. */
  113361. /**
  113362. * Sets the transparency mode of the material.
  113363. *
  113364. * | Value | Type | Description |
  113365. * | ----- | ----------------------------------- | ----------- |
  113366. * | 0 | OPAQUE | |
  113367. * | 1 | ALPHATEST | |
  113368. * | 2 | ALPHABLEND | |
  113369. * | 3 | ALPHATESTANDBLEND | |
  113370. *
  113371. */
  113372. transparencyMode: Nullable<number>;
  113373. /**
  113374. * Returns true if alpha blending should be disabled.
  113375. */
  113376. private readonly _disableAlphaBlending;
  113377. /**
  113378. * Specifies whether or not this material should be rendered in alpha blend mode.
  113379. */
  113380. needAlphaBlending(): boolean;
  113381. /**
  113382. * Specifies if the mesh will require alpha blending.
  113383. * @param mesh - BJS mesh.
  113384. */
  113385. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  113386. /**
  113387. * Specifies whether or not this material should be rendered in alpha test mode.
  113388. */
  113389. needAlphaTesting(): boolean;
  113390. /**
  113391. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  113392. */
  113393. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  113394. /**
  113395. * Gets the texture used for the alpha test.
  113396. */
  113397. getAlphaTestTexture(): Nullable<BaseTexture>;
  113398. /**
  113399. * Specifies that the submesh is ready to be used.
  113400. * @param mesh - BJS mesh.
  113401. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  113402. * @param useInstances - Specifies that instances should be used.
  113403. * @returns - boolean indicating that the submesh is ready or not.
  113404. */
  113405. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113406. /**
  113407. * Specifies if the material uses metallic roughness workflow.
  113408. * @returns boolean specifiying if the material uses metallic roughness workflow.
  113409. */
  113410. isMetallicWorkflow(): boolean;
  113411. private _prepareEffect;
  113412. private _prepareDefines;
  113413. /**
  113414. * Force shader compilation
  113415. */
  113416. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  113417. clipPlane: boolean;
  113418. }>): void;
  113419. /**
  113420. * Initializes the uniform buffer layout for the shader.
  113421. */
  113422. buildUniformLayout(): void;
  113423. /**
  113424. * Unbinds the material from the mesh
  113425. */
  113426. unbind(): void;
  113427. /**
  113428. * Binds the submesh data.
  113429. * @param world - The world matrix.
  113430. * @param mesh - The BJS mesh.
  113431. * @param subMesh - A submesh of the BJS mesh.
  113432. */
  113433. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113434. /**
  113435. * Returns the animatable textures.
  113436. * @returns - Array of animatable textures.
  113437. */
  113438. getAnimatables(): IAnimatable[];
  113439. /**
  113440. * Returns the texture used for reflections.
  113441. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  113442. */
  113443. private _getReflectionTexture;
  113444. /**
  113445. * Returns an array of the actively used textures.
  113446. * @returns - Array of BaseTextures
  113447. */
  113448. getActiveTextures(): BaseTexture[];
  113449. /**
  113450. * Checks to see if a texture is used in the material.
  113451. * @param texture - Base texture to use.
  113452. * @returns - Boolean specifying if a texture is used in the material.
  113453. */
  113454. hasTexture(texture: BaseTexture): boolean;
  113455. /**
  113456. * Disposes the resources of the material.
  113457. * @param forceDisposeEffect - Forces the disposal of effects.
  113458. * @param forceDisposeTextures - Forces the disposal of all textures.
  113459. */
  113460. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113461. }
  113462. }
  113463. declare module BABYLON {
  113464. /**
  113465. * The Physically based material of BJS.
  113466. *
  113467. * This offers the main features of a standard PBR material.
  113468. * For more information, please refer to the documentation :
  113469. * https://doc.babylonjs.com/how_to/physically_based_rendering
  113470. */
  113471. export class PBRMaterial extends PBRBaseMaterial {
  113472. /**
  113473. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  113474. */
  113475. static readonly PBRMATERIAL_OPAQUE: number;
  113476. /**
  113477. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  113478. */
  113479. static readonly PBRMATERIAL_ALPHATEST: number;
  113480. /**
  113481. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113482. */
  113483. static readonly PBRMATERIAL_ALPHABLEND: number;
  113484. /**
  113485. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113486. * They are also discarded below the alpha cutoff threshold to improve performances.
  113487. */
  113488. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  113489. /**
  113490. * Defines the default value of how much AO map is occluding the analytical lights
  113491. * (point spot...).
  113492. */
  113493. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  113494. /**
  113495. * Intensity of the direct lights e.g. the four lights available in your scene.
  113496. * This impacts both the direct diffuse and specular highlights.
  113497. */
  113498. directIntensity: number;
  113499. /**
  113500. * Intensity of the emissive part of the material.
  113501. * This helps controlling the emissive effect without modifying the emissive color.
  113502. */
  113503. emissiveIntensity: number;
  113504. /**
  113505. * Intensity of the environment e.g. how much the environment will light the object
  113506. * either through harmonics for rough material or through the refelction for shiny ones.
  113507. */
  113508. environmentIntensity: number;
  113509. /**
  113510. * This is a special control allowing the reduction of the specular highlights coming from the
  113511. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113512. */
  113513. specularIntensity: number;
  113514. /**
  113515. * Debug Control allowing disabling the bump map on this material.
  113516. */
  113517. disableBumpMap: boolean;
  113518. /**
  113519. * AKA Diffuse Texture in standard nomenclature.
  113520. */
  113521. albedoTexture: BaseTexture;
  113522. /**
  113523. * AKA Occlusion Texture in other nomenclature.
  113524. */
  113525. ambientTexture: BaseTexture;
  113526. /**
  113527. * AKA Occlusion Texture Intensity in other nomenclature.
  113528. */
  113529. ambientTextureStrength: number;
  113530. /**
  113531. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113532. * 1 means it completely occludes it
  113533. * 0 mean it has no impact
  113534. */
  113535. ambientTextureImpactOnAnalyticalLights: number;
  113536. /**
  113537. * Stores the alpha values in a texture.
  113538. */
  113539. opacityTexture: BaseTexture;
  113540. /**
  113541. * Stores the reflection values in a texture.
  113542. */
  113543. reflectionTexture: Nullable<BaseTexture>;
  113544. /**
  113545. * Stores the emissive values in a texture.
  113546. */
  113547. emissiveTexture: BaseTexture;
  113548. /**
  113549. * AKA Specular texture in other nomenclature.
  113550. */
  113551. reflectivityTexture: BaseTexture;
  113552. /**
  113553. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113554. */
  113555. metallicTexture: BaseTexture;
  113556. /**
  113557. * Specifies the metallic scalar of the metallic/roughness workflow.
  113558. * Can also be used to scale the metalness values of the metallic texture.
  113559. */
  113560. metallic: Nullable<number>;
  113561. /**
  113562. * Specifies the roughness scalar of the metallic/roughness workflow.
  113563. * Can also be used to scale the roughness values of the metallic texture.
  113564. */
  113565. roughness: Nullable<number>;
  113566. /**
  113567. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113568. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113569. */
  113570. microSurfaceTexture: BaseTexture;
  113571. /**
  113572. * Stores surface normal data used to displace a mesh in a texture.
  113573. */
  113574. bumpTexture: BaseTexture;
  113575. /**
  113576. * Stores the pre-calculated light information of a mesh in a texture.
  113577. */
  113578. lightmapTexture: BaseTexture;
  113579. /**
  113580. * Stores the refracted light information in a texture.
  113581. */
  113582. refractionTexture: Nullable<BaseTexture>;
  113583. /**
  113584. * The color of a material in ambient lighting.
  113585. */
  113586. ambientColor: Color3;
  113587. /**
  113588. * AKA Diffuse Color in other nomenclature.
  113589. */
  113590. albedoColor: Color3;
  113591. /**
  113592. * AKA Specular Color in other nomenclature.
  113593. */
  113594. reflectivityColor: Color3;
  113595. /**
  113596. * The color reflected from the material.
  113597. */
  113598. reflectionColor: Color3;
  113599. /**
  113600. * The color emitted from the material.
  113601. */
  113602. emissiveColor: Color3;
  113603. /**
  113604. * AKA Glossiness in other nomenclature.
  113605. */
  113606. microSurface: number;
  113607. /**
  113608. * source material index of refraction (IOR)' / 'destination material IOR.
  113609. */
  113610. indexOfRefraction: number;
  113611. /**
  113612. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113613. */
  113614. invertRefractionY: boolean;
  113615. /**
  113616. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113617. * Materials half opaque for instance using refraction could benefit from this control.
  113618. */
  113619. linkRefractionWithTransparency: boolean;
  113620. /**
  113621. * If true, the light map contains occlusion information instead of lighting info.
  113622. */
  113623. useLightmapAsShadowmap: boolean;
  113624. /**
  113625. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113626. */
  113627. useAlphaFromAlbedoTexture: boolean;
  113628. /**
  113629. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113630. */
  113631. forceAlphaTest: boolean;
  113632. /**
  113633. * Defines the alpha limits in alpha test mode.
  113634. */
  113635. alphaCutOff: number;
  113636. /**
  113637. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  113638. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113639. */
  113640. useSpecularOverAlpha: boolean;
  113641. /**
  113642. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113643. */
  113644. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113645. /**
  113646. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113647. */
  113648. useRoughnessFromMetallicTextureAlpha: boolean;
  113649. /**
  113650. * Specifies if the metallic texture contains the roughness information in its green channel.
  113651. */
  113652. useRoughnessFromMetallicTextureGreen: boolean;
  113653. /**
  113654. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113655. */
  113656. useMetallnessFromMetallicTextureBlue: boolean;
  113657. /**
  113658. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113659. */
  113660. useAmbientOcclusionFromMetallicTextureRed: boolean;
  113661. /**
  113662. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113663. */
  113664. useAmbientInGrayScale: boolean;
  113665. /**
  113666. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113667. * The material will try to infer what glossiness each pixel should be.
  113668. */
  113669. useAutoMicroSurfaceFromReflectivityMap: boolean;
  113670. /**
  113671. * BJS is using an harcoded light falloff based on a manually sets up range.
  113672. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113673. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113674. */
  113675. /**
  113676. * BJS is using an harcoded light falloff based on a manually sets up range.
  113677. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113678. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113679. */
  113680. usePhysicalLightFalloff: boolean;
  113681. /**
  113682. * In order to support the falloff compatibility with gltf, a special mode has been added
  113683. * to reproduce the gltf light falloff.
  113684. */
  113685. /**
  113686. * In order to support the falloff compatibility with gltf, a special mode has been added
  113687. * to reproduce the gltf light falloff.
  113688. */
  113689. useGLTFLightFalloff: boolean;
  113690. /**
  113691. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113692. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113693. */
  113694. useRadianceOverAlpha: boolean;
  113695. /**
  113696. * Allows using an object space normal map (instead of tangent space).
  113697. */
  113698. useObjectSpaceNormalMap: boolean;
  113699. /**
  113700. * Allows using the bump map in parallax mode.
  113701. */
  113702. useParallax: boolean;
  113703. /**
  113704. * Allows using the bump map in parallax occlusion mode.
  113705. */
  113706. useParallaxOcclusion: boolean;
  113707. /**
  113708. * Controls the scale bias of the parallax mode.
  113709. */
  113710. parallaxScaleBias: number;
  113711. /**
  113712. * If sets to true, disables all the lights affecting the material.
  113713. */
  113714. disableLighting: boolean;
  113715. /**
  113716. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113717. */
  113718. forceIrradianceInFragment: boolean;
  113719. /**
  113720. * Number of Simultaneous lights allowed on the material.
  113721. */
  113722. maxSimultaneousLights: number;
  113723. /**
  113724. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  113725. */
  113726. invertNormalMapX: boolean;
  113727. /**
  113728. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  113729. */
  113730. invertNormalMapY: boolean;
  113731. /**
  113732. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113733. */
  113734. twoSidedLighting: boolean;
  113735. /**
  113736. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113737. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113738. */
  113739. useAlphaFresnel: boolean;
  113740. /**
  113741. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113742. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113743. */
  113744. useLinearAlphaFresnel: boolean;
  113745. /**
  113746. * Let user defines the brdf lookup texture used for IBL.
  113747. * A default 8bit version is embedded but you could point at :
  113748. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  113749. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  113750. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  113751. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  113752. */
  113753. environmentBRDFTexture: Nullable<BaseTexture>;
  113754. /**
  113755. * Force normal to face away from face.
  113756. */
  113757. forceNormalForward: boolean;
  113758. /**
  113759. * Enables specular anti aliasing in the PBR shader.
  113760. * It will both interacts on the Geometry for analytical and IBL lighting.
  113761. * It also prefilter the roughness map based on the bump values.
  113762. */
  113763. enableSpecularAntiAliasing: boolean;
  113764. /**
  113765. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113766. * makes the reflect vector face the model (under horizon).
  113767. */
  113768. useHorizonOcclusion: boolean;
  113769. /**
  113770. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113771. * too much the area relying on ambient texture to define their ambient occlusion.
  113772. */
  113773. useRadianceOcclusion: boolean;
  113774. /**
  113775. * If set to true, no lighting calculations will be applied.
  113776. */
  113777. unlit: boolean;
  113778. /**
  113779. * Gets the image processing configuration used either in this material.
  113780. */
  113781. /**
  113782. * Sets the Default image processing configuration used either in the this material.
  113783. *
  113784. * If sets to null, the scene one is in use.
  113785. */
  113786. imageProcessingConfiguration: ImageProcessingConfiguration;
  113787. /**
  113788. * Gets wether the color curves effect is enabled.
  113789. */
  113790. /**
  113791. * Sets wether the color curves effect is enabled.
  113792. */
  113793. cameraColorCurvesEnabled: boolean;
  113794. /**
  113795. * Gets wether the color grading effect is enabled.
  113796. */
  113797. /**
  113798. * Gets wether the color grading effect is enabled.
  113799. */
  113800. cameraColorGradingEnabled: boolean;
  113801. /**
  113802. * Gets wether tonemapping is enabled or not.
  113803. */
  113804. /**
  113805. * Sets wether tonemapping is enabled or not
  113806. */
  113807. cameraToneMappingEnabled: boolean;
  113808. /**
  113809. * The camera exposure used on this material.
  113810. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113811. * This corresponds to a photographic exposure.
  113812. */
  113813. /**
  113814. * The camera exposure used on this material.
  113815. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113816. * This corresponds to a photographic exposure.
  113817. */
  113818. cameraExposure: number;
  113819. /**
  113820. * Gets The camera contrast used on this material.
  113821. */
  113822. /**
  113823. * Sets The camera contrast used on this material.
  113824. */
  113825. cameraContrast: number;
  113826. /**
  113827. * Gets the Color Grading 2D Lookup Texture.
  113828. */
  113829. /**
  113830. * Sets the Color Grading 2D Lookup Texture.
  113831. */
  113832. cameraColorGradingTexture: Nullable<BaseTexture>;
  113833. /**
  113834. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113835. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113836. * 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;
  113837. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113838. */
  113839. /**
  113840. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113841. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113842. * 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;
  113843. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113844. */
  113845. cameraColorCurves: Nullable<ColorCurves>;
  113846. /**
  113847. * Instantiates a new PBRMaterial instance.
  113848. *
  113849. * @param name The material name
  113850. * @param scene The scene the material will be use in.
  113851. */
  113852. constructor(name: string, scene: Scene);
  113853. /**
  113854. * Returns the name of this material class.
  113855. */
  113856. getClassName(): string;
  113857. /**
  113858. * Makes a duplicate of the current material.
  113859. * @param name - name to use for the new material.
  113860. */
  113861. clone(name: string): PBRMaterial;
  113862. /**
  113863. * Serializes this PBR Material.
  113864. * @returns - An object with the serialized material.
  113865. */
  113866. serialize(): any;
  113867. /**
  113868. * Parses a PBR Material from a serialized object.
  113869. * @param source - Serialized object.
  113870. * @param scene - BJS scene instance.
  113871. * @param rootUrl - url for the scene object
  113872. * @returns - PBRMaterial
  113873. */
  113874. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  113875. }
  113876. }
  113877. declare module BABYLON {
  113878. /**
  113879. * Direct draw surface info
  113880. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  113881. */
  113882. export interface DDSInfo {
  113883. /**
  113884. * Width of the texture
  113885. */
  113886. width: number;
  113887. /**
  113888. * Width of the texture
  113889. */
  113890. height: number;
  113891. /**
  113892. * Number of Mipmaps for the texture
  113893. * @see https://en.wikipedia.org/wiki/Mipmap
  113894. */
  113895. mipmapCount: number;
  113896. /**
  113897. * If the textures format is a known fourCC format
  113898. * @see https://www.fourcc.org/
  113899. */
  113900. isFourCC: boolean;
  113901. /**
  113902. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  113903. */
  113904. isRGB: boolean;
  113905. /**
  113906. * If the texture is a lumincance format
  113907. */
  113908. isLuminance: boolean;
  113909. /**
  113910. * If this is a cube texture
  113911. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  113912. */
  113913. isCube: boolean;
  113914. /**
  113915. * If the texture is a compressed format eg. FOURCC_DXT1
  113916. */
  113917. isCompressed: boolean;
  113918. /**
  113919. * The dxgiFormat of the texture
  113920. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  113921. */
  113922. dxgiFormat: number;
  113923. /**
  113924. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  113925. */
  113926. textureType: number;
  113927. /**
  113928. * Sphericle polynomial created for the dds texture
  113929. */
  113930. sphericalPolynomial?: SphericalPolynomial;
  113931. }
  113932. /**
  113933. * Class used to provide DDS decompression tools
  113934. */
  113935. export class DDSTools {
  113936. /**
  113937. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  113938. */
  113939. static StoreLODInAlphaChannel: boolean;
  113940. /**
  113941. * Gets DDS information from an array buffer
  113942. * @param arrayBuffer defines the array buffer to read data from
  113943. * @returns the DDS information
  113944. */
  113945. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  113946. private static _FloatView;
  113947. private static _Int32View;
  113948. private static _ToHalfFloat;
  113949. private static _FromHalfFloat;
  113950. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  113951. private static _GetHalfFloatRGBAArrayBuffer;
  113952. private static _GetFloatRGBAArrayBuffer;
  113953. private static _GetFloatAsUIntRGBAArrayBuffer;
  113954. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  113955. private static _GetRGBAArrayBuffer;
  113956. private static _ExtractLongWordOrder;
  113957. private static _GetRGBArrayBuffer;
  113958. private static _GetLuminanceArrayBuffer;
  113959. /**
  113960. * Uploads DDS Levels to a Babylon Texture
  113961. * @hidden
  113962. */
  113963. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  113964. }
  113965. interface Engine {
  113966. /**
  113967. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  113968. * @param rootUrl defines the url where the file to load is located
  113969. * @param scene defines the current scene
  113970. * @param lodScale defines scale to apply to the mip map selection
  113971. * @param lodOffset defines offset to apply to the mip map selection
  113972. * @param onLoad defines an optional callback raised when the texture is loaded
  113973. * @param onError defines an optional callback raised if there is an issue to load the texture
  113974. * @param format defines the format of the data
  113975. * @param forcedExtension defines the extension to use to pick the right loader
  113976. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  113977. * @returns the cube texture as an InternalTexture
  113978. */
  113979. 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;
  113980. }
  113981. }
  113982. declare module BABYLON {
  113983. /**
  113984. * Implementation of the DDS Texture Loader.
  113985. * @hidden
  113986. */
  113987. export class _DDSTextureLoader implements IInternalTextureLoader {
  113988. /**
  113989. * Defines wether the loader supports cascade loading the different faces.
  113990. */
  113991. readonly supportCascades: boolean;
  113992. /**
  113993. * This returns if the loader support the current file information.
  113994. * @param extension defines the file extension of the file being loaded
  113995. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113996. * @param fallback defines the fallback internal texture if any
  113997. * @param isBase64 defines whether the texture is encoded as a base64
  113998. * @param isBuffer defines whether the texture data are stored as a buffer
  113999. * @returns true if the loader can load the specified file
  114000. */
  114001. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114002. /**
  114003. * Transform the url before loading if required.
  114004. * @param rootUrl the url of the texture
  114005. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114006. * @returns the transformed texture
  114007. */
  114008. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114009. /**
  114010. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114011. * @param rootUrl the url of the texture
  114012. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114013. * @returns the fallback texture
  114014. */
  114015. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114016. /**
  114017. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114018. * @param data contains the texture data
  114019. * @param texture defines the BabylonJS internal texture
  114020. * @param createPolynomials will be true if polynomials have been requested
  114021. * @param onLoad defines the callback to trigger once the texture is ready
  114022. * @param onError defines the callback to trigger in case of error
  114023. */
  114024. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114025. /**
  114026. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114027. * @param data contains the texture data
  114028. * @param texture defines the BabylonJS internal texture
  114029. * @param callback defines the method to call once ready to upload
  114030. */
  114031. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114032. }
  114033. }
  114034. declare module BABYLON {
  114035. /**
  114036. * Implementation of the ENV Texture Loader.
  114037. * @hidden
  114038. */
  114039. export class _ENVTextureLoader implements IInternalTextureLoader {
  114040. /**
  114041. * Defines wether the loader supports cascade loading the different faces.
  114042. */
  114043. readonly supportCascades: boolean;
  114044. /**
  114045. * This returns if the loader support the current file information.
  114046. * @param extension defines the file extension of the file being loaded
  114047. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114048. * @param fallback defines the fallback internal texture if any
  114049. * @param isBase64 defines whether the texture is encoded as a base64
  114050. * @param isBuffer defines whether the texture data are stored as a buffer
  114051. * @returns true if the loader can load the specified file
  114052. */
  114053. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114054. /**
  114055. * Transform the url before loading if required.
  114056. * @param rootUrl the url of the texture
  114057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114058. * @returns the transformed texture
  114059. */
  114060. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114061. /**
  114062. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114063. * @param rootUrl the url of the texture
  114064. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114065. * @returns the fallback texture
  114066. */
  114067. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114068. /**
  114069. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114070. * @param data contains the texture data
  114071. * @param texture defines the BabylonJS internal texture
  114072. * @param createPolynomials will be true if polynomials have been requested
  114073. * @param onLoad defines the callback to trigger once the texture is ready
  114074. * @param onError defines the callback to trigger in case of error
  114075. */
  114076. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114077. /**
  114078. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114079. * @param data contains the texture data
  114080. * @param texture defines the BabylonJS internal texture
  114081. * @param callback defines the method to call once ready to upload
  114082. */
  114083. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114084. }
  114085. }
  114086. declare module BABYLON {
  114087. /**
  114088. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  114089. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  114090. */
  114091. export class KhronosTextureContainer {
  114092. /** contents of the KTX container file */
  114093. arrayBuffer: any;
  114094. private static HEADER_LEN;
  114095. private static COMPRESSED_2D;
  114096. private static COMPRESSED_3D;
  114097. private static TEX_2D;
  114098. private static TEX_3D;
  114099. /**
  114100. * Gets the openGL type
  114101. */
  114102. glType: number;
  114103. /**
  114104. * Gets the openGL type size
  114105. */
  114106. glTypeSize: number;
  114107. /**
  114108. * Gets the openGL format
  114109. */
  114110. glFormat: number;
  114111. /**
  114112. * Gets the openGL internal format
  114113. */
  114114. glInternalFormat: number;
  114115. /**
  114116. * Gets the base internal format
  114117. */
  114118. glBaseInternalFormat: number;
  114119. /**
  114120. * Gets image width in pixel
  114121. */
  114122. pixelWidth: number;
  114123. /**
  114124. * Gets image height in pixel
  114125. */
  114126. pixelHeight: number;
  114127. /**
  114128. * Gets image depth in pixels
  114129. */
  114130. pixelDepth: number;
  114131. /**
  114132. * Gets the number of array elements
  114133. */
  114134. numberOfArrayElements: number;
  114135. /**
  114136. * Gets the number of faces
  114137. */
  114138. numberOfFaces: number;
  114139. /**
  114140. * Gets the number of mipmap levels
  114141. */
  114142. numberOfMipmapLevels: number;
  114143. /**
  114144. * Gets the bytes of key value data
  114145. */
  114146. bytesOfKeyValueData: number;
  114147. /**
  114148. * Gets the load type
  114149. */
  114150. loadType: number;
  114151. /**
  114152. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  114153. */
  114154. isInvalid: boolean;
  114155. /**
  114156. * Creates a new KhronosTextureContainer
  114157. * @param arrayBuffer contents of the KTX container file
  114158. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  114159. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  114160. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  114161. */
  114162. constructor(
  114163. /** contents of the KTX container file */
  114164. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  114165. /**
  114166. * Uploads KTX content to a Babylon Texture.
  114167. * It is assumed that the texture has already been created & is currently bound
  114168. * @hidden
  114169. */
  114170. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  114171. private _upload2DCompressedLevels;
  114172. }
  114173. }
  114174. declare module BABYLON {
  114175. /**
  114176. * Implementation of the KTX Texture Loader.
  114177. * @hidden
  114178. */
  114179. export class _KTXTextureLoader implements IInternalTextureLoader {
  114180. /**
  114181. * Defines wether the loader supports cascade loading the different faces.
  114182. */
  114183. readonly supportCascades: boolean;
  114184. /**
  114185. * This returns if the loader support the current file information.
  114186. * @param extension defines the file extension of the file being loaded
  114187. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114188. * @param fallback defines the fallback internal texture if any
  114189. * @param isBase64 defines whether the texture is encoded as a base64
  114190. * @param isBuffer defines whether the texture data are stored as a buffer
  114191. * @returns true if the loader can load the specified file
  114192. */
  114193. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114194. /**
  114195. * Transform the url before loading if required.
  114196. * @param rootUrl the url of the texture
  114197. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114198. * @returns the transformed texture
  114199. */
  114200. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114201. /**
  114202. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114203. * @param rootUrl the url of the texture
  114204. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114205. * @returns the fallback texture
  114206. */
  114207. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114208. /**
  114209. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114210. * @param data contains the texture data
  114211. * @param texture defines the BabylonJS internal texture
  114212. * @param createPolynomials will be true if polynomials have been requested
  114213. * @param onLoad defines the callback to trigger once the texture is ready
  114214. * @param onError defines the callback to trigger in case of error
  114215. */
  114216. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114217. /**
  114218. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114219. * @param data contains the texture data
  114220. * @param texture defines the BabylonJS internal texture
  114221. * @param callback defines the method to call once ready to upload
  114222. */
  114223. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  114224. }
  114225. }
  114226. declare module BABYLON {
  114227. /**
  114228. * Options for the default xr helper
  114229. */
  114230. export class WebXRDefaultExperienceOptions {
  114231. /**
  114232. * Floor meshes that should be used for teleporting
  114233. */
  114234. floorMeshes: Array<AbstractMesh>;
  114235. }
  114236. /**
  114237. * Default experience which provides a similar setup to the previous webVRExperience
  114238. */
  114239. export class WebXRDefaultExperience {
  114240. /**
  114241. * Base experience
  114242. */
  114243. baseExperience: WebXRExperienceHelper;
  114244. /**
  114245. * Input experience extension
  114246. */
  114247. input: WebXRInput;
  114248. /**
  114249. * Loads the controller models
  114250. */
  114251. controllerModelLoader: WebXRControllerModelLoader;
  114252. /**
  114253. * Enables laser pointer and selection
  114254. */
  114255. pointerSelection: WebXRControllerPointerSelection;
  114256. /**
  114257. * Enables teleportation
  114258. */
  114259. teleportation: WebXRControllerTeleportation;
  114260. /**
  114261. * Enables ui for enetering/exiting xr
  114262. */
  114263. enterExitUI: WebXREnterExitUI;
  114264. /**
  114265. * Default output canvas xr should render to
  114266. */
  114267. outputCanvas: WebXRManagedOutputCanvas;
  114268. /**
  114269. * Creates the default xr experience
  114270. * @param scene scene
  114271. * @param options options for basic configuration
  114272. * @returns resulting WebXRDefaultExperience
  114273. */
  114274. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114275. private constructor();
  114276. /**
  114277. * DIsposes of the experience helper
  114278. */
  114279. dispose(): void;
  114280. }
  114281. }
  114282. declare module BABYLON {
  114283. /** @hidden */
  114284. export var _forceSceneHelpersToBundle: boolean;
  114285. interface Scene {
  114286. /**
  114287. * Creates a default light for the scene.
  114288. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  114289. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  114290. */
  114291. createDefaultLight(replace?: boolean): void;
  114292. /**
  114293. * Creates a default camera for the scene.
  114294. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  114295. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114296. * @param replace has default false, when true replaces the active camera in the scene
  114297. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  114298. */
  114299. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114300. /**
  114301. * Creates a default camera and a default light.
  114302. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  114303. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114304. * @param replace has the default false, when true replaces the active camera/light in the scene
  114305. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  114306. */
  114307. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114308. /**
  114309. * Creates a new sky box
  114310. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  114311. * @param environmentTexture defines the texture to use as environment texture
  114312. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  114313. * @param scale defines the overall scale of the skybox
  114314. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  114315. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  114316. * @returns a new mesh holding the sky box
  114317. */
  114318. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  114319. /**
  114320. * Creates a new environment
  114321. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  114322. * @param options defines the options you can use to configure the environment
  114323. * @returns the new EnvironmentHelper
  114324. */
  114325. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  114326. /**
  114327. * Creates a new VREXperienceHelper
  114328. * @see http://doc.babylonjs.com/how_to/webvr_helper
  114329. * @param webVROptions defines the options used to create the new VREXperienceHelper
  114330. * @returns a new VREXperienceHelper
  114331. */
  114332. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  114333. /**
  114334. * Creates a new WebXRDefaultExperience
  114335. * @see http://doc.babylonjs.com/how_to/webxr
  114336. * @param options experience options
  114337. * @returns a promise for a new WebXRDefaultExperience
  114338. */
  114339. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114340. }
  114341. }
  114342. declare module BABYLON {
  114343. /**
  114344. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  114345. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  114346. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  114347. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114348. */
  114349. export class VideoDome extends TransformNode {
  114350. /**
  114351. * Define the video source as a Monoscopic panoramic 360 video.
  114352. */
  114353. static readonly MODE_MONOSCOPIC: number;
  114354. /**
  114355. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114356. */
  114357. static readonly MODE_TOPBOTTOM: number;
  114358. /**
  114359. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114360. */
  114361. static readonly MODE_SIDEBYSIDE: number;
  114362. private _halfDome;
  114363. private _useDirectMapping;
  114364. /**
  114365. * The video texture being displayed on the sphere
  114366. */
  114367. protected _videoTexture: VideoTexture;
  114368. /**
  114369. * Gets the video texture being displayed on the sphere
  114370. */
  114371. readonly videoTexture: VideoTexture;
  114372. /**
  114373. * The skybox material
  114374. */
  114375. protected _material: BackgroundMaterial;
  114376. /**
  114377. * The surface used for the skybox
  114378. */
  114379. protected _mesh: Mesh;
  114380. /**
  114381. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  114382. */
  114383. private _halfDomeMask;
  114384. /**
  114385. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114386. * Also see the options.resolution property.
  114387. */
  114388. fovMultiplier: number;
  114389. private _videoMode;
  114390. /**
  114391. * Gets or set the current video mode for the video. It can be:
  114392. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  114393. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114394. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114395. */
  114396. videoMode: number;
  114397. /**
  114398. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  114399. *
  114400. */
  114401. /**
  114402. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  114403. */
  114404. halfDome: boolean;
  114405. /**
  114406. * Oberserver used in Stereoscopic VR Mode.
  114407. */
  114408. private _onBeforeCameraRenderObserver;
  114409. /**
  114410. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  114411. * @param name Element's name, child elements will append suffixes for their own names.
  114412. * @param urlsOrVideo defines the url(s) or the video element to use
  114413. * @param options An object containing optional or exposed sub element properties
  114414. */
  114415. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  114416. resolution?: number;
  114417. clickToPlay?: boolean;
  114418. autoPlay?: boolean;
  114419. loop?: boolean;
  114420. size?: number;
  114421. poster?: string;
  114422. faceForward?: boolean;
  114423. useDirectMapping?: boolean;
  114424. halfDomeMode?: boolean;
  114425. }, scene: Scene);
  114426. private _changeVideoMode;
  114427. /**
  114428. * Releases resources associated with this node.
  114429. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114430. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114431. */
  114432. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114433. }
  114434. }
  114435. declare module BABYLON {
  114436. /**
  114437. * This class can be used to get instrumentation data from a Babylon engine
  114438. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114439. */
  114440. export class EngineInstrumentation implements IDisposable {
  114441. /**
  114442. * Define the instrumented engine.
  114443. */
  114444. engine: Engine;
  114445. private _captureGPUFrameTime;
  114446. private _gpuFrameTimeToken;
  114447. private _gpuFrameTime;
  114448. private _captureShaderCompilationTime;
  114449. private _shaderCompilationTime;
  114450. private _onBeginFrameObserver;
  114451. private _onEndFrameObserver;
  114452. private _onBeforeShaderCompilationObserver;
  114453. private _onAfterShaderCompilationObserver;
  114454. /**
  114455. * Gets the perf counter used for GPU frame time
  114456. */
  114457. readonly gpuFrameTimeCounter: PerfCounter;
  114458. /**
  114459. * Gets the GPU frame time capture status
  114460. */
  114461. /**
  114462. * Enable or disable the GPU frame time capture
  114463. */
  114464. captureGPUFrameTime: boolean;
  114465. /**
  114466. * Gets the perf counter used for shader compilation time
  114467. */
  114468. readonly shaderCompilationTimeCounter: PerfCounter;
  114469. /**
  114470. * Gets the shader compilation time capture status
  114471. */
  114472. /**
  114473. * Enable or disable the shader compilation time capture
  114474. */
  114475. captureShaderCompilationTime: boolean;
  114476. /**
  114477. * Instantiates a new engine instrumentation.
  114478. * This class can be used to get instrumentation data from a Babylon engine
  114479. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114480. * @param engine Defines the engine to instrument
  114481. */
  114482. constructor(
  114483. /**
  114484. * Define the instrumented engine.
  114485. */
  114486. engine: Engine);
  114487. /**
  114488. * Dispose and release associated resources.
  114489. */
  114490. dispose(): void;
  114491. }
  114492. }
  114493. declare module BABYLON {
  114494. /**
  114495. * This class can be used to get instrumentation data from a Babylon engine
  114496. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114497. */
  114498. export class SceneInstrumentation implements IDisposable {
  114499. /**
  114500. * Defines the scene to instrument
  114501. */
  114502. scene: Scene;
  114503. private _captureActiveMeshesEvaluationTime;
  114504. private _activeMeshesEvaluationTime;
  114505. private _captureRenderTargetsRenderTime;
  114506. private _renderTargetsRenderTime;
  114507. private _captureFrameTime;
  114508. private _frameTime;
  114509. private _captureRenderTime;
  114510. private _renderTime;
  114511. private _captureInterFrameTime;
  114512. private _interFrameTime;
  114513. private _captureParticlesRenderTime;
  114514. private _particlesRenderTime;
  114515. private _captureSpritesRenderTime;
  114516. private _spritesRenderTime;
  114517. private _capturePhysicsTime;
  114518. private _physicsTime;
  114519. private _captureAnimationsTime;
  114520. private _animationsTime;
  114521. private _captureCameraRenderTime;
  114522. private _cameraRenderTime;
  114523. private _onBeforeActiveMeshesEvaluationObserver;
  114524. private _onAfterActiveMeshesEvaluationObserver;
  114525. private _onBeforeRenderTargetsRenderObserver;
  114526. private _onAfterRenderTargetsRenderObserver;
  114527. private _onAfterRenderObserver;
  114528. private _onBeforeDrawPhaseObserver;
  114529. private _onAfterDrawPhaseObserver;
  114530. private _onBeforeAnimationsObserver;
  114531. private _onBeforeParticlesRenderingObserver;
  114532. private _onAfterParticlesRenderingObserver;
  114533. private _onBeforeSpritesRenderingObserver;
  114534. private _onAfterSpritesRenderingObserver;
  114535. private _onBeforePhysicsObserver;
  114536. private _onAfterPhysicsObserver;
  114537. private _onAfterAnimationsObserver;
  114538. private _onBeforeCameraRenderObserver;
  114539. private _onAfterCameraRenderObserver;
  114540. /**
  114541. * Gets the perf counter used for active meshes evaluation time
  114542. */
  114543. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  114544. /**
  114545. * Gets the active meshes evaluation time capture status
  114546. */
  114547. /**
  114548. * Enable or disable the active meshes evaluation time capture
  114549. */
  114550. captureActiveMeshesEvaluationTime: boolean;
  114551. /**
  114552. * Gets the perf counter used for render targets render time
  114553. */
  114554. readonly renderTargetsRenderTimeCounter: PerfCounter;
  114555. /**
  114556. * Gets the render targets render time capture status
  114557. */
  114558. /**
  114559. * Enable or disable the render targets render time capture
  114560. */
  114561. captureRenderTargetsRenderTime: boolean;
  114562. /**
  114563. * Gets the perf counter used for particles render time
  114564. */
  114565. readonly particlesRenderTimeCounter: PerfCounter;
  114566. /**
  114567. * Gets the particles render time capture status
  114568. */
  114569. /**
  114570. * Enable or disable the particles render time capture
  114571. */
  114572. captureParticlesRenderTime: boolean;
  114573. /**
  114574. * Gets the perf counter used for sprites render time
  114575. */
  114576. readonly spritesRenderTimeCounter: PerfCounter;
  114577. /**
  114578. * Gets the sprites render time capture status
  114579. */
  114580. /**
  114581. * Enable or disable the sprites render time capture
  114582. */
  114583. captureSpritesRenderTime: boolean;
  114584. /**
  114585. * Gets the perf counter used for physics time
  114586. */
  114587. readonly physicsTimeCounter: PerfCounter;
  114588. /**
  114589. * Gets the physics time capture status
  114590. */
  114591. /**
  114592. * Enable or disable the physics time capture
  114593. */
  114594. capturePhysicsTime: boolean;
  114595. /**
  114596. * Gets the perf counter used for animations time
  114597. */
  114598. readonly animationsTimeCounter: PerfCounter;
  114599. /**
  114600. * Gets the animations time capture status
  114601. */
  114602. /**
  114603. * Enable or disable the animations time capture
  114604. */
  114605. captureAnimationsTime: boolean;
  114606. /**
  114607. * Gets the perf counter used for frame time capture
  114608. */
  114609. readonly frameTimeCounter: PerfCounter;
  114610. /**
  114611. * Gets the frame time capture status
  114612. */
  114613. /**
  114614. * Enable or disable the frame time capture
  114615. */
  114616. captureFrameTime: boolean;
  114617. /**
  114618. * Gets the perf counter used for inter-frames time capture
  114619. */
  114620. readonly interFrameTimeCounter: PerfCounter;
  114621. /**
  114622. * Gets the inter-frames time capture status
  114623. */
  114624. /**
  114625. * Enable or disable the inter-frames time capture
  114626. */
  114627. captureInterFrameTime: boolean;
  114628. /**
  114629. * Gets the perf counter used for render time capture
  114630. */
  114631. readonly renderTimeCounter: PerfCounter;
  114632. /**
  114633. * Gets the render time capture status
  114634. */
  114635. /**
  114636. * Enable or disable the render time capture
  114637. */
  114638. captureRenderTime: boolean;
  114639. /**
  114640. * Gets the perf counter used for camera render time capture
  114641. */
  114642. readonly cameraRenderTimeCounter: PerfCounter;
  114643. /**
  114644. * Gets the camera render time capture status
  114645. */
  114646. /**
  114647. * Enable or disable the camera render time capture
  114648. */
  114649. captureCameraRenderTime: boolean;
  114650. /**
  114651. * Gets the perf counter used for draw calls
  114652. */
  114653. readonly drawCallsCounter: PerfCounter;
  114654. /**
  114655. * Instantiates a new scene instrumentation.
  114656. * This class can be used to get instrumentation data from a Babylon engine
  114657. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114658. * @param scene Defines the scene to instrument
  114659. */
  114660. constructor(
  114661. /**
  114662. * Defines the scene to instrument
  114663. */
  114664. scene: Scene);
  114665. /**
  114666. * Dispose and release associated resources.
  114667. */
  114668. dispose(): void;
  114669. }
  114670. }
  114671. declare module BABYLON {
  114672. /** @hidden */
  114673. export var glowMapGenerationPixelShader: {
  114674. name: string;
  114675. shader: string;
  114676. };
  114677. }
  114678. declare module BABYLON {
  114679. /** @hidden */
  114680. export var glowMapGenerationVertexShader: {
  114681. name: string;
  114682. shader: string;
  114683. };
  114684. }
  114685. declare module BABYLON {
  114686. /**
  114687. * Effect layer options. This helps customizing the behaviour
  114688. * of the effect layer.
  114689. */
  114690. export interface IEffectLayerOptions {
  114691. /**
  114692. * Multiplication factor apply to the canvas size to compute the render target size
  114693. * used to generated the objects (the smaller the faster).
  114694. */
  114695. mainTextureRatio: number;
  114696. /**
  114697. * Enforces a fixed size texture to ensure effect stability across devices.
  114698. */
  114699. mainTextureFixedSize?: number;
  114700. /**
  114701. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  114702. */
  114703. alphaBlendingMode: number;
  114704. /**
  114705. * The camera attached to the layer.
  114706. */
  114707. camera: Nullable<Camera>;
  114708. /**
  114709. * The rendering group to draw the layer in.
  114710. */
  114711. renderingGroupId: number;
  114712. }
  114713. /**
  114714. * The effect layer Helps adding post process effect blended with the main pass.
  114715. *
  114716. * This can be for instance use to generate glow or higlight effects on the scene.
  114717. *
  114718. * The effect layer class can not be used directly and is intented to inherited from to be
  114719. * customized per effects.
  114720. */
  114721. export abstract class EffectLayer {
  114722. private _vertexBuffers;
  114723. private _indexBuffer;
  114724. private _cachedDefines;
  114725. private _effectLayerMapGenerationEffect;
  114726. private _effectLayerOptions;
  114727. private _mergeEffect;
  114728. protected _scene: Scene;
  114729. protected _engine: Engine;
  114730. protected _maxSize: number;
  114731. protected _mainTextureDesiredSize: ISize;
  114732. protected _mainTexture: RenderTargetTexture;
  114733. protected _shouldRender: boolean;
  114734. protected _postProcesses: PostProcess[];
  114735. protected _textures: BaseTexture[];
  114736. protected _emissiveTextureAndColor: {
  114737. texture: Nullable<BaseTexture>;
  114738. color: Color4;
  114739. };
  114740. /**
  114741. * The name of the layer
  114742. */
  114743. name: string;
  114744. /**
  114745. * The clear color of the texture used to generate the glow map.
  114746. */
  114747. neutralColor: Color4;
  114748. /**
  114749. * Specifies wether the highlight layer is enabled or not.
  114750. */
  114751. isEnabled: boolean;
  114752. /**
  114753. * Gets the camera attached to the layer.
  114754. */
  114755. readonly camera: Nullable<Camera>;
  114756. /**
  114757. * Gets the rendering group id the layer should render in.
  114758. */
  114759. renderingGroupId: number;
  114760. /**
  114761. * An event triggered when the effect layer has been disposed.
  114762. */
  114763. onDisposeObservable: Observable<EffectLayer>;
  114764. /**
  114765. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  114766. */
  114767. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  114768. /**
  114769. * An event triggered when the generated texture is being merged in the scene.
  114770. */
  114771. onBeforeComposeObservable: Observable<EffectLayer>;
  114772. /**
  114773. * An event triggered when the generated texture has been merged in the scene.
  114774. */
  114775. onAfterComposeObservable: Observable<EffectLayer>;
  114776. /**
  114777. * An event triggered when the efffect layer changes its size.
  114778. */
  114779. onSizeChangedObservable: Observable<EffectLayer>;
  114780. /** @hidden */
  114781. static _SceneComponentInitialization: (scene: Scene) => void;
  114782. /**
  114783. * Instantiates a new effect Layer and references it in the scene.
  114784. * @param name The name of the layer
  114785. * @param scene The scene to use the layer in
  114786. */
  114787. constructor(
  114788. /** The Friendly of the effect in the scene */
  114789. name: string, scene: Scene);
  114790. /**
  114791. * Get the effect name of the layer.
  114792. * @return The effect name
  114793. */
  114794. abstract getEffectName(): string;
  114795. /**
  114796. * Checks for the readiness of the element composing the layer.
  114797. * @param subMesh the mesh to check for
  114798. * @param useInstances specify wether or not to use instances to render the mesh
  114799. * @return true if ready otherwise, false
  114800. */
  114801. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114802. /**
  114803. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114804. * @returns true if the effect requires stencil during the main canvas render pass.
  114805. */
  114806. abstract needStencil(): boolean;
  114807. /**
  114808. * Create the merge effect. This is the shader use to blit the information back
  114809. * to the main canvas at the end of the scene rendering.
  114810. * @returns The effect containing the shader used to merge the effect on the main canvas
  114811. */
  114812. protected abstract _createMergeEffect(): Effect;
  114813. /**
  114814. * Creates the render target textures and post processes used in the effect layer.
  114815. */
  114816. protected abstract _createTextureAndPostProcesses(): void;
  114817. /**
  114818. * Implementation specific of rendering the generating effect on the main canvas.
  114819. * @param effect The effect used to render through
  114820. */
  114821. protected abstract _internalRender(effect: Effect): void;
  114822. /**
  114823. * Sets the required values for both the emissive texture and and the main color.
  114824. */
  114825. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114826. /**
  114827. * Free any resources and references associated to a mesh.
  114828. * Internal use
  114829. * @param mesh The mesh to free.
  114830. */
  114831. abstract _disposeMesh(mesh: Mesh): void;
  114832. /**
  114833. * Serializes this layer (Glow or Highlight for example)
  114834. * @returns a serialized layer object
  114835. */
  114836. abstract serialize?(): any;
  114837. /**
  114838. * Initializes the effect layer with the required options.
  114839. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  114840. */
  114841. protected _init(options: Partial<IEffectLayerOptions>): void;
  114842. /**
  114843. * Generates the index buffer of the full screen quad blending to the main canvas.
  114844. */
  114845. private _generateIndexBuffer;
  114846. /**
  114847. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  114848. */
  114849. private _generateVertexBuffer;
  114850. /**
  114851. * Sets the main texture desired size which is the closest power of two
  114852. * of the engine canvas size.
  114853. */
  114854. private _setMainTextureSize;
  114855. /**
  114856. * Creates the main texture for the effect layer.
  114857. */
  114858. protected _createMainTexture(): void;
  114859. /**
  114860. * Adds specific effects defines.
  114861. * @param defines The defines to add specifics to.
  114862. */
  114863. protected _addCustomEffectDefines(defines: string[]): void;
  114864. /**
  114865. * Checks for the readiness of the element composing the layer.
  114866. * @param subMesh the mesh to check for
  114867. * @param useInstances specify wether or not to use instances to render the mesh
  114868. * @param emissiveTexture the associated emissive texture used to generate the glow
  114869. * @return true if ready otherwise, false
  114870. */
  114871. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  114872. /**
  114873. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  114874. */
  114875. render(): void;
  114876. /**
  114877. * Determine if a given mesh will be used in the current effect.
  114878. * @param mesh mesh to test
  114879. * @returns true if the mesh will be used
  114880. */
  114881. hasMesh(mesh: AbstractMesh): boolean;
  114882. /**
  114883. * Returns true if the layer contains information to display, otherwise false.
  114884. * @returns true if the glow layer should be rendered
  114885. */
  114886. shouldRender(): boolean;
  114887. /**
  114888. * Returns true if the mesh should render, otherwise false.
  114889. * @param mesh The mesh to render
  114890. * @returns true if it should render otherwise false
  114891. */
  114892. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  114893. /**
  114894. * Returns true if the mesh can be rendered, otherwise false.
  114895. * @param mesh The mesh to render
  114896. * @param material The material used on the mesh
  114897. * @returns true if it can be rendered otherwise false
  114898. */
  114899. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114900. /**
  114901. * Returns true if the mesh should render, otherwise false.
  114902. * @param mesh The mesh to render
  114903. * @returns true if it should render otherwise false
  114904. */
  114905. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  114906. /**
  114907. * Renders the submesh passed in parameter to the generation map.
  114908. */
  114909. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  114910. /**
  114911. * Rebuild the required buffers.
  114912. * @hidden Internal use only.
  114913. */
  114914. _rebuild(): void;
  114915. /**
  114916. * Dispose only the render target textures and post process.
  114917. */
  114918. private _disposeTextureAndPostProcesses;
  114919. /**
  114920. * Dispose the highlight layer and free resources.
  114921. */
  114922. dispose(): void;
  114923. /**
  114924. * Gets the class name of the effect layer
  114925. * @returns the string with the class name of the effect layer
  114926. */
  114927. getClassName(): string;
  114928. /**
  114929. * Creates an effect layer from parsed effect layer data
  114930. * @param parsedEffectLayer defines effect layer data
  114931. * @param scene defines the current scene
  114932. * @param rootUrl defines the root URL containing the effect layer information
  114933. * @returns a parsed effect Layer
  114934. */
  114935. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  114936. }
  114937. }
  114938. declare module BABYLON {
  114939. interface AbstractScene {
  114940. /**
  114941. * The list of effect layers (highlights/glow) added to the scene
  114942. * @see http://doc.babylonjs.com/how_to/highlight_layer
  114943. * @see http://doc.babylonjs.com/how_to/glow_layer
  114944. */
  114945. effectLayers: Array<EffectLayer>;
  114946. /**
  114947. * Removes the given effect layer from this scene.
  114948. * @param toRemove defines the effect layer to remove
  114949. * @returns the index of the removed effect layer
  114950. */
  114951. removeEffectLayer(toRemove: EffectLayer): number;
  114952. /**
  114953. * Adds the given effect layer to this scene
  114954. * @param newEffectLayer defines the effect layer to add
  114955. */
  114956. addEffectLayer(newEffectLayer: EffectLayer): void;
  114957. }
  114958. /**
  114959. * Defines the layer scene component responsible to manage any effect layers
  114960. * in a given scene.
  114961. */
  114962. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  114963. /**
  114964. * The component name helpfull to identify the component in the list of scene components.
  114965. */
  114966. readonly name: string;
  114967. /**
  114968. * The scene the component belongs to.
  114969. */
  114970. scene: Scene;
  114971. private _engine;
  114972. private _renderEffects;
  114973. private _needStencil;
  114974. private _previousStencilState;
  114975. /**
  114976. * Creates a new instance of the component for the given scene
  114977. * @param scene Defines the scene to register the component in
  114978. */
  114979. constructor(scene: Scene);
  114980. /**
  114981. * Registers the component in a given scene
  114982. */
  114983. register(): void;
  114984. /**
  114985. * Rebuilds the elements related to this component in case of
  114986. * context lost for instance.
  114987. */
  114988. rebuild(): void;
  114989. /**
  114990. * Serializes the component data to the specified json object
  114991. * @param serializationObject The object to serialize to
  114992. */
  114993. serialize(serializationObject: any): void;
  114994. /**
  114995. * Adds all the elements from the container to the scene
  114996. * @param container the container holding the elements
  114997. */
  114998. addFromContainer(container: AbstractScene): void;
  114999. /**
  115000. * Removes all the elements in the container from the scene
  115001. * @param container contains the elements to remove
  115002. * @param dispose if the removed element should be disposed (default: false)
  115003. */
  115004. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115005. /**
  115006. * Disposes the component and the associated ressources.
  115007. */
  115008. dispose(): void;
  115009. private _isReadyForMesh;
  115010. private _renderMainTexture;
  115011. private _setStencil;
  115012. private _setStencilBack;
  115013. private _draw;
  115014. private _drawCamera;
  115015. private _drawRenderingGroup;
  115016. }
  115017. }
  115018. declare module BABYLON {
  115019. /** @hidden */
  115020. export var glowMapMergePixelShader: {
  115021. name: string;
  115022. shader: string;
  115023. };
  115024. }
  115025. declare module BABYLON {
  115026. /** @hidden */
  115027. export var glowMapMergeVertexShader: {
  115028. name: string;
  115029. shader: string;
  115030. };
  115031. }
  115032. declare module BABYLON {
  115033. interface AbstractScene {
  115034. /**
  115035. * Return a the first highlight layer of the scene with a given name.
  115036. * @param name The name of the highlight layer to look for.
  115037. * @return The highlight layer if found otherwise null.
  115038. */
  115039. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  115040. }
  115041. /**
  115042. * Glow layer options. This helps customizing the behaviour
  115043. * of the glow layer.
  115044. */
  115045. export interface IGlowLayerOptions {
  115046. /**
  115047. * Multiplication factor apply to the canvas size to compute the render target size
  115048. * used to generated the glowing objects (the smaller the faster).
  115049. */
  115050. mainTextureRatio: number;
  115051. /**
  115052. * Enforces a fixed size texture to ensure resize independant blur.
  115053. */
  115054. mainTextureFixedSize?: number;
  115055. /**
  115056. * How big is the kernel of the blur texture.
  115057. */
  115058. blurKernelSize: number;
  115059. /**
  115060. * The camera attached to the layer.
  115061. */
  115062. camera: Nullable<Camera>;
  115063. /**
  115064. * Enable MSAA by chosing the number of samples.
  115065. */
  115066. mainTextureSamples?: number;
  115067. /**
  115068. * The rendering group to draw the layer in.
  115069. */
  115070. renderingGroupId: number;
  115071. }
  115072. /**
  115073. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  115074. *
  115075. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115076. * glowy meshes to your scene.
  115077. *
  115078. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  115079. */
  115080. export class GlowLayer extends EffectLayer {
  115081. /**
  115082. * Effect Name of the layer.
  115083. */
  115084. static readonly EffectName: string;
  115085. /**
  115086. * The default blur kernel size used for the glow.
  115087. */
  115088. static DefaultBlurKernelSize: number;
  115089. /**
  115090. * The default texture size ratio used for the glow.
  115091. */
  115092. static DefaultTextureRatio: number;
  115093. /**
  115094. * Sets the kernel size of the blur.
  115095. */
  115096. /**
  115097. * Gets the kernel size of the blur.
  115098. */
  115099. blurKernelSize: number;
  115100. /**
  115101. * Sets the glow intensity.
  115102. */
  115103. /**
  115104. * Gets the glow intensity.
  115105. */
  115106. intensity: number;
  115107. private _options;
  115108. private _intensity;
  115109. private _horizontalBlurPostprocess1;
  115110. private _verticalBlurPostprocess1;
  115111. private _horizontalBlurPostprocess2;
  115112. private _verticalBlurPostprocess2;
  115113. private _blurTexture1;
  115114. private _blurTexture2;
  115115. private _postProcesses1;
  115116. private _postProcesses2;
  115117. private _includedOnlyMeshes;
  115118. private _excludedMeshes;
  115119. /**
  115120. * Callback used to let the user override the color selection on a per mesh basis
  115121. */
  115122. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  115123. /**
  115124. * Callback used to let the user override the texture selection on a per mesh basis
  115125. */
  115126. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  115127. /**
  115128. * Instantiates a new glow Layer and references it to the scene.
  115129. * @param name The name of the layer
  115130. * @param scene The scene to use the layer in
  115131. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  115132. */
  115133. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  115134. /**
  115135. * Get the effect name of the layer.
  115136. * @return The effect name
  115137. */
  115138. getEffectName(): string;
  115139. /**
  115140. * Create the merge effect. This is the shader use to blit the information back
  115141. * to the main canvas at the end of the scene rendering.
  115142. */
  115143. protected _createMergeEffect(): Effect;
  115144. /**
  115145. * Creates the render target textures and post processes used in the glow layer.
  115146. */
  115147. protected _createTextureAndPostProcesses(): void;
  115148. /**
  115149. * Checks for the readiness of the element composing the layer.
  115150. * @param subMesh the mesh to check for
  115151. * @param useInstances specify wether or not to use instances to render the mesh
  115152. * @param emissiveTexture the associated emissive texture used to generate the glow
  115153. * @return true if ready otherwise, false
  115154. */
  115155. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115156. /**
  115157. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115158. */
  115159. needStencil(): boolean;
  115160. /**
  115161. * Returns true if the mesh can be rendered, otherwise false.
  115162. * @param mesh The mesh to render
  115163. * @param material The material used on the mesh
  115164. * @returns true if it can be rendered otherwise false
  115165. */
  115166. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  115167. /**
  115168. * Implementation specific of rendering the generating effect on the main canvas.
  115169. * @param effect The effect used to render through
  115170. */
  115171. protected _internalRender(effect: Effect): void;
  115172. /**
  115173. * Sets the required values for both the emissive texture and and the main color.
  115174. */
  115175. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115176. /**
  115177. * Returns true if the mesh should render, otherwise false.
  115178. * @param mesh The mesh to render
  115179. * @returns true if it should render otherwise false
  115180. */
  115181. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115182. /**
  115183. * Adds specific effects defines.
  115184. * @param defines The defines to add specifics to.
  115185. */
  115186. protected _addCustomEffectDefines(defines: string[]): void;
  115187. /**
  115188. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  115189. * @param mesh The mesh to exclude from the glow layer
  115190. */
  115191. addExcludedMesh(mesh: Mesh): void;
  115192. /**
  115193. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  115194. * @param mesh The mesh to remove
  115195. */
  115196. removeExcludedMesh(mesh: Mesh): void;
  115197. /**
  115198. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  115199. * @param mesh The mesh to include in the glow layer
  115200. */
  115201. addIncludedOnlyMesh(mesh: Mesh): void;
  115202. /**
  115203. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  115204. * @param mesh The mesh to remove
  115205. */
  115206. removeIncludedOnlyMesh(mesh: Mesh): void;
  115207. /**
  115208. * Determine if a given mesh will be used in the glow layer
  115209. * @param mesh The mesh to test
  115210. * @returns true if the mesh will be highlighted by the current glow layer
  115211. */
  115212. hasMesh(mesh: AbstractMesh): boolean;
  115213. /**
  115214. * Free any resources and references associated to a mesh.
  115215. * Internal use
  115216. * @param mesh The mesh to free.
  115217. * @hidden
  115218. */
  115219. _disposeMesh(mesh: Mesh): void;
  115220. /**
  115221. * Gets the class name of the effect layer
  115222. * @returns the string with the class name of the effect layer
  115223. */
  115224. getClassName(): string;
  115225. /**
  115226. * Serializes this glow layer
  115227. * @returns a serialized glow layer object
  115228. */
  115229. serialize(): any;
  115230. /**
  115231. * Creates a Glow Layer from parsed glow layer data
  115232. * @param parsedGlowLayer defines glow layer data
  115233. * @param scene defines the current scene
  115234. * @param rootUrl defines the root URL containing the glow layer information
  115235. * @returns a parsed Glow Layer
  115236. */
  115237. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  115238. }
  115239. }
  115240. declare module BABYLON {
  115241. /** @hidden */
  115242. export var glowBlurPostProcessPixelShader: {
  115243. name: string;
  115244. shader: string;
  115245. };
  115246. }
  115247. declare module BABYLON {
  115248. interface AbstractScene {
  115249. /**
  115250. * Return a the first highlight layer of the scene with a given name.
  115251. * @param name The name of the highlight layer to look for.
  115252. * @return The highlight layer if found otherwise null.
  115253. */
  115254. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  115255. }
  115256. /**
  115257. * Highlight layer options. This helps customizing the behaviour
  115258. * of the highlight layer.
  115259. */
  115260. export interface IHighlightLayerOptions {
  115261. /**
  115262. * Multiplication factor apply to the canvas size to compute the render target size
  115263. * used to generated the glowing objects (the smaller the faster).
  115264. */
  115265. mainTextureRatio: number;
  115266. /**
  115267. * Enforces a fixed size texture to ensure resize independant blur.
  115268. */
  115269. mainTextureFixedSize?: number;
  115270. /**
  115271. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  115272. * of the picture to blur (the smaller the faster).
  115273. */
  115274. blurTextureSizeRatio: number;
  115275. /**
  115276. * How big in texel of the blur texture is the vertical blur.
  115277. */
  115278. blurVerticalSize: number;
  115279. /**
  115280. * How big in texel of the blur texture is the horizontal blur.
  115281. */
  115282. blurHorizontalSize: number;
  115283. /**
  115284. * Alpha blending mode used to apply the blur. Default is combine.
  115285. */
  115286. alphaBlendingMode: number;
  115287. /**
  115288. * The camera attached to the layer.
  115289. */
  115290. camera: Nullable<Camera>;
  115291. /**
  115292. * Should we display highlight as a solid stroke?
  115293. */
  115294. isStroke?: boolean;
  115295. /**
  115296. * The rendering group to draw the layer in.
  115297. */
  115298. renderingGroupId: number;
  115299. }
  115300. /**
  115301. * The highlight layer Helps adding a glow effect around a mesh.
  115302. *
  115303. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115304. * glowy meshes to your scene.
  115305. *
  115306. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  115307. */
  115308. export class HighlightLayer extends EffectLayer {
  115309. name: string;
  115310. /**
  115311. * Effect Name of the highlight layer.
  115312. */
  115313. static readonly EffectName: string;
  115314. /**
  115315. * The neutral color used during the preparation of the glow effect.
  115316. * This is black by default as the blend operation is a blend operation.
  115317. */
  115318. static NeutralColor: Color4;
  115319. /**
  115320. * Stencil value used for glowing meshes.
  115321. */
  115322. static GlowingMeshStencilReference: number;
  115323. /**
  115324. * Stencil value used for the other meshes in the scene.
  115325. */
  115326. static NormalMeshStencilReference: number;
  115327. /**
  115328. * Specifies whether or not the inner glow is ACTIVE in the layer.
  115329. */
  115330. innerGlow: boolean;
  115331. /**
  115332. * Specifies whether or not the outer glow is ACTIVE in the layer.
  115333. */
  115334. outerGlow: boolean;
  115335. /**
  115336. * Specifies the horizontal size of the blur.
  115337. */
  115338. /**
  115339. * Gets the horizontal size of the blur.
  115340. */
  115341. blurHorizontalSize: number;
  115342. /**
  115343. * Specifies the vertical size of the blur.
  115344. */
  115345. /**
  115346. * Gets the vertical size of the blur.
  115347. */
  115348. blurVerticalSize: number;
  115349. /**
  115350. * An event triggered when the highlight layer is being blurred.
  115351. */
  115352. onBeforeBlurObservable: Observable<HighlightLayer>;
  115353. /**
  115354. * An event triggered when the highlight layer has been blurred.
  115355. */
  115356. onAfterBlurObservable: Observable<HighlightLayer>;
  115357. private _instanceGlowingMeshStencilReference;
  115358. private _options;
  115359. private _downSamplePostprocess;
  115360. private _horizontalBlurPostprocess;
  115361. private _verticalBlurPostprocess;
  115362. private _blurTexture;
  115363. private _meshes;
  115364. private _excludedMeshes;
  115365. /**
  115366. * Instantiates a new highlight Layer and references it to the scene..
  115367. * @param name The name of the layer
  115368. * @param scene The scene to use the layer in
  115369. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  115370. */
  115371. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  115372. /**
  115373. * Get the effect name of the layer.
  115374. * @return The effect name
  115375. */
  115376. getEffectName(): string;
  115377. /**
  115378. * Create the merge effect. This is the shader use to blit the information back
  115379. * to the main canvas at the end of the scene rendering.
  115380. */
  115381. protected _createMergeEffect(): Effect;
  115382. /**
  115383. * Creates the render target textures and post processes used in the highlight layer.
  115384. */
  115385. protected _createTextureAndPostProcesses(): void;
  115386. /**
  115387. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115388. */
  115389. needStencil(): boolean;
  115390. /**
  115391. * Checks for the readiness of the element composing the layer.
  115392. * @param subMesh the mesh to check for
  115393. * @param useInstances specify wether or not to use instances to render the mesh
  115394. * @param emissiveTexture the associated emissive texture used to generate the glow
  115395. * @return true if ready otherwise, false
  115396. */
  115397. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115398. /**
  115399. * Implementation specific of rendering the generating effect on the main canvas.
  115400. * @param effect The effect used to render through
  115401. */
  115402. protected _internalRender(effect: Effect): void;
  115403. /**
  115404. * Returns true if the layer contains information to display, otherwise false.
  115405. */
  115406. shouldRender(): boolean;
  115407. /**
  115408. * Returns true if the mesh should render, otherwise false.
  115409. * @param mesh The mesh to render
  115410. * @returns true if it should render otherwise false
  115411. */
  115412. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115413. /**
  115414. * Sets the required values for both the emissive texture and and the main color.
  115415. */
  115416. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115417. /**
  115418. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  115419. * @param mesh The mesh to exclude from the highlight layer
  115420. */
  115421. addExcludedMesh(mesh: Mesh): void;
  115422. /**
  115423. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  115424. * @param mesh The mesh to highlight
  115425. */
  115426. removeExcludedMesh(mesh: Mesh): void;
  115427. /**
  115428. * Determine if a given mesh will be highlighted by the current HighlightLayer
  115429. * @param mesh mesh to test
  115430. * @returns true if the mesh will be highlighted by the current HighlightLayer
  115431. */
  115432. hasMesh(mesh: AbstractMesh): boolean;
  115433. /**
  115434. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  115435. * @param mesh The mesh to highlight
  115436. * @param color The color of the highlight
  115437. * @param glowEmissiveOnly Extract the glow from the emissive texture
  115438. */
  115439. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  115440. /**
  115441. * Remove a mesh from the highlight layer in order to make it stop glowing.
  115442. * @param mesh The mesh to highlight
  115443. */
  115444. removeMesh(mesh: Mesh): void;
  115445. /**
  115446. * Force the stencil to the normal expected value for none glowing parts
  115447. */
  115448. private _defaultStencilReference;
  115449. /**
  115450. * Free any resources and references associated to a mesh.
  115451. * Internal use
  115452. * @param mesh The mesh to free.
  115453. * @hidden
  115454. */
  115455. _disposeMesh(mesh: Mesh): void;
  115456. /**
  115457. * Dispose the highlight layer and free resources.
  115458. */
  115459. dispose(): void;
  115460. /**
  115461. * Gets the class name of the effect layer
  115462. * @returns the string with the class name of the effect layer
  115463. */
  115464. getClassName(): string;
  115465. /**
  115466. * Serializes this Highlight layer
  115467. * @returns a serialized Highlight layer object
  115468. */
  115469. serialize(): any;
  115470. /**
  115471. * Creates a Highlight layer from parsed Highlight layer data
  115472. * @param parsedHightlightLayer defines the Highlight layer data
  115473. * @param scene defines the current scene
  115474. * @param rootUrl defines the root URL containing the Highlight layer information
  115475. * @returns a parsed Highlight layer
  115476. */
  115477. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  115478. }
  115479. }
  115480. declare module BABYLON {
  115481. interface AbstractScene {
  115482. /**
  115483. * The list of layers (background and foreground) of the scene
  115484. */
  115485. layers: Array<Layer>;
  115486. }
  115487. /**
  115488. * Defines the layer scene component responsible to manage any layers
  115489. * in a given scene.
  115490. */
  115491. export class LayerSceneComponent implements ISceneComponent {
  115492. /**
  115493. * The component name helpfull to identify the component in the list of scene components.
  115494. */
  115495. readonly name: string;
  115496. /**
  115497. * The scene the component belongs to.
  115498. */
  115499. scene: Scene;
  115500. private _engine;
  115501. /**
  115502. * Creates a new instance of the component for the given scene
  115503. * @param scene Defines the scene to register the component in
  115504. */
  115505. constructor(scene: Scene);
  115506. /**
  115507. * Registers the component in a given scene
  115508. */
  115509. register(): void;
  115510. /**
  115511. * Rebuilds the elements related to this component in case of
  115512. * context lost for instance.
  115513. */
  115514. rebuild(): void;
  115515. /**
  115516. * Disposes the component and the associated ressources.
  115517. */
  115518. dispose(): void;
  115519. private _draw;
  115520. private _drawCameraPredicate;
  115521. private _drawCameraBackground;
  115522. private _drawCameraForeground;
  115523. private _drawRenderTargetPredicate;
  115524. private _drawRenderTargetBackground;
  115525. private _drawRenderTargetForeground;
  115526. /**
  115527. * Adds all the elements from the container to the scene
  115528. * @param container the container holding the elements
  115529. */
  115530. addFromContainer(container: AbstractScene): void;
  115531. /**
  115532. * Removes all the elements in the container from the scene
  115533. * @param container contains the elements to remove
  115534. * @param dispose if the removed element should be disposed (default: false)
  115535. */
  115536. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115537. }
  115538. }
  115539. declare module BABYLON {
  115540. /** @hidden */
  115541. export var layerPixelShader: {
  115542. name: string;
  115543. shader: string;
  115544. };
  115545. }
  115546. declare module BABYLON {
  115547. /** @hidden */
  115548. export var layerVertexShader: {
  115549. name: string;
  115550. shader: string;
  115551. };
  115552. }
  115553. declare module BABYLON {
  115554. /**
  115555. * This represents a full screen 2d layer.
  115556. * This can be useful to display a picture in the background of your scene for instance.
  115557. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115558. */
  115559. export class Layer {
  115560. /**
  115561. * Define the name of the layer.
  115562. */
  115563. name: string;
  115564. /**
  115565. * Define the texture the layer should display.
  115566. */
  115567. texture: Nullable<Texture>;
  115568. /**
  115569. * Is the layer in background or foreground.
  115570. */
  115571. isBackground: boolean;
  115572. /**
  115573. * Define the color of the layer (instead of texture).
  115574. */
  115575. color: Color4;
  115576. /**
  115577. * Define the scale of the layer in order to zoom in out of the texture.
  115578. */
  115579. scale: Vector2;
  115580. /**
  115581. * Define an offset for the layer in order to shift the texture.
  115582. */
  115583. offset: Vector2;
  115584. /**
  115585. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  115586. */
  115587. alphaBlendingMode: number;
  115588. /**
  115589. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  115590. * Alpha test will not mix with the background color in case of transparency.
  115591. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  115592. */
  115593. alphaTest: boolean;
  115594. /**
  115595. * Define a mask to restrict the layer to only some of the scene cameras.
  115596. */
  115597. layerMask: number;
  115598. /**
  115599. * Define the list of render target the layer is visible into.
  115600. */
  115601. renderTargetTextures: RenderTargetTexture[];
  115602. /**
  115603. * Define if the layer is only used in renderTarget or if it also
  115604. * renders in the main frame buffer of the canvas.
  115605. */
  115606. renderOnlyInRenderTargetTextures: boolean;
  115607. private _scene;
  115608. private _vertexBuffers;
  115609. private _indexBuffer;
  115610. private _effect;
  115611. private _alphaTestEffect;
  115612. /**
  115613. * An event triggered when the layer is disposed.
  115614. */
  115615. onDisposeObservable: Observable<Layer>;
  115616. private _onDisposeObserver;
  115617. /**
  115618. * Back compatibility with callback before the onDisposeObservable existed.
  115619. * The set callback will be triggered when the layer has been disposed.
  115620. */
  115621. onDispose: () => void;
  115622. /**
  115623. * An event triggered before rendering the scene
  115624. */
  115625. onBeforeRenderObservable: Observable<Layer>;
  115626. private _onBeforeRenderObserver;
  115627. /**
  115628. * Back compatibility with callback before the onBeforeRenderObservable existed.
  115629. * The set callback will be triggered just before rendering the layer.
  115630. */
  115631. onBeforeRender: () => void;
  115632. /**
  115633. * An event triggered after rendering the scene
  115634. */
  115635. onAfterRenderObservable: Observable<Layer>;
  115636. private _onAfterRenderObserver;
  115637. /**
  115638. * Back compatibility with callback before the onAfterRenderObservable existed.
  115639. * The set callback will be triggered just after rendering the layer.
  115640. */
  115641. onAfterRender: () => void;
  115642. /**
  115643. * Instantiates a new layer.
  115644. * This represents a full screen 2d layer.
  115645. * This can be useful to display a picture in the background of your scene for instance.
  115646. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115647. * @param name Define the name of the layer in the scene
  115648. * @param imgUrl Define the url of the texture to display in the layer
  115649. * @param scene Define the scene the layer belongs to
  115650. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  115651. * @param color Defines a color for the layer
  115652. */
  115653. constructor(
  115654. /**
  115655. * Define the name of the layer.
  115656. */
  115657. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  115658. private _createIndexBuffer;
  115659. /** @hidden */
  115660. _rebuild(): void;
  115661. /**
  115662. * Renders the layer in the scene.
  115663. */
  115664. render(): void;
  115665. /**
  115666. * Disposes and releases the associated ressources.
  115667. */
  115668. dispose(): void;
  115669. }
  115670. }
  115671. declare module BABYLON {
  115672. /** @hidden */
  115673. export var lensFlarePixelShader: {
  115674. name: string;
  115675. shader: string;
  115676. };
  115677. }
  115678. declare module BABYLON {
  115679. /** @hidden */
  115680. export var lensFlareVertexShader: {
  115681. name: string;
  115682. shader: string;
  115683. };
  115684. }
  115685. declare module BABYLON {
  115686. /**
  115687. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115688. * It is usually composed of several `lensFlare`.
  115689. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115690. */
  115691. export class LensFlareSystem {
  115692. /**
  115693. * Define the name of the lens flare system
  115694. */
  115695. name: string;
  115696. /**
  115697. * List of lens flares used in this system.
  115698. */
  115699. lensFlares: LensFlare[];
  115700. /**
  115701. * Define a limit from the border the lens flare can be visible.
  115702. */
  115703. borderLimit: number;
  115704. /**
  115705. * Define a viewport border we do not want to see the lens flare in.
  115706. */
  115707. viewportBorder: number;
  115708. /**
  115709. * Define a predicate which could limit the list of meshes able to occlude the effect.
  115710. */
  115711. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115712. /**
  115713. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  115714. */
  115715. layerMask: number;
  115716. /**
  115717. * Define the id of the lens flare system in the scene.
  115718. * (equal to name by default)
  115719. */
  115720. id: string;
  115721. private _scene;
  115722. private _emitter;
  115723. private _vertexBuffers;
  115724. private _indexBuffer;
  115725. private _effect;
  115726. private _positionX;
  115727. private _positionY;
  115728. private _isEnabled;
  115729. /** @hidden */
  115730. static _SceneComponentInitialization: (scene: Scene) => void;
  115731. /**
  115732. * Instantiates a lens flare system.
  115733. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115734. * It is usually composed of several `lensFlare`.
  115735. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115736. * @param name Define the name of the lens flare system in the scene
  115737. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  115738. * @param scene Define the scene the lens flare system belongs to
  115739. */
  115740. constructor(
  115741. /**
  115742. * Define the name of the lens flare system
  115743. */
  115744. name: string, emitter: any, scene: Scene);
  115745. /**
  115746. * Define if the lens flare system is enabled.
  115747. */
  115748. isEnabled: boolean;
  115749. /**
  115750. * Get the scene the effects belongs to.
  115751. * @returns the scene holding the lens flare system
  115752. */
  115753. getScene(): Scene;
  115754. /**
  115755. * Get the emitter of the lens flare system.
  115756. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115757. * @returns the emitter of the lens flare system
  115758. */
  115759. getEmitter(): any;
  115760. /**
  115761. * Set the emitter of the lens flare system.
  115762. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115763. * @param newEmitter Define the new emitter of the system
  115764. */
  115765. setEmitter(newEmitter: any): void;
  115766. /**
  115767. * Get the lens flare system emitter position.
  115768. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  115769. * @returns the position
  115770. */
  115771. getEmitterPosition(): Vector3;
  115772. /**
  115773. * @hidden
  115774. */
  115775. computeEffectivePosition(globalViewport: Viewport): boolean;
  115776. /** @hidden */
  115777. _isVisible(): boolean;
  115778. /**
  115779. * @hidden
  115780. */
  115781. render(): boolean;
  115782. /**
  115783. * Dispose and release the lens flare with its associated resources.
  115784. */
  115785. dispose(): void;
  115786. /**
  115787. * Parse a lens flare system from a JSON repressentation
  115788. * @param parsedLensFlareSystem Define the JSON to parse
  115789. * @param scene Define the scene the parsed system should be instantiated in
  115790. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  115791. * @returns the parsed system
  115792. */
  115793. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  115794. /**
  115795. * Serialize the current Lens Flare System into a JSON representation.
  115796. * @returns the serialized JSON
  115797. */
  115798. serialize(): any;
  115799. }
  115800. }
  115801. declare module BABYLON {
  115802. /**
  115803. * This represents one of the lens effect in a `lensFlareSystem`.
  115804. * It controls one of the indiviual texture used in the effect.
  115805. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115806. */
  115807. export class LensFlare {
  115808. /**
  115809. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115810. */
  115811. size: number;
  115812. /**
  115813. * 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.
  115814. */
  115815. position: number;
  115816. /**
  115817. * Define the lens color.
  115818. */
  115819. color: Color3;
  115820. /**
  115821. * Define the lens texture.
  115822. */
  115823. texture: Nullable<Texture>;
  115824. /**
  115825. * Define the alpha mode to render this particular lens.
  115826. */
  115827. alphaMode: number;
  115828. private _system;
  115829. /**
  115830. * Creates a new Lens Flare.
  115831. * This represents one of the lens effect in a `lensFlareSystem`.
  115832. * It controls one of the indiviual texture used in the effect.
  115833. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115834. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  115835. * @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.
  115836. * @param color Define the lens color
  115837. * @param imgUrl Define the lens texture url
  115838. * @param system Define the `lensFlareSystem` this flare is part of
  115839. * @returns The newly created Lens Flare
  115840. */
  115841. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  115842. /**
  115843. * Instantiates a new Lens Flare.
  115844. * This represents one of the lens effect in a `lensFlareSystem`.
  115845. * It controls one of the indiviual texture used in the effect.
  115846. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115847. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  115848. * @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.
  115849. * @param color Define the lens color
  115850. * @param imgUrl Define the lens texture url
  115851. * @param system Define the `lensFlareSystem` this flare is part of
  115852. */
  115853. constructor(
  115854. /**
  115855. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115856. */
  115857. size: number,
  115858. /**
  115859. * 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.
  115860. */
  115861. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  115862. /**
  115863. * Dispose and release the lens flare with its associated resources.
  115864. */
  115865. dispose(): void;
  115866. }
  115867. }
  115868. declare module BABYLON {
  115869. interface AbstractScene {
  115870. /**
  115871. * The list of lens flare system added to the scene
  115872. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115873. */
  115874. lensFlareSystems: Array<LensFlareSystem>;
  115875. /**
  115876. * Removes the given lens flare system from this scene.
  115877. * @param toRemove The lens flare system to remove
  115878. * @returns The index of the removed lens flare system
  115879. */
  115880. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  115881. /**
  115882. * Adds the given lens flare system to this scene
  115883. * @param newLensFlareSystem The lens flare system to add
  115884. */
  115885. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  115886. /**
  115887. * Gets a lens flare system using its name
  115888. * @param name defines the name to look for
  115889. * @returns the lens flare system or null if not found
  115890. */
  115891. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  115892. /**
  115893. * Gets a lens flare system using its id
  115894. * @param id defines the id to look for
  115895. * @returns the lens flare system or null if not found
  115896. */
  115897. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  115898. }
  115899. /**
  115900. * Defines the lens flare scene component responsible to manage any lens flares
  115901. * in a given scene.
  115902. */
  115903. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  115904. /**
  115905. * The component name helpfull to identify the component in the list of scene components.
  115906. */
  115907. readonly name: string;
  115908. /**
  115909. * The scene the component belongs to.
  115910. */
  115911. scene: Scene;
  115912. /**
  115913. * Creates a new instance of the component for the given scene
  115914. * @param scene Defines the scene to register the component in
  115915. */
  115916. constructor(scene: Scene);
  115917. /**
  115918. * Registers the component in a given scene
  115919. */
  115920. register(): void;
  115921. /**
  115922. * Rebuilds the elements related to this component in case of
  115923. * context lost for instance.
  115924. */
  115925. rebuild(): void;
  115926. /**
  115927. * Adds all the elements from the container to the scene
  115928. * @param container the container holding the elements
  115929. */
  115930. addFromContainer(container: AbstractScene): void;
  115931. /**
  115932. * Removes all the elements in the container from the scene
  115933. * @param container contains the elements to remove
  115934. * @param dispose if the removed element should be disposed (default: false)
  115935. */
  115936. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115937. /**
  115938. * Serializes the component data to the specified json object
  115939. * @param serializationObject The object to serialize to
  115940. */
  115941. serialize(serializationObject: any): void;
  115942. /**
  115943. * Disposes the component and the associated ressources.
  115944. */
  115945. dispose(): void;
  115946. private _draw;
  115947. }
  115948. }
  115949. declare module BABYLON {
  115950. /**
  115951. * Defines the shadow generator component responsible to manage any shadow generators
  115952. * in a given scene.
  115953. */
  115954. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  115955. /**
  115956. * The component name helpfull to identify the component in the list of scene components.
  115957. */
  115958. readonly name: string;
  115959. /**
  115960. * The scene the component belongs to.
  115961. */
  115962. scene: Scene;
  115963. /**
  115964. * Creates a new instance of the component for the given scene
  115965. * @param scene Defines the scene to register the component in
  115966. */
  115967. constructor(scene: Scene);
  115968. /**
  115969. * Registers the component in a given scene
  115970. */
  115971. register(): void;
  115972. /**
  115973. * Rebuilds the elements related to this component in case of
  115974. * context lost for instance.
  115975. */
  115976. rebuild(): void;
  115977. /**
  115978. * Serializes the component data to the specified json object
  115979. * @param serializationObject The object to serialize to
  115980. */
  115981. serialize(serializationObject: any): void;
  115982. /**
  115983. * Adds all the elements from the container to the scene
  115984. * @param container the container holding the elements
  115985. */
  115986. addFromContainer(container: AbstractScene): void;
  115987. /**
  115988. * Removes all the elements in the container from the scene
  115989. * @param container contains the elements to remove
  115990. * @param dispose if the removed element should be disposed (default: false)
  115991. */
  115992. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115993. /**
  115994. * Rebuilds the elements related to this component in case of
  115995. * context lost for instance.
  115996. */
  115997. dispose(): void;
  115998. private _gatherRenderTargets;
  115999. }
  116000. }
  116001. declare module BABYLON {
  116002. /**
  116003. * A point light is a light defined by an unique point in world space.
  116004. * The light is emitted in every direction from this point.
  116005. * A good example of a point light is a standard light bulb.
  116006. * Documentation: https://doc.babylonjs.com/babylon101/lights
  116007. */
  116008. export class PointLight extends ShadowLight {
  116009. private _shadowAngle;
  116010. /**
  116011. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116012. * This specifies what angle the shadow will use to be created.
  116013. *
  116014. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  116015. */
  116016. /**
  116017. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116018. * This specifies what angle the shadow will use to be created.
  116019. *
  116020. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  116021. */
  116022. shadowAngle: number;
  116023. /**
  116024. * Gets the direction if it has been set.
  116025. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116026. */
  116027. /**
  116028. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116029. */
  116030. direction: Vector3;
  116031. /**
  116032. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  116033. * A PointLight emits the light in every direction.
  116034. * It can cast shadows.
  116035. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  116036. * ```javascript
  116037. * var pointLight = new PointLight("pl", camera.position, scene);
  116038. * ```
  116039. * Documentation : https://doc.babylonjs.com/babylon101/lights
  116040. * @param name The light friendly name
  116041. * @param position The position of the point light in the scene
  116042. * @param scene The scene the lights belongs to
  116043. */
  116044. constructor(name: string, position: Vector3, scene: Scene);
  116045. /**
  116046. * Returns the string "PointLight"
  116047. * @returns the class name
  116048. */
  116049. getClassName(): string;
  116050. /**
  116051. * Returns the integer 0.
  116052. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  116053. */
  116054. getTypeID(): number;
  116055. /**
  116056. * Specifies wether or not the shadowmap should be a cube texture.
  116057. * @returns true if the shadowmap needs to be a cube texture.
  116058. */
  116059. needCube(): boolean;
  116060. /**
  116061. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  116062. * @param faceIndex The index of the face we are computed the direction to generate shadow
  116063. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  116064. */
  116065. getShadowDirection(faceIndex?: number): Vector3;
  116066. /**
  116067. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  116068. * - fov = PI / 2
  116069. * - aspect ratio : 1.0
  116070. * - z-near and far equal to the active camera minZ and maxZ.
  116071. * Returns the PointLight.
  116072. */
  116073. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  116074. protected _buildUniformLayout(): void;
  116075. /**
  116076. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  116077. * @param effect The effect to update
  116078. * @param lightIndex The index of the light in the effect to update
  116079. * @returns The point light
  116080. */
  116081. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  116082. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  116083. /**
  116084. * Prepares the list of defines specific to the light type.
  116085. * @param defines the list of defines
  116086. * @param lightIndex defines the index of the light for the effect
  116087. */
  116088. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  116089. }
  116090. }
  116091. declare module BABYLON {
  116092. /**
  116093. * Header information of HDR texture files.
  116094. */
  116095. export interface HDRInfo {
  116096. /**
  116097. * The height of the texture in pixels.
  116098. */
  116099. height: number;
  116100. /**
  116101. * The width of the texture in pixels.
  116102. */
  116103. width: number;
  116104. /**
  116105. * The index of the beginning of the data in the binary file.
  116106. */
  116107. dataPosition: number;
  116108. }
  116109. /**
  116110. * This groups tools to convert HDR texture to native colors array.
  116111. */
  116112. export class HDRTools {
  116113. private static Ldexp;
  116114. private static Rgbe2float;
  116115. private static readStringLine;
  116116. /**
  116117. * Reads header information from an RGBE texture stored in a native array.
  116118. * More information on this format are available here:
  116119. * https://en.wikipedia.org/wiki/RGBE_image_format
  116120. *
  116121. * @param uint8array The binary file stored in native array.
  116122. * @return The header information.
  116123. */
  116124. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  116125. /**
  116126. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  116127. * This RGBE texture needs to store the information as a panorama.
  116128. *
  116129. * More information on this format are available here:
  116130. * https://en.wikipedia.org/wiki/RGBE_image_format
  116131. *
  116132. * @param buffer The binary file stored in an array buffer.
  116133. * @param size The expected size of the extracted cubemap.
  116134. * @return The Cube Map information.
  116135. */
  116136. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  116137. /**
  116138. * Returns the pixels data extracted from an RGBE texture.
  116139. * This pixels will be stored left to right up to down in the R G B order in one array.
  116140. *
  116141. * More information on this format are available here:
  116142. * https://en.wikipedia.org/wiki/RGBE_image_format
  116143. *
  116144. * @param uint8array The binary file stored in an array buffer.
  116145. * @param hdrInfo The header information of the file.
  116146. * @return The pixels data in RGB right to left up to down order.
  116147. */
  116148. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  116149. private static RGBE_ReadPixels_RLE;
  116150. }
  116151. }
  116152. declare module BABYLON {
  116153. /**
  116154. * This represents a texture coming from an HDR input.
  116155. *
  116156. * The only supported format is currently panorama picture stored in RGBE format.
  116157. * Example of such files can be found on HDRLib: http://hdrlib.com/
  116158. */
  116159. export class HDRCubeTexture extends BaseTexture {
  116160. private static _facesMapping;
  116161. private _generateHarmonics;
  116162. private _noMipmap;
  116163. private _textureMatrix;
  116164. private _size;
  116165. private _onLoad;
  116166. private _onError;
  116167. /**
  116168. * The texture URL.
  116169. */
  116170. url: string;
  116171. /**
  116172. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  116173. */
  116174. coordinatesMode: number;
  116175. protected _isBlocking: boolean;
  116176. /**
  116177. * Sets wether or not the texture is blocking during loading.
  116178. */
  116179. /**
  116180. * Gets wether or not the texture is blocking during loading.
  116181. */
  116182. isBlocking: boolean;
  116183. protected _rotationY: number;
  116184. /**
  116185. * Sets texture matrix rotation angle around Y axis in radians.
  116186. */
  116187. /**
  116188. * Gets texture matrix rotation angle around Y axis radians.
  116189. */
  116190. rotationY: number;
  116191. /**
  116192. * Gets or sets the center of the bounding box associated with the cube texture
  116193. * It must define where the camera used to render the texture was set
  116194. */
  116195. boundingBoxPosition: Vector3;
  116196. private _boundingBoxSize;
  116197. /**
  116198. * Gets or sets the size of the bounding box associated with the cube texture
  116199. * When defined, the cubemap will switch to local mode
  116200. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  116201. * @example https://www.babylonjs-playground.com/#RNASML
  116202. */
  116203. boundingBoxSize: Vector3;
  116204. /**
  116205. * Instantiates an HDRTexture from the following parameters.
  116206. *
  116207. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  116208. * @param scene The scene the texture will be used in
  116209. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  116210. * @param noMipmap Forces to not generate the mipmap if true
  116211. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  116212. * @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)
  116213. * @param reserved Reserved flag for internal use.
  116214. */
  116215. 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>);
  116216. /**
  116217. * Get the current class name of the texture useful for serialization or dynamic coding.
  116218. * @returns "HDRCubeTexture"
  116219. */
  116220. getClassName(): string;
  116221. /**
  116222. * Occurs when the file is raw .hdr file.
  116223. */
  116224. private loadTexture;
  116225. clone(): HDRCubeTexture;
  116226. delayLoad(): void;
  116227. /**
  116228. * Get the texture reflection matrix used to rotate/transform the reflection.
  116229. * @returns the reflection matrix
  116230. */
  116231. getReflectionTextureMatrix(): Matrix;
  116232. /**
  116233. * Set the texture reflection matrix used to rotate/transform the reflection.
  116234. * @param value Define the reflection matrix to set
  116235. */
  116236. setReflectionTextureMatrix(value: Matrix): void;
  116237. /**
  116238. * Parses a JSON representation of an HDR Texture in order to create the texture
  116239. * @param parsedTexture Define the JSON representation
  116240. * @param scene Define the scene the texture should be created in
  116241. * @param rootUrl Define the root url in case we need to load relative dependencies
  116242. * @returns the newly created texture after parsing
  116243. */
  116244. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  116245. serialize(): any;
  116246. }
  116247. }
  116248. declare module BABYLON {
  116249. /**
  116250. * Class used to control physics engine
  116251. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116252. */
  116253. export class PhysicsEngine implements IPhysicsEngine {
  116254. private _physicsPlugin;
  116255. /**
  116256. * Global value used to control the smallest number supported by the simulation
  116257. */
  116258. static Epsilon: number;
  116259. private _impostors;
  116260. private _joints;
  116261. /**
  116262. * Gets the gravity vector used by the simulation
  116263. */
  116264. gravity: Vector3;
  116265. /**
  116266. * Factory used to create the default physics plugin.
  116267. * @returns The default physics plugin
  116268. */
  116269. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  116270. /**
  116271. * Creates a new Physics Engine
  116272. * @param gravity defines the gravity vector used by the simulation
  116273. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  116274. */
  116275. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  116276. /**
  116277. * Sets the gravity vector used by the simulation
  116278. * @param gravity defines the gravity vector to use
  116279. */
  116280. setGravity(gravity: Vector3): void;
  116281. /**
  116282. * Set the time step of the physics engine.
  116283. * Default is 1/60.
  116284. * To slow it down, enter 1/600 for example.
  116285. * To speed it up, 1/30
  116286. * @param newTimeStep defines the new timestep to apply to this world.
  116287. */
  116288. setTimeStep(newTimeStep?: number): void;
  116289. /**
  116290. * Get the time step of the physics engine.
  116291. * @returns the current time step
  116292. */
  116293. getTimeStep(): number;
  116294. /**
  116295. * Release all resources
  116296. */
  116297. dispose(): void;
  116298. /**
  116299. * Gets the name of the current physics plugin
  116300. * @returns the name of the plugin
  116301. */
  116302. getPhysicsPluginName(): string;
  116303. /**
  116304. * Adding a new impostor for the impostor tracking.
  116305. * This will be done by the impostor itself.
  116306. * @param impostor the impostor to add
  116307. */
  116308. addImpostor(impostor: PhysicsImpostor): void;
  116309. /**
  116310. * Remove an impostor from the engine.
  116311. * This impostor and its mesh will not longer be updated by the physics engine.
  116312. * @param impostor the impostor to remove
  116313. */
  116314. removeImpostor(impostor: PhysicsImpostor): void;
  116315. /**
  116316. * Add a joint to the physics engine
  116317. * @param mainImpostor defines the main impostor to which the joint is added.
  116318. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116319. * @param joint defines the joint that will connect both impostors.
  116320. */
  116321. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116322. /**
  116323. * Removes a joint from the simulation
  116324. * @param mainImpostor defines the impostor used with the joint
  116325. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116326. * @param joint defines the joint to remove
  116327. */
  116328. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116329. /**
  116330. * Called by the scene. No need to call it.
  116331. * @param delta defines the timespam between frames
  116332. */
  116333. _step(delta: number): void;
  116334. /**
  116335. * Gets the current plugin used to run the simulation
  116336. * @returns current plugin
  116337. */
  116338. getPhysicsPlugin(): IPhysicsEnginePlugin;
  116339. /**
  116340. * Gets the list of physic impostors
  116341. * @returns an array of PhysicsImpostor
  116342. */
  116343. getImpostors(): Array<PhysicsImpostor>;
  116344. /**
  116345. * Gets the impostor for a physics enabled object
  116346. * @param object defines the object impersonated by the impostor
  116347. * @returns the PhysicsImpostor or null if not found
  116348. */
  116349. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  116350. /**
  116351. * Gets the impostor for a physics body object
  116352. * @param body defines physics body used by the impostor
  116353. * @returns the PhysicsImpostor or null if not found
  116354. */
  116355. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  116356. /**
  116357. * Does a raycast in the physics world
  116358. * @param from when should the ray start?
  116359. * @param to when should the ray end?
  116360. * @returns PhysicsRaycastResult
  116361. */
  116362. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116363. }
  116364. }
  116365. declare module BABYLON {
  116366. /** @hidden */
  116367. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  116368. private _useDeltaForWorldStep;
  116369. world: any;
  116370. name: string;
  116371. private _physicsMaterials;
  116372. private _fixedTimeStep;
  116373. private _cannonRaycastResult;
  116374. private _raycastResult;
  116375. private _physicsBodysToRemoveAfterStep;
  116376. BJSCANNON: any;
  116377. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  116378. setGravity(gravity: Vector3): void;
  116379. setTimeStep(timeStep: number): void;
  116380. getTimeStep(): number;
  116381. executeStep(delta: number): void;
  116382. private _removeMarkedPhysicsBodiesFromWorld;
  116383. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116384. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116385. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116386. private _processChildMeshes;
  116387. removePhysicsBody(impostor: PhysicsImpostor): void;
  116388. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116389. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116390. private _addMaterial;
  116391. private _checkWithEpsilon;
  116392. private _createShape;
  116393. private _createHeightmap;
  116394. private _minus90X;
  116395. private _plus90X;
  116396. private _tmpPosition;
  116397. private _tmpDeltaPosition;
  116398. private _tmpUnityRotation;
  116399. private _updatePhysicsBodyTransformation;
  116400. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116401. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116402. isSupported(): boolean;
  116403. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116404. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116405. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116406. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116407. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116408. getBodyMass(impostor: PhysicsImpostor): number;
  116409. getBodyFriction(impostor: PhysicsImpostor): number;
  116410. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116411. getBodyRestitution(impostor: PhysicsImpostor): number;
  116412. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116413. sleepBody(impostor: PhysicsImpostor): void;
  116414. wakeUpBody(impostor: PhysicsImpostor): void;
  116415. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  116416. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116417. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116418. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116419. getRadius(impostor: PhysicsImpostor): number;
  116420. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116421. dispose(): void;
  116422. private _extendNamespace;
  116423. /**
  116424. * Does a raycast in the physics world
  116425. * @param from when should the ray start?
  116426. * @param to when should the ray end?
  116427. * @returns PhysicsRaycastResult
  116428. */
  116429. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116430. }
  116431. }
  116432. declare module BABYLON {
  116433. /** @hidden */
  116434. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  116435. world: any;
  116436. name: string;
  116437. BJSOIMO: any;
  116438. private _raycastResult;
  116439. constructor(iterations?: number, oimoInjection?: any);
  116440. setGravity(gravity: Vector3): void;
  116441. setTimeStep(timeStep: number): void;
  116442. getTimeStep(): number;
  116443. private _tmpImpostorsArray;
  116444. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116445. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116446. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116447. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116448. private _tmpPositionVector;
  116449. removePhysicsBody(impostor: PhysicsImpostor): void;
  116450. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116451. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116452. isSupported(): boolean;
  116453. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116454. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116455. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116456. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116457. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116458. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116459. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116460. getBodyMass(impostor: PhysicsImpostor): number;
  116461. getBodyFriction(impostor: PhysicsImpostor): number;
  116462. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116463. getBodyRestitution(impostor: PhysicsImpostor): number;
  116464. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116465. sleepBody(impostor: PhysicsImpostor): void;
  116466. wakeUpBody(impostor: PhysicsImpostor): void;
  116467. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116468. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  116469. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116470. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116471. getRadius(impostor: PhysicsImpostor): number;
  116472. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116473. dispose(): void;
  116474. /**
  116475. * Does a raycast in the physics world
  116476. * @param from when should the ray start?
  116477. * @param to when should the ray end?
  116478. * @returns PhysicsRaycastResult
  116479. */
  116480. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116481. }
  116482. }
  116483. declare module BABYLON {
  116484. /**
  116485. * Class containing static functions to help procedurally build meshes
  116486. */
  116487. export class RibbonBuilder {
  116488. /**
  116489. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116490. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116491. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116492. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116493. * * 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
  116494. * * 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
  116495. * * 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
  116496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116498. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116499. * * 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
  116500. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116501. * * 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
  116502. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116504. * @param name defines the name of the mesh
  116505. * @param options defines the options used to create the mesh
  116506. * @param scene defines the hosting scene
  116507. * @returns the ribbon mesh
  116508. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116509. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116510. */
  116511. static CreateRibbon(name: string, options: {
  116512. pathArray: Vector3[][];
  116513. closeArray?: boolean;
  116514. closePath?: boolean;
  116515. offset?: number;
  116516. updatable?: boolean;
  116517. sideOrientation?: number;
  116518. frontUVs?: Vector4;
  116519. backUVs?: Vector4;
  116520. instance?: Mesh;
  116521. invertUV?: boolean;
  116522. uvs?: Vector2[];
  116523. colors?: Color4[];
  116524. }, scene?: Nullable<Scene>): Mesh;
  116525. }
  116526. }
  116527. declare module BABYLON {
  116528. /**
  116529. * Class containing static functions to help procedurally build meshes
  116530. */
  116531. export class ShapeBuilder {
  116532. /**
  116533. * 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.
  116534. * * 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.
  116535. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116536. * * 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.
  116537. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116538. * * 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
  116539. * * 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
  116540. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116543. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116545. * @param name defines the name of the mesh
  116546. * @param options defines the options used to create the mesh
  116547. * @param scene defines the hosting scene
  116548. * @returns the extruded shape mesh
  116549. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116550. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116551. */
  116552. static ExtrudeShape(name: string, options: {
  116553. shape: Vector3[];
  116554. path: Vector3[];
  116555. scale?: number;
  116556. rotation?: number;
  116557. cap?: number;
  116558. updatable?: boolean;
  116559. sideOrientation?: number;
  116560. frontUVs?: Vector4;
  116561. backUVs?: Vector4;
  116562. instance?: Mesh;
  116563. invertUV?: boolean;
  116564. }, scene?: Nullable<Scene>): Mesh;
  116565. /**
  116566. * Creates an custom extruded shape mesh.
  116567. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116568. * * 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.
  116569. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116570. * * 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
  116571. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116572. * * 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
  116573. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116574. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116575. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116576. * * 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
  116577. * * 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
  116578. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116581. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116583. * @param name defines the name of the mesh
  116584. * @param options defines the options used to create the mesh
  116585. * @param scene defines the hosting scene
  116586. * @returns the custom extruded shape mesh
  116587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116588. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116590. */
  116591. static ExtrudeShapeCustom(name: string, options: {
  116592. shape: Vector3[];
  116593. path: Vector3[];
  116594. scaleFunction?: any;
  116595. rotationFunction?: any;
  116596. ribbonCloseArray?: boolean;
  116597. ribbonClosePath?: boolean;
  116598. cap?: number;
  116599. updatable?: boolean;
  116600. sideOrientation?: number;
  116601. frontUVs?: Vector4;
  116602. backUVs?: Vector4;
  116603. instance?: Mesh;
  116604. invertUV?: boolean;
  116605. }, scene?: Nullable<Scene>): Mesh;
  116606. private static _ExtrudeShapeGeneric;
  116607. }
  116608. }
  116609. declare module BABYLON {
  116610. /**
  116611. * AmmoJS Physics plugin
  116612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116613. * @see https://github.com/kripken/ammo.js/
  116614. */
  116615. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  116616. private _useDeltaForWorldStep;
  116617. /**
  116618. * Reference to the Ammo library
  116619. */
  116620. bjsAMMO: any;
  116621. /**
  116622. * Created ammoJS world which physics bodies are added to
  116623. */
  116624. world: any;
  116625. /**
  116626. * Name of the plugin
  116627. */
  116628. name: string;
  116629. private _timeStep;
  116630. private _fixedTimeStep;
  116631. private _maxSteps;
  116632. private _tmpQuaternion;
  116633. private _tmpAmmoTransform;
  116634. private _tmpAmmoQuaternion;
  116635. private _tmpAmmoConcreteContactResultCallback;
  116636. private _collisionConfiguration;
  116637. private _dispatcher;
  116638. private _overlappingPairCache;
  116639. private _solver;
  116640. private _softBodySolver;
  116641. private _tmpAmmoVectorA;
  116642. private _tmpAmmoVectorB;
  116643. private _tmpAmmoVectorC;
  116644. private _tmpAmmoVectorD;
  116645. private _tmpContactCallbackResult;
  116646. private _tmpAmmoVectorRCA;
  116647. private _tmpAmmoVectorRCB;
  116648. private _raycastResult;
  116649. private static readonly DISABLE_COLLISION_FLAG;
  116650. private static readonly KINEMATIC_FLAG;
  116651. private static readonly DISABLE_DEACTIVATION_FLAG;
  116652. /**
  116653. * Initializes the ammoJS plugin
  116654. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  116655. * @param ammoInjection can be used to inject your own ammo reference
  116656. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  116657. */
  116658. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  116659. /**
  116660. * Sets the gravity of the physics world (m/(s^2))
  116661. * @param gravity Gravity to set
  116662. */
  116663. setGravity(gravity: Vector3): void;
  116664. /**
  116665. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  116666. * @param timeStep timestep to use in seconds
  116667. */
  116668. setTimeStep(timeStep: number): void;
  116669. /**
  116670. * 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)
  116671. * @param fixedTimeStep fixedTimeStep to use in seconds
  116672. */
  116673. setFixedTimeStep(fixedTimeStep: number): void;
  116674. /**
  116675. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  116676. * @param maxSteps the maximum number of steps by the physics engine per frame
  116677. */
  116678. setMaxSteps(maxSteps: number): void;
  116679. /**
  116680. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  116681. * @returns the current timestep in seconds
  116682. */
  116683. getTimeStep(): number;
  116684. private _isImpostorInContact;
  116685. private _isImpostorPairInContact;
  116686. private _stepSimulation;
  116687. /**
  116688. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  116689. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  116690. * After the step the babylon meshes are set to the position of the physics imposters
  116691. * @param delta amount of time to step forward
  116692. * @param impostors array of imposters to update before/after the step
  116693. */
  116694. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116695. /**
  116696. * Update babylon mesh to match physics world object
  116697. * @param impostor imposter to match
  116698. */
  116699. private _afterSoftStep;
  116700. /**
  116701. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116702. * @param impostor imposter to match
  116703. */
  116704. private _ropeStep;
  116705. /**
  116706. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116707. * @param impostor imposter to match
  116708. */
  116709. private _softbodyOrClothStep;
  116710. private _tmpVector;
  116711. private _tmpMatrix;
  116712. /**
  116713. * Applies an impulse on the imposter
  116714. * @param impostor imposter to apply impulse to
  116715. * @param force amount of force to be applied to the imposter
  116716. * @param contactPoint the location to apply the impulse on the imposter
  116717. */
  116718. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116719. /**
  116720. * Applies a force on the imposter
  116721. * @param impostor imposter to apply force
  116722. * @param force amount of force to be applied to the imposter
  116723. * @param contactPoint the location to apply the force on the imposter
  116724. */
  116725. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116726. /**
  116727. * Creates a physics body using the plugin
  116728. * @param impostor the imposter to create the physics body on
  116729. */
  116730. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116731. /**
  116732. * Removes the physics body from the imposter and disposes of the body's memory
  116733. * @param impostor imposter to remove the physics body from
  116734. */
  116735. removePhysicsBody(impostor: PhysicsImpostor): void;
  116736. /**
  116737. * Generates a joint
  116738. * @param impostorJoint the imposter joint to create the joint with
  116739. */
  116740. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116741. /**
  116742. * Removes a joint
  116743. * @param impostorJoint the imposter joint to remove the joint from
  116744. */
  116745. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116746. private _addMeshVerts;
  116747. /**
  116748. * Initialise the soft body vertices to match its object's (mesh) vertices
  116749. * Softbody vertices (nodes) are in world space and to match this
  116750. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  116751. * @param impostor to create the softbody for
  116752. */
  116753. private _softVertexData;
  116754. /**
  116755. * Create an impostor's soft body
  116756. * @param impostor to create the softbody for
  116757. */
  116758. private _createSoftbody;
  116759. /**
  116760. * Create cloth for an impostor
  116761. * @param impostor to create the softbody for
  116762. */
  116763. private _createCloth;
  116764. /**
  116765. * Create rope for an impostor
  116766. * @param impostor to create the softbody for
  116767. */
  116768. private _createRope;
  116769. private _addHullVerts;
  116770. private _createShape;
  116771. /**
  116772. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  116773. * @param impostor imposter containing the physics body and babylon object
  116774. */
  116775. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116776. /**
  116777. * Sets the babylon object's position/rotation from the physics body's position/rotation
  116778. * @param impostor imposter containing the physics body and babylon object
  116779. * @param newPosition new position
  116780. * @param newRotation new rotation
  116781. */
  116782. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116783. /**
  116784. * If this plugin is supported
  116785. * @returns true if its supported
  116786. */
  116787. isSupported(): boolean;
  116788. /**
  116789. * Sets the linear velocity of the physics body
  116790. * @param impostor imposter to set the velocity on
  116791. * @param velocity velocity to set
  116792. */
  116793. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116794. /**
  116795. * Sets the angular velocity of the physics body
  116796. * @param impostor imposter to set the velocity on
  116797. * @param velocity velocity to set
  116798. */
  116799. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116800. /**
  116801. * gets the linear velocity
  116802. * @param impostor imposter to get linear velocity from
  116803. * @returns linear velocity
  116804. */
  116805. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116806. /**
  116807. * gets the angular velocity
  116808. * @param impostor imposter to get angular velocity from
  116809. * @returns angular velocity
  116810. */
  116811. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116812. /**
  116813. * Sets the mass of physics body
  116814. * @param impostor imposter to set the mass on
  116815. * @param mass mass to set
  116816. */
  116817. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116818. /**
  116819. * Gets the mass of the physics body
  116820. * @param impostor imposter to get the mass from
  116821. * @returns mass
  116822. */
  116823. getBodyMass(impostor: PhysicsImpostor): number;
  116824. /**
  116825. * Gets friction of the impostor
  116826. * @param impostor impostor to get friction from
  116827. * @returns friction value
  116828. */
  116829. getBodyFriction(impostor: PhysicsImpostor): number;
  116830. /**
  116831. * Sets friction of the impostor
  116832. * @param impostor impostor to set friction on
  116833. * @param friction friction value
  116834. */
  116835. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116836. /**
  116837. * Gets restitution of the impostor
  116838. * @param impostor impostor to get restitution from
  116839. * @returns restitution value
  116840. */
  116841. getBodyRestitution(impostor: PhysicsImpostor): number;
  116842. /**
  116843. * Sets resitution of the impostor
  116844. * @param impostor impostor to set resitution on
  116845. * @param restitution resitution value
  116846. */
  116847. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116848. /**
  116849. * Gets pressure inside the impostor
  116850. * @param impostor impostor to get pressure from
  116851. * @returns pressure value
  116852. */
  116853. getBodyPressure(impostor: PhysicsImpostor): number;
  116854. /**
  116855. * Sets pressure inside a soft body impostor
  116856. * Cloth and rope must remain 0 pressure
  116857. * @param impostor impostor to set pressure on
  116858. * @param pressure pressure value
  116859. */
  116860. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  116861. /**
  116862. * Gets stiffness of the impostor
  116863. * @param impostor impostor to get stiffness from
  116864. * @returns pressure value
  116865. */
  116866. getBodyStiffness(impostor: PhysicsImpostor): number;
  116867. /**
  116868. * Sets stiffness of the impostor
  116869. * @param impostor impostor to set stiffness on
  116870. * @param stiffness stiffness value from 0 to 1
  116871. */
  116872. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  116873. /**
  116874. * Gets velocityIterations of the impostor
  116875. * @param impostor impostor to get velocity iterations from
  116876. * @returns velocityIterations value
  116877. */
  116878. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  116879. /**
  116880. * Sets velocityIterations of the impostor
  116881. * @param impostor impostor to set velocity iterations on
  116882. * @param velocityIterations velocityIterations value
  116883. */
  116884. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  116885. /**
  116886. * Gets positionIterations of the impostor
  116887. * @param impostor impostor to get position iterations from
  116888. * @returns positionIterations value
  116889. */
  116890. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  116891. /**
  116892. * Sets positionIterations of the impostor
  116893. * @param impostor impostor to set position on
  116894. * @param positionIterations positionIterations value
  116895. */
  116896. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  116897. /**
  116898. * Append an anchor to a cloth object
  116899. * @param impostor is the cloth impostor to add anchor to
  116900. * @param otherImpostor is the rigid impostor to anchor to
  116901. * @param width ratio across width from 0 to 1
  116902. * @param height ratio up height from 0 to 1
  116903. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  116904. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116905. */
  116906. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116907. /**
  116908. * Append an hook to a rope object
  116909. * @param impostor is the rope impostor to add hook to
  116910. * @param otherImpostor is the rigid impostor to hook to
  116911. * @param length ratio along the rope from 0 to 1
  116912. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  116913. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116914. */
  116915. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116916. /**
  116917. * Sleeps the physics body and stops it from being active
  116918. * @param impostor impostor to sleep
  116919. */
  116920. sleepBody(impostor: PhysicsImpostor): void;
  116921. /**
  116922. * Activates the physics body
  116923. * @param impostor impostor to activate
  116924. */
  116925. wakeUpBody(impostor: PhysicsImpostor): void;
  116926. /**
  116927. * Updates the distance parameters of the joint
  116928. * @param joint joint to update
  116929. * @param maxDistance maximum distance of the joint
  116930. * @param minDistance minimum distance of the joint
  116931. */
  116932. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116933. /**
  116934. * Sets a motor on the joint
  116935. * @param joint joint to set motor on
  116936. * @param speed speed of the motor
  116937. * @param maxForce maximum force of the motor
  116938. * @param motorIndex index of the motor
  116939. */
  116940. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116941. /**
  116942. * Sets the motors limit
  116943. * @param joint joint to set limit on
  116944. * @param upperLimit upper limit
  116945. * @param lowerLimit lower limit
  116946. */
  116947. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116948. /**
  116949. * Syncs the position and rotation of a mesh with the impostor
  116950. * @param mesh mesh to sync
  116951. * @param impostor impostor to update the mesh with
  116952. */
  116953. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116954. /**
  116955. * Gets the radius of the impostor
  116956. * @param impostor impostor to get radius from
  116957. * @returns the radius
  116958. */
  116959. getRadius(impostor: PhysicsImpostor): number;
  116960. /**
  116961. * Gets the box size of the impostor
  116962. * @param impostor impostor to get box size from
  116963. * @param result the resulting box size
  116964. */
  116965. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116966. /**
  116967. * Disposes of the impostor
  116968. */
  116969. dispose(): void;
  116970. /**
  116971. * Does a raycast in the physics world
  116972. * @param from when should the ray start?
  116973. * @param to when should the ray end?
  116974. * @returns PhysicsRaycastResult
  116975. */
  116976. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116977. }
  116978. }
  116979. declare module BABYLON {
  116980. interface AbstractScene {
  116981. /**
  116982. * The list of reflection probes added to the scene
  116983. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116984. */
  116985. reflectionProbes: Array<ReflectionProbe>;
  116986. /**
  116987. * Removes the given reflection probe from this scene.
  116988. * @param toRemove The reflection probe to remove
  116989. * @returns The index of the removed reflection probe
  116990. */
  116991. removeReflectionProbe(toRemove: ReflectionProbe): number;
  116992. /**
  116993. * Adds the given reflection probe to this scene.
  116994. * @param newReflectionProbe The reflection probe to add
  116995. */
  116996. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  116997. }
  116998. /**
  116999. * Class used to generate realtime reflection / refraction cube textures
  117000. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  117001. */
  117002. export class ReflectionProbe {
  117003. /** defines the name of the probe */
  117004. name: string;
  117005. private _scene;
  117006. private _renderTargetTexture;
  117007. private _projectionMatrix;
  117008. private _viewMatrix;
  117009. private _target;
  117010. private _add;
  117011. private _attachedMesh;
  117012. private _invertYAxis;
  117013. /** Gets or sets probe position (center of the cube map) */
  117014. position: Vector3;
  117015. /**
  117016. * Creates a new reflection probe
  117017. * @param name defines the name of the probe
  117018. * @param size defines the texture resolution (for each face)
  117019. * @param scene defines the hosting scene
  117020. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  117021. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  117022. */
  117023. constructor(
  117024. /** defines the name of the probe */
  117025. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  117026. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  117027. samples: number;
  117028. /** Gets or sets the refresh rate to use (on every frame by default) */
  117029. refreshRate: number;
  117030. /**
  117031. * Gets the hosting scene
  117032. * @returns a Scene
  117033. */
  117034. getScene(): Scene;
  117035. /** Gets the internal CubeTexture used to render to */
  117036. readonly cubeTexture: RenderTargetTexture;
  117037. /** Gets the list of meshes to render */
  117038. readonly renderList: Nullable<AbstractMesh[]>;
  117039. /**
  117040. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  117041. * @param mesh defines the mesh to attach to
  117042. */
  117043. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  117044. /**
  117045. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  117046. * @param renderingGroupId The rendering group id corresponding to its index
  117047. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  117048. */
  117049. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  117050. /**
  117051. * Clean all associated resources
  117052. */
  117053. dispose(): void;
  117054. /**
  117055. * Converts the reflection probe information to a readable string for debug purpose.
  117056. * @param fullDetails Supports for multiple levels of logging within scene loading
  117057. * @returns the human readable reflection probe info
  117058. */
  117059. toString(fullDetails?: boolean): string;
  117060. /**
  117061. * Get the class name of the relfection probe.
  117062. * @returns "ReflectionProbe"
  117063. */
  117064. getClassName(): string;
  117065. /**
  117066. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  117067. * @returns The JSON representation of the texture
  117068. */
  117069. serialize(): any;
  117070. /**
  117071. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  117072. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  117073. * @param scene Define the scene the parsed reflection probe should be instantiated in
  117074. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  117075. * @returns The parsed reflection probe if successful
  117076. */
  117077. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  117078. }
  117079. }
  117080. declare module BABYLON {
  117081. /** @hidden */
  117082. export var _BabylonLoaderRegistered: boolean;
  117083. }
  117084. declare module BABYLON {
  117085. /**
  117086. * The Physically based simple base material of BJS.
  117087. *
  117088. * This enables better naming and convention enforcements on top of the pbrMaterial.
  117089. * It is used as the base class for both the specGloss and metalRough conventions.
  117090. */
  117091. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  117092. /**
  117093. * Number of Simultaneous lights allowed on the material.
  117094. */
  117095. maxSimultaneousLights: number;
  117096. /**
  117097. * If sets to true, disables all the lights affecting the material.
  117098. */
  117099. disableLighting: boolean;
  117100. /**
  117101. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  117102. */
  117103. environmentTexture: BaseTexture;
  117104. /**
  117105. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  117106. */
  117107. invertNormalMapX: boolean;
  117108. /**
  117109. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  117110. */
  117111. invertNormalMapY: boolean;
  117112. /**
  117113. * Normal map used in the model.
  117114. */
  117115. normalTexture: BaseTexture;
  117116. /**
  117117. * Emissivie color used to self-illuminate the model.
  117118. */
  117119. emissiveColor: Color3;
  117120. /**
  117121. * Emissivie texture used to self-illuminate the model.
  117122. */
  117123. emissiveTexture: BaseTexture;
  117124. /**
  117125. * Occlusion Channel Strenght.
  117126. */
  117127. occlusionStrength: number;
  117128. /**
  117129. * Occlusion Texture of the material (adding extra occlusion effects).
  117130. */
  117131. occlusionTexture: BaseTexture;
  117132. /**
  117133. * Defines the alpha limits in alpha test mode.
  117134. */
  117135. alphaCutOff: number;
  117136. /**
  117137. * Gets the current double sided mode.
  117138. */
  117139. /**
  117140. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117141. */
  117142. doubleSided: boolean;
  117143. /**
  117144. * Stores the pre-calculated light information of a mesh in a texture.
  117145. */
  117146. lightmapTexture: BaseTexture;
  117147. /**
  117148. * If true, the light map contains occlusion information instead of lighting info.
  117149. */
  117150. useLightmapAsShadowmap: boolean;
  117151. /**
  117152. * Instantiates a new PBRMaterial instance.
  117153. *
  117154. * @param name The material name
  117155. * @param scene The scene the material will be use in.
  117156. */
  117157. constructor(name: string, scene: Scene);
  117158. getClassName(): string;
  117159. }
  117160. }
  117161. declare module BABYLON {
  117162. /**
  117163. * The PBR material of BJS following the metal roughness convention.
  117164. *
  117165. * This fits to the PBR convention in the GLTF definition:
  117166. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  117167. */
  117168. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  117169. /**
  117170. * The base color has two different interpretations depending on the value of metalness.
  117171. * When the material is a metal, the base color is the specific measured reflectance value
  117172. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  117173. * of the material.
  117174. */
  117175. baseColor: Color3;
  117176. /**
  117177. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  117178. * well as opacity information in the alpha channel.
  117179. */
  117180. baseTexture: BaseTexture;
  117181. /**
  117182. * Specifies the metallic scalar value of the material.
  117183. * Can also be used to scale the metalness values of the metallic texture.
  117184. */
  117185. metallic: number;
  117186. /**
  117187. * Specifies the roughness scalar value of the material.
  117188. * Can also be used to scale the roughness values of the metallic texture.
  117189. */
  117190. roughness: number;
  117191. /**
  117192. * Texture containing both the metallic value in the B channel and the
  117193. * roughness value in the G channel to keep better precision.
  117194. */
  117195. metallicRoughnessTexture: BaseTexture;
  117196. /**
  117197. * Instantiates a new PBRMetalRoughnessMaterial instance.
  117198. *
  117199. * @param name The material name
  117200. * @param scene The scene the material will be use in.
  117201. */
  117202. constructor(name: string, scene: Scene);
  117203. /**
  117204. * Return the currrent class name of the material.
  117205. */
  117206. getClassName(): string;
  117207. /**
  117208. * Makes a duplicate of the current material.
  117209. * @param name - name to use for the new material.
  117210. */
  117211. clone(name: string): PBRMetallicRoughnessMaterial;
  117212. /**
  117213. * Serialize the material to a parsable JSON object.
  117214. */
  117215. serialize(): any;
  117216. /**
  117217. * Parses a JSON object correponding to the serialize function.
  117218. */
  117219. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  117220. }
  117221. }
  117222. declare module BABYLON {
  117223. /**
  117224. * The PBR material of BJS following the specular glossiness convention.
  117225. *
  117226. * This fits to the PBR convention in the GLTF definition:
  117227. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  117228. */
  117229. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  117230. /**
  117231. * Specifies the diffuse color of the material.
  117232. */
  117233. diffuseColor: Color3;
  117234. /**
  117235. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  117236. * channel.
  117237. */
  117238. diffuseTexture: BaseTexture;
  117239. /**
  117240. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  117241. */
  117242. specularColor: Color3;
  117243. /**
  117244. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  117245. */
  117246. glossiness: number;
  117247. /**
  117248. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  117249. */
  117250. specularGlossinessTexture: BaseTexture;
  117251. /**
  117252. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  117253. *
  117254. * @param name The material name
  117255. * @param scene The scene the material will be use in.
  117256. */
  117257. constructor(name: string, scene: Scene);
  117258. /**
  117259. * Return the currrent class name of the material.
  117260. */
  117261. getClassName(): string;
  117262. /**
  117263. * Makes a duplicate of the current material.
  117264. * @param name - name to use for the new material.
  117265. */
  117266. clone(name: string): PBRSpecularGlossinessMaterial;
  117267. /**
  117268. * Serialize the material to a parsable JSON object.
  117269. */
  117270. serialize(): any;
  117271. /**
  117272. * Parses a JSON object correponding to the serialize function.
  117273. */
  117274. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  117275. }
  117276. }
  117277. declare module BABYLON {
  117278. /**
  117279. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  117280. * It can help converting any input color in a desired output one. This can then be used to create effects
  117281. * from sepia, black and white to sixties or futuristic rendering...
  117282. *
  117283. * The only supported format is currently 3dl.
  117284. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  117285. */
  117286. export class ColorGradingTexture extends BaseTexture {
  117287. /**
  117288. * The current texture matrix. (will always be identity in color grading texture)
  117289. */
  117290. private _textureMatrix;
  117291. /**
  117292. * The texture URL.
  117293. */
  117294. url: string;
  117295. /**
  117296. * Empty line regex stored for GC.
  117297. */
  117298. private static _noneEmptyLineRegex;
  117299. private _engine;
  117300. /**
  117301. * Instantiates a ColorGradingTexture from the following parameters.
  117302. *
  117303. * @param url The location of the color gradind data (currently only supporting 3dl)
  117304. * @param scene The scene the texture will be used in
  117305. */
  117306. constructor(url: string, scene: Scene);
  117307. /**
  117308. * Returns the texture matrix used in most of the material.
  117309. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  117310. */
  117311. getTextureMatrix(): Matrix;
  117312. /**
  117313. * Occurs when the file being loaded is a .3dl LUT file.
  117314. */
  117315. private load3dlTexture;
  117316. /**
  117317. * Starts the loading process of the texture.
  117318. */
  117319. private loadTexture;
  117320. /**
  117321. * Clones the color gradind texture.
  117322. */
  117323. clone(): ColorGradingTexture;
  117324. /**
  117325. * Called during delayed load for textures.
  117326. */
  117327. delayLoad(): void;
  117328. /**
  117329. * Parses a color grading texture serialized by Babylon.
  117330. * @param parsedTexture The texture information being parsedTexture
  117331. * @param scene The scene to load the texture in
  117332. * @param rootUrl The root url of the data assets to load
  117333. * @return A color gradind texture
  117334. */
  117335. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  117336. /**
  117337. * Serializes the LUT texture to json format.
  117338. */
  117339. serialize(): any;
  117340. }
  117341. }
  117342. declare module BABYLON {
  117343. /**
  117344. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  117345. */
  117346. export class EquiRectangularCubeTexture extends BaseTexture {
  117347. /** The six faces of the cube. */
  117348. private static _FacesMapping;
  117349. private _noMipmap;
  117350. private _onLoad;
  117351. private _onError;
  117352. /** The size of the cubemap. */
  117353. private _size;
  117354. /** The buffer of the image. */
  117355. private _buffer;
  117356. /** The width of the input image. */
  117357. private _width;
  117358. /** The height of the input image. */
  117359. private _height;
  117360. /** The URL to the image. */
  117361. url: string;
  117362. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  117363. coordinatesMode: number;
  117364. /**
  117365. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  117366. * @param url The location of the image
  117367. * @param scene The scene the texture will be used in
  117368. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117369. * @param noMipmap Forces to not generate the mipmap if true
  117370. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  117371. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  117372. * @param onLoad — defines a callback called when texture is loaded
  117373. * @param onError — defines a callback called if there is an error
  117374. */
  117375. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  117376. /**
  117377. * Load the image data, by putting the image on a canvas and extracting its buffer.
  117378. */
  117379. private loadImage;
  117380. /**
  117381. * Convert the image buffer into a cubemap and create a CubeTexture.
  117382. */
  117383. private loadTexture;
  117384. /**
  117385. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  117386. * @param buffer The ArrayBuffer that should be converted.
  117387. * @returns The buffer as Float32Array.
  117388. */
  117389. private getFloat32ArrayFromArrayBuffer;
  117390. /**
  117391. * Get the current class name of the texture useful for serialization or dynamic coding.
  117392. * @returns "EquiRectangularCubeTexture"
  117393. */
  117394. getClassName(): string;
  117395. /**
  117396. * Create a clone of the current EquiRectangularCubeTexture and return it.
  117397. * @returns A clone of the current EquiRectangularCubeTexture.
  117398. */
  117399. clone(): EquiRectangularCubeTexture;
  117400. }
  117401. }
  117402. declare module BABYLON {
  117403. /**
  117404. * Based on jsTGALoader - Javascript loader for TGA file
  117405. * By Vincent Thibault
  117406. * @see http://blog.robrowser.com/javascript-tga-loader.html
  117407. */
  117408. export class TGATools {
  117409. private static _TYPE_INDEXED;
  117410. private static _TYPE_RGB;
  117411. private static _TYPE_GREY;
  117412. private static _TYPE_RLE_INDEXED;
  117413. private static _TYPE_RLE_RGB;
  117414. private static _TYPE_RLE_GREY;
  117415. private static _ORIGIN_MASK;
  117416. private static _ORIGIN_SHIFT;
  117417. private static _ORIGIN_BL;
  117418. private static _ORIGIN_BR;
  117419. private static _ORIGIN_UL;
  117420. private static _ORIGIN_UR;
  117421. /**
  117422. * Gets the header of a TGA file
  117423. * @param data defines the TGA data
  117424. * @returns the header
  117425. */
  117426. static GetTGAHeader(data: Uint8Array): any;
  117427. /**
  117428. * Uploads TGA content to a Babylon Texture
  117429. * @hidden
  117430. */
  117431. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  117432. /** @hidden */
  117433. 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;
  117434. /** @hidden */
  117435. 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;
  117436. /** @hidden */
  117437. 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;
  117438. /** @hidden */
  117439. 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;
  117440. /** @hidden */
  117441. 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;
  117442. /** @hidden */
  117443. 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;
  117444. }
  117445. }
  117446. declare module BABYLON {
  117447. /**
  117448. * Implementation of the TGA Texture Loader.
  117449. * @hidden
  117450. */
  117451. export class _TGATextureLoader implements IInternalTextureLoader {
  117452. /**
  117453. * Defines wether the loader supports cascade loading the different faces.
  117454. */
  117455. readonly supportCascades: boolean;
  117456. /**
  117457. * This returns if the loader support the current file information.
  117458. * @param extension defines the file extension of the file being loaded
  117459. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117460. * @param fallback defines the fallback internal texture if any
  117461. * @param isBase64 defines whether the texture is encoded as a base64
  117462. * @param isBuffer defines whether the texture data are stored as a buffer
  117463. * @returns true if the loader can load the specified file
  117464. */
  117465. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117466. /**
  117467. * Transform the url before loading if required.
  117468. * @param rootUrl the url of the texture
  117469. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117470. * @returns the transformed texture
  117471. */
  117472. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117473. /**
  117474. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117475. * @param rootUrl the url of the texture
  117476. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117477. * @returns the fallback texture
  117478. */
  117479. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117480. /**
  117481. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117482. * @param data contains the texture data
  117483. * @param texture defines the BabylonJS internal texture
  117484. * @param createPolynomials will be true if polynomials have been requested
  117485. * @param onLoad defines the callback to trigger once the texture is ready
  117486. * @param onError defines the callback to trigger in case of error
  117487. */
  117488. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117489. /**
  117490. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117491. * @param data contains the texture data
  117492. * @param texture defines the BabylonJS internal texture
  117493. * @param callback defines the method to call once ready to upload
  117494. */
  117495. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117496. }
  117497. }
  117498. declare module BABYLON {
  117499. /**
  117500. * Info about the .basis files
  117501. */
  117502. class BasisFileInfo {
  117503. /**
  117504. * If the file has alpha
  117505. */
  117506. hasAlpha: boolean;
  117507. /**
  117508. * Info about each image of the basis file
  117509. */
  117510. images: Array<{
  117511. levels: Array<{
  117512. width: number;
  117513. height: number;
  117514. transcodedPixels: ArrayBufferView;
  117515. }>;
  117516. }>;
  117517. }
  117518. /**
  117519. * Result of transcoding a basis file
  117520. */
  117521. class TranscodeResult {
  117522. /**
  117523. * Info about the .basis file
  117524. */
  117525. fileInfo: BasisFileInfo;
  117526. /**
  117527. * Format to use when loading the file
  117528. */
  117529. format: number;
  117530. }
  117531. /**
  117532. * Configuration options for the Basis transcoder
  117533. */
  117534. export class BasisTranscodeConfiguration {
  117535. /**
  117536. * Supported compression formats used to determine the supported output format of the transcoder
  117537. */
  117538. supportedCompressionFormats?: {
  117539. /**
  117540. * etc1 compression format
  117541. */
  117542. etc1?: boolean;
  117543. /**
  117544. * s3tc compression format
  117545. */
  117546. s3tc?: boolean;
  117547. /**
  117548. * pvrtc compression format
  117549. */
  117550. pvrtc?: boolean;
  117551. /**
  117552. * etc2 compression format
  117553. */
  117554. etc2?: boolean;
  117555. };
  117556. /**
  117557. * If mipmap levels should be loaded for transcoded images (Default: true)
  117558. */
  117559. loadMipmapLevels?: boolean;
  117560. /**
  117561. * Index of a single image to load (Default: all images)
  117562. */
  117563. loadSingleImage?: number;
  117564. }
  117565. /**
  117566. * Used to load .Basis files
  117567. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  117568. */
  117569. export class BasisTools {
  117570. private static _IgnoreSupportedFormats;
  117571. /**
  117572. * URL to use when loading the basis transcoder
  117573. */
  117574. static JSModuleURL: string;
  117575. /**
  117576. * URL to use when loading the wasm module for the transcoder
  117577. */
  117578. static WasmModuleURL: string;
  117579. /**
  117580. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  117581. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  117582. * @returns internal format corresponding to the Basis format
  117583. */
  117584. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  117585. private static _WorkerPromise;
  117586. private static _Worker;
  117587. private static _actionId;
  117588. private static _CreateWorkerAsync;
  117589. /**
  117590. * Transcodes a loaded image file to compressed pixel data
  117591. * @param imageData image data to transcode
  117592. * @param config configuration options for the transcoding
  117593. * @returns a promise resulting in the transcoded image
  117594. */
  117595. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  117596. /**
  117597. * Loads a texture from the transcode result
  117598. * @param texture texture load to
  117599. * @param transcodeResult the result of transcoding the basis file to load from
  117600. */
  117601. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  117602. }
  117603. }
  117604. declare module BABYLON {
  117605. /**
  117606. * Loader for .basis file format
  117607. */
  117608. export class _BasisTextureLoader implements IInternalTextureLoader {
  117609. /**
  117610. * Defines whether the loader supports cascade loading the different faces.
  117611. */
  117612. readonly supportCascades: boolean;
  117613. /**
  117614. * This returns if the loader support the current file information.
  117615. * @param extension defines the file extension of the file being loaded
  117616. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117617. * @param fallback defines the fallback internal texture if any
  117618. * @param isBase64 defines whether the texture is encoded as a base64
  117619. * @param isBuffer defines whether the texture data are stored as a buffer
  117620. * @returns true if the loader can load the specified file
  117621. */
  117622. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117623. /**
  117624. * Transform the url before loading if required.
  117625. * @param rootUrl the url of the texture
  117626. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117627. * @returns the transformed texture
  117628. */
  117629. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117630. /**
  117631. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117632. * @param rootUrl the url of the texture
  117633. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117634. * @returns the fallback texture
  117635. */
  117636. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117637. /**
  117638. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  117639. * @param data contains the texture data
  117640. * @param texture defines the BabylonJS internal texture
  117641. * @param createPolynomials will be true if polynomials have been requested
  117642. * @param onLoad defines the callback to trigger once the texture is ready
  117643. * @param onError defines the callback to trigger in case of error
  117644. */
  117645. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117646. /**
  117647. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117648. * @param data contains the texture data
  117649. * @param texture defines the BabylonJS internal texture
  117650. * @param callback defines the method to call once ready to upload
  117651. */
  117652. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117653. }
  117654. }
  117655. declare module BABYLON {
  117656. /**
  117657. * 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.
  117658. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117659. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117660. */
  117661. export class CustomProceduralTexture extends ProceduralTexture {
  117662. private _animate;
  117663. private _time;
  117664. private _config;
  117665. private _texturePath;
  117666. /**
  117667. * Instantiates a new Custom Procedural Texture.
  117668. * 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.
  117669. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117670. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117671. * @param name Define the name of the texture
  117672. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  117673. * @param size Define the size of the texture to create
  117674. * @param scene Define the scene the texture belongs to
  117675. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  117676. * @param generateMipMaps Define if the texture should creates mip maps or not
  117677. */
  117678. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117679. private _loadJson;
  117680. /**
  117681. * Is the texture ready to be used ? (rendered at least once)
  117682. * @returns true if ready, otherwise, false.
  117683. */
  117684. isReady(): boolean;
  117685. /**
  117686. * Render the texture to its associated render target.
  117687. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  117688. */
  117689. render(useCameraPostProcess?: boolean): void;
  117690. /**
  117691. * Update the list of dependant textures samplers in the shader.
  117692. */
  117693. updateTextures(): void;
  117694. /**
  117695. * Update the uniform values of the procedural texture in the shader.
  117696. */
  117697. updateShaderUniforms(): void;
  117698. /**
  117699. * Define if the texture animates or not.
  117700. */
  117701. animate: boolean;
  117702. }
  117703. }
  117704. declare module BABYLON {
  117705. /** @hidden */
  117706. export var noisePixelShader: {
  117707. name: string;
  117708. shader: string;
  117709. };
  117710. }
  117711. declare module BABYLON {
  117712. /**
  117713. * Class used to generate noise procedural textures
  117714. */
  117715. export class NoiseProceduralTexture extends ProceduralTexture {
  117716. private _time;
  117717. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  117718. brightness: number;
  117719. /** Defines the number of octaves to process */
  117720. octaves: number;
  117721. /** Defines the level of persistence (0.8 by default) */
  117722. persistence: number;
  117723. /** Gets or sets animation speed factor (default is 1) */
  117724. animationSpeedFactor: number;
  117725. /**
  117726. * Creates a new NoiseProceduralTexture
  117727. * @param name defines the name fo the texture
  117728. * @param size defines the size of the texture (default is 256)
  117729. * @param scene defines the hosting scene
  117730. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  117731. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  117732. */
  117733. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117734. private _updateShaderUniforms;
  117735. protected _getDefines(): string;
  117736. /** Generate the current state of the procedural texture */
  117737. render(useCameraPostProcess?: boolean): void;
  117738. /**
  117739. * Serializes this noise procedural texture
  117740. * @returns a serialized noise procedural texture object
  117741. */
  117742. serialize(): any;
  117743. /**
  117744. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  117745. * @param parsedTexture defines parsed texture data
  117746. * @param scene defines the current scene
  117747. * @param rootUrl defines the root URL containing noise procedural texture information
  117748. * @returns a parsed NoiseProceduralTexture
  117749. */
  117750. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  117751. }
  117752. }
  117753. declare module BABYLON {
  117754. /**
  117755. * Raw cube texture where the raw buffers are passed in
  117756. */
  117757. export class RawCubeTexture extends CubeTexture {
  117758. /**
  117759. * Creates a cube texture where the raw buffers are passed in.
  117760. * @param scene defines the scene the texture is attached to
  117761. * @param data defines the array of data to use to create each face
  117762. * @param size defines the size of the textures
  117763. * @param format defines the format of the data
  117764. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  117765. * @param generateMipMaps defines if the engine should generate the mip levels
  117766. * @param invertY defines if data must be stored with Y axis inverted
  117767. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  117768. * @param compression defines the compression used (null by default)
  117769. */
  117770. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  117771. /**
  117772. * Updates the raw cube texture.
  117773. * @param data defines the data to store
  117774. * @param format defines the data format
  117775. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  117776. * @param invertY defines if data must be stored with Y axis inverted
  117777. * @param compression defines the compression used (null by default)
  117778. * @param level defines which level of the texture to update
  117779. */
  117780. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  117781. /**
  117782. * Updates a raw cube texture with RGBD encoded data.
  117783. * @param data defines the array of data [mipmap][face] to use to create each face
  117784. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  117785. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117786. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117787. * @returns a promsie that resolves when the operation is complete
  117788. */
  117789. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  117790. /**
  117791. * Clones the raw cube texture.
  117792. * @return a new cube texture
  117793. */
  117794. clone(): CubeTexture;
  117795. /** @hidden */
  117796. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117797. }
  117798. }
  117799. declare module BABYLON {
  117800. /**
  117801. * Class used to store 3D textures containing user data
  117802. */
  117803. export class RawTexture3D extends Texture {
  117804. /** Gets or sets the texture format to use */
  117805. format: number;
  117806. private _engine;
  117807. /**
  117808. * Create a new RawTexture3D
  117809. * @param data defines the data of the texture
  117810. * @param width defines the width of the texture
  117811. * @param height defines the height of the texture
  117812. * @param depth defines the depth of the texture
  117813. * @param format defines the texture format to use
  117814. * @param scene defines the hosting scene
  117815. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  117816. * @param invertY defines if texture must be stored with Y axis inverted
  117817. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  117818. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  117819. */
  117820. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  117821. /** Gets or sets the texture format to use */
  117822. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  117823. /**
  117824. * Update the texture with new data
  117825. * @param data defines the data to store in the texture
  117826. */
  117827. update(data: ArrayBufferView): void;
  117828. }
  117829. }
  117830. declare module BABYLON {
  117831. /**
  117832. * Creates a refraction texture used by refraction channel of the standard material.
  117833. * It is like a mirror but to see through a material.
  117834. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117835. */
  117836. export class RefractionTexture extends RenderTargetTexture {
  117837. /**
  117838. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  117839. * 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.
  117840. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117841. */
  117842. refractionPlane: Plane;
  117843. /**
  117844. * Define how deep under the surface we should see.
  117845. */
  117846. depth: number;
  117847. /**
  117848. * Creates a refraction texture used by refraction channel of the standard material.
  117849. * It is like a mirror but to see through a material.
  117850. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117851. * @param name Define the texture name
  117852. * @param size Define the size of the underlying texture
  117853. * @param scene Define the scene the refraction belongs to
  117854. * @param generateMipMaps Define if we need to generate mips level for the refraction
  117855. */
  117856. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  117857. /**
  117858. * Clone the refraction texture.
  117859. * @returns the cloned texture
  117860. */
  117861. clone(): RefractionTexture;
  117862. /**
  117863. * Serialize the texture to a JSON representation you could use in Parse later on
  117864. * @returns the serialized JSON representation
  117865. */
  117866. serialize(): any;
  117867. }
  117868. }
  117869. declare module BABYLON {
  117870. /**
  117871. * Defines the options related to the creation of an HtmlElementTexture
  117872. */
  117873. export interface IHtmlElementTextureOptions {
  117874. /**
  117875. * Defines wether mip maps should be created or not.
  117876. */
  117877. generateMipMaps?: boolean;
  117878. /**
  117879. * Defines the sampling mode of the texture.
  117880. */
  117881. samplingMode?: number;
  117882. /**
  117883. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  117884. */
  117885. engine: Nullable<Engine>;
  117886. /**
  117887. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  117888. */
  117889. scene: Nullable<Scene>;
  117890. }
  117891. /**
  117892. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  117893. * To be as efficient as possible depending on your constraints nothing aside the first upload
  117894. * is automatically managed.
  117895. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  117896. * in your application.
  117897. *
  117898. * As the update is not automatic, you need to call them manually.
  117899. */
  117900. export class HtmlElementTexture extends BaseTexture {
  117901. /**
  117902. * The texture URL.
  117903. */
  117904. element: HTMLVideoElement | HTMLCanvasElement;
  117905. private static readonly DefaultOptions;
  117906. private _textureMatrix;
  117907. private _engine;
  117908. private _isVideo;
  117909. private _generateMipMaps;
  117910. private _samplingMode;
  117911. /**
  117912. * Instantiates a HtmlElementTexture from the following parameters.
  117913. *
  117914. * @param name Defines the name of the texture
  117915. * @param element Defines the video or canvas the texture is filled with
  117916. * @param options Defines the other none mandatory texture creation options
  117917. */
  117918. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  117919. private _createInternalTexture;
  117920. /**
  117921. * Returns the texture matrix used in most of the material.
  117922. */
  117923. getTextureMatrix(): Matrix;
  117924. /**
  117925. * Updates the content of the texture.
  117926. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  117927. */
  117928. update(invertY?: Nullable<boolean>): void;
  117929. }
  117930. }
  117931. declare module BABYLON {
  117932. /**
  117933. * Enum used to define the target of a block
  117934. */
  117935. export enum NodeMaterialBlockTargets {
  117936. /** Vertex shader */
  117937. Vertex = 1,
  117938. /** Fragment shader */
  117939. Fragment = 2,
  117940. /** Neutral */
  117941. Neutral = 4,
  117942. /** Vertex and Fragment */
  117943. VertexAndFragment = 3
  117944. }
  117945. }
  117946. declare module BABYLON {
  117947. /**
  117948. * Defines the kind of connection point for node based material
  117949. */
  117950. export enum NodeMaterialBlockConnectionPointTypes {
  117951. /** Float */
  117952. Float = 1,
  117953. /** Int */
  117954. Int = 2,
  117955. /** Vector2 */
  117956. Vector2 = 4,
  117957. /** Vector3 */
  117958. Vector3 = 8,
  117959. /** Vector4 */
  117960. Vector4 = 16,
  117961. /** Color3 */
  117962. Color3 = 32,
  117963. /** Color4 */
  117964. Color4 = 64,
  117965. /** Matrix */
  117966. Matrix = 128,
  117967. /** Detect type based on connection */
  117968. AutoDetect = 1024,
  117969. /** Output type that will be defined by input type */
  117970. BasedOnInput = 2048
  117971. }
  117972. }
  117973. declare module BABYLON {
  117974. /**
  117975. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  117976. */
  117977. export enum NodeMaterialBlockConnectionPointMode {
  117978. /** Value is an uniform */
  117979. Uniform = 0,
  117980. /** Value is a mesh attribute */
  117981. Attribute = 1,
  117982. /** Value is a varying between vertex and fragment shaders */
  117983. Varying = 2,
  117984. /** Mode is undefined */
  117985. Undefined = 3
  117986. }
  117987. }
  117988. declare module BABYLON {
  117989. /**
  117990. * Enum used to define system values e.g. values automatically provided by the system
  117991. */
  117992. export enum NodeMaterialSystemValues {
  117993. /** World */
  117994. World = 1,
  117995. /** View */
  117996. View = 2,
  117997. /** Projection */
  117998. Projection = 3,
  117999. /** ViewProjection */
  118000. ViewProjection = 4,
  118001. /** WorldView */
  118002. WorldView = 5,
  118003. /** WorldViewProjection */
  118004. WorldViewProjection = 6,
  118005. /** CameraPosition */
  118006. CameraPosition = 7,
  118007. /** Fog Color */
  118008. FogColor = 8
  118009. }
  118010. }
  118011. declare module BABYLON {
  118012. /**
  118013. * Root class for all node material optimizers
  118014. */
  118015. export class NodeMaterialOptimizer {
  118016. /**
  118017. * Function used to optimize a NodeMaterial graph
  118018. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  118019. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  118020. */
  118021. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  118022. }
  118023. }
  118024. declare module BABYLON {
  118025. /**
  118026. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  118027. */
  118028. export class TransformBlock extends NodeMaterialBlock {
  118029. /**
  118030. * Defines the value to use to complement W value to transform it to a Vector4
  118031. */
  118032. complementW: number;
  118033. /**
  118034. * Defines the value to use to complement z value to transform it to a Vector4
  118035. */
  118036. complementZ: number;
  118037. /**
  118038. * Creates a new TransformBlock
  118039. * @param name defines the block name
  118040. */
  118041. constructor(name: string);
  118042. /**
  118043. * Gets the current class name
  118044. * @returns the class name
  118045. */
  118046. getClassName(): string;
  118047. /**
  118048. * Gets the vector input
  118049. */
  118050. readonly vector: NodeMaterialConnectionPoint;
  118051. /**
  118052. * Gets the output component
  118053. */
  118054. readonly output: NodeMaterialConnectionPoint;
  118055. /**
  118056. * Gets the matrix transform input
  118057. */
  118058. readonly transform: NodeMaterialConnectionPoint;
  118059. protected _buildBlock(state: NodeMaterialBuildState): this;
  118060. serialize(): any;
  118061. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118062. protected _dumpPropertiesCode(): string;
  118063. }
  118064. }
  118065. declare module BABYLON {
  118066. /**
  118067. * Block used to output the vertex position
  118068. */
  118069. export class VertexOutputBlock extends NodeMaterialBlock {
  118070. /**
  118071. * Creates a new VertexOutputBlock
  118072. * @param name defines the block name
  118073. */
  118074. constructor(name: string);
  118075. /**
  118076. * Gets the current class name
  118077. * @returns the class name
  118078. */
  118079. getClassName(): string;
  118080. /**
  118081. * Gets the vector input component
  118082. */
  118083. readonly vector: NodeMaterialConnectionPoint;
  118084. protected _buildBlock(state: NodeMaterialBuildState): this;
  118085. }
  118086. }
  118087. declare module BABYLON {
  118088. /**
  118089. * Block used to output the final color
  118090. */
  118091. export class FragmentOutputBlock extends NodeMaterialBlock {
  118092. /**
  118093. * Create a new FragmentOutputBlock
  118094. * @param name defines the block name
  118095. */
  118096. constructor(name: string);
  118097. /**
  118098. * Gets the current class name
  118099. * @returns the class name
  118100. */
  118101. getClassName(): string;
  118102. /**
  118103. * Gets the rgba input component
  118104. */
  118105. readonly rgba: NodeMaterialConnectionPoint;
  118106. /**
  118107. * Gets the rgb input component
  118108. */
  118109. readonly rgb: NodeMaterialConnectionPoint;
  118110. /**
  118111. * Gets the a input component
  118112. */
  118113. readonly a: NodeMaterialConnectionPoint;
  118114. protected _buildBlock(state: NodeMaterialBuildState): this;
  118115. }
  118116. }
  118117. declare module BABYLON {
  118118. /**
  118119. * Block used to read a reflection texture from a sampler
  118120. */
  118121. export class ReflectionTextureBlock extends NodeMaterialBlock {
  118122. private _define3DName;
  118123. private _defineCubicName;
  118124. private _defineExplicitName;
  118125. private _defineProjectionName;
  118126. private _defineLocalCubicName;
  118127. private _defineSphericalName;
  118128. private _definePlanarName;
  118129. private _defineEquirectangularName;
  118130. private _defineMirroredEquirectangularFixedName;
  118131. private _defineEquirectangularFixedName;
  118132. private _defineSkyboxName;
  118133. private _cubeSamplerName;
  118134. private _2DSamplerName;
  118135. private _positionUVWName;
  118136. private _directionWName;
  118137. private _reflectionCoordsName;
  118138. private _reflection2DCoordsName;
  118139. private _reflectionColorName;
  118140. private _reflectionMatrixName;
  118141. /**
  118142. * Gets or sets the texture associated with the node
  118143. */
  118144. texture: Nullable<BaseTexture>;
  118145. /**
  118146. * Create a new TextureBlock
  118147. * @param name defines the block name
  118148. */
  118149. constructor(name: string);
  118150. /**
  118151. * Gets the current class name
  118152. * @returns the class name
  118153. */
  118154. getClassName(): string;
  118155. /**
  118156. * Gets the world position input component
  118157. */
  118158. readonly position: NodeMaterialConnectionPoint;
  118159. /**
  118160. * Gets the world position input component
  118161. */
  118162. readonly worldPosition: NodeMaterialConnectionPoint;
  118163. /**
  118164. * Gets the world normal input component
  118165. */
  118166. readonly worldNormal: NodeMaterialConnectionPoint;
  118167. /**
  118168. * Gets the world input component
  118169. */
  118170. readonly world: NodeMaterialConnectionPoint;
  118171. /**
  118172. * Gets the camera (or eye) position component
  118173. */
  118174. readonly cameraPosition: NodeMaterialConnectionPoint;
  118175. /**
  118176. * Gets the view input component
  118177. */
  118178. readonly view: NodeMaterialConnectionPoint;
  118179. /**
  118180. * Gets the rgb output component
  118181. */
  118182. readonly rgb: NodeMaterialConnectionPoint;
  118183. /**
  118184. * Gets the r output component
  118185. */
  118186. readonly r: NodeMaterialConnectionPoint;
  118187. /**
  118188. * Gets the g output component
  118189. */
  118190. readonly g: NodeMaterialConnectionPoint;
  118191. /**
  118192. * Gets the b output component
  118193. */
  118194. readonly b: NodeMaterialConnectionPoint;
  118195. autoConfigure(material: NodeMaterial): void;
  118196. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118197. isReady(): boolean;
  118198. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118199. private _injectVertexCode;
  118200. private _writeOutput;
  118201. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118202. serialize(): any;
  118203. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118204. }
  118205. }
  118206. declare module BABYLON {
  118207. /**
  118208. * Interface used to configure the node material editor
  118209. */
  118210. export interface INodeMaterialEditorOptions {
  118211. /** Define the URl to load node editor script */
  118212. editorURL?: string;
  118213. }
  118214. /** @hidden */
  118215. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  118216. /** BONES */
  118217. NUM_BONE_INFLUENCERS: number;
  118218. BonesPerMesh: number;
  118219. BONETEXTURE: boolean;
  118220. /** MORPH TARGETS */
  118221. MORPHTARGETS: boolean;
  118222. MORPHTARGETS_NORMAL: boolean;
  118223. MORPHTARGETS_TANGENT: boolean;
  118224. MORPHTARGETS_UV: boolean;
  118225. NUM_MORPH_INFLUENCERS: number;
  118226. /** IMAGE PROCESSING */
  118227. IMAGEPROCESSING: boolean;
  118228. VIGNETTE: boolean;
  118229. VIGNETTEBLENDMODEMULTIPLY: boolean;
  118230. VIGNETTEBLENDMODEOPAQUE: boolean;
  118231. TONEMAPPING: boolean;
  118232. TONEMAPPING_ACES: boolean;
  118233. CONTRAST: boolean;
  118234. EXPOSURE: boolean;
  118235. COLORCURVES: boolean;
  118236. COLORGRADING: boolean;
  118237. COLORGRADING3D: boolean;
  118238. SAMPLER3DGREENDEPTH: boolean;
  118239. SAMPLER3DBGRMAP: boolean;
  118240. IMAGEPROCESSINGPOSTPROCESS: boolean;
  118241. /** MISC. */
  118242. BUMPDIRECTUV: number;
  118243. constructor();
  118244. setValue(name: string, value: boolean): void;
  118245. }
  118246. /**
  118247. * Class used to configure NodeMaterial
  118248. */
  118249. export interface INodeMaterialOptions {
  118250. /**
  118251. * Defines if blocks should emit comments
  118252. */
  118253. emitComments: boolean;
  118254. }
  118255. /**
  118256. * Class used to create a node based material built by assembling shader blocks
  118257. */
  118258. export class NodeMaterial extends PushMaterial {
  118259. private static _BuildIdGenerator;
  118260. private _options;
  118261. private _vertexCompilationState;
  118262. private _fragmentCompilationState;
  118263. private _sharedData;
  118264. private _buildId;
  118265. private _buildWasSuccessful;
  118266. private _cachedWorldViewMatrix;
  118267. private _cachedWorldViewProjectionMatrix;
  118268. private _optimizers;
  118269. private _animationFrame;
  118270. /** Define the URl to load node editor script */
  118271. static EditorURL: string;
  118272. private BJSNODEMATERIALEDITOR;
  118273. /** Get the inspector from bundle or global */
  118274. private _getGlobalNodeMaterialEditor;
  118275. /**
  118276. * 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)
  118277. */
  118278. ignoreAlpha: boolean;
  118279. /**
  118280. * Defines the maximum number of lights that can be used in the material
  118281. */
  118282. maxSimultaneousLights: number;
  118283. /**
  118284. * Observable raised when the material is built
  118285. */
  118286. onBuildObservable: Observable<NodeMaterial>;
  118287. /**
  118288. * Gets or sets the root nodes of the material vertex shader
  118289. */
  118290. _vertexOutputNodes: NodeMaterialBlock[];
  118291. /**
  118292. * Gets or sets the root nodes of the material fragment (pixel) shader
  118293. */
  118294. _fragmentOutputNodes: NodeMaterialBlock[];
  118295. /** Gets or sets options to control the node material overall behavior */
  118296. options: INodeMaterialOptions;
  118297. /**
  118298. * Default configuration related to image processing available in the standard Material.
  118299. */
  118300. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118301. /**
  118302. * Gets the image processing configuration used either in this material.
  118303. */
  118304. /**
  118305. * Sets the Default image processing configuration used either in the this material.
  118306. *
  118307. * If sets to null, the scene one is in use.
  118308. */
  118309. imageProcessingConfiguration: ImageProcessingConfiguration;
  118310. /**
  118311. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  118312. */
  118313. attachedBlocks: NodeMaterialBlock[];
  118314. /**
  118315. * Create a new node based material
  118316. * @param name defines the material name
  118317. * @param scene defines the hosting scene
  118318. * @param options defines creation option
  118319. */
  118320. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  118321. /**
  118322. * Gets the current class name of the material e.g. "NodeMaterial"
  118323. * @returns the class name
  118324. */
  118325. getClassName(): string;
  118326. /**
  118327. * Keep track of the image processing observer to allow dispose and replace.
  118328. */
  118329. private _imageProcessingObserver;
  118330. /**
  118331. * Attaches a new image processing configuration to the Standard Material.
  118332. * @param configuration
  118333. */
  118334. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118335. /**
  118336. * Get a block by its name
  118337. * @param name defines the name of the block to retrieve
  118338. * @returns the required block or null if not found
  118339. */
  118340. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  118341. /**
  118342. * Get a block by its name
  118343. * @param predicate defines the predicate used to find the good candidate
  118344. * @returns the required block or null if not found
  118345. */
  118346. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  118347. /**
  118348. * Get an input block by its name
  118349. * @param predicate defines the predicate used to find the good candidate
  118350. * @returns the required input block or null if not found
  118351. */
  118352. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  118353. /**
  118354. * Gets the list of input blocks attached to this material
  118355. * @returns an array of InputBlocks
  118356. */
  118357. getInputBlocks(): InputBlock[];
  118358. /**
  118359. * Adds a new optimizer to the list of optimizers
  118360. * @param optimizer defines the optimizers to add
  118361. * @returns the current material
  118362. */
  118363. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118364. /**
  118365. * Remove an optimizer from the list of optimizers
  118366. * @param optimizer defines the optimizers to remove
  118367. * @returns the current material
  118368. */
  118369. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118370. /**
  118371. * Add a new block to the list of output nodes
  118372. * @param node defines the node to add
  118373. * @returns the current material
  118374. */
  118375. addOutputNode(node: NodeMaterialBlock): this;
  118376. /**
  118377. * Remove a block from the list of root nodes
  118378. * @param node defines the node to remove
  118379. * @returns the current material
  118380. */
  118381. removeOutputNode(node: NodeMaterialBlock): this;
  118382. private _addVertexOutputNode;
  118383. private _removeVertexOutputNode;
  118384. private _addFragmentOutputNode;
  118385. private _removeFragmentOutputNode;
  118386. /**
  118387. * Specifies if the material will require alpha blending
  118388. * @returns a boolean specifying if alpha blending is needed
  118389. */
  118390. needAlphaBlending(): boolean;
  118391. /**
  118392. * Specifies if this material should be rendered in alpha test mode
  118393. * @returns a boolean specifying if an alpha test is needed.
  118394. */
  118395. needAlphaTesting(): boolean;
  118396. private _initializeBlock;
  118397. private _resetDualBlocks;
  118398. /**
  118399. * Build the material and generates the inner effect
  118400. * @param verbose defines if the build should log activity
  118401. */
  118402. build(verbose?: boolean): void;
  118403. /**
  118404. * Runs an otpimization phase to try to improve the shader code
  118405. */
  118406. optimize(): void;
  118407. private _prepareDefinesForAttributes;
  118408. /**
  118409. * Get if the submesh is ready to be used and all its information available.
  118410. * Child classes can use it to update shaders
  118411. * @param mesh defines the mesh to check
  118412. * @param subMesh defines which submesh to check
  118413. * @param useInstances specifies that instances should be used
  118414. * @returns a boolean indicating that the submesh is ready or not
  118415. */
  118416. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118417. /**
  118418. * Get a string representing the shaders built by the current node graph
  118419. */
  118420. readonly compiledShaders: string;
  118421. /**
  118422. * Binds the world matrix to the material
  118423. * @param world defines the world transformation matrix
  118424. */
  118425. bindOnlyWorldMatrix(world: Matrix): void;
  118426. /**
  118427. * Binds the submesh to this material by preparing the effect and shader to draw
  118428. * @param world defines the world transformation matrix
  118429. * @param mesh defines the mesh containing the submesh
  118430. * @param subMesh defines the submesh to bind the material to
  118431. */
  118432. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118433. /**
  118434. * Gets the active textures from the material
  118435. * @returns an array of textures
  118436. */
  118437. getActiveTextures(): BaseTexture[];
  118438. /**
  118439. * Gets the list of texture blocks
  118440. * @returns an array of texture blocks
  118441. */
  118442. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  118443. /**
  118444. * Specifies if the material uses a texture
  118445. * @param texture defines the texture to check against the material
  118446. * @returns a boolean specifying if the material uses the texture
  118447. */
  118448. hasTexture(texture: BaseTexture): boolean;
  118449. /**
  118450. * Disposes the material
  118451. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  118452. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  118453. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  118454. */
  118455. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  118456. /** Creates the node editor window. */
  118457. private _createNodeEditor;
  118458. /**
  118459. * Launch the node material editor
  118460. * @param config Define the configuration of the editor
  118461. * @return a promise fulfilled when the node editor is visible
  118462. */
  118463. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  118464. /**
  118465. * Clear the current material
  118466. */
  118467. clear(): void;
  118468. /**
  118469. * Clear the current material and set it to a default state
  118470. */
  118471. setToDefault(): void;
  118472. /**
  118473. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  118474. * @param url defines the url to load from
  118475. * @returns a promise that will fullfil when the material is fully loaded
  118476. */
  118477. loadAsync(url: string): Promise<unknown>;
  118478. private _gatherBlocks;
  118479. /**
  118480. * Generate a string containing the code declaration required to create an equivalent of this material
  118481. * @returns a string
  118482. */
  118483. generateCode(): string;
  118484. /**
  118485. * Serializes this material in a JSON representation
  118486. * @returns the serialized material object
  118487. */
  118488. serialize(): any;
  118489. private _restoreConnections;
  118490. /**
  118491. * Clear the current graph and load a new one from a serialization object
  118492. * @param source defines the JSON representation of the material
  118493. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118494. */
  118495. loadFromSerialization(source: any, rootUrl?: string): void;
  118496. /**
  118497. * Creates a node material from parsed material data
  118498. * @param source defines the JSON representation of the material
  118499. * @param scene defines the hosting scene
  118500. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118501. * @returns a new node material
  118502. */
  118503. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  118504. /**
  118505. * Creates a new node material set to default basic configuration
  118506. * @param name defines the name of the material
  118507. * @param scene defines the hosting scene
  118508. * @returns a new NodeMaterial
  118509. */
  118510. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  118511. }
  118512. }
  118513. declare module BABYLON {
  118514. /**
  118515. * Block used to read a texture from a sampler
  118516. */
  118517. export class TextureBlock extends NodeMaterialBlock {
  118518. private _defineName;
  118519. private _samplerName;
  118520. private _transformedUVName;
  118521. private _textureTransformName;
  118522. private _textureInfoName;
  118523. private _mainUVName;
  118524. private _mainUVDefineName;
  118525. /**
  118526. * Gets or sets the texture associated with the node
  118527. */
  118528. texture: Nullable<Texture>;
  118529. /**
  118530. * Create a new TextureBlock
  118531. * @param name defines the block name
  118532. */
  118533. constructor(name: string);
  118534. /**
  118535. * Gets the current class name
  118536. * @returns the class name
  118537. */
  118538. getClassName(): string;
  118539. /**
  118540. * Gets the uv input component
  118541. */
  118542. readonly uv: NodeMaterialConnectionPoint;
  118543. /**
  118544. * Gets the rgba output component
  118545. */
  118546. readonly rgba: NodeMaterialConnectionPoint;
  118547. /**
  118548. * Gets the rgb output component
  118549. */
  118550. readonly rgb: NodeMaterialConnectionPoint;
  118551. /**
  118552. * Gets the r output component
  118553. */
  118554. readonly r: NodeMaterialConnectionPoint;
  118555. /**
  118556. * Gets the g output component
  118557. */
  118558. readonly g: NodeMaterialConnectionPoint;
  118559. /**
  118560. * Gets the b output component
  118561. */
  118562. readonly b: NodeMaterialConnectionPoint;
  118563. /**
  118564. * Gets the a output component
  118565. */
  118566. readonly a: NodeMaterialConnectionPoint;
  118567. readonly target: NodeMaterialBlockTargets;
  118568. autoConfigure(material: NodeMaterial): void;
  118569. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118571. isReady(): boolean;
  118572. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118573. private readonly _isMixed;
  118574. private _injectVertexCode;
  118575. private _writeOutput;
  118576. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118577. protected _dumpPropertiesCode(): string;
  118578. serialize(): any;
  118579. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118580. }
  118581. }
  118582. declare module BABYLON {
  118583. /**
  118584. * Class used to store shared data between 2 NodeMaterialBuildState
  118585. */
  118586. export class NodeMaterialBuildStateSharedData {
  118587. /**
  118588. * Gets the list of emitted varyings
  118589. */
  118590. temps: string[];
  118591. /**
  118592. * Gets the list of emitted varyings
  118593. */
  118594. varyings: string[];
  118595. /**
  118596. * Gets the varying declaration string
  118597. */
  118598. varyingDeclaration: string;
  118599. /**
  118600. * Input blocks
  118601. */
  118602. inputBlocks: InputBlock[];
  118603. /**
  118604. * Input blocks
  118605. */
  118606. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  118607. /**
  118608. * Bindable blocks (Blocks that need to set data to the effect)
  118609. */
  118610. bindableBlocks: NodeMaterialBlock[];
  118611. /**
  118612. * List of blocks that can provide a compilation fallback
  118613. */
  118614. blocksWithFallbacks: NodeMaterialBlock[];
  118615. /**
  118616. * List of blocks that can provide a define update
  118617. */
  118618. blocksWithDefines: NodeMaterialBlock[];
  118619. /**
  118620. * List of blocks that can provide a repeatable content
  118621. */
  118622. repeatableContentBlocks: NodeMaterialBlock[];
  118623. /**
  118624. * List of blocks that can provide a dynamic list of uniforms
  118625. */
  118626. dynamicUniformBlocks: NodeMaterialBlock[];
  118627. /**
  118628. * List of blocks that can block the isReady function for the material
  118629. */
  118630. blockingBlocks: NodeMaterialBlock[];
  118631. /**
  118632. * Gets the list of animated inputs
  118633. */
  118634. animatedInputs: InputBlock[];
  118635. /**
  118636. * Build Id used to avoid multiple recompilations
  118637. */
  118638. buildId: number;
  118639. /** List of emitted variables */
  118640. variableNames: {
  118641. [key: string]: number;
  118642. };
  118643. /** List of emitted defines */
  118644. defineNames: {
  118645. [key: string]: number;
  118646. };
  118647. /** Should emit comments? */
  118648. emitComments: boolean;
  118649. /** Emit build activity */
  118650. verbose: boolean;
  118651. /** Gets or sets the hosting scene */
  118652. scene: Scene;
  118653. /**
  118654. * Gets the compilation hints emitted at compilation time
  118655. */
  118656. hints: {
  118657. needWorldViewMatrix: boolean;
  118658. needWorldViewProjectionMatrix: boolean;
  118659. needAlphaBlending: boolean;
  118660. needAlphaTesting: boolean;
  118661. };
  118662. /**
  118663. * List of compilation checks
  118664. */
  118665. checks: {
  118666. emitVertex: boolean;
  118667. emitFragment: boolean;
  118668. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  118669. };
  118670. /** Creates a new shared data */
  118671. constructor();
  118672. /**
  118673. * Emits console errors and exceptions if there is a failing check
  118674. */
  118675. emitErrors(): void;
  118676. }
  118677. }
  118678. declare module BABYLON {
  118679. /**
  118680. * Class used to store node based material build state
  118681. */
  118682. export class NodeMaterialBuildState {
  118683. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  118684. supportUniformBuffers: boolean;
  118685. /**
  118686. * Gets the list of emitted attributes
  118687. */
  118688. attributes: string[];
  118689. /**
  118690. * Gets the list of emitted uniforms
  118691. */
  118692. uniforms: string[];
  118693. /**
  118694. * Gets the list of emitted constants
  118695. */
  118696. constants: string[];
  118697. /**
  118698. * Gets the list of emitted uniform buffers
  118699. */
  118700. uniformBuffers: string[];
  118701. /**
  118702. * Gets the list of emitted samplers
  118703. */
  118704. samplers: string[];
  118705. /**
  118706. * Gets the list of emitted functions
  118707. */
  118708. functions: {
  118709. [key: string]: string;
  118710. };
  118711. /**
  118712. * Gets the list of emitted extensions
  118713. */
  118714. extensions: {
  118715. [key: string]: string;
  118716. };
  118717. /**
  118718. * Gets the target of the compilation state
  118719. */
  118720. target: NodeMaterialBlockTargets;
  118721. /**
  118722. * Gets the list of emitted counters
  118723. */
  118724. counters: {
  118725. [key: string]: number;
  118726. };
  118727. /**
  118728. * Shared data between multiple NodeMaterialBuildState instances
  118729. */
  118730. sharedData: NodeMaterialBuildStateSharedData;
  118731. /** @hidden */
  118732. _vertexState: NodeMaterialBuildState;
  118733. /** @hidden */
  118734. _attributeDeclaration: string;
  118735. /** @hidden */
  118736. _uniformDeclaration: string;
  118737. /** @hidden */
  118738. _constantDeclaration: string;
  118739. /** @hidden */
  118740. _samplerDeclaration: string;
  118741. /** @hidden */
  118742. _varyingTransfer: string;
  118743. private _repeatableContentAnchorIndex;
  118744. /** @hidden */
  118745. _builtCompilationString: string;
  118746. /**
  118747. * Gets the emitted compilation strings
  118748. */
  118749. compilationString: string;
  118750. /**
  118751. * Finalize the compilation strings
  118752. * @param state defines the current compilation state
  118753. */
  118754. finalize(state: NodeMaterialBuildState): void;
  118755. /** @hidden */
  118756. readonly _repeatableContentAnchor: string;
  118757. /** @hidden */
  118758. _getFreeVariableName(prefix: string): string;
  118759. /** @hidden */
  118760. _getFreeDefineName(prefix: string): string;
  118761. /** @hidden */
  118762. _excludeVariableName(name: string): void;
  118763. /** @hidden */
  118764. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  118765. /** @hidden */
  118766. _emitExtension(name: string, extension: string): void;
  118767. /** @hidden */
  118768. _emitFunction(name: string, code: string, comments: string): void;
  118769. /** @hidden */
  118770. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  118771. replaceStrings?: {
  118772. search: RegExp;
  118773. replace: string;
  118774. }[];
  118775. repeatKey?: string;
  118776. }): string;
  118777. /** @hidden */
  118778. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  118779. repeatKey?: string;
  118780. removeAttributes?: boolean;
  118781. removeUniforms?: boolean;
  118782. removeVaryings?: boolean;
  118783. removeIfDef?: boolean;
  118784. replaceStrings?: {
  118785. search: RegExp;
  118786. replace: string;
  118787. }[];
  118788. }, storeKey?: string): void;
  118789. /** @hidden */
  118790. _registerTempVariable(name: string): boolean;
  118791. /** @hidden */
  118792. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  118793. /** @hidden */
  118794. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  118795. }
  118796. }
  118797. declare module BABYLON {
  118798. /**
  118799. * Defines a block that can be used inside a node based material
  118800. */
  118801. export class NodeMaterialBlock {
  118802. private _buildId;
  118803. private _buildTarget;
  118804. private _target;
  118805. private _isFinalMerger;
  118806. private _isInput;
  118807. /** @hidden */
  118808. _codeVariableName: string;
  118809. /** @hidden */
  118810. _inputs: NodeMaterialConnectionPoint[];
  118811. /** @hidden */
  118812. _outputs: NodeMaterialConnectionPoint[];
  118813. /** @hidden */
  118814. _preparationId: number;
  118815. /**
  118816. * Gets or sets the name of the block
  118817. */
  118818. name: string;
  118819. /**
  118820. * Gets or sets the unique id of the node
  118821. */
  118822. uniqueId: number;
  118823. /**
  118824. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  118825. */
  118826. readonly isFinalMerger: boolean;
  118827. /**
  118828. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  118829. */
  118830. readonly isInput: boolean;
  118831. /**
  118832. * Gets or sets the build Id
  118833. */
  118834. buildId: number;
  118835. /**
  118836. * Gets or sets the target of the block
  118837. */
  118838. target: NodeMaterialBlockTargets;
  118839. /**
  118840. * Gets the list of input points
  118841. */
  118842. readonly inputs: NodeMaterialConnectionPoint[];
  118843. /** Gets the list of output points */
  118844. readonly outputs: NodeMaterialConnectionPoint[];
  118845. /**
  118846. * Find an input by its name
  118847. * @param name defines the name of the input to look for
  118848. * @returns the input or null if not found
  118849. */
  118850. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118851. /**
  118852. * Find an output by its name
  118853. * @param name defines the name of the outputto look for
  118854. * @returns the output or null if not found
  118855. */
  118856. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118857. /**
  118858. * Creates a new NodeMaterialBlock
  118859. * @param name defines the block name
  118860. * @param target defines the target of that block (Vertex by default)
  118861. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  118862. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  118863. */
  118864. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  118865. /**
  118866. * Initialize the block and prepare the context for build
  118867. * @param state defines the state that will be used for the build
  118868. */
  118869. initialize(state: NodeMaterialBuildState): void;
  118870. /**
  118871. * Bind data to effect. Will only be called for blocks with isBindable === true
  118872. * @param effect defines the effect to bind data to
  118873. * @param nodeMaterial defines the hosting NodeMaterial
  118874. * @param mesh defines the mesh that will be rendered
  118875. */
  118876. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118877. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  118878. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  118879. protected _writeFloat(value: number): string;
  118880. /**
  118881. * Gets the current class name e.g. "NodeMaterialBlock"
  118882. * @returns the class name
  118883. */
  118884. getClassName(): string;
  118885. /**
  118886. * Register a new input. Must be called inside a block constructor
  118887. * @param name defines the connection point name
  118888. * @param type defines the connection point type
  118889. * @param isOptional defines a boolean indicating that this input can be omitted
  118890. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118891. * @returns the current block
  118892. */
  118893. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  118894. /**
  118895. * Register a new output. Must be called inside a block constructor
  118896. * @param name defines the connection point name
  118897. * @param type defines the connection point type
  118898. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118899. * @returns the current block
  118900. */
  118901. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  118902. /**
  118903. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  118904. * @param forOutput defines an optional connection point to check compatibility with
  118905. * @returns the first available input or null
  118906. */
  118907. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  118908. /**
  118909. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  118910. * @param forBlock defines an optional block to check compatibility with
  118911. * @returns the first available input or null
  118912. */
  118913. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  118914. /**
  118915. * Gets the sibling of the given output
  118916. * @param current defines the current output
  118917. * @returns the next output in the list or null
  118918. */
  118919. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  118920. /**
  118921. * Connect current block with another block
  118922. * @param other defines the block to connect with
  118923. * @param options define the various options to help pick the right connections
  118924. * @returns the current block
  118925. */
  118926. connectTo(other: NodeMaterialBlock, options?: {
  118927. input?: string;
  118928. output?: string;
  118929. outputSwizzle?: string;
  118930. }): this | undefined;
  118931. protected _buildBlock(state: NodeMaterialBuildState): void;
  118932. /**
  118933. * Add uniforms, samplers and uniform buffers at compilation time
  118934. * @param state defines the state to update
  118935. * @param nodeMaterial defines the node material requesting the update
  118936. * @param defines defines the material defines to update
  118937. */
  118938. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118939. /**
  118940. * Add potential fallbacks if shader compilation fails
  118941. * @param mesh defines the mesh to be rendered
  118942. * @param fallbacks defines the current prioritized list of fallbacks
  118943. */
  118944. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118945. /**
  118946. * Initialize defines for shader compilation
  118947. * @param mesh defines the mesh to be rendered
  118948. * @param nodeMaterial defines the node material requesting the update
  118949. * @param defines defines the material defines to update
  118950. * @param useInstances specifies that instances should be used
  118951. */
  118952. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118953. /**
  118954. * Update defines for shader compilation
  118955. * @param mesh defines the mesh to be rendered
  118956. * @param nodeMaterial defines the node material requesting the update
  118957. * @param defines defines the material defines to update
  118958. * @param useInstances specifies that instances should be used
  118959. */
  118960. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118961. /**
  118962. * Lets the block try to connect some inputs automatically
  118963. * @param material defines the hosting NodeMaterial
  118964. */
  118965. autoConfigure(material: NodeMaterial): void;
  118966. /**
  118967. * Function called when a block is declared as repeatable content generator
  118968. * @param vertexShaderState defines the current compilation state for the vertex shader
  118969. * @param fragmentShaderState defines the current compilation state for the fragment shader
  118970. * @param mesh defines the mesh to be rendered
  118971. * @param defines defines the material defines to update
  118972. */
  118973. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118974. /**
  118975. * Checks if the block is ready
  118976. * @param mesh defines the mesh to be rendered
  118977. * @param nodeMaterial defines the node material requesting the update
  118978. * @param defines defines the material defines to update
  118979. * @param useInstances specifies that instances should be used
  118980. * @returns true if the block is ready
  118981. */
  118982. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  118983. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  118984. private _processBuild;
  118985. /**
  118986. * Compile the current node and generate the shader code
  118987. * @param state defines the current compilation state (uniforms, samplers, current string)
  118988. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  118989. * @returns true if already built
  118990. */
  118991. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  118992. protected _inputRename(name: string): string;
  118993. protected _outputRename(name: string): string;
  118994. protected _dumpPropertiesCode(): string;
  118995. /** @hidden */
  118996. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  118997. /**
  118998. * Clone the current block to a new identical block
  118999. * @param scene defines the hosting scene
  119000. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119001. * @returns a copy of the current block
  119002. */
  119003. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  119004. /**
  119005. * Serializes this block in a JSON representation
  119006. * @returns the serialized block object
  119007. */
  119008. serialize(): any;
  119009. /** @hidden */
  119010. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119011. }
  119012. }
  119013. declare module BABYLON {
  119014. /**
  119015. * Enum defining the type of animations supported by InputBlock
  119016. */
  119017. export enum AnimatedInputBlockTypes {
  119018. /** No animation */
  119019. None = 0,
  119020. /** Time based animation. Will only work for floats */
  119021. Time = 1
  119022. }
  119023. }
  119024. declare module BABYLON {
  119025. /**
  119026. * Block used to expose an input value
  119027. */
  119028. export class InputBlock extends NodeMaterialBlock {
  119029. private _mode;
  119030. private _associatedVariableName;
  119031. private _storedValue;
  119032. private _valueCallback;
  119033. private _type;
  119034. private _animationType;
  119035. /** Gets or set a value used to limit the range of float values */
  119036. min: number;
  119037. /** Gets or set a value used to limit the range of float values */
  119038. max: number;
  119039. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  119040. matrixMode: number;
  119041. /** @hidden */
  119042. _systemValue: Nullable<NodeMaterialSystemValues>;
  119043. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  119044. visibleInInspector: boolean;
  119045. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  119046. isConstant: boolean;
  119047. /**
  119048. * Gets or sets the connection point type (default is float)
  119049. */
  119050. readonly type: NodeMaterialBlockConnectionPointTypes;
  119051. /**
  119052. * Creates a new InputBlock
  119053. * @param name defines the block name
  119054. * @param target defines the target of that block (Vertex by default)
  119055. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  119056. */
  119057. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  119058. /**
  119059. * Gets the output component
  119060. */
  119061. readonly output: NodeMaterialConnectionPoint;
  119062. /**
  119063. * Set the source of this connection point to a vertex attribute
  119064. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  119065. * @returns the current connection point
  119066. */
  119067. setAsAttribute(attributeName?: string): InputBlock;
  119068. /**
  119069. * Set the source of this connection point to a system value
  119070. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  119071. * @returns the current connection point
  119072. */
  119073. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  119074. /**
  119075. * Gets or sets the value of that point.
  119076. * Please note that this value will be ignored if valueCallback is defined
  119077. */
  119078. value: any;
  119079. /**
  119080. * Gets or sets a callback used to get the value of that point.
  119081. * Please note that setting this value will force the connection point to ignore the value property
  119082. */
  119083. valueCallback: () => any;
  119084. /**
  119085. * Gets or sets the associated variable name in the shader
  119086. */
  119087. associatedVariableName: string;
  119088. /** Gets or sets the type of animation applied to the input */
  119089. animationType: AnimatedInputBlockTypes;
  119090. /**
  119091. * Gets a boolean indicating that this connection point not defined yet
  119092. */
  119093. readonly isUndefined: boolean;
  119094. /**
  119095. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  119096. * In this case the connection point name must be the name of the uniform to use.
  119097. * Can only be set on inputs
  119098. */
  119099. isUniform: boolean;
  119100. /**
  119101. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  119102. * In this case the connection point name must be the name of the attribute to use
  119103. * Can only be set on inputs
  119104. */
  119105. isAttribute: boolean;
  119106. /**
  119107. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  119108. * Can only be set on exit points
  119109. */
  119110. isVarying: boolean;
  119111. /**
  119112. * Gets a boolean indicating that the current connection point is a system value
  119113. */
  119114. readonly isSystemValue: boolean;
  119115. /**
  119116. * Gets or sets the current well known value or null if not defined as a system value
  119117. */
  119118. systemValue: Nullable<NodeMaterialSystemValues>;
  119119. /**
  119120. * Gets the current class name
  119121. * @returns the class name
  119122. */
  119123. getClassName(): string;
  119124. /**
  119125. * Animate the input if animationType !== None
  119126. * @param scene defines the rendering scene
  119127. */
  119128. animate(scene: Scene): void;
  119129. private _emitDefine;
  119130. initialize(state: NodeMaterialBuildState): void;
  119131. /**
  119132. * Set the input block to its default value (based on its type)
  119133. */
  119134. setDefaultValue(): void;
  119135. private _emitConstant;
  119136. private _emit;
  119137. /** @hidden */
  119138. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  119139. /** @hidden */
  119140. _transmit(effect: Effect, scene: Scene): void;
  119141. protected _buildBlock(state: NodeMaterialBuildState): void;
  119142. protected _dumpPropertiesCode(): string;
  119143. serialize(): any;
  119144. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119145. }
  119146. }
  119147. declare module BABYLON {
  119148. /**
  119149. * Defines a connection point for a block
  119150. */
  119151. export class NodeMaterialConnectionPoint {
  119152. /** @hidden */
  119153. _ownerBlock: NodeMaterialBlock;
  119154. /** @hidden */
  119155. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119156. private _endpoints;
  119157. private _associatedVariableName;
  119158. /** @hidden */
  119159. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119160. /** @hidden */
  119161. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119162. private _type;
  119163. /** @hidden */
  119164. _enforceAssociatedVariableName: boolean;
  119165. /**
  119166. * Gets or sets the additional types supported by this connection point
  119167. */
  119168. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119169. /**
  119170. * Gets or sets the additional types excluded by this connection point
  119171. */
  119172. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119173. /**
  119174. * Gets or sets the associated variable name in the shader
  119175. */
  119176. associatedVariableName: string;
  119177. /**
  119178. * Gets or sets the connection point type (default is float)
  119179. */
  119180. type: NodeMaterialBlockConnectionPointTypes;
  119181. /**
  119182. * Gets or sets the connection point name
  119183. */
  119184. name: string;
  119185. /**
  119186. * Gets or sets a boolean indicating that this connection point can be omitted
  119187. */
  119188. isOptional: boolean;
  119189. /**
  119190. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  119191. */
  119192. define: string;
  119193. /** Gets or sets the target of that connection point */
  119194. target: NodeMaterialBlockTargets;
  119195. /**
  119196. * Gets a boolean indicating that the current point is connected
  119197. */
  119198. readonly isConnected: boolean;
  119199. /**
  119200. * Gets a boolean indicating that the current point is connected to an input block
  119201. */
  119202. readonly isConnectedToInputBlock: boolean;
  119203. /**
  119204. * Gets a the connected input block (if any)
  119205. */
  119206. readonly connectInputBlock: Nullable<InputBlock>;
  119207. /** Get the other side of the connection (if any) */
  119208. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119209. /** Get the block that owns this connection point */
  119210. readonly ownerBlock: NodeMaterialBlock;
  119211. /** Get the block connected on the other side of this connection (if any) */
  119212. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  119213. /** Get the block connected on the endpoints of this connection (if any) */
  119214. readonly connectedBlocks: Array<NodeMaterialBlock>;
  119215. /** Gets the list of connected endpoints */
  119216. readonly endpoints: NodeMaterialConnectionPoint[];
  119217. /** Gets a boolean indicating if that output point is connected to at least one input */
  119218. readonly hasEndpoints: boolean;
  119219. /**
  119220. * Creates a new connection point
  119221. * @param name defines the connection point name
  119222. * @param ownerBlock defines the block hosting this connection point
  119223. */
  119224. constructor(name: string, ownerBlock: NodeMaterialBlock);
  119225. /**
  119226. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  119227. * @returns the class name
  119228. */
  119229. getClassName(): string;
  119230. /**
  119231. * Gets an boolean indicating if the current point can be connected to another point
  119232. * @param connectionPoint defines the other connection point
  119233. * @returns true if the connection is possible
  119234. */
  119235. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  119236. /**
  119237. * Connect this point to another connection point
  119238. * @param connectionPoint defines the other connection point
  119239. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  119240. * @returns the current connection point
  119241. */
  119242. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  119243. /**
  119244. * Disconnect this point from one of his endpoint
  119245. * @param endpoint defines the other connection point
  119246. * @returns the current connection point
  119247. */
  119248. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  119249. /**
  119250. * Serializes this point in a JSON representation
  119251. * @returns the serialized point object
  119252. */
  119253. serialize(): any;
  119254. }
  119255. }
  119256. declare module BABYLON {
  119257. /**
  119258. * Block used to add support for vertex skinning (bones)
  119259. */
  119260. export class BonesBlock extends NodeMaterialBlock {
  119261. /**
  119262. * Creates a new BonesBlock
  119263. * @param name defines the block name
  119264. */
  119265. constructor(name: string);
  119266. /**
  119267. * Initialize the block and prepare the context for build
  119268. * @param state defines the state that will be used for the build
  119269. */
  119270. initialize(state: NodeMaterialBuildState): void;
  119271. /**
  119272. * Gets the current class name
  119273. * @returns the class name
  119274. */
  119275. getClassName(): string;
  119276. /**
  119277. * Gets the matrix indices input component
  119278. */
  119279. readonly matricesIndices: NodeMaterialConnectionPoint;
  119280. /**
  119281. * Gets the matrix weights input component
  119282. */
  119283. readonly matricesWeights: NodeMaterialConnectionPoint;
  119284. /**
  119285. * Gets the extra matrix indices input component
  119286. */
  119287. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  119288. /**
  119289. * Gets the extra matrix weights input component
  119290. */
  119291. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  119292. /**
  119293. * Gets the world input component
  119294. */
  119295. readonly world: NodeMaterialConnectionPoint;
  119296. /**
  119297. * Gets the output component
  119298. */
  119299. readonly output: NodeMaterialConnectionPoint;
  119300. autoConfigure(material: NodeMaterial): void;
  119301. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  119302. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119303. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119304. protected _buildBlock(state: NodeMaterialBuildState): this;
  119305. }
  119306. }
  119307. declare module BABYLON {
  119308. /**
  119309. * Block used to add support for instances
  119310. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  119311. */
  119312. export class InstancesBlock extends NodeMaterialBlock {
  119313. /**
  119314. * Creates a new InstancesBlock
  119315. * @param name defines the block name
  119316. */
  119317. constructor(name: string);
  119318. /**
  119319. * Gets the current class name
  119320. * @returns the class name
  119321. */
  119322. getClassName(): string;
  119323. /**
  119324. * Gets the first world row input component
  119325. */
  119326. readonly world0: NodeMaterialConnectionPoint;
  119327. /**
  119328. * Gets the second world row input component
  119329. */
  119330. readonly world1: NodeMaterialConnectionPoint;
  119331. /**
  119332. * Gets the third world row input component
  119333. */
  119334. readonly world2: NodeMaterialConnectionPoint;
  119335. /**
  119336. * Gets the forth world row input component
  119337. */
  119338. readonly world3: NodeMaterialConnectionPoint;
  119339. /**
  119340. * Gets the world input component
  119341. */
  119342. readonly world: NodeMaterialConnectionPoint;
  119343. /**
  119344. * Gets the output component
  119345. */
  119346. readonly output: NodeMaterialConnectionPoint;
  119347. autoConfigure(material: NodeMaterial): void;
  119348. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119349. protected _buildBlock(state: NodeMaterialBuildState): this;
  119350. }
  119351. }
  119352. declare module BABYLON {
  119353. /**
  119354. * Block used to add morph targets support to vertex shader
  119355. */
  119356. export class MorphTargetsBlock extends NodeMaterialBlock {
  119357. private _repeatableContentAnchor;
  119358. private _repeatebleContentGenerated;
  119359. /**
  119360. * Create a new MorphTargetsBlock
  119361. * @param name defines the block name
  119362. */
  119363. constructor(name: string);
  119364. /**
  119365. * Gets the current class name
  119366. * @returns the class name
  119367. */
  119368. getClassName(): string;
  119369. /**
  119370. * Gets the position input component
  119371. */
  119372. readonly position: NodeMaterialConnectionPoint;
  119373. /**
  119374. * Gets the normal input component
  119375. */
  119376. readonly normal: NodeMaterialConnectionPoint;
  119377. /**
  119378. * Gets the tangent input component
  119379. */
  119380. readonly tangent: NodeMaterialConnectionPoint;
  119381. /**
  119382. * Gets the tangent input component
  119383. */
  119384. readonly uv: NodeMaterialConnectionPoint;
  119385. /**
  119386. * Gets the position output component
  119387. */
  119388. readonly positionOutput: NodeMaterialConnectionPoint;
  119389. /**
  119390. * Gets the normal output component
  119391. */
  119392. readonly normalOutput: NodeMaterialConnectionPoint;
  119393. /**
  119394. * Gets the tangent output component
  119395. */
  119396. readonly tangentOutput: NodeMaterialConnectionPoint;
  119397. /**
  119398. * Gets the tangent output component
  119399. */
  119400. readonly uvOutput: NodeMaterialConnectionPoint;
  119401. initialize(state: NodeMaterialBuildState): void;
  119402. autoConfigure(material: NodeMaterial): void;
  119403. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119404. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119405. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  119406. protected _buildBlock(state: NodeMaterialBuildState): this;
  119407. }
  119408. }
  119409. declare module BABYLON {
  119410. /**
  119411. * Block used to get data information from a light
  119412. */
  119413. export class LightInformationBlock extends NodeMaterialBlock {
  119414. private _lightDataUniformName;
  119415. private _lightColorUniformName;
  119416. private _lightTypeDefineName;
  119417. /**
  119418. * Gets or sets the light associated with this block
  119419. */
  119420. light: Nullable<Light>;
  119421. /**
  119422. * Creates a new LightInformationBlock
  119423. * @param name defines the block name
  119424. */
  119425. constructor(name: string);
  119426. /**
  119427. * Gets the current class name
  119428. * @returns the class name
  119429. */
  119430. getClassName(): string;
  119431. /**
  119432. * Gets the world position input component
  119433. */
  119434. readonly worldPosition: NodeMaterialConnectionPoint;
  119435. /**
  119436. * Gets the direction output component
  119437. */
  119438. readonly direction: NodeMaterialConnectionPoint;
  119439. /**
  119440. * Gets the direction output component
  119441. */
  119442. readonly color: NodeMaterialConnectionPoint;
  119443. /**
  119444. * Gets the direction output component
  119445. */
  119446. readonly intensity: NodeMaterialConnectionPoint;
  119447. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119448. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119449. protected _buildBlock(state: NodeMaterialBuildState): this;
  119450. serialize(): any;
  119451. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119452. }
  119453. }
  119454. declare module BABYLON {
  119455. /**
  119456. * Block used to add image processing support to fragment shader
  119457. */
  119458. export class ImageProcessingBlock extends NodeMaterialBlock {
  119459. /**
  119460. * Create a new ImageProcessingBlock
  119461. * @param name defines the block name
  119462. */
  119463. constructor(name: string);
  119464. /**
  119465. * Gets the current class name
  119466. * @returns the class name
  119467. */
  119468. getClassName(): string;
  119469. /**
  119470. * Gets the color input component
  119471. */
  119472. readonly color: NodeMaterialConnectionPoint;
  119473. /**
  119474. * Gets the output component
  119475. */
  119476. readonly output: NodeMaterialConnectionPoint;
  119477. /**
  119478. * Initialize the block and prepare the context for build
  119479. * @param state defines the state that will be used for the build
  119480. */
  119481. initialize(state: NodeMaterialBuildState): void;
  119482. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  119483. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119484. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119485. protected _buildBlock(state: NodeMaterialBuildState): this;
  119486. }
  119487. }
  119488. declare module BABYLON {
  119489. /**
  119490. * Block used to pertub normals based on a normal map
  119491. */
  119492. export class PerturbNormalBlock extends NodeMaterialBlock {
  119493. private _tangentSpaceParameterName;
  119494. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  119495. invertX: boolean;
  119496. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  119497. invertY: boolean;
  119498. /**
  119499. * Create a new PerturbNormalBlock
  119500. * @param name defines the block name
  119501. */
  119502. constructor(name: string);
  119503. /**
  119504. * Gets the current class name
  119505. * @returns the class name
  119506. */
  119507. getClassName(): string;
  119508. /**
  119509. * Gets the world position input component
  119510. */
  119511. readonly worldPosition: NodeMaterialConnectionPoint;
  119512. /**
  119513. * Gets the world normal input component
  119514. */
  119515. readonly worldNormal: NodeMaterialConnectionPoint;
  119516. /**
  119517. * Gets the uv input component
  119518. */
  119519. readonly uv: NodeMaterialConnectionPoint;
  119520. /**
  119521. * Gets the normal map color input component
  119522. */
  119523. readonly normalMapColor: NodeMaterialConnectionPoint;
  119524. /**
  119525. * Gets the strength input component
  119526. */
  119527. readonly strength: NodeMaterialConnectionPoint;
  119528. /**
  119529. * Gets the output component
  119530. */
  119531. readonly output: NodeMaterialConnectionPoint;
  119532. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119533. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119534. autoConfigure(material: NodeMaterial): void;
  119535. protected _buildBlock(state: NodeMaterialBuildState): this;
  119536. protected _dumpPropertiesCode(): string;
  119537. serialize(): any;
  119538. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119539. }
  119540. }
  119541. declare module BABYLON {
  119542. /**
  119543. * Block used to discard a pixel if a value is smaller than a cutoff
  119544. */
  119545. export class DiscardBlock extends NodeMaterialBlock {
  119546. /**
  119547. * Create a new DiscardBlock
  119548. * @param name defines the block name
  119549. */
  119550. constructor(name: string);
  119551. /**
  119552. * Gets the current class name
  119553. * @returns the class name
  119554. */
  119555. getClassName(): string;
  119556. /**
  119557. * Gets the color input component
  119558. */
  119559. readonly value: NodeMaterialConnectionPoint;
  119560. /**
  119561. * Gets the cutoff input component
  119562. */
  119563. readonly cutoff: NodeMaterialConnectionPoint;
  119564. protected _buildBlock(state: NodeMaterialBuildState): this;
  119565. }
  119566. }
  119567. declare module BABYLON {
  119568. /**
  119569. * Block used to add support for scene fog
  119570. */
  119571. export class FogBlock extends NodeMaterialBlock {
  119572. private _fogDistanceName;
  119573. private _fogParameters;
  119574. /**
  119575. * Create a new FogBlock
  119576. * @param name defines the block name
  119577. */
  119578. constructor(name: string);
  119579. /**
  119580. * Gets the current class name
  119581. * @returns the class name
  119582. */
  119583. getClassName(): string;
  119584. /**
  119585. * Gets the world position input component
  119586. */
  119587. readonly worldPosition: NodeMaterialConnectionPoint;
  119588. /**
  119589. * Gets the view input component
  119590. */
  119591. readonly view: NodeMaterialConnectionPoint;
  119592. /**
  119593. * Gets the color input component
  119594. */
  119595. readonly input: NodeMaterialConnectionPoint;
  119596. /**
  119597. * Gets the fog color input component
  119598. */
  119599. readonly fogColor: NodeMaterialConnectionPoint;
  119600. /**
  119601. * Gets the output component
  119602. */
  119603. readonly output: NodeMaterialConnectionPoint;
  119604. autoConfigure(material: NodeMaterial): void;
  119605. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119606. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119607. protected _buildBlock(state: NodeMaterialBuildState): this;
  119608. }
  119609. }
  119610. declare module BABYLON {
  119611. /**
  119612. * Block used to add light in the fragment shader
  119613. */
  119614. export class LightBlock extends NodeMaterialBlock {
  119615. private _lightId;
  119616. /**
  119617. * Gets or sets the light associated with this block
  119618. */
  119619. light: Nullable<Light>;
  119620. /**
  119621. * Create a new LightBlock
  119622. * @param name defines the block name
  119623. */
  119624. constructor(name: string);
  119625. /**
  119626. * Gets the current class name
  119627. * @returns the class name
  119628. */
  119629. getClassName(): string;
  119630. /**
  119631. * Gets the world position input component
  119632. */
  119633. readonly worldPosition: NodeMaterialConnectionPoint;
  119634. /**
  119635. * Gets the world normal input component
  119636. */
  119637. readonly worldNormal: NodeMaterialConnectionPoint;
  119638. /**
  119639. * Gets the camera (or eye) position component
  119640. */
  119641. readonly cameraPosition: NodeMaterialConnectionPoint;
  119642. /**
  119643. * Gets the diffuse output component
  119644. */
  119645. readonly diffuseOutput: NodeMaterialConnectionPoint;
  119646. /**
  119647. * Gets the specular output component
  119648. */
  119649. readonly specularOutput: NodeMaterialConnectionPoint;
  119650. autoConfigure(material: NodeMaterial): void;
  119651. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119652. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119653. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119654. private _injectVertexCode;
  119655. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119656. serialize(): any;
  119657. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119658. }
  119659. }
  119660. declare module BABYLON {
  119661. /**
  119662. * Block used to multiply 2 values
  119663. */
  119664. export class MultiplyBlock extends NodeMaterialBlock {
  119665. /**
  119666. * Creates a new MultiplyBlock
  119667. * @param name defines the block name
  119668. */
  119669. constructor(name: string);
  119670. /**
  119671. * Gets the current class name
  119672. * @returns the class name
  119673. */
  119674. getClassName(): string;
  119675. /**
  119676. * Gets the left operand input component
  119677. */
  119678. readonly left: NodeMaterialConnectionPoint;
  119679. /**
  119680. * Gets the right operand input component
  119681. */
  119682. readonly right: NodeMaterialConnectionPoint;
  119683. /**
  119684. * Gets the output component
  119685. */
  119686. readonly output: NodeMaterialConnectionPoint;
  119687. protected _buildBlock(state: NodeMaterialBuildState): this;
  119688. }
  119689. }
  119690. declare module BABYLON {
  119691. /**
  119692. * Block used to add 2 vectors
  119693. */
  119694. export class AddBlock extends NodeMaterialBlock {
  119695. /**
  119696. * Creates a new AddBlock
  119697. * @param name defines the block name
  119698. */
  119699. constructor(name: string);
  119700. /**
  119701. * Gets the current class name
  119702. * @returns the class name
  119703. */
  119704. getClassName(): string;
  119705. /**
  119706. * Gets the left operand input component
  119707. */
  119708. readonly left: NodeMaterialConnectionPoint;
  119709. /**
  119710. * Gets the right operand input component
  119711. */
  119712. readonly right: NodeMaterialConnectionPoint;
  119713. /**
  119714. * Gets the output component
  119715. */
  119716. readonly output: NodeMaterialConnectionPoint;
  119717. protected _buildBlock(state: NodeMaterialBuildState): this;
  119718. }
  119719. }
  119720. declare module BABYLON {
  119721. /**
  119722. * Block used to scale a vector by a float
  119723. */
  119724. export class ScaleBlock extends NodeMaterialBlock {
  119725. /**
  119726. * Creates a new ScaleBlock
  119727. * @param name defines the block name
  119728. */
  119729. constructor(name: string);
  119730. /**
  119731. * Gets the current class name
  119732. * @returns the class name
  119733. */
  119734. getClassName(): string;
  119735. /**
  119736. * Gets the input component
  119737. */
  119738. readonly input: NodeMaterialConnectionPoint;
  119739. /**
  119740. * Gets the factor input component
  119741. */
  119742. readonly factor: NodeMaterialConnectionPoint;
  119743. /**
  119744. * Gets the output component
  119745. */
  119746. readonly output: NodeMaterialConnectionPoint;
  119747. protected _buildBlock(state: NodeMaterialBuildState): this;
  119748. }
  119749. }
  119750. declare module BABYLON {
  119751. /**
  119752. * Block used to clamp a float
  119753. */
  119754. export class ClampBlock extends NodeMaterialBlock {
  119755. /** Gets or sets the minimum range */
  119756. minimum: number;
  119757. /** Gets or sets the maximum range */
  119758. maximum: number;
  119759. /**
  119760. * Creates a new ClampBlock
  119761. * @param name defines the block name
  119762. */
  119763. constructor(name: string);
  119764. /**
  119765. * Gets the current class name
  119766. * @returns the class name
  119767. */
  119768. getClassName(): string;
  119769. /**
  119770. * Gets the value input component
  119771. */
  119772. readonly value: NodeMaterialConnectionPoint;
  119773. /**
  119774. * Gets the output component
  119775. */
  119776. readonly output: NodeMaterialConnectionPoint;
  119777. protected _buildBlock(state: NodeMaterialBuildState): this;
  119778. protected _dumpPropertiesCode(): string;
  119779. serialize(): any;
  119780. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119781. }
  119782. }
  119783. declare module BABYLON {
  119784. /**
  119785. * Block used to apply a cross product between 2 vectors
  119786. */
  119787. export class CrossBlock extends NodeMaterialBlock {
  119788. /**
  119789. * Creates a new CrossBlock
  119790. * @param name defines the block name
  119791. */
  119792. constructor(name: string);
  119793. /**
  119794. * Gets the current class name
  119795. * @returns the class name
  119796. */
  119797. getClassName(): string;
  119798. /**
  119799. * Gets the left operand input component
  119800. */
  119801. readonly left: NodeMaterialConnectionPoint;
  119802. /**
  119803. * Gets the right operand input component
  119804. */
  119805. readonly right: NodeMaterialConnectionPoint;
  119806. /**
  119807. * Gets the output component
  119808. */
  119809. readonly output: NodeMaterialConnectionPoint;
  119810. protected _buildBlock(state: NodeMaterialBuildState): this;
  119811. }
  119812. }
  119813. declare module BABYLON {
  119814. /**
  119815. * Block used to apply a dot product between 2 vectors
  119816. */
  119817. export class DotBlock extends NodeMaterialBlock {
  119818. /**
  119819. * Creates a new DotBlock
  119820. * @param name defines the block name
  119821. */
  119822. constructor(name: string);
  119823. /**
  119824. * Gets the current class name
  119825. * @returns the class name
  119826. */
  119827. getClassName(): string;
  119828. /**
  119829. * Gets the left operand input component
  119830. */
  119831. readonly left: NodeMaterialConnectionPoint;
  119832. /**
  119833. * Gets the right operand input component
  119834. */
  119835. readonly right: NodeMaterialConnectionPoint;
  119836. /**
  119837. * Gets the output component
  119838. */
  119839. readonly output: NodeMaterialConnectionPoint;
  119840. protected _buildBlock(state: NodeMaterialBuildState): this;
  119841. }
  119842. }
  119843. declare module BABYLON {
  119844. /**
  119845. * Block used to remap a float from a range to a new one
  119846. */
  119847. export class RemapBlock extends NodeMaterialBlock {
  119848. /**
  119849. * Gets or sets the source range
  119850. */
  119851. sourceRange: Vector2;
  119852. /**
  119853. * Gets or sets the target range
  119854. */
  119855. targetRange: Vector2;
  119856. /**
  119857. * Creates a new RemapBlock
  119858. * @param name defines the block name
  119859. */
  119860. constructor(name: string);
  119861. /**
  119862. * Gets the current class name
  119863. * @returns the class name
  119864. */
  119865. getClassName(): string;
  119866. /**
  119867. * Gets the input component
  119868. */
  119869. readonly input: NodeMaterialConnectionPoint;
  119870. /**
  119871. * Gets the source min input component
  119872. */
  119873. readonly sourceMin: NodeMaterialConnectionPoint;
  119874. /**
  119875. * Gets the source max input component
  119876. */
  119877. readonly sourceMax: NodeMaterialConnectionPoint;
  119878. /**
  119879. * Gets the target min input component
  119880. */
  119881. readonly targetMin: NodeMaterialConnectionPoint;
  119882. /**
  119883. * Gets the target max input component
  119884. */
  119885. readonly targetMax: NodeMaterialConnectionPoint;
  119886. /**
  119887. * Gets the output component
  119888. */
  119889. readonly output: NodeMaterialConnectionPoint;
  119890. protected _buildBlock(state: NodeMaterialBuildState): this;
  119891. protected _dumpPropertiesCode(): string;
  119892. serialize(): any;
  119893. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119894. }
  119895. }
  119896. declare module BABYLON {
  119897. /**
  119898. * Block used to normalize a vector
  119899. */
  119900. export class NormalizeBlock extends NodeMaterialBlock {
  119901. /**
  119902. * Creates a new NormalizeBlock
  119903. * @param name defines the block name
  119904. */
  119905. constructor(name: string);
  119906. /**
  119907. * Gets the current class name
  119908. * @returns the class name
  119909. */
  119910. getClassName(): string;
  119911. /**
  119912. * Gets the input component
  119913. */
  119914. readonly input: NodeMaterialConnectionPoint;
  119915. /**
  119916. * Gets the output component
  119917. */
  119918. readonly output: NodeMaterialConnectionPoint;
  119919. protected _buildBlock(state: NodeMaterialBuildState): this;
  119920. }
  119921. }
  119922. declare module BABYLON {
  119923. /**
  119924. * Operations supported by the Trigonometry block
  119925. */
  119926. export enum TrigonometryBlockOperations {
  119927. /** Cos */
  119928. Cos = 0,
  119929. /** Sin */
  119930. Sin = 1,
  119931. /** Abs */
  119932. Abs = 2,
  119933. /** Exp */
  119934. Exp = 3,
  119935. /** Exp2 */
  119936. Exp2 = 4,
  119937. /** Round */
  119938. Round = 5,
  119939. /** Floor */
  119940. Floor = 6,
  119941. /** Ceiling */
  119942. Ceiling = 7,
  119943. /** Square root */
  119944. Sqrt = 8
  119945. }
  119946. /**
  119947. * Block used to apply trigonometry operation to floats
  119948. */
  119949. export class TrigonometryBlock extends NodeMaterialBlock {
  119950. /**
  119951. * Gets or sets the operation applied by the block
  119952. */
  119953. operation: TrigonometryBlockOperations;
  119954. /**
  119955. * Creates a new TrigonometryBlock
  119956. * @param name defines the block name
  119957. */
  119958. constructor(name: string);
  119959. /**
  119960. * Gets the current class name
  119961. * @returns the class name
  119962. */
  119963. getClassName(): string;
  119964. /**
  119965. * Gets the input component
  119966. */
  119967. readonly input: NodeMaterialConnectionPoint;
  119968. /**
  119969. * Gets the output component
  119970. */
  119971. readonly output: NodeMaterialConnectionPoint;
  119972. protected _buildBlock(state: NodeMaterialBuildState): this;
  119973. serialize(): any;
  119974. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119975. }
  119976. }
  119977. declare module BABYLON {
  119978. /**
  119979. * Block used to create a Color3/4 out of individual inputs (one for each component)
  119980. */
  119981. export class ColorMergerBlock extends NodeMaterialBlock {
  119982. /**
  119983. * Create a new ColorMergerBlock
  119984. * @param name defines the block name
  119985. */
  119986. constructor(name: string);
  119987. /**
  119988. * Gets the current class name
  119989. * @returns the class name
  119990. */
  119991. getClassName(): string;
  119992. /**
  119993. * Gets the r component (input)
  119994. */
  119995. readonly r: NodeMaterialConnectionPoint;
  119996. /**
  119997. * Gets the g component (input)
  119998. */
  119999. readonly g: NodeMaterialConnectionPoint;
  120000. /**
  120001. * Gets the b component (input)
  120002. */
  120003. readonly b: NodeMaterialConnectionPoint;
  120004. /**
  120005. * Gets the a component (input)
  120006. */
  120007. readonly a: NodeMaterialConnectionPoint;
  120008. /**
  120009. * Gets the rgba component (output)
  120010. */
  120011. readonly rgba: NodeMaterialConnectionPoint;
  120012. /**
  120013. * Gets the rgb component (output)
  120014. */
  120015. readonly rgb: NodeMaterialConnectionPoint;
  120016. protected _buildBlock(state: NodeMaterialBuildState): this;
  120017. }
  120018. }
  120019. declare module BABYLON {
  120020. /**
  120021. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  120022. */
  120023. export class VectorMergerBlock extends NodeMaterialBlock {
  120024. /**
  120025. * Create a new VectorMergerBlock
  120026. * @param name defines the block name
  120027. */
  120028. constructor(name: string);
  120029. /**
  120030. * Gets the current class name
  120031. * @returns the class name
  120032. */
  120033. getClassName(): string;
  120034. /**
  120035. * Gets the x component (input)
  120036. */
  120037. readonly x: NodeMaterialConnectionPoint;
  120038. /**
  120039. * Gets the y component (input)
  120040. */
  120041. readonly y: NodeMaterialConnectionPoint;
  120042. /**
  120043. * Gets the z component (input)
  120044. */
  120045. readonly z: NodeMaterialConnectionPoint;
  120046. /**
  120047. * Gets the w component (input)
  120048. */
  120049. readonly w: NodeMaterialConnectionPoint;
  120050. /**
  120051. * Gets the xyzw component (output)
  120052. */
  120053. readonly xyzw: NodeMaterialConnectionPoint;
  120054. /**
  120055. * Gets the xyz component (output)
  120056. */
  120057. readonly xyz: NodeMaterialConnectionPoint;
  120058. /**
  120059. * Gets the xy component (output)
  120060. */
  120061. readonly xy: NodeMaterialConnectionPoint;
  120062. protected _buildBlock(state: NodeMaterialBuildState): this;
  120063. }
  120064. }
  120065. declare module BABYLON {
  120066. /**
  120067. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  120068. */
  120069. export class ColorSplitterBlock extends NodeMaterialBlock {
  120070. /**
  120071. * Create a new ColorSplitterBlock
  120072. * @param name defines the block name
  120073. */
  120074. constructor(name: string);
  120075. /**
  120076. * Gets the current class name
  120077. * @returns the class name
  120078. */
  120079. getClassName(): string;
  120080. /**
  120081. * Gets the rgba component (input)
  120082. */
  120083. readonly rgba: NodeMaterialConnectionPoint;
  120084. /**
  120085. * Gets the rgb component (input)
  120086. */
  120087. readonly rgbIn: NodeMaterialConnectionPoint;
  120088. /**
  120089. * Gets the rgb component (output)
  120090. */
  120091. readonly rgbOut: NodeMaterialConnectionPoint;
  120092. /**
  120093. * Gets the r component (output)
  120094. */
  120095. readonly r: NodeMaterialConnectionPoint;
  120096. /**
  120097. * Gets the g component (output)
  120098. */
  120099. readonly g: NodeMaterialConnectionPoint;
  120100. /**
  120101. * Gets the b component (output)
  120102. */
  120103. readonly b: NodeMaterialConnectionPoint;
  120104. /**
  120105. * Gets the a component (output)
  120106. */
  120107. readonly a: NodeMaterialConnectionPoint;
  120108. protected _inputRename(name: string): string;
  120109. protected _outputRename(name: string): string;
  120110. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120111. }
  120112. }
  120113. declare module BABYLON {
  120114. /**
  120115. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  120116. */
  120117. export class VectorSplitterBlock extends NodeMaterialBlock {
  120118. /**
  120119. * Create a new VectorSplitterBlock
  120120. * @param name defines the block name
  120121. */
  120122. constructor(name: string);
  120123. /**
  120124. * Gets the current class name
  120125. * @returns the class name
  120126. */
  120127. getClassName(): string;
  120128. /**
  120129. * Gets the xyzw component (input)
  120130. */
  120131. readonly xyzw: NodeMaterialConnectionPoint;
  120132. /**
  120133. * Gets the xyz component (input)
  120134. */
  120135. readonly xyzIn: NodeMaterialConnectionPoint;
  120136. /**
  120137. * Gets the xy component (input)
  120138. */
  120139. readonly xyIn: NodeMaterialConnectionPoint;
  120140. /**
  120141. * Gets the xyz component (output)
  120142. */
  120143. readonly xyzOut: NodeMaterialConnectionPoint;
  120144. /**
  120145. * Gets the xy component (output)
  120146. */
  120147. readonly xyOut: NodeMaterialConnectionPoint;
  120148. /**
  120149. * Gets the x component (output)
  120150. */
  120151. readonly x: NodeMaterialConnectionPoint;
  120152. /**
  120153. * Gets the y component (output)
  120154. */
  120155. readonly y: NodeMaterialConnectionPoint;
  120156. /**
  120157. * Gets the z component (output)
  120158. */
  120159. readonly z: NodeMaterialConnectionPoint;
  120160. /**
  120161. * Gets the w component (output)
  120162. */
  120163. readonly w: NodeMaterialConnectionPoint;
  120164. protected _inputRename(name: string): string;
  120165. protected _outputRename(name: string): string;
  120166. protected _buildBlock(state: NodeMaterialBuildState): this;
  120167. }
  120168. }
  120169. declare module BABYLON {
  120170. /**
  120171. * Block used to lerp 2 values
  120172. */
  120173. export class LerpBlock extends NodeMaterialBlock {
  120174. /**
  120175. * Creates a new LerpBlock
  120176. * @param name defines the block name
  120177. */
  120178. constructor(name: string);
  120179. /**
  120180. * Gets the current class name
  120181. * @returns the class name
  120182. */
  120183. getClassName(): string;
  120184. /**
  120185. * Gets the left operand input component
  120186. */
  120187. readonly left: NodeMaterialConnectionPoint;
  120188. /**
  120189. * Gets the right operand input component
  120190. */
  120191. readonly right: NodeMaterialConnectionPoint;
  120192. /**
  120193. * Gets the gradient operand input component
  120194. */
  120195. readonly gradient: NodeMaterialConnectionPoint;
  120196. /**
  120197. * Gets the output component
  120198. */
  120199. readonly output: NodeMaterialConnectionPoint;
  120200. protected _buildBlock(state: NodeMaterialBuildState): this;
  120201. }
  120202. }
  120203. declare module BABYLON {
  120204. /**
  120205. * Block used to divide 2 vectors
  120206. */
  120207. export class DivideBlock extends NodeMaterialBlock {
  120208. /**
  120209. * Creates a new DivideBlock
  120210. * @param name defines the block name
  120211. */
  120212. constructor(name: string);
  120213. /**
  120214. * Gets the current class name
  120215. * @returns the class name
  120216. */
  120217. getClassName(): string;
  120218. /**
  120219. * Gets the left operand input component
  120220. */
  120221. readonly left: NodeMaterialConnectionPoint;
  120222. /**
  120223. * Gets the right operand input component
  120224. */
  120225. readonly right: NodeMaterialConnectionPoint;
  120226. /**
  120227. * Gets the output component
  120228. */
  120229. readonly output: NodeMaterialConnectionPoint;
  120230. protected _buildBlock(state: NodeMaterialBuildState): this;
  120231. }
  120232. }
  120233. declare module BABYLON {
  120234. /**
  120235. * Block used to subtract 2 vectors
  120236. */
  120237. export class SubtractBlock extends NodeMaterialBlock {
  120238. /**
  120239. * Creates a new SubtractBlock
  120240. * @param name defines the block name
  120241. */
  120242. constructor(name: string);
  120243. /**
  120244. * Gets the current class name
  120245. * @returns the class name
  120246. */
  120247. getClassName(): string;
  120248. /**
  120249. * Gets the left operand input component
  120250. */
  120251. readonly left: NodeMaterialConnectionPoint;
  120252. /**
  120253. * Gets the right operand input component
  120254. */
  120255. readonly right: NodeMaterialConnectionPoint;
  120256. /**
  120257. * Gets the output component
  120258. */
  120259. readonly output: NodeMaterialConnectionPoint;
  120260. protected _buildBlock(state: NodeMaterialBuildState): this;
  120261. }
  120262. }
  120263. declare module BABYLON {
  120264. /**
  120265. * Block used to step a value
  120266. */
  120267. export class StepBlock extends NodeMaterialBlock {
  120268. /**
  120269. * Creates a new AddBlock
  120270. * @param name defines the block name
  120271. */
  120272. constructor(name: string);
  120273. /**
  120274. * Gets the current class name
  120275. * @returns the class name
  120276. */
  120277. getClassName(): string;
  120278. /**
  120279. * Gets the value operand input component
  120280. */
  120281. readonly value: NodeMaterialConnectionPoint;
  120282. /**
  120283. * Gets the edge operand input component
  120284. */
  120285. readonly edge: NodeMaterialConnectionPoint;
  120286. /**
  120287. * Gets the output component
  120288. */
  120289. readonly output: NodeMaterialConnectionPoint;
  120290. protected _buildBlock(state: NodeMaterialBuildState): this;
  120291. }
  120292. }
  120293. declare module BABYLON {
  120294. /**
  120295. * Block used to get the opposite (1 - x) of a value
  120296. */
  120297. export class OneMinusBlock extends NodeMaterialBlock {
  120298. /**
  120299. * Creates a new OneMinusBlock
  120300. * @param name defines the block name
  120301. */
  120302. constructor(name: string);
  120303. /**
  120304. * Gets the current class name
  120305. * @returns the class name
  120306. */
  120307. getClassName(): string;
  120308. /**
  120309. * Gets the input component
  120310. */
  120311. readonly input: NodeMaterialConnectionPoint;
  120312. /**
  120313. * Gets the output component
  120314. */
  120315. readonly output: NodeMaterialConnectionPoint;
  120316. protected _buildBlock(state: NodeMaterialBuildState): this;
  120317. }
  120318. }
  120319. declare module BABYLON {
  120320. /**
  120321. * Block used to get the view direction
  120322. */
  120323. export class ViewDirectionBlock extends NodeMaterialBlock {
  120324. /**
  120325. * Creates a new ViewDirectionBlock
  120326. * @param name defines the block name
  120327. */
  120328. constructor(name: string);
  120329. /**
  120330. * Gets the current class name
  120331. * @returns the class name
  120332. */
  120333. getClassName(): string;
  120334. /**
  120335. * Gets the world position component
  120336. */
  120337. readonly worldPosition: NodeMaterialConnectionPoint;
  120338. /**
  120339. * Gets the camera position component
  120340. */
  120341. readonly cameraPosition: NodeMaterialConnectionPoint;
  120342. /**
  120343. * Gets the output component
  120344. */
  120345. readonly output: NodeMaterialConnectionPoint;
  120346. autoConfigure(material: NodeMaterial): void;
  120347. protected _buildBlock(state: NodeMaterialBuildState): this;
  120348. }
  120349. }
  120350. declare module BABYLON {
  120351. /**
  120352. * Block used to compute fresnel value
  120353. */
  120354. export class FresnelBlock extends NodeMaterialBlock {
  120355. /**
  120356. * Create a new FresnelBlock
  120357. * @param name defines the block name
  120358. */
  120359. constructor(name: string);
  120360. /**
  120361. * Gets the current class name
  120362. * @returns the class name
  120363. */
  120364. getClassName(): string;
  120365. /**
  120366. * Gets the world normal input component
  120367. */
  120368. readonly worldNormal: NodeMaterialConnectionPoint;
  120369. /**
  120370. * Gets the view direction input component
  120371. */
  120372. readonly viewDirection: NodeMaterialConnectionPoint;
  120373. /**
  120374. * Gets the bias input component
  120375. */
  120376. readonly bias: NodeMaterialConnectionPoint;
  120377. /**
  120378. * Gets the camera (or eye) position component
  120379. */
  120380. readonly power: NodeMaterialConnectionPoint;
  120381. /**
  120382. * Gets the fresnel output component
  120383. */
  120384. readonly fresnel: NodeMaterialConnectionPoint;
  120385. autoConfigure(material: NodeMaterial): void;
  120386. protected _buildBlock(state: NodeMaterialBuildState): this;
  120387. }
  120388. }
  120389. declare module BABYLON {
  120390. /**
  120391. * Block used to get the max of 2 values
  120392. */
  120393. export class MaxBlock extends NodeMaterialBlock {
  120394. /**
  120395. * Creates a new MaxBlock
  120396. * @param name defines the block name
  120397. */
  120398. constructor(name: string);
  120399. /**
  120400. * Gets the current class name
  120401. * @returns the class name
  120402. */
  120403. getClassName(): string;
  120404. /**
  120405. * Gets the left operand input component
  120406. */
  120407. readonly left: NodeMaterialConnectionPoint;
  120408. /**
  120409. * Gets the right operand input component
  120410. */
  120411. readonly right: NodeMaterialConnectionPoint;
  120412. /**
  120413. * Gets the output component
  120414. */
  120415. readonly output: NodeMaterialConnectionPoint;
  120416. protected _buildBlock(state: NodeMaterialBuildState): this;
  120417. }
  120418. }
  120419. declare module BABYLON {
  120420. /**
  120421. * Block used to get the min of 2 values
  120422. */
  120423. export class MinBlock extends NodeMaterialBlock {
  120424. /**
  120425. * Creates a new MinBlock
  120426. * @param name defines the block name
  120427. */
  120428. constructor(name: string);
  120429. /**
  120430. * Gets the current class name
  120431. * @returns the class name
  120432. */
  120433. getClassName(): string;
  120434. /**
  120435. * Gets the left operand input component
  120436. */
  120437. readonly left: NodeMaterialConnectionPoint;
  120438. /**
  120439. * Gets the right operand input component
  120440. */
  120441. readonly right: NodeMaterialConnectionPoint;
  120442. /**
  120443. * Gets the output component
  120444. */
  120445. readonly output: NodeMaterialConnectionPoint;
  120446. protected _buildBlock(state: NodeMaterialBuildState): this;
  120447. }
  120448. }
  120449. declare module BABYLON {
  120450. /**
  120451. * Block used to get the distance between 2 values
  120452. */
  120453. export class DistanceBlock extends NodeMaterialBlock {
  120454. /**
  120455. * Creates a new DistanceBlock
  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 left operand input component
  120466. */
  120467. readonly left: NodeMaterialConnectionPoint;
  120468. /**
  120469. * Gets the right operand input component
  120470. */
  120471. readonly right: NodeMaterialConnectionPoint;
  120472. /**
  120473. * Gets the output component
  120474. */
  120475. readonly output: NodeMaterialConnectionPoint;
  120476. protected _buildBlock(state: NodeMaterialBuildState): this;
  120477. }
  120478. }
  120479. declare module BABYLON {
  120480. /**
  120481. * Block used to get the length of a vector
  120482. */
  120483. export class LengthBlock extends NodeMaterialBlock {
  120484. /**
  120485. * Creates a new LengthBlock
  120486. * @param name defines the block name
  120487. */
  120488. constructor(name: string);
  120489. /**
  120490. * Gets the current class name
  120491. * @returns the class name
  120492. */
  120493. getClassName(): string;
  120494. /**
  120495. * Gets the value input component
  120496. */
  120497. readonly value: NodeMaterialConnectionPoint;
  120498. /**
  120499. * Gets the output component
  120500. */
  120501. readonly output: NodeMaterialConnectionPoint;
  120502. protected _buildBlock(state: NodeMaterialBuildState): this;
  120503. }
  120504. }
  120505. declare module BABYLON {
  120506. /**
  120507. * Block used to get negative version of a value (i.e. x * -1)
  120508. */
  120509. export class NegateBlock extends NodeMaterialBlock {
  120510. /**
  120511. * Creates a new NegateBlock
  120512. * @param name defines the block name
  120513. */
  120514. constructor(name: string);
  120515. /**
  120516. * Gets the current class name
  120517. * @returns the class name
  120518. */
  120519. getClassName(): string;
  120520. /**
  120521. * Gets the value input component
  120522. */
  120523. readonly value: NodeMaterialConnectionPoint;
  120524. /**
  120525. * Gets the output component
  120526. */
  120527. readonly output: NodeMaterialConnectionPoint;
  120528. protected _buildBlock(state: NodeMaterialBuildState): this;
  120529. }
  120530. }
  120531. declare module BABYLON {
  120532. /**
  120533. * Block used to get the value of the first parameter raised to the power of the second
  120534. */
  120535. export class PowBlock extends NodeMaterialBlock {
  120536. /**
  120537. * Creates a new PowBlock
  120538. * @param name defines the block name
  120539. */
  120540. constructor(name: string);
  120541. /**
  120542. * Gets the current class name
  120543. * @returns the class name
  120544. */
  120545. getClassName(): string;
  120546. /**
  120547. * Gets the value operand input component
  120548. */
  120549. readonly value: NodeMaterialConnectionPoint;
  120550. /**
  120551. * Gets the power operand input component
  120552. */
  120553. readonly power: NodeMaterialConnectionPoint;
  120554. /**
  120555. * Gets the output component
  120556. */
  120557. readonly output: NodeMaterialConnectionPoint;
  120558. protected _buildBlock(state: NodeMaterialBuildState): this;
  120559. }
  120560. }
  120561. declare module BABYLON {
  120562. /**
  120563. * Block used to get a random number
  120564. */
  120565. export class RandomNumberBlock extends NodeMaterialBlock {
  120566. /**
  120567. * Creates a new RandomNumberBlock
  120568. * @param name defines the block name
  120569. */
  120570. constructor(name: string);
  120571. /**
  120572. * Gets the current class name
  120573. * @returns the class name
  120574. */
  120575. getClassName(): string;
  120576. /**
  120577. * Gets the seed input component
  120578. */
  120579. readonly seed: NodeMaterialConnectionPoint;
  120580. /**
  120581. * Gets the output component
  120582. */
  120583. readonly output: NodeMaterialConnectionPoint;
  120584. protected _buildBlock(state: NodeMaterialBuildState): this;
  120585. }
  120586. }
  120587. declare module BABYLON {
  120588. /**
  120589. * Effect Render Options
  120590. */
  120591. export interface IEffectRendererOptions {
  120592. /**
  120593. * Defines the vertices positions.
  120594. */
  120595. positions?: number[];
  120596. /**
  120597. * Defines the indices.
  120598. */
  120599. indices?: number[];
  120600. }
  120601. /**
  120602. * Helper class to render one or more effects
  120603. */
  120604. export class EffectRenderer {
  120605. private engine;
  120606. private static _DefaultOptions;
  120607. private _vertexBuffers;
  120608. private _indexBuffer;
  120609. private _ringBufferIndex;
  120610. private _ringScreenBuffer;
  120611. private _fullscreenViewport;
  120612. private _getNextFrameBuffer;
  120613. /**
  120614. * Creates an effect renderer
  120615. * @param engine the engine to use for rendering
  120616. * @param options defines the options of the effect renderer
  120617. */
  120618. constructor(engine: Engine, options?: IEffectRendererOptions);
  120619. /**
  120620. * Sets the current viewport in normalized coordinates 0-1
  120621. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  120622. */
  120623. setViewport(viewport?: Viewport): void;
  120624. /**
  120625. * Binds the embedded attributes buffer to the effect.
  120626. * @param effect Defines the effect to bind the attributes for
  120627. */
  120628. bindBuffers(effect: Effect): void;
  120629. /**
  120630. * Sets the current effect wrapper to use during draw.
  120631. * The effect needs to be ready before calling this api.
  120632. * This also sets the default full screen position attribute.
  120633. * @param effectWrapper Defines the effect to draw with
  120634. */
  120635. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  120636. /**
  120637. * Draws a full screen quad.
  120638. */
  120639. draw(): void;
  120640. /**
  120641. * renders one or more effects to a specified texture
  120642. * @param effectWrappers list of effects to renderer
  120643. * @param outputTexture texture to draw to, if null it will render to the screen
  120644. */
  120645. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  120646. /**
  120647. * Disposes of the effect renderer
  120648. */
  120649. dispose(): void;
  120650. }
  120651. /**
  120652. * Options to create an EffectWrapper
  120653. */
  120654. interface EffectWrapperCreationOptions {
  120655. /**
  120656. * Engine to use to create the effect
  120657. */
  120658. engine: Engine;
  120659. /**
  120660. * Fragment shader for the effect
  120661. */
  120662. fragmentShader: string;
  120663. /**
  120664. * Vertex shader for the effect
  120665. */
  120666. vertexShader?: string;
  120667. /**
  120668. * Attributes to use in the shader
  120669. */
  120670. attributeNames?: Array<string>;
  120671. /**
  120672. * Uniforms to use in the shader
  120673. */
  120674. uniformNames?: Array<string>;
  120675. /**
  120676. * Texture sampler names to use in the shader
  120677. */
  120678. samplerNames?: Array<string>;
  120679. /**
  120680. * The friendly name of the effect displayed in Spector.
  120681. */
  120682. name?: string;
  120683. }
  120684. /**
  120685. * Wraps an effect to be used for rendering
  120686. */
  120687. export class EffectWrapper {
  120688. /**
  120689. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  120690. */
  120691. onApplyObservable: Observable<{}>;
  120692. /**
  120693. * The underlying effect
  120694. */
  120695. effect: Effect;
  120696. /**
  120697. * Creates an effect to be renderer
  120698. * @param creationOptions options to create the effect
  120699. */
  120700. constructor(creationOptions: EffectWrapperCreationOptions);
  120701. /**
  120702. * Disposes of the effect wrapper
  120703. */
  120704. dispose(): void;
  120705. }
  120706. }
  120707. declare module BABYLON {
  120708. /**
  120709. * Helper class to push actions to a pool of workers.
  120710. */
  120711. export class WorkerPool implements IDisposable {
  120712. private _workerInfos;
  120713. private _pendingActions;
  120714. /**
  120715. * Constructor
  120716. * @param workers Array of workers to use for actions
  120717. */
  120718. constructor(workers: Array<Worker>);
  120719. /**
  120720. * Terminates all workers and clears any pending actions.
  120721. */
  120722. dispose(): void;
  120723. /**
  120724. * Pushes an action to the worker pool. If all the workers are active, the action will be
  120725. * pended until a worker has completed its action.
  120726. * @param action The action to perform. Call onComplete when the action is complete.
  120727. */
  120728. push(action: (worker: Worker, onComplete: () => void) => void): void;
  120729. private _execute;
  120730. }
  120731. }
  120732. declare module BABYLON {
  120733. /**
  120734. * Configuration for Draco compression
  120735. */
  120736. export interface IDracoCompressionConfiguration {
  120737. /**
  120738. * Configuration for the decoder.
  120739. */
  120740. decoder: {
  120741. /**
  120742. * The url to the WebAssembly module.
  120743. */
  120744. wasmUrl?: string;
  120745. /**
  120746. * The url to the WebAssembly binary.
  120747. */
  120748. wasmBinaryUrl?: string;
  120749. /**
  120750. * The url to the fallback JavaScript module.
  120751. */
  120752. fallbackUrl?: string;
  120753. };
  120754. }
  120755. /**
  120756. * Draco compression (https://google.github.io/draco/)
  120757. *
  120758. * This class wraps the Draco module.
  120759. *
  120760. * **Encoder**
  120761. *
  120762. * The encoder is not currently implemented.
  120763. *
  120764. * **Decoder**
  120765. *
  120766. * 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.
  120767. *
  120768. * To update the configuration, use the following code:
  120769. * ```javascript
  120770. * DracoCompression.Configuration = {
  120771. * decoder: {
  120772. * wasmUrl: "<url to the WebAssembly library>",
  120773. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  120774. * fallbackUrl: "<url to the fallback JavaScript library>",
  120775. * }
  120776. * };
  120777. * ```
  120778. *
  120779. * 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.
  120780. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  120781. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  120782. *
  120783. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  120784. * ```javascript
  120785. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  120786. * ```
  120787. *
  120788. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  120789. */
  120790. export class DracoCompression implements IDisposable {
  120791. private _workerPoolPromise?;
  120792. private _decoderModulePromise?;
  120793. /**
  120794. * The configuration. Defaults to the following urls:
  120795. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  120796. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  120797. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  120798. */
  120799. static Configuration: IDracoCompressionConfiguration;
  120800. /**
  120801. * Returns true if the decoder configuration is available.
  120802. */
  120803. static readonly DecoderAvailable: boolean;
  120804. /**
  120805. * Default number of workers to create when creating the draco compression object.
  120806. */
  120807. static DefaultNumWorkers: number;
  120808. private static GetDefaultNumWorkers;
  120809. private static _Default;
  120810. /**
  120811. * Default instance for the draco compression object.
  120812. */
  120813. static readonly Default: DracoCompression;
  120814. /**
  120815. * Constructor
  120816. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  120817. */
  120818. constructor(numWorkers?: number);
  120819. /**
  120820. * Stop all async operations and release resources.
  120821. */
  120822. dispose(): void;
  120823. /**
  120824. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  120825. * @returns a promise that resolves when ready
  120826. */
  120827. whenReadyAsync(): Promise<void>;
  120828. /**
  120829. * Decode Draco compressed mesh data to vertex data.
  120830. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  120831. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  120832. * @returns A promise that resolves with the decoded vertex data
  120833. */
  120834. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  120835. [kind: string]: number;
  120836. }): Promise<VertexData>;
  120837. }
  120838. }
  120839. declare module BABYLON {
  120840. /**
  120841. * Class for building Constructive Solid Geometry
  120842. */
  120843. export class CSG {
  120844. private polygons;
  120845. /**
  120846. * The world matrix
  120847. */
  120848. matrix: Matrix;
  120849. /**
  120850. * Stores the position
  120851. */
  120852. position: Vector3;
  120853. /**
  120854. * Stores the rotation
  120855. */
  120856. rotation: Vector3;
  120857. /**
  120858. * Stores the rotation quaternion
  120859. */
  120860. rotationQuaternion: Nullable<Quaternion>;
  120861. /**
  120862. * Stores the scaling vector
  120863. */
  120864. scaling: Vector3;
  120865. /**
  120866. * Convert the Mesh to CSG
  120867. * @param mesh The Mesh to convert to CSG
  120868. * @returns A new CSG from the Mesh
  120869. */
  120870. static FromMesh(mesh: Mesh): CSG;
  120871. /**
  120872. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  120873. * @param polygons Polygons used to construct a CSG solid
  120874. */
  120875. private static FromPolygons;
  120876. /**
  120877. * Clones, or makes a deep copy, of the CSG
  120878. * @returns A new CSG
  120879. */
  120880. clone(): CSG;
  120881. /**
  120882. * Unions this CSG with another CSG
  120883. * @param csg The CSG to union against this CSG
  120884. * @returns The unioned CSG
  120885. */
  120886. union(csg: CSG): CSG;
  120887. /**
  120888. * Unions this CSG with another CSG in place
  120889. * @param csg The CSG to union against this CSG
  120890. */
  120891. unionInPlace(csg: CSG): void;
  120892. /**
  120893. * Subtracts this CSG with another CSG
  120894. * @param csg The CSG to subtract against this CSG
  120895. * @returns A new CSG
  120896. */
  120897. subtract(csg: CSG): CSG;
  120898. /**
  120899. * Subtracts this CSG with another CSG in place
  120900. * @param csg The CSG to subtact against this CSG
  120901. */
  120902. subtractInPlace(csg: CSG): void;
  120903. /**
  120904. * Intersect this CSG with another CSG
  120905. * @param csg The CSG to intersect against this CSG
  120906. * @returns A new CSG
  120907. */
  120908. intersect(csg: CSG): CSG;
  120909. /**
  120910. * Intersects this CSG with another CSG in place
  120911. * @param csg The CSG to intersect against this CSG
  120912. */
  120913. intersectInPlace(csg: CSG): void;
  120914. /**
  120915. * Return a new CSG solid with solid and empty space switched. This solid is
  120916. * not modified.
  120917. * @returns A new CSG solid with solid and empty space switched
  120918. */
  120919. inverse(): CSG;
  120920. /**
  120921. * Inverses the CSG in place
  120922. */
  120923. inverseInPlace(): void;
  120924. /**
  120925. * This is used to keep meshes transformations so they can be restored
  120926. * when we build back a Babylon Mesh
  120927. * NB : All CSG operations are performed in world coordinates
  120928. * @param csg The CSG to copy the transform attributes from
  120929. * @returns This CSG
  120930. */
  120931. copyTransformAttributes(csg: CSG): CSG;
  120932. /**
  120933. * Build Raw mesh from CSG
  120934. * Coordinates here are in world space
  120935. * @param name The name of the mesh geometry
  120936. * @param scene The Scene
  120937. * @param keepSubMeshes Specifies if the submeshes should be kept
  120938. * @returns A new Mesh
  120939. */
  120940. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120941. /**
  120942. * Build Mesh from CSG taking material and transforms into account
  120943. * @param name The name of the Mesh
  120944. * @param material The material of the Mesh
  120945. * @param scene The Scene
  120946. * @param keepSubMeshes Specifies if submeshes should be kept
  120947. * @returns The new Mesh
  120948. */
  120949. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120950. }
  120951. }
  120952. declare module BABYLON {
  120953. /**
  120954. * Class used to create a trail following a mesh
  120955. */
  120956. export class TrailMesh extends Mesh {
  120957. private _generator;
  120958. private _autoStart;
  120959. private _running;
  120960. private _diameter;
  120961. private _length;
  120962. private _sectionPolygonPointsCount;
  120963. private _sectionVectors;
  120964. private _sectionNormalVectors;
  120965. private _beforeRenderObserver;
  120966. /**
  120967. * @constructor
  120968. * @param name The value used by scene.getMeshByName() to do a lookup.
  120969. * @param generator The mesh to generate a trail.
  120970. * @param scene The scene to add this mesh to.
  120971. * @param diameter Diameter of trailing mesh. Default is 1.
  120972. * @param length Length of trailing mesh. Default is 60.
  120973. * @param autoStart Automatically start trailing mesh. Default true.
  120974. */
  120975. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  120976. /**
  120977. * "TrailMesh"
  120978. * @returns "TrailMesh"
  120979. */
  120980. getClassName(): string;
  120981. private _createMesh;
  120982. /**
  120983. * Start trailing mesh.
  120984. */
  120985. start(): void;
  120986. /**
  120987. * Stop trailing mesh.
  120988. */
  120989. stop(): void;
  120990. /**
  120991. * Update trailing mesh geometry.
  120992. */
  120993. update(): void;
  120994. /**
  120995. * Returns a new TrailMesh object.
  120996. * @param name is a string, the name given to the new mesh
  120997. * @param newGenerator use new generator object for cloned trail mesh
  120998. * @returns a new mesh
  120999. */
  121000. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  121001. /**
  121002. * Serializes this trail mesh
  121003. * @param serializationObject object to write serialization to
  121004. */
  121005. serialize(serializationObject: any): void;
  121006. /**
  121007. * Parses a serialized trail mesh
  121008. * @param parsedMesh the serialized mesh
  121009. * @param scene the scene to create the trail mesh in
  121010. * @returns the created trail mesh
  121011. */
  121012. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  121013. }
  121014. }
  121015. declare module BABYLON {
  121016. /**
  121017. * Class containing static functions to help procedurally build meshes
  121018. */
  121019. export class TiledBoxBuilder {
  121020. /**
  121021. * Creates a box mesh
  121022. * 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)
  121023. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121025. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121027. * @param name defines the name of the mesh
  121028. * @param options defines the options used to create the mesh
  121029. * @param scene defines the hosting scene
  121030. * @returns the box mesh
  121031. */
  121032. static CreateTiledBox(name: string, options: {
  121033. pattern?: number;
  121034. width?: number;
  121035. height?: number;
  121036. depth?: number;
  121037. tileSize?: number;
  121038. tileWidth?: number;
  121039. tileHeight?: number;
  121040. alignHorizontal?: number;
  121041. alignVertical?: number;
  121042. faceUV?: Vector4[];
  121043. faceColors?: Color4[];
  121044. sideOrientation?: number;
  121045. updatable?: boolean;
  121046. }, scene?: Nullable<Scene>): Mesh;
  121047. }
  121048. }
  121049. declare module BABYLON {
  121050. /**
  121051. * Class containing static functions to help procedurally build meshes
  121052. */
  121053. export class TorusKnotBuilder {
  121054. /**
  121055. * Creates a torus knot mesh
  121056. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121057. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121058. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121059. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121063. * @param name defines the name of the mesh
  121064. * @param options defines the options used to create the mesh
  121065. * @param scene defines the hosting scene
  121066. * @returns the torus knot mesh
  121067. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121068. */
  121069. static CreateTorusKnot(name: string, options: {
  121070. radius?: number;
  121071. tube?: number;
  121072. radialSegments?: number;
  121073. tubularSegments?: number;
  121074. p?: number;
  121075. q?: number;
  121076. updatable?: boolean;
  121077. sideOrientation?: number;
  121078. frontUVs?: Vector4;
  121079. backUVs?: Vector4;
  121080. }, scene: any): Mesh;
  121081. }
  121082. }
  121083. declare module BABYLON {
  121084. /**
  121085. * Polygon
  121086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  121087. */
  121088. export class Polygon {
  121089. /**
  121090. * Creates a rectangle
  121091. * @param xmin bottom X coord
  121092. * @param ymin bottom Y coord
  121093. * @param xmax top X coord
  121094. * @param ymax top Y coord
  121095. * @returns points that make the resulting rectation
  121096. */
  121097. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  121098. /**
  121099. * Creates a circle
  121100. * @param radius radius of circle
  121101. * @param cx scale in x
  121102. * @param cy scale in y
  121103. * @param numberOfSides number of sides that make up the circle
  121104. * @returns points that make the resulting circle
  121105. */
  121106. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  121107. /**
  121108. * Creates a polygon from input string
  121109. * @param input Input polygon data
  121110. * @returns the parsed points
  121111. */
  121112. static Parse(input: string): Vector2[];
  121113. /**
  121114. * Starts building a polygon from x and y coordinates
  121115. * @param x x coordinate
  121116. * @param y y coordinate
  121117. * @returns the started path2
  121118. */
  121119. static StartingAt(x: number, y: number): Path2;
  121120. }
  121121. /**
  121122. * Builds a polygon
  121123. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  121124. */
  121125. export class PolygonMeshBuilder {
  121126. private _points;
  121127. private _outlinepoints;
  121128. private _holes;
  121129. private _name;
  121130. private _scene;
  121131. private _epoints;
  121132. private _eholes;
  121133. private _addToepoint;
  121134. /**
  121135. * Babylon reference to the earcut plugin.
  121136. */
  121137. bjsEarcut: any;
  121138. /**
  121139. * Creates a PolygonMeshBuilder
  121140. * @param name name of the builder
  121141. * @param contours Path of the polygon
  121142. * @param scene scene to add to when creating the mesh
  121143. * @param earcutInjection can be used to inject your own earcut reference
  121144. */
  121145. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  121146. /**
  121147. * Adds a whole within the polygon
  121148. * @param hole Array of points defining the hole
  121149. * @returns this
  121150. */
  121151. addHole(hole: Vector2[]): PolygonMeshBuilder;
  121152. /**
  121153. * Creates the polygon
  121154. * @param updatable If the mesh should be updatable
  121155. * @param depth The depth of the mesh created
  121156. * @returns the created mesh
  121157. */
  121158. build(updatable?: boolean, depth?: number): Mesh;
  121159. /**
  121160. * Creates the polygon
  121161. * @param depth The depth of the mesh created
  121162. * @returns the created VertexData
  121163. */
  121164. buildVertexData(depth?: number): VertexData;
  121165. /**
  121166. * Adds a side to the polygon
  121167. * @param positions points that make the polygon
  121168. * @param normals normals of the polygon
  121169. * @param uvs uvs of the polygon
  121170. * @param indices indices of the polygon
  121171. * @param bounds bounds of the polygon
  121172. * @param points points of the polygon
  121173. * @param depth depth of the polygon
  121174. * @param flip flip of the polygon
  121175. */
  121176. private addSide;
  121177. }
  121178. }
  121179. declare module BABYLON {
  121180. /**
  121181. * Class containing static functions to help procedurally build meshes
  121182. */
  121183. export class PolygonBuilder {
  121184. /**
  121185. * Creates a polygon mesh
  121186. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121187. * * 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
  121188. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121191. * * Remember you can only change the shape positions, not their number when updating a polygon
  121192. * @param name defines the name of the mesh
  121193. * @param options defines the options used to create the mesh
  121194. * @param scene defines the hosting scene
  121195. * @param earcutInjection can be used to inject your own earcut reference
  121196. * @returns the polygon mesh
  121197. */
  121198. static CreatePolygon(name: string, options: {
  121199. shape: Vector3[];
  121200. holes?: Vector3[][];
  121201. depth?: number;
  121202. faceUV?: Vector4[];
  121203. faceColors?: Color4[];
  121204. updatable?: boolean;
  121205. sideOrientation?: number;
  121206. frontUVs?: Vector4;
  121207. backUVs?: Vector4;
  121208. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121209. /**
  121210. * Creates an extruded polygon mesh, with depth in the Y direction.
  121211. * * 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)
  121212. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121213. * @param name defines the name of the mesh
  121214. * @param options defines the options used to create the mesh
  121215. * @param scene defines the hosting scene
  121216. * @param earcutInjection can be used to inject your own earcut reference
  121217. * @returns the polygon mesh
  121218. */
  121219. static ExtrudePolygon(name: string, options: {
  121220. shape: Vector3[];
  121221. holes?: Vector3[][];
  121222. depth?: number;
  121223. faceUV?: Vector4[];
  121224. faceColors?: Color4[];
  121225. updatable?: boolean;
  121226. sideOrientation?: number;
  121227. frontUVs?: Vector4;
  121228. backUVs?: Vector4;
  121229. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121230. }
  121231. }
  121232. declare module BABYLON {
  121233. /**
  121234. * Class containing static functions to help procedurally build meshes
  121235. */
  121236. export class LatheBuilder {
  121237. /**
  121238. * Creates lathe mesh.
  121239. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121240. * * 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
  121241. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121242. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121243. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121244. * * 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
  121245. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121246. * * 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
  121247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121248. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121249. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121251. * @param name defines the name of the mesh
  121252. * @param options defines the options used to create the mesh
  121253. * @param scene defines the hosting scene
  121254. * @returns the lathe mesh
  121255. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121256. */
  121257. static CreateLathe(name: string, options: {
  121258. shape: Vector3[];
  121259. radius?: number;
  121260. tessellation?: number;
  121261. clip?: number;
  121262. arc?: number;
  121263. closed?: boolean;
  121264. updatable?: boolean;
  121265. sideOrientation?: number;
  121266. frontUVs?: Vector4;
  121267. backUVs?: Vector4;
  121268. cap?: number;
  121269. invertUV?: boolean;
  121270. }, scene?: Nullable<Scene>): Mesh;
  121271. }
  121272. }
  121273. declare module BABYLON {
  121274. /**
  121275. * Class containing static functions to help procedurally build meshes
  121276. */
  121277. export class TiledPlaneBuilder {
  121278. /**
  121279. * Creates a tiled plane mesh
  121280. * * The parameter `pattern` will, depending on value, do nothing or
  121281. * * * flip (reflect about central vertical) alternate tiles across and up
  121282. * * * flip every tile on alternate rows
  121283. * * * rotate (180 degs) alternate tiles across and up
  121284. * * * rotate every tile on alternate rows
  121285. * * * flip and rotate alternate tiles across and up
  121286. * * * flip and rotate every tile on alternate rows
  121287. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  121288. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  121289. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121291. * * 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)
  121292. * * 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)
  121293. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121294. * @param name defines the name of the mesh
  121295. * @param options defines the options used to create the mesh
  121296. * @param scene defines the hosting scene
  121297. * @returns the box mesh
  121298. */
  121299. static CreateTiledPlane(name: string, options: {
  121300. pattern?: number;
  121301. tileSize?: number;
  121302. tileWidth?: number;
  121303. tileHeight?: number;
  121304. size?: number;
  121305. width?: number;
  121306. height?: number;
  121307. alignHorizontal?: number;
  121308. alignVertical?: number;
  121309. sideOrientation?: number;
  121310. frontUVs?: Vector4;
  121311. backUVs?: Vector4;
  121312. updatable?: boolean;
  121313. }, scene?: Nullable<Scene>): Mesh;
  121314. }
  121315. }
  121316. declare module BABYLON {
  121317. /**
  121318. * Class containing static functions to help procedurally build meshes
  121319. */
  121320. export class TubeBuilder {
  121321. /**
  121322. * Creates a tube mesh.
  121323. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121324. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121325. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121326. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121327. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121328. * * 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)
  121329. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121330. * * 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
  121331. * * 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
  121332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121333. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121336. * @param name defines the name of the mesh
  121337. * @param options defines the options used to create the mesh
  121338. * @param scene defines the hosting scene
  121339. * @returns the tube mesh
  121340. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121341. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121342. */
  121343. static CreateTube(name: string, options: {
  121344. path: Vector3[];
  121345. radius?: number;
  121346. tessellation?: number;
  121347. radiusFunction?: {
  121348. (i: number, distance: number): number;
  121349. };
  121350. cap?: number;
  121351. arc?: number;
  121352. updatable?: boolean;
  121353. sideOrientation?: number;
  121354. frontUVs?: Vector4;
  121355. backUVs?: Vector4;
  121356. instance?: Mesh;
  121357. invertUV?: boolean;
  121358. }, scene?: Nullable<Scene>): Mesh;
  121359. }
  121360. }
  121361. declare module BABYLON {
  121362. /**
  121363. * Class containing static functions to help procedurally build meshes
  121364. */
  121365. export class IcoSphereBuilder {
  121366. /**
  121367. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121368. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121369. * * 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`)
  121370. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121371. * * 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
  121372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121375. * @param name defines the name of the mesh
  121376. * @param options defines the options used to create the mesh
  121377. * @param scene defines the hosting scene
  121378. * @returns the icosahedron mesh
  121379. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121380. */
  121381. static CreateIcoSphere(name: string, options: {
  121382. radius?: number;
  121383. radiusX?: number;
  121384. radiusY?: number;
  121385. radiusZ?: number;
  121386. flat?: boolean;
  121387. subdivisions?: number;
  121388. sideOrientation?: number;
  121389. frontUVs?: Vector4;
  121390. backUVs?: Vector4;
  121391. updatable?: boolean;
  121392. }, scene?: Nullable<Scene>): Mesh;
  121393. }
  121394. }
  121395. declare module BABYLON {
  121396. /**
  121397. * Class containing static functions to help procedurally build meshes
  121398. */
  121399. export class DecalBuilder {
  121400. /**
  121401. * Creates a decal mesh.
  121402. * 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
  121403. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121404. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121405. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121406. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121407. * @param name defines the name of the mesh
  121408. * @param sourceMesh defines the mesh where the decal must be applied
  121409. * @param options defines the options used to create the mesh
  121410. * @param scene defines the hosting scene
  121411. * @returns the decal mesh
  121412. * @see https://doc.babylonjs.com/how_to/decals
  121413. */
  121414. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121415. position?: Vector3;
  121416. normal?: Vector3;
  121417. size?: Vector3;
  121418. angle?: number;
  121419. }): Mesh;
  121420. }
  121421. }
  121422. declare module BABYLON {
  121423. /**
  121424. * Class containing static functions to help procedurally build meshes
  121425. */
  121426. export class MeshBuilder {
  121427. /**
  121428. * Creates a box mesh
  121429. * * The parameter `size` sets the size (float) of each box side (default 1)
  121430. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  121431. * * 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)
  121432. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121436. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121437. * @param name defines the name of the mesh
  121438. * @param options defines the options used to create the mesh
  121439. * @param scene defines the hosting scene
  121440. * @returns the box mesh
  121441. */
  121442. static CreateBox(name: string, options: {
  121443. size?: number;
  121444. width?: number;
  121445. height?: number;
  121446. depth?: number;
  121447. faceUV?: Vector4[];
  121448. faceColors?: Color4[];
  121449. sideOrientation?: number;
  121450. frontUVs?: Vector4;
  121451. backUVs?: Vector4;
  121452. updatable?: boolean;
  121453. }, scene?: Nullable<Scene>): Mesh;
  121454. /**
  121455. * Creates a tiled box mesh
  121456. * * faceTiles sets the pattern, tile size and number of tiles for a face
  121457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121458. * @param name defines the name of the mesh
  121459. * @param options defines the options used to create the mesh
  121460. * @param scene defines the hosting scene
  121461. * @returns the tiled box mesh
  121462. */
  121463. static CreateTiledBox(name: string, options: {
  121464. pattern?: number;
  121465. size?: number;
  121466. width?: number;
  121467. height?: number;
  121468. depth: number;
  121469. tileSize?: number;
  121470. tileWidth?: number;
  121471. tileHeight?: number;
  121472. faceUV?: Vector4[];
  121473. faceColors?: Color4[];
  121474. alignHorizontal?: number;
  121475. alignVertical?: number;
  121476. sideOrientation?: number;
  121477. updatable?: boolean;
  121478. }, scene?: Nullable<Scene>): Mesh;
  121479. /**
  121480. * Creates a sphere mesh
  121481. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  121482. * * 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`)
  121483. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  121484. * * 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
  121485. * * 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)
  121486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121489. * @param name defines the name of the mesh
  121490. * @param options defines the options used to create the mesh
  121491. * @param scene defines the hosting scene
  121492. * @returns the sphere mesh
  121493. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  121494. */
  121495. static CreateSphere(name: string, options: {
  121496. segments?: number;
  121497. diameter?: number;
  121498. diameterX?: number;
  121499. diameterY?: number;
  121500. diameterZ?: number;
  121501. arc?: number;
  121502. slice?: number;
  121503. sideOrientation?: number;
  121504. frontUVs?: Vector4;
  121505. backUVs?: Vector4;
  121506. updatable?: boolean;
  121507. }, scene?: Nullable<Scene>): Mesh;
  121508. /**
  121509. * Creates a plane polygonal mesh. By default, this is a disc
  121510. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  121511. * * 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
  121512. * * 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
  121513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121516. * @param name defines the name of the mesh
  121517. * @param options defines the options used to create the mesh
  121518. * @param scene defines the hosting scene
  121519. * @returns the plane polygonal mesh
  121520. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  121521. */
  121522. static CreateDisc(name: string, options: {
  121523. radius?: number;
  121524. tessellation?: number;
  121525. arc?: number;
  121526. updatable?: boolean;
  121527. sideOrientation?: number;
  121528. frontUVs?: Vector4;
  121529. backUVs?: Vector4;
  121530. }, scene?: Nullable<Scene>): Mesh;
  121531. /**
  121532. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121533. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121534. * * 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`)
  121535. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121536. * * 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
  121537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121540. * @param name defines the name of the mesh
  121541. * @param options defines the options used to create the mesh
  121542. * @param scene defines the hosting scene
  121543. * @returns the icosahedron mesh
  121544. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121545. */
  121546. static CreateIcoSphere(name: string, options: {
  121547. radius?: number;
  121548. radiusX?: number;
  121549. radiusY?: number;
  121550. radiusZ?: number;
  121551. flat?: boolean;
  121552. subdivisions?: number;
  121553. sideOrientation?: number;
  121554. frontUVs?: Vector4;
  121555. backUVs?: Vector4;
  121556. updatable?: boolean;
  121557. }, scene?: Nullable<Scene>): Mesh;
  121558. /**
  121559. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121560. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121561. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121562. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121563. * * 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
  121564. * * 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
  121565. * * 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
  121566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121568. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121569. * * 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
  121570. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121571. * * 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
  121572. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121574. * @param name defines the name of the mesh
  121575. * @param options defines the options used to create the mesh
  121576. * @param scene defines the hosting scene
  121577. * @returns the ribbon mesh
  121578. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121579. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121580. */
  121581. static CreateRibbon(name: string, options: {
  121582. pathArray: Vector3[][];
  121583. closeArray?: boolean;
  121584. closePath?: boolean;
  121585. offset?: number;
  121586. updatable?: boolean;
  121587. sideOrientation?: number;
  121588. frontUVs?: Vector4;
  121589. backUVs?: Vector4;
  121590. instance?: Mesh;
  121591. invertUV?: boolean;
  121592. uvs?: Vector2[];
  121593. colors?: Color4[];
  121594. }, scene?: Nullable<Scene>): Mesh;
  121595. /**
  121596. * Creates a cylinder or a cone mesh
  121597. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  121598. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  121599. * * 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.
  121600. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  121601. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  121602. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  121603. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  121604. * * 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).
  121605. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  121606. * * 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).
  121607. * * 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
  121608. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  121609. * * 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
  121610. * * 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.
  121611. * * If `enclose` is false, a ring surface is one element.
  121612. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  121613. * * 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
  121614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121615. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121617. * @param name defines the name of the mesh
  121618. * @param options defines the options used to create the mesh
  121619. * @param scene defines the hosting scene
  121620. * @returns the cylinder mesh
  121621. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  121622. */
  121623. static CreateCylinder(name: string, options: {
  121624. height?: number;
  121625. diameterTop?: number;
  121626. diameterBottom?: number;
  121627. diameter?: number;
  121628. tessellation?: number;
  121629. subdivisions?: number;
  121630. arc?: number;
  121631. faceColors?: Color4[];
  121632. faceUV?: Vector4[];
  121633. updatable?: boolean;
  121634. hasRings?: boolean;
  121635. enclose?: boolean;
  121636. cap?: number;
  121637. sideOrientation?: number;
  121638. frontUVs?: Vector4;
  121639. backUVs?: Vector4;
  121640. }, scene?: Nullable<Scene>): Mesh;
  121641. /**
  121642. * Creates a torus mesh
  121643. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  121644. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  121645. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  121646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121649. * @param name defines the name of the mesh
  121650. * @param options defines the options used to create the mesh
  121651. * @param scene defines the hosting scene
  121652. * @returns the torus mesh
  121653. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  121654. */
  121655. static CreateTorus(name: string, options: {
  121656. diameter?: number;
  121657. thickness?: number;
  121658. tessellation?: number;
  121659. updatable?: boolean;
  121660. sideOrientation?: number;
  121661. frontUVs?: Vector4;
  121662. backUVs?: Vector4;
  121663. }, scene?: Nullable<Scene>): Mesh;
  121664. /**
  121665. * Creates a torus knot mesh
  121666. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121667. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121668. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121669. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121673. * @param name defines the name of the mesh
  121674. * @param options defines the options used to create the mesh
  121675. * @param scene defines the hosting scene
  121676. * @returns the torus knot mesh
  121677. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121678. */
  121679. static CreateTorusKnot(name: string, options: {
  121680. radius?: number;
  121681. tube?: number;
  121682. radialSegments?: number;
  121683. tubularSegments?: number;
  121684. p?: number;
  121685. q?: number;
  121686. updatable?: boolean;
  121687. sideOrientation?: number;
  121688. frontUVs?: Vector4;
  121689. backUVs?: Vector4;
  121690. }, scene?: Nullable<Scene>): Mesh;
  121691. /**
  121692. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121693. * * 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
  121694. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121695. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121696. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121697. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121698. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121699. * * 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
  121700. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121702. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121703. * @param name defines the name of the new line system
  121704. * @param options defines the options used to create the line system
  121705. * @param scene defines the hosting scene
  121706. * @returns a new line system mesh
  121707. */
  121708. static CreateLineSystem(name: string, options: {
  121709. lines: Vector3[][];
  121710. updatable?: boolean;
  121711. instance?: Nullable<LinesMesh>;
  121712. colors?: Nullable<Color4[][]>;
  121713. useVertexAlpha?: boolean;
  121714. }, scene: Nullable<Scene>): LinesMesh;
  121715. /**
  121716. * Creates a line mesh
  121717. * 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
  121718. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121719. * * The parameter `points` is an array successive Vector3
  121720. * * 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
  121721. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121722. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121723. * * When updating an instance, remember that only point positions can change, not the number of points
  121724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121726. * @param name defines the name of the new line system
  121727. * @param options defines the options used to create the line system
  121728. * @param scene defines the hosting scene
  121729. * @returns a new line mesh
  121730. */
  121731. static CreateLines(name: string, options: {
  121732. points: Vector3[];
  121733. updatable?: boolean;
  121734. instance?: Nullable<LinesMesh>;
  121735. colors?: Color4[];
  121736. useVertexAlpha?: boolean;
  121737. }, scene?: Nullable<Scene>): LinesMesh;
  121738. /**
  121739. * Creates a dashed line mesh
  121740. * * 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
  121741. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121742. * * The parameter `points` is an array successive Vector3
  121743. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121744. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121745. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121746. * * 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
  121747. * * When updating an instance, remember that only point positions can change, not the number of points
  121748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121749. * @param name defines the name of the mesh
  121750. * @param options defines the options used to create the mesh
  121751. * @param scene defines the hosting scene
  121752. * @returns the dashed line mesh
  121753. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121754. */
  121755. static CreateDashedLines(name: string, options: {
  121756. points: Vector3[];
  121757. dashSize?: number;
  121758. gapSize?: number;
  121759. dashNb?: number;
  121760. updatable?: boolean;
  121761. instance?: LinesMesh;
  121762. }, scene?: Nullable<Scene>): LinesMesh;
  121763. /**
  121764. * 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.
  121765. * * 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.
  121766. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121767. * * 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.
  121768. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121769. * * 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
  121770. * * 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
  121771. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121773. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121774. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121776. * @param name defines the name of the mesh
  121777. * @param options defines the options used to create the mesh
  121778. * @param scene defines the hosting scene
  121779. * @returns the extruded shape mesh
  121780. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121781. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121782. */
  121783. static ExtrudeShape(name: string, options: {
  121784. shape: Vector3[];
  121785. path: Vector3[];
  121786. scale?: number;
  121787. rotation?: number;
  121788. cap?: number;
  121789. updatable?: boolean;
  121790. sideOrientation?: number;
  121791. frontUVs?: Vector4;
  121792. backUVs?: Vector4;
  121793. instance?: Mesh;
  121794. invertUV?: boolean;
  121795. }, scene?: Nullable<Scene>): Mesh;
  121796. /**
  121797. * Creates an custom extruded shape mesh.
  121798. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121799. * * 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.
  121800. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121801. * * 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
  121802. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121803. * * 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
  121804. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121805. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121806. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121807. * * 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
  121808. * * 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
  121809. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121812. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121814. * @param name defines the name of the mesh
  121815. * @param options defines the options used to create the mesh
  121816. * @param scene defines the hosting scene
  121817. * @returns the custom extruded shape mesh
  121818. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121819. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121821. */
  121822. static ExtrudeShapeCustom(name: string, options: {
  121823. shape: Vector3[];
  121824. path: Vector3[];
  121825. scaleFunction?: any;
  121826. rotationFunction?: any;
  121827. ribbonCloseArray?: boolean;
  121828. ribbonClosePath?: boolean;
  121829. cap?: number;
  121830. updatable?: boolean;
  121831. sideOrientation?: number;
  121832. frontUVs?: Vector4;
  121833. backUVs?: Vector4;
  121834. instance?: Mesh;
  121835. invertUV?: boolean;
  121836. }, scene?: Nullable<Scene>): Mesh;
  121837. /**
  121838. * Creates lathe mesh.
  121839. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121840. * * 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
  121841. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121842. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121843. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121844. * * 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
  121845. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121846. * * 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
  121847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121848. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121849. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121851. * @param name defines the name of the mesh
  121852. * @param options defines the options used to create the mesh
  121853. * @param scene defines the hosting scene
  121854. * @returns the lathe mesh
  121855. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121856. */
  121857. static CreateLathe(name: string, options: {
  121858. shape: Vector3[];
  121859. radius?: number;
  121860. tessellation?: number;
  121861. clip?: number;
  121862. arc?: number;
  121863. closed?: boolean;
  121864. updatable?: boolean;
  121865. sideOrientation?: number;
  121866. frontUVs?: Vector4;
  121867. backUVs?: Vector4;
  121868. cap?: number;
  121869. invertUV?: boolean;
  121870. }, scene?: Nullable<Scene>): Mesh;
  121871. /**
  121872. * Creates a tiled plane mesh
  121873. * * You can set a limited pattern arrangement with the tiles
  121874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121877. * @param name defines the name of the mesh
  121878. * @param options defines the options used to create the mesh
  121879. * @param scene defines the hosting scene
  121880. * @returns the plane mesh
  121881. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121882. */
  121883. static CreateTiledPlane(name: string, options: {
  121884. pattern?: number;
  121885. tileSize?: number;
  121886. tileWidth?: number;
  121887. tileHeight?: number;
  121888. size?: number;
  121889. width?: number;
  121890. height?: number;
  121891. alignHorizontal?: number;
  121892. alignVertical?: number;
  121893. sideOrientation?: number;
  121894. frontUVs?: Vector4;
  121895. backUVs?: Vector4;
  121896. updatable?: boolean;
  121897. }, scene?: Nullable<Scene>): Mesh;
  121898. /**
  121899. * Creates a plane mesh
  121900. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  121901. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  121902. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  121903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121904. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121906. * @param name defines the name of the mesh
  121907. * @param options defines the options used to create the mesh
  121908. * @param scene defines the hosting scene
  121909. * @returns the plane mesh
  121910. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121911. */
  121912. static CreatePlane(name: string, options: {
  121913. size?: number;
  121914. width?: number;
  121915. height?: number;
  121916. sideOrientation?: number;
  121917. frontUVs?: Vector4;
  121918. backUVs?: Vector4;
  121919. updatable?: boolean;
  121920. sourcePlane?: Plane;
  121921. }, scene?: Nullable<Scene>): Mesh;
  121922. /**
  121923. * Creates a ground mesh
  121924. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  121925. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  121926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121927. * @param name defines the name of the mesh
  121928. * @param options defines the options used to create the mesh
  121929. * @param scene defines the hosting scene
  121930. * @returns the ground mesh
  121931. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  121932. */
  121933. static CreateGround(name: string, options: {
  121934. width?: number;
  121935. height?: number;
  121936. subdivisions?: number;
  121937. subdivisionsX?: number;
  121938. subdivisionsY?: number;
  121939. updatable?: boolean;
  121940. }, scene?: Nullable<Scene>): Mesh;
  121941. /**
  121942. * Creates a tiled ground mesh
  121943. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  121944. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  121945. * * 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
  121946. * * 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
  121947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121948. * @param name defines the name of the mesh
  121949. * @param options defines the options used to create the mesh
  121950. * @param scene defines the hosting scene
  121951. * @returns the tiled ground mesh
  121952. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  121953. */
  121954. static CreateTiledGround(name: string, options: {
  121955. xmin: number;
  121956. zmin: number;
  121957. xmax: number;
  121958. zmax: number;
  121959. subdivisions?: {
  121960. w: number;
  121961. h: number;
  121962. };
  121963. precision?: {
  121964. w: number;
  121965. h: number;
  121966. };
  121967. updatable?: boolean;
  121968. }, scene?: Nullable<Scene>): Mesh;
  121969. /**
  121970. * Creates a ground mesh from a height map
  121971. * * The parameter `url` sets the URL of the height map image resource.
  121972. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  121973. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  121974. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  121975. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  121976. * * 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.
  121977. * * 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).
  121978. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  121979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121980. * @param name defines the name of the mesh
  121981. * @param url defines the url to the height map
  121982. * @param options defines the options used to create the mesh
  121983. * @param scene defines the hosting scene
  121984. * @returns the ground mesh
  121985. * @see https://doc.babylonjs.com/babylon101/height_map
  121986. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  121987. */
  121988. static CreateGroundFromHeightMap(name: string, url: string, options: {
  121989. width?: number;
  121990. height?: number;
  121991. subdivisions?: number;
  121992. minHeight?: number;
  121993. maxHeight?: number;
  121994. colorFilter?: Color3;
  121995. alphaFilter?: number;
  121996. updatable?: boolean;
  121997. onReady?: (mesh: GroundMesh) => void;
  121998. }, scene?: Nullable<Scene>): GroundMesh;
  121999. /**
  122000. * Creates a polygon mesh
  122001. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122002. * * 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
  122003. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122006. * * Remember you can only change the shape positions, not their number when updating a polygon
  122007. * @param name defines the name of the mesh
  122008. * @param options defines the options used to create the mesh
  122009. * @param scene defines the hosting scene
  122010. * @param earcutInjection can be used to inject your own earcut reference
  122011. * @returns the polygon mesh
  122012. */
  122013. static CreatePolygon(name: string, options: {
  122014. shape: Vector3[];
  122015. holes?: Vector3[][];
  122016. depth?: number;
  122017. faceUV?: Vector4[];
  122018. faceColors?: Color4[];
  122019. updatable?: boolean;
  122020. sideOrientation?: number;
  122021. frontUVs?: Vector4;
  122022. backUVs?: Vector4;
  122023. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122024. /**
  122025. * Creates an extruded polygon mesh, with depth in the Y direction.
  122026. * * 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)
  122027. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122028. * @param name defines the name of the mesh
  122029. * @param options defines the options used to create the mesh
  122030. * @param scene defines the hosting scene
  122031. * @param earcutInjection can be used to inject your own earcut reference
  122032. * @returns the polygon mesh
  122033. */
  122034. static ExtrudePolygon(name: string, options: {
  122035. shape: Vector3[];
  122036. holes?: Vector3[][];
  122037. depth?: number;
  122038. faceUV?: Vector4[];
  122039. faceColors?: Color4[];
  122040. updatable?: boolean;
  122041. sideOrientation?: number;
  122042. frontUVs?: Vector4;
  122043. backUVs?: Vector4;
  122044. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122045. /**
  122046. * Creates a tube mesh.
  122047. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122048. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  122049. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  122050. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  122051. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  122052. * * 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)
  122053. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  122054. * * 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
  122055. * * 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
  122056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122058. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122060. * @param name defines the name of the mesh
  122061. * @param options defines the options used to create the mesh
  122062. * @param scene defines the hosting scene
  122063. * @returns the tube mesh
  122064. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122065. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  122066. */
  122067. static CreateTube(name: string, options: {
  122068. path: Vector3[];
  122069. radius?: number;
  122070. tessellation?: number;
  122071. radiusFunction?: {
  122072. (i: number, distance: number): number;
  122073. };
  122074. cap?: number;
  122075. arc?: number;
  122076. updatable?: boolean;
  122077. sideOrientation?: number;
  122078. frontUVs?: Vector4;
  122079. backUVs?: Vector4;
  122080. instance?: Mesh;
  122081. invertUV?: boolean;
  122082. }, scene?: Nullable<Scene>): Mesh;
  122083. /**
  122084. * Creates a polyhedron mesh
  122085. * * 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
  122086. * * The parameter `size` (positive float, default 1) sets the polygon size
  122087. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  122088. * * 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`
  122089. * * 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
  122090. * * 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)`)
  122091. * * 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
  122092. * * 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
  122093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122096. * @param name defines the name of the mesh
  122097. * @param options defines the options used to create the mesh
  122098. * @param scene defines the hosting scene
  122099. * @returns the polyhedron mesh
  122100. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  122101. */
  122102. static CreatePolyhedron(name: string, options: {
  122103. type?: number;
  122104. size?: number;
  122105. sizeX?: number;
  122106. sizeY?: number;
  122107. sizeZ?: number;
  122108. custom?: any;
  122109. faceUV?: Vector4[];
  122110. faceColors?: Color4[];
  122111. flat?: boolean;
  122112. updatable?: boolean;
  122113. sideOrientation?: number;
  122114. frontUVs?: Vector4;
  122115. backUVs?: Vector4;
  122116. }, scene?: Nullable<Scene>): Mesh;
  122117. /**
  122118. * Creates a decal mesh.
  122119. * 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
  122120. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  122121. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  122122. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  122123. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  122124. * @param name defines the name of the mesh
  122125. * @param sourceMesh defines the mesh where the decal must be applied
  122126. * @param options defines the options used to create the mesh
  122127. * @param scene defines the hosting scene
  122128. * @returns the decal mesh
  122129. * @see https://doc.babylonjs.com/how_to/decals
  122130. */
  122131. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  122132. position?: Vector3;
  122133. normal?: Vector3;
  122134. size?: Vector3;
  122135. angle?: number;
  122136. }): Mesh;
  122137. }
  122138. }
  122139. declare module BABYLON {
  122140. /**
  122141. * A simplifier interface for future simplification implementations
  122142. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122143. */
  122144. export interface ISimplifier {
  122145. /**
  122146. * Simplification of a given mesh according to the given settings.
  122147. * Since this requires computation, it is assumed that the function runs async.
  122148. * @param settings The settings of the simplification, including quality and distance
  122149. * @param successCallback A callback that will be called after the mesh was simplified.
  122150. * @param errorCallback in case of an error, this callback will be called. optional.
  122151. */
  122152. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  122153. }
  122154. /**
  122155. * Expected simplification settings.
  122156. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  122157. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122158. */
  122159. export interface ISimplificationSettings {
  122160. /**
  122161. * Gets or sets the expected quality
  122162. */
  122163. quality: number;
  122164. /**
  122165. * Gets or sets the distance when this optimized version should be used
  122166. */
  122167. distance: number;
  122168. /**
  122169. * Gets an already optimized mesh
  122170. */
  122171. optimizeMesh?: boolean;
  122172. }
  122173. /**
  122174. * Class used to specify simplification options
  122175. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122176. */
  122177. export class SimplificationSettings implements ISimplificationSettings {
  122178. /** expected quality */
  122179. quality: number;
  122180. /** distance when this optimized version should be used */
  122181. distance: number;
  122182. /** already optimized mesh */
  122183. optimizeMesh?: boolean | undefined;
  122184. /**
  122185. * Creates a SimplificationSettings
  122186. * @param quality expected quality
  122187. * @param distance distance when this optimized version should be used
  122188. * @param optimizeMesh already optimized mesh
  122189. */
  122190. constructor(
  122191. /** expected quality */
  122192. quality: number,
  122193. /** distance when this optimized version should be used */
  122194. distance: number,
  122195. /** already optimized mesh */
  122196. optimizeMesh?: boolean | undefined);
  122197. }
  122198. /**
  122199. * Interface used to define a simplification task
  122200. */
  122201. export interface ISimplificationTask {
  122202. /**
  122203. * Array of settings
  122204. */
  122205. settings: Array<ISimplificationSettings>;
  122206. /**
  122207. * Simplification type
  122208. */
  122209. simplificationType: SimplificationType;
  122210. /**
  122211. * Mesh to simplify
  122212. */
  122213. mesh: Mesh;
  122214. /**
  122215. * Callback called on success
  122216. */
  122217. successCallback?: () => void;
  122218. /**
  122219. * Defines if parallel processing can be used
  122220. */
  122221. parallelProcessing: boolean;
  122222. }
  122223. /**
  122224. * Queue used to order the simplification tasks
  122225. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122226. */
  122227. export class SimplificationQueue {
  122228. private _simplificationArray;
  122229. /**
  122230. * Gets a boolean indicating that the process is still running
  122231. */
  122232. running: boolean;
  122233. /**
  122234. * Creates a new queue
  122235. */
  122236. constructor();
  122237. /**
  122238. * Adds a new simplification task
  122239. * @param task defines a task to add
  122240. */
  122241. addTask(task: ISimplificationTask): void;
  122242. /**
  122243. * Execute next task
  122244. */
  122245. executeNext(): void;
  122246. /**
  122247. * Execute a simplification task
  122248. * @param task defines the task to run
  122249. */
  122250. runSimplification(task: ISimplificationTask): void;
  122251. private getSimplifier;
  122252. }
  122253. /**
  122254. * The implemented types of simplification
  122255. * At the moment only Quadratic Error Decimation is implemented
  122256. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122257. */
  122258. export enum SimplificationType {
  122259. /** Quadratic error decimation */
  122260. QUADRATIC = 0
  122261. }
  122262. }
  122263. declare module BABYLON {
  122264. interface Scene {
  122265. /** @hidden (Backing field) */
  122266. _simplificationQueue: SimplificationQueue;
  122267. /**
  122268. * Gets or sets the simplification queue attached to the scene
  122269. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122270. */
  122271. simplificationQueue: SimplificationQueue;
  122272. }
  122273. interface Mesh {
  122274. /**
  122275. * Simplify the mesh according to the given array of settings.
  122276. * Function will return immediately and will simplify async
  122277. * @param settings a collection of simplification settings
  122278. * @param parallelProcessing should all levels calculate parallel or one after the other
  122279. * @param simplificationType the type of simplification to run
  122280. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  122281. * @returns the current mesh
  122282. */
  122283. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  122284. }
  122285. /**
  122286. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  122287. * created in a scene
  122288. */
  122289. export class SimplicationQueueSceneComponent implements ISceneComponent {
  122290. /**
  122291. * The component name helpfull to identify the component in the list of scene components.
  122292. */
  122293. readonly name: string;
  122294. /**
  122295. * The scene the component belongs to.
  122296. */
  122297. scene: Scene;
  122298. /**
  122299. * Creates a new instance of the component for the given scene
  122300. * @param scene Defines the scene to register the component in
  122301. */
  122302. constructor(scene: Scene);
  122303. /**
  122304. * Registers the component in a given scene
  122305. */
  122306. register(): void;
  122307. /**
  122308. * Rebuilds the elements related to this component in case of
  122309. * context lost for instance.
  122310. */
  122311. rebuild(): void;
  122312. /**
  122313. * Disposes the component and the associated ressources
  122314. */
  122315. dispose(): void;
  122316. private _beforeCameraUpdate;
  122317. }
  122318. }
  122319. declare module BABYLON {
  122320. /**
  122321. * Navigation plugin interface to add navigation constrained by a navigation mesh
  122322. */
  122323. export interface INavigationEnginePlugin {
  122324. /**
  122325. * plugin name
  122326. */
  122327. name: string;
  122328. /**
  122329. * Creates a navigation mesh
  122330. * @param meshes array of all the geometry used to compute the navigatio mesh
  122331. * @param parameters bunch of parameters used to filter geometry
  122332. */
  122333. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122334. /**
  122335. * Create a navigation mesh debug mesh
  122336. * @param scene is where the mesh will be added
  122337. * @returns debug display mesh
  122338. */
  122339. createDebugNavMesh(scene: Scene): Mesh;
  122340. /**
  122341. * Get a navigation mesh constrained position, closest to the parameter position
  122342. * @param position world position
  122343. * @returns the closest point to position constrained by the navigation mesh
  122344. */
  122345. getClosestPoint(position: Vector3): Vector3;
  122346. /**
  122347. * Get a navigation mesh constrained position, within a particular radius
  122348. * @param position world position
  122349. * @param maxRadius the maximum distance to the constrained world position
  122350. * @returns the closest point to position constrained by the navigation mesh
  122351. */
  122352. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122353. /**
  122354. * Compute the final position from a segment made of destination-position
  122355. * @param position world position
  122356. * @param destination world position
  122357. * @returns the resulting point along the navmesh
  122358. */
  122359. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122360. /**
  122361. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122362. * @param start world position
  122363. * @param end world position
  122364. * @returns array containing world position composing the path
  122365. */
  122366. computePath(start: Vector3, end: Vector3): Vector3[];
  122367. /**
  122368. * If this plugin is supported
  122369. * @returns true if plugin is supported
  122370. */
  122371. isSupported(): boolean;
  122372. /**
  122373. * Create a new Crowd so you can add agents
  122374. * @param maxAgents the maximum agent count in the crowd
  122375. * @param maxAgentRadius the maximum radius an agent can have
  122376. * @param scene to attach the crowd to
  122377. * @returns the crowd you can add agents to
  122378. */
  122379. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122380. /**
  122381. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122382. * The queries will try to find a solution within those bounds
  122383. * default is (1,1,1)
  122384. * @param extent x,y,z value that define the extent around the queries point of reference
  122385. */
  122386. setDefaultQueryExtent(extent: Vector3): void;
  122387. /**
  122388. * Get the Bounding box extent specified by setDefaultQueryExtent
  122389. * @returns the box extent values
  122390. */
  122391. getDefaultQueryExtent(): Vector3;
  122392. /**
  122393. * Release all resources
  122394. */
  122395. dispose(): void;
  122396. }
  122397. /**
  122398. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  122399. */
  122400. export interface ICrowd {
  122401. /**
  122402. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122403. * You can attach anything to that node. The node position is updated in the scene update tick.
  122404. * @param pos world position that will be constrained by the navigation mesh
  122405. * @param parameters agent parameters
  122406. * @param transform hooked to the agent that will be update by the scene
  122407. * @returns agent index
  122408. */
  122409. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122410. /**
  122411. * Returns the agent position in world space
  122412. * @param index agent index returned by addAgent
  122413. * @returns world space position
  122414. */
  122415. getAgentPosition(index: number): Vector3;
  122416. /**
  122417. * Gets the agent velocity in world space
  122418. * @param index agent index returned by addAgent
  122419. * @returns world space velocity
  122420. */
  122421. getAgentVelocity(index: number): Vector3;
  122422. /**
  122423. * remove a particular agent previously created
  122424. * @param index agent index returned by addAgent
  122425. */
  122426. removeAgent(index: number): void;
  122427. /**
  122428. * get the list of all agents attached to this crowd
  122429. * @returns list of agent indices
  122430. */
  122431. getAgents(): number[];
  122432. /**
  122433. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122434. * @param deltaTime in seconds
  122435. */
  122436. update(deltaTime: number): void;
  122437. /**
  122438. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122439. * @param index agent index returned by addAgent
  122440. * @param destination targeted world position
  122441. */
  122442. agentGoto(index: number, destination: Vector3): void;
  122443. /**
  122444. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122445. * The queries will try to find a solution within those bounds
  122446. * default is (1,1,1)
  122447. * @param extent x,y,z value that define the extent around the queries point of reference
  122448. */
  122449. setDefaultQueryExtent(extent: Vector3): void;
  122450. /**
  122451. * Get the Bounding box extent specified by setDefaultQueryExtent
  122452. * @returns the box extent values
  122453. */
  122454. getDefaultQueryExtent(): Vector3;
  122455. /**
  122456. * Release all resources
  122457. */
  122458. dispose(): void;
  122459. }
  122460. /**
  122461. * Configures an agent
  122462. */
  122463. export interface IAgentParameters {
  122464. /**
  122465. * Agent radius. [Limit: >= 0]
  122466. */
  122467. radius: number;
  122468. /**
  122469. * Agent height. [Limit: > 0]
  122470. */
  122471. height: number;
  122472. /**
  122473. * Maximum allowed acceleration. [Limit: >= 0]
  122474. */
  122475. maxAcceleration: number;
  122476. /**
  122477. * Maximum allowed speed. [Limit: >= 0]
  122478. */
  122479. maxSpeed: number;
  122480. /**
  122481. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  122482. */
  122483. collisionQueryRange: number;
  122484. /**
  122485. * The path visibility optimization range. [Limit: > 0]
  122486. */
  122487. pathOptimizationRange: number;
  122488. /**
  122489. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  122490. */
  122491. separationWeight: number;
  122492. }
  122493. /**
  122494. * Configures the navigation mesh creation
  122495. */
  122496. export interface INavMeshParameters {
  122497. /**
  122498. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  122499. */
  122500. cs: number;
  122501. /**
  122502. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  122503. */
  122504. ch: number;
  122505. /**
  122506. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  122507. */
  122508. walkableSlopeAngle: number;
  122509. /**
  122510. * Minimum floor to 'ceiling' height that will still allow the floor area to
  122511. * be considered walkable. [Limit: >= 3] [Units: vx]
  122512. */
  122513. walkableHeight: number;
  122514. /**
  122515. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  122516. */
  122517. walkableClimb: number;
  122518. /**
  122519. * The distance to erode/shrink the walkable area of the heightfield away from
  122520. * obstructions. [Limit: >=0] [Units: vx]
  122521. */
  122522. walkableRadius: number;
  122523. /**
  122524. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  122525. */
  122526. maxEdgeLen: number;
  122527. /**
  122528. * The maximum distance a simplfied contour's border edges should deviate
  122529. * the original raw contour. [Limit: >=0] [Units: vx]
  122530. */
  122531. maxSimplificationError: number;
  122532. /**
  122533. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  122534. */
  122535. minRegionArea: number;
  122536. /**
  122537. * Any regions with a span count smaller than this value will, if possible,
  122538. * be merged with larger regions. [Limit: >=0] [Units: vx]
  122539. */
  122540. mergeRegionArea: number;
  122541. /**
  122542. * The maximum number of vertices allowed for polygons generated during the
  122543. * contour to polygon conversion process. [Limit: >= 3]
  122544. */
  122545. maxVertsPerPoly: number;
  122546. /**
  122547. * Sets the sampling distance to use when generating the detail mesh.
  122548. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  122549. */
  122550. detailSampleDist: number;
  122551. /**
  122552. * The maximum distance the detail mesh surface should deviate from heightfield
  122553. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  122554. */
  122555. detailSampleMaxError: number;
  122556. }
  122557. }
  122558. declare module BABYLON {
  122559. /**
  122560. * RecastJS navigation plugin
  122561. */
  122562. export class RecastJSPlugin implements INavigationEnginePlugin {
  122563. /**
  122564. * Reference to the Recast library
  122565. */
  122566. bjsRECAST: any;
  122567. /**
  122568. * plugin name
  122569. */
  122570. name: string;
  122571. /**
  122572. * the first navmesh created. We might extend this to support multiple navmeshes
  122573. */
  122574. navMesh: any;
  122575. /**
  122576. * Initializes the recastJS plugin
  122577. * @param recastInjection can be used to inject your own recast reference
  122578. */
  122579. constructor(recastInjection?: any);
  122580. /**
  122581. * Creates a navigation mesh
  122582. * @param meshes array of all the geometry used to compute the navigatio mesh
  122583. * @param parameters bunch of parameters used to filter geometry
  122584. */
  122585. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122586. /**
  122587. * Create a navigation mesh debug mesh
  122588. * @param scene is where the mesh will be added
  122589. * @returns debug display mesh
  122590. */
  122591. createDebugNavMesh(scene: Scene): Mesh;
  122592. /**
  122593. * Get a navigation mesh constrained position, closest to the parameter position
  122594. * @param position world position
  122595. * @returns the closest point to position constrained by the navigation mesh
  122596. */
  122597. getClosestPoint(position: Vector3): Vector3;
  122598. /**
  122599. * Get a navigation mesh constrained position, within a particular radius
  122600. * @param position world position
  122601. * @param maxRadius the maximum distance to the constrained world position
  122602. * @returns the closest point to position constrained by the navigation mesh
  122603. */
  122604. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122605. /**
  122606. * Compute the final position from a segment made of destination-position
  122607. * @param position world position
  122608. * @param destination world position
  122609. * @returns the resulting point along the navmesh
  122610. */
  122611. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122612. /**
  122613. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122614. * @param start world position
  122615. * @param end world position
  122616. * @returns array containing world position composing the path
  122617. */
  122618. computePath(start: Vector3, end: Vector3): Vector3[];
  122619. /**
  122620. * Create a new Crowd so you can add agents
  122621. * @param maxAgents the maximum agent count in the crowd
  122622. * @param maxAgentRadius the maximum radius an agent can have
  122623. * @param scene to attach the crowd to
  122624. * @returns the crowd you can add agents to
  122625. */
  122626. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122627. /**
  122628. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122629. * The queries will try to find a solution within those bounds
  122630. * default is (1,1,1)
  122631. * @param extent x,y,z value that define the extent around the queries point of reference
  122632. */
  122633. setDefaultQueryExtent(extent: Vector3): void;
  122634. /**
  122635. * Get the Bounding box extent specified by setDefaultQueryExtent
  122636. * @returns the box extent values
  122637. */
  122638. getDefaultQueryExtent(): Vector3;
  122639. /**
  122640. * Disposes
  122641. */
  122642. dispose(): void;
  122643. /**
  122644. * If this plugin is supported
  122645. * @returns true if plugin is supported
  122646. */
  122647. isSupported(): boolean;
  122648. }
  122649. /**
  122650. * Recast detour crowd implementation
  122651. */
  122652. export class RecastJSCrowd implements ICrowd {
  122653. /**
  122654. * Recast/detour plugin
  122655. */
  122656. bjsRECASTPlugin: RecastJSPlugin;
  122657. /**
  122658. * Link to the detour crowd
  122659. */
  122660. recastCrowd: any;
  122661. /**
  122662. * One transform per agent
  122663. */
  122664. transforms: TransformNode[];
  122665. /**
  122666. * All agents created
  122667. */
  122668. agents: number[];
  122669. /**
  122670. * Link to the scene is kept to unregister the crowd from the scene
  122671. */
  122672. private _scene;
  122673. /**
  122674. * Observer for crowd updates
  122675. */
  122676. private _onBeforeAnimationsObserver;
  122677. /**
  122678. * Constructor
  122679. * @param plugin recastJS plugin
  122680. * @param maxAgents the maximum agent count in the crowd
  122681. * @param maxAgentRadius the maximum radius an agent can have
  122682. * @param scene to attach the crowd to
  122683. * @returns the crowd you can add agents to
  122684. */
  122685. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  122686. /**
  122687. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122688. * You can attach anything to that node. The node position is updated in the scene update tick.
  122689. * @param pos world position that will be constrained by the navigation mesh
  122690. * @param parameters agent parameters
  122691. * @param transform hooked to the agent that will be update by the scene
  122692. * @returns agent index
  122693. */
  122694. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122695. /**
  122696. * Returns the agent position in world space
  122697. * @param index agent index returned by addAgent
  122698. * @returns world space position
  122699. */
  122700. getAgentPosition(index: number): Vector3;
  122701. /**
  122702. * Returns the agent velocity in world space
  122703. * @param index agent index returned by addAgent
  122704. * @returns world space velocity
  122705. */
  122706. getAgentVelocity(index: number): Vector3;
  122707. /**
  122708. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122709. * @param index agent index returned by addAgent
  122710. * @param destination targeted world position
  122711. */
  122712. agentGoto(index: number, destination: Vector3): void;
  122713. /**
  122714. * remove a particular agent previously created
  122715. * @param index agent index returned by addAgent
  122716. */
  122717. removeAgent(index: number): void;
  122718. /**
  122719. * get the list of all agents attached to this crowd
  122720. * @returns list of agent indices
  122721. */
  122722. getAgents(): number[];
  122723. /**
  122724. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122725. * @param deltaTime in seconds
  122726. */
  122727. update(deltaTime: number): void;
  122728. /**
  122729. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122730. * The queries will try to find a solution within those bounds
  122731. * default is (1,1,1)
  122732. * @param extent x,y,z value that define the extent around the queries point of reference
  122733. */
  122734. setDefaultQueryExtent(extent: Vector3): void;
  122735. /**
  122736. * Get the Bounding box extent specified by setDefaultQueryExtent
  122737. * @returns the box extent values
  122738. */
  122739. getDefaultQueryExtent(): Vector3;
  122740. /**
  122741. * Release all resources
  122742. */
  122743. dispose(): void;
  122744. }
  122745. }
  122746. declare module BABYLON {
  122747. /**
  122748. * Class used to enable access to IndexedDB
  122749. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  122750. */
  122751. export class Database implements IOfflineProvider {
  122752. private _callbackManifestChecked;
  122753. private _currentSceneUrl;
  122754. private _db;
  122755. private _enableSceneOffline;
  122756. private _enableTexturesOffline;
  122757. private _manifestVersionFound;
  122758. private _mustUpdateRessources;
  122759. private _hasReachedQuota;
  122760. private _isSupported;
  122761. private _idbFactory;
  122762. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  122763. private static IsUASupportingBlobStorage;
  122764. /**
  122765. * Gets a boolean indicating if Database storate is enabled (off by default)
  122766. */
  122767. static IDBStorageEnabled: boolean;
  122768. /**
  122769. * Gets a boolean indicating if scene must be saved in the database
  122770. */
  122771. readonly enableSceneOffline: boolean;
  122772. /**
  122773. * Gets a boolean indicating if textures must be saved in the database
  122774. */
  122775. readonly enableTexturesOffline: boolean;
  122776. /**
  122777. * Creates a new Database
  122778. * @param urlToScene defines the url to load the scene
  122779. * @param callbackManifestChecked defines the callback to use when manifest is checked
  122780. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  122781. */
  122782. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  122783. private static _ParseURL;
  122784. private static _ReturnFullUrlLocation;
  122785. private _checkManifestFile;
  122786. /**
  122787. * Open the database and make it available
  122788. * @param successCallback defines the callback to call on success
  122789. * @param errorCallback defines the callback to call on error
  122790. */
  122791. open(successCallback: () => void, errorCallback: () => void): void;
  122792. /**
  122793. * Loads an image from the database
  122794. * @param url defines the url to load from
  122795. * @param image defines the target DOM image
  122796. */
  122797. loadImage(url: string, image: HTMLImageElement): void;
  122798. private _loadImageFromDBAsync;
  122799. private _saveImageIntoDBAsync;
  122800. private _checkVersionFromDB;
  122801. private _loadVersionFromDBAsync;
  122802. private _saveVersionIntoDBAsync;
  122803. /**
  122804. * Loads a file from database
  122805. * @param url defines the URL to load from
  122806. * @param sceneLoaded defines a callback to call on success
  122807. * @param progressCallBack defines a callback to call when progress changed
  122808. * @param errorCallback defines a callback to call on error
  122809. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  122810. */
  122811. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  122812. private _loadFileAsync;
  122813. private _saveFileAsync;
  122814. /**
  122815. * Validates if xhr data is correct
  122816. * @param xhr defines the request to validate
  122817. * @param dataType defines the expected data type
  122818. * @returns true if data is correct
  122819. */
  122820. private static _ValidateXHRData;
  122821. }
  122822. }
  122823. declare module BABYLON {
  122824. /** @hidden */
  122825. export var gpuUpdateParticlesPixelShader: {
  122826. name: string;
  122827. shader: string;
  122828. };
  122829. }
  122830. declare module BABYLON {
  122831. /** @hidden */
  122832. export var gpuUpdateParticlesVertexShader: {
  122833. name: string;
  122834. shader: string;
  122835. };
  122836. }
  122837. declare module BABYLON {
  122838. /** @hidden */
  122839. export var clipPlaneFragmentDeclaration2: {
  122840. name: string;
  122841. shader: string;
  122842. };
  122843. }
  122844. declare module BABYLON {
  122845. /** @hidden */
  122846. export var gpuRenderParticlesPixelShader: {
  122847. name: string;
  122848. shader: string;
  122849. };
  122850. }
  122851. declare module BABYLON {
  122852. /** @hidden */
  122853. export var clipPlaneVertexDeclaration2: {
  122854. name: string;
  122855. shader: string;
  122856. };
  122857. }
  122858. declare module BABYLON {
  122859. /** @hidden */
  122860. export var gpuRenderParticlesVertexShader: {
  122861. name: string;
  122862. shader: string;
  122863. };
  122864. }
  122865. declare module BABYLON {
  122866. /**
  122867. * This represents a GPU particle system in Babylon
  122868. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  122869. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  122870. */
  122871. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  122872. /**
  122873. * The layer mask we are rendering the particles through.
  122874. */
  122875. layerMask: number;
  122876. private _capacity;
  122877. private _activeCount;
  122878. private _currentActiveCount;
  122879. private _accumulatedCount;
  122880. private _renderEffect;
  122881. private _updateEffect;
  122882. private _buffer0;
  122883. private _buffer1;
  122884. private _spriteBuffer;
  122885. private _updateVAO;
  122886. private _renderVAO;
  122887. private _targetIndex;
  122888. private _sourceBuffer;
  122889. private _targetBuffer;
  122890. private _engine;
  122891. private _currentRenderId;
  122892. private _started;
  122893. private _stopped;
  122894. private _timeDelta;
  122895. private _randomTexture;
  122896. private _randomTexture2;
  122897. private _attributesStrideSize;
  122898. private _updateEffectOptions;
  122899. private _randomTextureSize;
  122900. private _actualFrame;
  122901. private readonly _rawTextureWidth;
  122902. /**
  122903. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  122904. */
  122905. static readonly IsSupported: boolean;
  122906. /**
  122907. * An event triggered when the system is disposed.
  122908. */
  122909. onDisposeObservable: Observable<GPUParticleSystem>;
  122910. /**
  122911. * Gets the maximum number of particles active at the same time.
  122912. * @returns The max number of active particles.
  122913. */
  122914. getCapacity(): number;
  122915. /**
  122916. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  122917. * to override the particles.
  122918. */
  122919. forceDepthWrite: boolean;
  122920. /**
  122921. * Gets or set the number of active particles
  122922. */
  122923. activeParticleCount: number;
  122924. private _preWarmDone;
  122925. /**
  122926. * Is this system ready to be used/rendered
  122927. * @return true if the system is ready
  122928. */
  122929. isReady(): boolean;
  122930. /**
  122931. * Gets if the system has been started. (Note: this will still be true after stop is called)
  122932. * @returns True if it has been started, otherwise false.
  122933. */
  122934. isStarted(): boolean;
  122935. /**
  122936. * Starts the particle system and begins to emit
  122937. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  122938. */
  122939. start(delay?: number): void;
  122940. /**
  122941. * Stops the particle system.
  122942. */
  122943. stop(): void;
  122944. /**
  122945. * Remove all active particles
  122946. */
  122947. reset(): void;
  122948. /**
  122949. * Returns the string "GPUParticleSystem"
  122950. * @returns a string containing the class name
  122951. */
  122952. getClassName(): string;
  122953. private _colorGradientsTexture;
  122954. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  122955. /**
  122956. * Adds a new color gradient
  122957. * @param gradient defines the gradient to use (between 0 and 1)
  122958. * @param color1 defines the color to affect to the specified gradient
  122959. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  122960. * @returns the current particle system
  122961. */
  122962. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  122963. /**
  122964. * Remove a specific color gradient
  122965. * @param gradient defines the gradient to remove
  122966. * @returns the current particle system
  122967. */
  122968. removeColorGradient(gradient: number): GPUParticleSystem;
  122969. private _angularSpeedGradientsTexture;
  122970. private _sizeGradientsTexture;
  122971. private _velocityGradientsTexture;
  122972. private _limitVelocityGradientsTexture;
  122973. private _dragGradientsTexture;
  122974. private _addFactorGradient;
  122975. /**
  122976. * Adds a new size gradient
  122977. * @param gradient defines the gradient to use (between 0 and 1)
  122978. * @param factor defines the size factor to affect to the specified gradient
  122979. * @returns the current particle system
  122980. */
  122981. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  122982. /**
  122983. * Remove a specific size gradient
  122984. * @param gradient defines the gradient to remove
  122985. * @returns the current particle system
  122986. */
  122987. removeSizeGradient(gradient: number): GPUParticleSystem;
  122988. /**
  122989. * Adds a new angular speed gradient
  122990. * @param gradient defines the gradient to use (between 0 and 1)
  122991. * @param factor defines the angular speed to affect to the specified gradient
  122992. * @returns the current particle system
  122993. */
  122994. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  122995. /**
  122996. * Remove a specific angular speed gradient
  122997. * @param gradient defines the gradient to remove
  122998. * @returns the current particle system
  122999. */
  123000. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  123001. /**
  123002. * Adds a new velocity gradient
  123003. * @param gradient defines the gradient to use (between 0 and 1)
  123004. * @param factor defines the velocity to affect to the specified gradient
  123005. * @returns the current particle system
  123006. */
  123007. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  123008. /**
  123009. * Remove a specific velocity gradient
  123010. * @param gradient defines the gradient to remove
  123011. * @returns the current particle system
  123012. */
  123013. removeVelocityGradient(gradient: number): GPUParticleSystem;
  123014. /**
  123015. * Adds a new limit velocity gradient
  123016. * @param gradient defines the gradient to use (between 0 and 1)
  123017. * @param factor defines the limit velocity value to affect to the specified gradient
  123018. * @returns the current particle system
  123019. */
  123020. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  123021. /**
  123022. * Remove a specific limit velocity gradient
  123023. * @param gradient defines the gradient to remove
  123024. * @returns the current particle system
  123025. */
  123026. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  123027. /**
  123028. * Adds a new drag gradient
  123029. * @param gradient defines the gradient to use (between 0 and 1)
  123030. * @param factor defines the drag value to affect to the specified gradient
  123031. * @returns the current particle system
  123032. */
  123033. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  123034. /**
  123035. * Remove a specific drag gradient
  123036. * @param gradient defines the gradient to remove
  123037. * @returns the current particle system
  123038. */
  123039. removeDragGradient(gradient: number): GPUParticleSystem;
  123040. /**
  123041. * Not supported by GPUParticleSystem
  123042. * @param gradient defines the gradient to use (between 0 and 1)
  123043. * @param factor defines the emit rate value to affect to the specified gradient
  123044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123045. * @returns the current particle system
  123046. */
  123047. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123048. /**
  123049. * Not supported by GPUParticleSystem
  123050. * @param gradient defines the gradient to remove
  123051. * @returns the current particle system
  123052. */
  123053. removeEmitRateGradient(gradient: number): IParticleSystem;
  123054. /**
  123055. * Not supported by GPUParticleSystem
  123056. * @param gradient defines the gradient to use (between 0 and 1)
  123057. * @param factor defines the start size value to affect to the specified gradient
  123058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123059. * @returns the current particle system
  123060. */
  123061. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123062. /**
  123063. * Not supported by GPUParticleSystem
  123064. * @param gradient defines the gradient to remove
  123065. * @returns the current particle system
  123066. */
  123067. removeStartSizeGradient(gradient: number): IParticleSystem;
  123068. /**
  123069. * Not supported by GPUParticleSystem
  123070. * @param gradient defines the gradient to use (between 0 and 1)
  123071. * @param min defines the color remap minimal range
  123072. * @param max defines the color remap maximal range
  123073. * @returns the current particle system
  123074. */
  123075. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  123076. /**
  123077. * Not supported by GPUParticleSystem
  123078. * @param gradient defines the gradient to remove
  123079. * @returns the current particle system
  123080. */
  123081. removeColorRemapGradient(): IParticleSystem;
  123082. /**
  123083. * Not supported by GPUParticleSystem
  123084. * @param gradient defines the gradient to use (between 0 and 1)
  123085. * @param min defines the alpha remap minimal range
  123086. * @param max defines the alpha remap maximal range
  123087. * @returns the current particle system
  123088. */
  123089. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  123090. /**
  123091. * Not supported by GPUParticleSystem
  123092. * @param gradient defines the gradient to remove
  123093. * @returns the current particle system
  123094. */
  123095. removeAlphaRemapGradient(): IParticleSystem;
  123096. /**
  123097. * Not supported by GPUParticleSystem
  123098. * @param gradient defines the gradient to use (between 0 and 1)
  123099. * @param color defines the color to affect to the specified gradient
  123100. * @returns the current particle system
  123101. */
  123102. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  123103. /**
  123104. * Not supported by GPUParticleSystem
  123105. * @param gradient defines the gradient to remove
  123106. * @returns the current particle system
  123107. */
  123108. removeRampGradient(): IParticleSystem;
  123109. /**
  123110. * Not supported by GPUParticleSystem
  123111. * @returns the list of ramp gradients
  123112. */
  123113. getRampGradients(): Nullable<Array<Color3Gradient>>;
  123114. /**
  123115. * Not supported by GPUParticleSystem
  123116. * Gets or sets a boolean indicating that ramp gradients must be used
  123117. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  123118. */
  123119. useRampGradients: boolean;
  123120. /**
  123121. * Not supported by GPUParticleSystem
  123122. * @param gradient defines the gradient to use (between 0 and 1)
  123123. * @param factor defines the life time factor to affect to the specified gradient
  123124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123125. * @returns the current particle system
  123126. */
  123127. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123128. /**
  123129. * Not supported by GPUParticleSystem
  123130. * @param gradient defines the gradient to remove
  123131. * @returns the current particle system
  123132. */
  123133. removeLifeTimeGradient(gradient: number): IParticleSystem;
  123134. /**
  123135. * Instantiates a GPU particle system.
  123136. * 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.
  123137. * @param name The name of the particle system
  123138. * @param options The options used to create the system
  123139. * @param scene The scene the particle system belongs to
  123140. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  123141. */
  123142. constructor(name: string, options: Partial<{
  123143. capacity: number;
  123144. randomTextureSize: number;
  123145. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  123146. protected _reset(): void;
  123147. private _createUpdateVAO;
  123148. private _createRenderVAO;
  123149. private _initialize;
  123150. /** @hidden */
  123151. _recreateUpdateEffect(): void;
  123152. /** @hidden */
  123153. _recreateRenderEffect(): void;
  123154. /**
  123155. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  123156. * @param preWarm defines if we are in the pre-warmimg phase
  123157. */
  123158. animate(preWarm?: boolean): void;
  123159. private _createFactorGradientTexture;
  123160. private _createSizeGradientTexture;
  123161. private _createAngularSpeedGradientTexture;
  123162. private _createVelocityGradientTexture;
  123163. private _createLimitVelocityGradientTexture;
  123164. private _createDragGradientTexture;
  123165. private _createColorGradientTexture;
  123166. /**
  123167. * Renders the particle system in its current state
  123168. * @param preWarm defines if the system should only update the particles but not render them
  123169. * @returns the current number of particles
  123170. */
  123171. render(preWarm?: boolean): number;
  123172. /**
  123173. * Rebuilds the particle system
  123174. */
  123175. rebuild(): void;
  123176. private _releaseBuffers;
  123177. private _releaseVAOs;
  123178. /**
  123179. * Disposes the particle system and free the associated resources
  123180. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  123181. */
  123182. dispose(disposeTexture?: boolean): void;
  123183. /**
  123184. * Clones the particle system.
  123185. * @param name The name of the cloned object
  123186. * @param newEmitter The new emitter to use
  123187. * @returns the cloned particle system
  123188. */
  123189. clone(name: string, newEmitter: any): GPUParticleSystem;
  123190. /**
  123191. * Serializes the particle system to a JSON object.
  123192. * @returns the JSON object
  123193. */
  123194. serialize(): any;
  123195. /**
  123196. * Parses a JSON object to create a GPU particle system.
  123197. * @param parsedParticleSystem The JSON object to parse
  123198. * @param scene The scene to create the particle system in
  123199. * @param rootUrl The root url to use to load external dependencies like texture
  123200. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  123201. * @returns the parsed GPU particle system
  123202. */
  123203. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  123204. }
  123205. }
  123206. declare module BABYLON {
  123207. /**
  123208. * Represents a set of particle systems working together to create a specific effect
  123209. */
  123210. export class ParticleSystemSet implements IDisposable {
  123211. private _emitterCreationOptions;
  123212. private _emitterNode;
  123213. /**
  123214. * Gets the particle system list
  123215. */
  123216. systems: IParticleSystem[];
  123217. /**
  123218. * Gets the emitter node used with this set
  123219. */
  123220. readonly emitterNode: Nullable<TransformNode>;
  123221. /**
  123222. * Creates a new emitter mesh as a sphere
  123223. * @param options defines the options used to create the sphere
  123224. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  123225. * @param scene defines the hosting scene
  123226. */
  123227. setEmitterAsSphere(options: {
  123228. diameter: number;
  123229. segments: number;
  123230. color: Color3;
  123231. }, renderingGroupId: number, scene: Scene): void;
  123232. /**
  123233. * Starts all particle systems of the set
  123234. * @param emitter defines an optional mesh to use as emitter for the particle systems
  123235. */
  123236. start(emitter?: AbstractMesh): void;
  123237. /**
  123238. * Release all associated resources
  123239. */
  123240. dispose(): void;
  123241. /**
  123242. * Serialize the set into a JSON compatible object
  123243. * @returns a JSON compatible representation of the set
  123244. */
  123245. serialize(): any;
  123246. /**
  123247. * Parse a new ParticleSystemSet from a serialized source
  123248. * @param data defines a JSON compatible representation of the set
  123249. * @param scene defines the hosting scene
  123250. * @param gpu defines if we want GPU particles or CPU particles
  123251. * @returns a new ParticleSystemSet
  123252. */
  123253. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  123254. }
  123255. }
  123256. declare module BABYLON {
  123257. /**
  123258. * This class is made for on one-liner static method to help creating particle system set.
  123259. */
  123260. export class ParticleHelper {
  123261. /**
  123262. * Gets or sets base Assets URL
  123263. */
  123264. static BaseAssetsUrl: string;
  123265. /**
  123266. * Create a default particle system that you can tweak
  123267. * @param emitter defines the emitter to use
  123268. * @param capacity defines the system capacity (default is 500 particles)
  123269. * @param scene defines the hosting scene
  123270. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  123271. * @returns the new Particle system
  123272. */
  123273. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  123274. /**
  123275. * This is the main static method (one-liner) of this helper to create different particle systems
  123276. * @param type This string represents the type to the particle system to create
  123277. * @param scene The scene where the particle system should live
  123278. * @param gpu If the system will use gpu
  123279. * @returns the ParticleSystemSet created
  123280. */
  123281. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  123282. /**
  123283. * Static function used to export a particle system to a ParticleSystemSet variable.
  123284. * Please note that the emitter shape is not exported
  123285. * @param systems defines the particle systems to export
  123286. * @returns the created particle system set
  123287. */
  123288. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  123289. }
  123290. }
  123291. declare module BABYLON {
  123292. interface Engine {
  123293. /**
  123294. * Create an effect to use with particle systems.
  123295. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  123296. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  123297. * @param uniformsNames defines a list of attribute names
  123298. * @param samplers defines an array of string used to represent textures
  123299. * @param defines defines the string containing the defines to use to compile the shaders
  123300. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  123301. * @param onCompiled defines a function to call when the effect creation is successful
  123302. * @param onError defines a function to call when the effect creation has failed
  123303. * @returns the new Effect
  123304. */
  123305. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  123306. }
  123307. interface Mesh {
  123308. /**
  123309. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  123310. * @returns an array of IParticleSystem
  123311. */
  123312. getEmittedParticleSystems(): IParticleSystem[];
  123313. /**
  123314. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  123315. * @returns an array of IParticleSystem
  123316. */
  123317. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  123318. }
  123319. /**
  123320. * @hidden
  123321. */
  123322. export var _IDoNeedToBeInTheBuild: number;
  123323. }
  123324. declare module BABYLON {
  123325. interface Scene {
  123326. /** @hidden (Backing field) */
  123327. _physicsEngine: Nullable<IPhysicsEngine>;
  123328. /**
  123329. * Gets the current physics engine
  123330. * @returns a IPhysicsEngine or null if none attached
  123331. */
  123332. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  123333. /**
  123334. * Enables physics to the current scene
  123335. * @param gravity defines the scene's gravity for the physics engine
  123336. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  123337. * @return a boolean indicating if the physics engine was initialized
  123338. */
  123339. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  123340. /**
  123341. * Disables and disposes the physics engine associated with the scene
  123342. */
  123343. disablePhysicsEngine(): void;
  123344. /**
  123345. * Gets a boolean indicating if there is an active physics engine
  123346. * @returns a boolean indicating if there is an active physics engine
  123347. */
  123348. isPhysicsEnabled(): boolean;
  123349. /**
  123350. * Deletes a physics compound impostor
  123351. * @param compound defines the compound to delete
  123352. */
  123353. deleteCompoundImpostor(compound: any): void;
  123354. /**
  123355. * An event triggered when physic simulation is about to be run
  123356. */
  123357. onBeforePhysicsObservable: Observable<Scene>;
  123358. /**
  123359. * An event triggered when physic simulation has been done
  123360. */
  123361. onAfterPhysicsObservable: Observable<Scene>;
  123362. }
  123363. interface AbstractMesh {
  123364. /** @hidden */
  123365. _physicsImpostor: Nullable<PhysicsImpostor>;
  123366. /**
  123367. * Gets or sets impostor used for physic simulation
  123368. * @see http://doc.babylonjs.com/features/physics_engine
  123369. */
  123370. physicsImpostor: Nullable<PhysicsImpostor>;
  123371. /**
  123372. * Gets the current physics impostor
  123373. * @see http://doc.babylonjs.com/features/physics_engine
  123374. * @returns a physics impostor or null
  123375. */
  123376. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  123377. /** Apply a physic impulse to the mesh
  123378. * @param force defines the force to apply
  123379. * @param contactPoint defines where to apply the force
  123380. * @returns the current mesh
  123381. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123382. */
  123383. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  123384. /**
  123385. * Creates a physic joint between two meshes
  123386. * @param otherMesh defines the other mesh to use
  123387. * @param pivot1 defines the pivot to use on this mesh
  123388. * @param pivot2 defines the pivot to use on the other mesh
  123389. * @param options defines additional options (can be plugin dependent)
  123390. * @returns the current mesh
  123391. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  123392. */
  123393. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  123394. /** @hidden */
  123395. _disposePhysicsObserver: Nullable<Observer<Node>>;
  123396. }
  123397. /**
  123398. * Defines the physics engine scene component responsible to manage a physics engine
  123399. */
  123400. export class PhysicsEngineSceneComponent implements ISceneComponent {
  123401. /**
  123402. * The component name helpful to identify the component in the list of scene components.
  123403. */
  123404. readonly name: string;
  123405. /**
  123406. * The scene the component belongs to.
  123407. */
  123408. scene: Scene;
  123409. /**
  123410. * Creates a new instance of the component for the given scene
  123411. * @param scene Defines the scene to register the component in
  123412. */
  123413. constructor(scene: Scene);
  123414. /**
  123415. * Registers the component in a given scene
  123416. */
  123417. register(): void;
  123418. /**
  123419. * Rebuilds the elements related to this component in case of
  123420. * context lost for instance.
  123421. */
  123422. rebuild(): void;
  123423. /**
  123424. * Disposes the component and the associated ressources
  123425. */
  123426. dispose(): void;
  123427. }
  123428. }
  123429. declare module BABYLON {
  123430. /**
  123431. * A helper for physics simulations
  123432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123433. */
  123434. export class PhysicsHelper {
  123435. private _scene;
  123436. private _physicsEngine;
  123437. /**
  123438. * Initializes the Physics helper
  123439. * @param scene Babylon.js scene
  123440. */
  123441. constructor(scene: Scene);
  123442. /**
  123443. * Applies a radial explosion impulse
  123444. * @param origin the origin of the explosion
  123445. * @param radiusOrEventOptions the radius or the options of radial explosion
  123446. * @param strength the explosion strength
  123447. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123448. * @returns A physics radial explosion event, or null
  123449. */
  123450. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123451. /**
  123452. * Applies a radial explosion force
  123453. * @param origin the origin of the explosion
  123454. * @param radiusOrEventOptions the radius or the options of radial explosion
  123455. * @param strength the explosion strength
  123456. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123457. * @returns A physics radial explosion event, or null
  123458. */
  123459. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123460. /**
  123461. * Creates a gravitational field
  123462. * @param origin the origin of the explosion
  123463. * @param radiusOrEventOptions the radius or the options of radial explosion
  123464. * @param strength the explosion strength
  123465. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123466. * @returns A physics gravitational field event, or null
  123467. */
  123468. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  123469. /**
  123470. * Creates a physics updraft event
  123471. * @param origin the origin of the updraft
  123472. * @param radiusOrEventOptions the radius or the options of the updraft
  123473. * @param strength the strength of the updraft
  123474. * @param height the height of the updraft
  123475. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  123476. * @returns A physics updraft event, or null
  123477. */
  123478. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  123479. /**
  123480. * Creates a physics vortex event
  123481. * @param origin the of the vortex
  123482. * @param radiusOrEventOptions the radius or the options of the vortex
  123483. * @param strength the strength of the vortex
  123484. * @param height the height of the vortex
  123485. * @returns a Physics vortex event, or null
  123486. * A physics vortex event or null
  123487. */
  123488. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  123489. }
  123490. /**
  123491. * Represents a physics radial explosion event
  123492. */
  123493. class PhysicsRadialExplosionEvent {
  123494. private _scene;
  123495. private _options;
  123496. private _sphere;
  123497. private _dataFetched;
  123498. /**
  123499. * Initializes a radial explosioin event
  123500. * @param _scene BabylonJS scene
  123501. * @param _options The options for the vortex event
  123502. */
  123503. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  123504. /**
  123505. * Returns the data related to the radial explosion event (sphere).
  123506. * @returns The radial explosion event data
  123507. */
  123508. getData(): PhysicsRadialExplosionEventData;
  123509. /**
  123510. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  123511. * @param impostor A physics imposter
  123512. * @param origin the origin of the explosion
  123513. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  123514. */
  123515. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  123516. /**
  123517. * Triggers affecterd impostors callbacks
  123518. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  123519. */
  123520. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  123521. /**
  123522. * Disposes the sphere.
  123523. * @param force Specifies if the sphere should be disposed by force
  123524. */
  123525. dispose(force?: boolean): void;
  123526. /*** Helpers ***/
  123527. private _prepareSphere;
  123528. private _intersectsWithSphere;
  123529. }
  123530. /**
  123531. * Represents a gravitational field event
  123532. */
  123533. class PhysicsGravitationalFieldEvent {
  123534. private _physicsHelper;
  123535. private _scene;
  123536. private _origin;
  123537. private _options;
  123538. private _tickCallback;
  123539. private _sphere;
  123540. private _dataFetched;
  123541. /**
  123542. * Initializes the physics gravitational field event
  123543. * @param _physicsHelper A physics helper
  123544. * @param _scene BabylonJS scene
  123545. * @param _origin The origin position of the gravitational field event
  123546. * @param _options The options for the vortex event
  123547. */
  123548. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  123549. /**
  123550. * Returns the data related to the gravitational field event (sphere).
  123551. * @returns A gravitational field event
  123552. */
  123553. getData(): PhysicsGravitationalFieldEventData;
  123554. /**
  123555. * Enables the gravitational field.
  123556. */
  123557. enable(): void;
  123558. /**
  123559. * Disables the gravitational field.
  123560. */
  123561. disable(): void;
  123562. /**
  123563. * Disposes the sphere.
  123564. * @param force The force to dispose from the gravitational field event
  123565. */
  123566. dispose(force?: boolean): void;
  123567. private _tick;
  123568. }
  123569. /**
  123570. * Represents a physics updraft event
  123571. */
  123572. class PhysicsUpdraftEvent {
  123573. private _scene;
  123574. private _origin;
  123575. private _options;
  123576. private _physicsEngine;
  123577. private _originTop;
  123578. private _originDirection;
  123579. private _tickCallback;
  123580. private _cylinder;
  123581. private _cylinderPosition;
  123582. private _dataFetched;
  123583. /**
  123584. * Initializes the physics updraft event
  123585. * @param _scene BabylonJS scene
  123586. * @param _origin The origin position of the updraft
  123587. * @param _options The options for the updraft event
  123588. */
  123589. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  123590. /**
  123591. * Returns the data related to the updraft event (cylinder).
  123592. * @returns A physics updraft event
  123593. */
  123594. getData(): PhysicsUpdraftEventData;
  123595. /**
  123596. * Enables the updraft.
  123597. */
  123598. enable(): void;
  123599. /**
  123600. * Disables the updraft.
  123601. */
  123602. disable(): void;
  123603. /**
  123604. * Disposes the cylinder.
  123605. * @param force Specifies if the updraft should be disposed by force
  123606. */
  123607. dispose(force?: boolean): void;
  123608. private getImpostorHitData;
  123609. private _tick;
  123610. /*** Helpers ***/
  123611. private _prepareCylinder;
  123612. private _intersectsWithCylinder;
  123613. }
  123614. /**
  123615. * Represents a physics vortex event
  123616. */
  123617. class PhysicsVortexEvent {
  123618. private _scene;
  123619. private _origin;
  123620. private _options;
  123621. private _physicsEngine;
  123622. private _originTop;
  123623. private _tickCallback;
  123624. private _cylinder;
  123625. private _cylinderPosition;
  123626. private _dataFetched;
  123627. /**
  123628. * Initializes the physics vortex event
  123629. * @param _scene The BabylonJS scene
  123630. * @param _origin The origin position of the vortex
  123631. * @param _options The options for the vortex event
  123632. */
  123633. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  123634. /**
  123635. * Returns the data related to the vortex event (cylinder).
  123636. * @returns The physics vortex event data
  123637. */
  123638. getData(): PhysicsVortexEventData;
  123639. /**
  123640. * Enables the vortex.
  123641. */
  123642. enable(): void;
  123643. /**
  123644. * Disables the cortex.
  123645. */
  123646. disable(): void;
  123647. /**
  123648. * Disposes the sphere.
  123649. * @param force
  123650. */
  123651. dispose(force?: boolean): void;
  123652. private getImpostorHitData;
  123653. private _tick;
  123654. /*** Helpers ***/
  123655. private _prepareCylinder;
  123656. private _intersectsWithCylinder;
  123657. }
  123658. /**
  123659. * Options fot the radial explosion event
  123660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123661. */
  123662. export class PhysicsRadialExplosionEventOptions {
  123663. /**
  123664. * The radius of the sphere for the radial explosion.
  123665. */
  123666. radius: number;
  123667. /**
  123668. * The strenth of the explosion.
  123669. */
  123670. strength: number;
  123671. /**
  123672. * The strenght of the force in correspondence to the distance of the affected object
  123673. */
  123674. falloff: PhysicsRadialImpulseFalloff;
  123675. /**
  123676. * Sphere options for the radial explosion.
  123677. */
  123678. sphere: {
  123679. segments: number;
  123680. diameter: number;
  123681. };
  123682. /**
  123683. * Sphere options for the radial explosion.
  123684. */
  123685. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  123686. }
  123687. /**
  123688. * Options fot the updraft event
  123689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123690. */
  123691. export class PhysicsUpdraftEventOptions {
  123692. /**
  123693. * The radius of the cylinder for the vortex
  123694. */
  123695. radius: number;
  123696. /**
  123697. * The strenth of the updraft.
  123698. */
  123699. strength: number;
  123700. /**
  123701. * The height of the cylinder for the updraft.
  123702. */
  123703. height: number;
  123704. /**
  123705. * The mode for the the updraft.
  123706. */
  123707. updraftMode: PhysicsUpdraftMode;
  123708. }
  123709. /**
  123710. * Options fot the vortex event
  123711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123712. */
  123713. export class PhysicsVortexEventOptions {
  123714. /**
  123715. * The radius of the cylinder for the vortex
  123716. */
  123717. radius: number;
  123718. /**
  123719. * The strenth of the vortex.
  123720. */
  123721. strength: number;
  123722. /**
  123723. * The height of the cylinder for the vortex.
  123724. */
  123725. height: number;
  123726. /**
  123727. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  123728. */
  123729. centripetalForceThreshold: number;
  123730. /**
  123731. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  123732. */
  123733. centripetalForceMultiplier: number;
  123734. /**
  123735. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  123736. */
  123737. centrifugalForceMultiplier: number;
  123738. /**
  123739. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  123740. */
  123741. updraftForceMultiplier: number;
  123742. }
  123743. /**
  123744. * The strenght of the force in correspondence to the distance of the affected object
  123745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123746. */
  123747. export enum PhysicsRadialImpulseFalloff {
  123748. /** Defines that impulse is constant in strength across it's whole radius */
  123749. Constant = 0,
  123750. /** Defines that impulse gets weaker if it's further from the origin */
  123751. Linear = 1
  123752. }
  123753. /**
  123754. * The strength of the force in correspondence to the distance of the affected object
  123755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123756. */
  123757. export enum PhysicsUpdraftMode {
  123758. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  123759. Center = 0,
  123760. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  123761. Perpendicular = 1
  123762. }
  123763. /**
  123764. * Interface for a physics hit data
  123765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123766. */
  123767. export interface PhysicsHitData {
  123768. /**
  123769. * The force applied at the contact point
  123770. */
  123771. force: Vector3;
  123772. /**
  123773. * The contact point
  123774. */
  123775. contactPoint: Vector3;
  123776. /**
  123777. * The distance from the origin to the contact point
  123778. */
  123779. distanceFromOrigin: number;
  123780. }
  123781. /**
  123782. * Interface for radial explosion event data
  123783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123784. */
  123785. export interface PhysicsRadialExplosionEventData {
  123786. /**
  123787. * A sphere used for the radial explosion event
  123788. */
  123789. sphere: Mesh;
  123790. }
  123791. /**
  123792. * Interface for gravitational field event data
  123793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123794. */
  123795. export interface PhysicsGravitationalFieldEventData {
  123796. /**
  123797. * A sphere mesh used for the gravitational field event
  123798. */
  123799. sphere: Mesh;
  123800. }
  123801. /**
  123802. * Interface for updraft event data
  123803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123804. */
  123805. export interface PhysicsUpdraftEventData {
  123806. /**
  123807. * A cylinder used for the updraft event
  123808. */
  123809. cylinder: Mesh;
  123810. }
  123811. /**
  123812. * Interface for vortex event data
  123813. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123814. */
  123815. export interface PhysicsVortexEventData {
  123816. /**
  123817. * A cylinder used for the vortex event
  123818. */
  123819. cylinder: Mesh;
  123820. }
  123821. /**
  123822. * Interface for an affected physics impostor
  123823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123824. */
  123825. export interface PhysicsAffectedImpostorWithData {
  123826. /**
  123827. * The impostor affected by the effect
  123828. */
  123829. impostor: PhysicsImpostor;
  123830. /**
  123831. * The data about the hit/horce from the explosion
  123832. */
  123833. hitData: PhysicsHitData;
  123834. }
  123835. }
  123836. declare module BABYLON {
  123837. /** @hidden */
  123838. export var blackAndWhitePixelShader: {
  123839. name: string;
  123840. shader: string;
  123841. };
  123842. }
  123843. declare module BABYLON {
  123844. /**
  123845. * Post process used to render in black and white
  123846. */
  123847. export class BlackAndWhitePostProcess extends PostProcess {
  123848. /**
  123849. * Linear about to convert he result to black and white (default: 1)
  123850. */
  123851. degree: number;
  123852. /**
  123853. * Creates a black and white post process
  123854. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  123855. * @param name The name of the effect.
  123856. * @param options The required width/height ratio to downsize to before computing the render pass.
  123857. * @param camera The camera to apply the render pass to.
  123858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123859. * @param engine The engine which the post process will be applied. (default: current engine)
  123860. * @param reusable If the post process can be reused on the same frame. (default: false)
  123861. */
  123862. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123863. }
  123864. }
  123865. declare module BABYLON {
  123866. /**
  123867. * This represents a set of one or more post processes in Babylon.
  123868. * A post process can be used to apply a shader to a texture after it is rendered.
  123869. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123870. */
  123871. export class PostProcessRenderEffect {
  123872. private _postProcesses;
  123873. private _getPostProcesses;
  123874. private _singleInstance;
  123875. private _cameras;
  123876. private _indicesForCamera;
  123877. /**
  123878. * Name of the effect
  123879. * @hidden
  123880. */
  123881. _name: string;
  123882. /**
  123883. * Instantiates a post process render effect.
  123884. * A post process can be used to apply a shader to a texture after it is rendered.
  123885. * @param engine The engine the effect is tied to
  123886. * @param name The name of the effect
  123887. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  123888. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  123889. */
  123890. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  123891. /**
  123892. * Checks if all the post processes in the effect are supported.
  123893. */
  123894. readonly isSupported: boolean;
  123895. /**
  123896. * Updates the current state of the effect
  123897. * @hidden
  123898. */
  123899. _update(): void;
  123900. /**
  123901. * Attaches the effect on cameras
  123902. * @param cameras The camera to attach to.
  123903. * @hidden
  123904. */
  123905. _attachCameras(cameras: Camera): void;
  123906. /**
  123907. * Attaches the effect on cameras
  123908. * @param cameras The camera to attach to.
  123909. * @hidden
  123910. */
  123911. _attachCameras(cameras: Camera[]): void;
  123912. /**
  123913. * Detaches the effect on cameras
  123914. * @param cameras The camera to detatch from.
  123915. * @hidden
  123916. */
  123917. _detachCameras(cameras: Camera): void;
  123918. /**
  123919. * Detatches the effect on cameras
  123920. * @param cameras The camera to detatch from.
  123921. * @hidden
  123922. */
  123923. _detachCameras(cameras: Camera[]): void;
  123924. /**
  123925. * Enables the effect on given cameras
  123926. * @param cameras The camera to enable.
  123927. * @hidden
  123928. */
  123929. _enable(cameras: Camera): void;
  123930. /**
  123931. * Enables the effect on given cameras
  123932. * @param cameras The camera to enable.
  123933. * @hidden
  123934. */
  123935. _enable(cameras: Nullable<Camera[]>): void;
  123936. /**
  123937. * Disables the effect on the given cameras
  123938. * @param cameras The camera to disable.
  123939. * @hidden
  123940. */
  123941. _disable(cameras: Camera): void;
  123942. /**
  123943. * Disables the effect on the given cameras
  123944. * @param cameras The camera to disable.
  123945. * @hidden
  123946. */
  123947. _disable(cameras: Nullable<Camera[]>): void;
  123948. /**
  123949. * Gets a list of the post processes contained in the effect.
  123950. * @param camera The camera to get the post processes on.
  123951. * @returns The list of the post processes in the effect.
  123952. */
  123953. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  123954. }
  123955. }
  123956. declare module BABYLON {
  123957. /** @hidden */
  123958. export var extractHighlightsPixelShader: {
  123959. name: string;
  123960. shader: string;
  123961. };
  123962. }
  123963. declare module BABYLON {
  123964. /**
  123965. * 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.
  123966. */
  123967. export class ExtractHighlightsPostProcess extends PostProcess {
  123968. /**
  123969. * The luminance threshold, pixels below this value will be set to black.
  123970. */
  123971. threshold: number;
  123972. /** @hidden */
  123973. _exposure: number;
  123974. /**
  123975. * Post process which has the input texture to be used when performing highlight extraction
  123976. * @hidden
  123977. */
  123978. _inputPostProcess: Nullable<PostProcess>;
  123979. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123980. }
  123981. }
  123982. declare module BABYLON {
  123983. /** @hidden */
  123984. export var bloomMergePixelShader: {
  123985. name: string;
  123986. shader: string;
  123987. };
  123988. }
  123989. declare module BABYLON {
  123990. /**
  123991. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123992. */
  123993. export class BloomMergePostProcess extends PostProcess {
  123994. /** Weight of the bloom to be added to the original input. */
  123995. weight: number;
  123996. /**
  123997. * Creates a new instance of @see BloomMergePostProcess
  123998. * @param name The name of the effect.
  123999. * @param originalFromInput Post process which's input will be used for the merge.
  124000. * @param blurred Blurred highlights post process which's output will be used.
  124001. * @param weight Weight of the bloom to be added to the original input.
  124002. * @param options The required width/height ratio to downsize to before computing the render pass.
  124003. * @param camera The camera to apply the render pass to.
  124004. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124005. * @param engine The engine which the post process will be applied. (default: current engine)
  124006. * @param reusable If the post process can be reused on the same frame. (default: false)
  124007. * @param textureType Type of textures used when performing the post process. (default: 0)
  124008. * @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)
  124009. */
  124010. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  124011. /** Weight of the bloom to be added to the original input. */
  124012. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124013. }
  124014. }
  124015. declare module BABYLON {
  124016. /**
  124017. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  124018. */
  124019. export class BloomEffect extends PostProcessRenderEffect {
  124020. private bloomScale;
  124021. /**
  124022. * @hidden Internal
  124023. */
  124024. _effects: Array<PostProcess>;
  124025. /**
  124026. * @hidden Internal
  124027. */
  124028. _downscale: ExtractHighlightsPostProcess;
  124029. private _blurX;
  124030. private _blurY;
  124031. private _merge;
  124032. /**
  124033. * The luminance threshold to find bright areas of the image to bloom.
  124034. */
  124035. threshold: number;
  124036. /**
  124037. * The strength of the bloom.
  124038. */
  124039. weight: number;
  124040. /**
  124041. * Specifies the size of the bloom blur kernel, relative to the final output size
  124042. */
  124043. kernel: number;
  124044. /**
  124045. * Creates a new instance of @see BloomEffect
  124046. * @param scene The scene the effect belongs to.
  124047. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  124048. * @param bloomKernel The size of the kernel to be used when applying the blur.
  124049. * @param bloomWeight The the strength of bloom.
  124050. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124051. * @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)
  124052. */
  124053. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  124054. /**
  124055. * Disposes each of the internal effects for a given camera.
  124056. * @param camera The camera to dispose the effect on.
  124057. */
  124058. disposeEffects(camera: Camera): void;
  124059. /**
  124060. * @hidden Internal
  124061. */
  124062. _updateEffects(): void;
  124063. /**
  124064. * Internal
  124065. * @returns if all the contained post processes are ready.
  124066. * @hidden
  124067. */
  124068. _isReady(): boolean;
  124069. }
  124070. }
  124071. declare module BABYLON {
  124072. /** @hidden */
  124073. export var chromaticAberrationPixelShader: {
  124074. name: string;
  124075. shader: string;
  124076. };
  124077. }
  124078. declare module BABYLON {
  124079. /**
  124080. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  124081. */
  124082. export class ChromaticAberrationPostProcess extends PostProcess {
  124083. /**
  124084. * The amount of seperation of rgb channels (default: 30)
  124085. */
  124086. aberrationAmount: number;
  124087. /**
  124088. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  124089. */
  124090. radialIntensity: number;
  124091. /**
  124092. * 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))
  124093. */
  124094. direction: Vector2;
  124095. /**
  124096. * 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))
  124097. */
  124098. centerPosition: Vector2;
  124099. /**
  124100. * Creates a new instance ChromaticAberrationPostProcess
  124101. * @param name The name of the effect.
  124102. * @param screenWidth The width of the screen to apply the effect on.
  124103. * @param screenHeight The height of the screen to apply the effect on.
  124104. * @param options The required width/height ratio to downsize to before computing the render pass.
  124105. * @param camera The camera to apply the render pass to.
  124106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124107. * @param engine The engine which the post process will be applied. (default: current engine)
  124108. * @param reusable If the post process can be reused on the same frame. (default: false)
  124109. * @param textureType Type of textures used when performing the post process. (default: 0)
  124110. * @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)
  124111. */
  124112. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124113. }
  124114. }
  124115. declare module BABYLON {
  124116. /** @hidden */
  124117. export var circleOfConfusionPixelShader: {
  124118. name: string;
  124119. shader: string;
  124120. };
  124121. }
  124122. declare module BABYLON {
  124123. /**
  124124. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  124125. */
  124126. export class CircleOfConfusionPostProcess extends PostProcess {
  124127. /**
  124128. * 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.
  124129. */
  124130. lensSize: number;
  124131. /**
  124132. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124133. */
  124134. fStop: number;
  124135. /**
  124136. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124137. */
  124138. focusDistance: number;
  124139. /**
  124140. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  124141. */
  124142. focalLength: number;
  124143. private _depthTexture;
  124144. /**
  124145. * Creates a new instance CircleOfConfusionPostProcess
  124146. * @param name The name of the effect.
  124147. * @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.
  124148. * @param options The required width/height ratio to downsize to before computing the render pass.
  124149. * @param camera The camera to apply the render pass to.
  124150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124151. * @param engine The engine which the post process will be applied. (default: current engine)
  124152. * @param reusable If the post process can be reused on the same frame. (default: false)
  124153. * @param textureType Type of textures used when performing the post process. (default: 0)
  124154. * @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)
  124155. */
  124156. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124157. /**
  124158. * 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.
  124159. */
  124160. depthTexture: RenderTargetTexture;
  124161. }
  124162. }
  124163. declare module BABYLON {
  124164. /** @hidden */
  124165. export var colorCorrectionPixelShader: {
  124166. name: string;
  124167. shader: string;
  124168. };
  124169. }
  124170. declare module BABYLON {
  124171. /**
  124172. *
  124173. * This post-process allows the modification of rendered colors by using
  124174. * a 'look-up table' (LUT). This effect is also called Color Grading.
  124175. *
  124176. * The object needs to be provided an url to a texture containing the color
  124177. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  124178. * Use an image editing software to tweak the LUT to match your needs.
  124179. *
  124180. * For an example of a color LUT, see here:
  124181. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  124182. * For explanations on color grading, see here:
  124183. * @see http://udn.epicgames.com/Three/ColorGrading.html
  124184. *
  124185. */
  124186. export class ColorCorrectionPostProcess extends PostProcess {
  124187. private _colorTableTexture;
  124188. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124189. }
  124190. }
  124191. declare module BABYLON {
  124192. /** @hidden */
  124193. export var convolutionPixelShader: {
  124194. name: string;
  124195. shader: string;
  124196. };
  124197. }
  124198. declare module BABYLON {
  124199. /**
  124200. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  124201. * input texture to perform effects such as edge detection or sharpening
  124202. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124203. */
  124204. export class ConvolutionPostProcess extends PostProcess {
  124205. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124206. kernel: number[];
  124207. /**
  124208. * Creates a new instance ConvolutionPostProcess
  124209. * @param name The name of the effect.
  124210. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  124211. * @param options The required width/height ratio to downsize to before computing the render pass.
  124212. * @param camera The camera to apply the render pass to.
  124213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124214. * @param engine The engine which the post process will be applied. (default: current engine)
  124215. * @param reusable If the post process can be reused on the same frame. (default: false)
  124216. * @param textureType Type of textures used when performing the post process. (default: 0)
  124217. */
  124218. constructor(name: string,
  124219. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124220. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124221. /**
  124222. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124223. */
  124224. static EdgeDetect0Kernel: number[];
  124225. /**
  124226. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124227. */
  124228. static EdgeDetect1Kernel: number[];
  124229. /**
  124230. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124231. */
  124232. static EdgeDetect2Kernel: number[];
  124233. /**
  124234. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124235. */
  124236. static SharpenKernel: number[];
  124237. /**
  124238. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124239. */
  124240. static EmbossKernel: number[];
  124241. /**
  124242. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124243. */
  124244. static GaussianKernel: number[];
  124245. }
  124246. }
  124247. declare module BABYLON {
  124248. /**
  124249. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  124250. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  124251. * based on samples that have a large difference in distance than the center pixel.
  124252. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  124253. */
  124254. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  124255. direction: Vector2;
  124256. /**
  124257. * Creates a new instance CircleOfConfusionPostProcess
  124258. * @param name The name of the effect.
  124259. * @param scene The scene the effect belongs to.
  124260. * @param direction The direction the blur should be applied.
  124261. * @param kernel The size of the kernel used to blur.
  124262. * @param options The required width/height ratio to downsize to before computing the render pass.
  124263. * @param camera The camera to apply the render pass to.
  124264. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  124265. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  124266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124267. * @param engine The engine which the post process will be applied. (default: current engine)
  124268. * @param reusable If the post process can be reused on the same frame. (default: false)
  124269. * @param textureType Type of textures used when performing the post process. (default: 0)
  124270. * @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)
  124271. */
  124272. 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);
  124273. }
  124274. }
  124275. declare module BABYLON {
  124276. /** @hidden */
  124277. export var depthOfFieldMergePixelShader: {
  124278. name: string;
  124279. shader: string;
  124280. };
  124281. }
  124282. declare module BABYLON {
  124283. /**
  124284. * Options to be set when merging outputs from the default pipeline.
  124285. */
  124286. export class DepthOfFieldMergePostProcessOptions {
  124287. /**
  124288. * The original image to merge on top of
  124289. */
  124290. originalFromInput: PostProcess;
  124291. /**
  124292. * Parameters to perform the merge of the depth of field effect
  124293. */
  124294. depthOfField?: {
  124295. circleOfConfusion: PostProcess;
  124296. blurSteps: Array<PostProcess>;
  124297. };
  124298. /**
  124299. * Parameters to perform the merge of bloom effect
  124300. */
  124301. bloom?: {
  124302. blurred: PostProcess;
  124303. weight: number;
  124304. };
  124305. }
  124306. /**
  124307. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  124308. */
  124309. export class DepthOfFieldMergePostProcess extends PostProcess {
  124310. private blurSteps;
  124311. /**
  124312. * Creates a new instance of DepthOfFieldMergePostProcess
  124313. * @param name The name of the effect.
  124314. * @param originalFromInput Post process which's input will be used for the merge.
  124315. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  124316. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  124317. * @param options The required width/height ratio to downsize to before computing the render pass.
  124318. * @param camera The camera to apply the render pass to.
  124319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124320. * @param engine The engine which the post process will be applied. (default: current engine)
  124321. * @param reusable If the post process can be reused on the same frame. (default: false)
  124322. * @param textureType Type of textures used when performing the post process. (default: 0)
  124323. * @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)
  124324. */
  124325. 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);
  124326. /**
  124327. * Updates the effect with the current post process compile time values and recompiles the shader.
  124328. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  124329. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  124330. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  124331. * @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
  124332. * @param onCompiled Called when the shader has been compiled.
  124333. * @param onError Called if there is an error when compiling a shader.
  124334. */
  124335. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  124336. }
  124337. }
  124338. declare module BABYLON {
  124339. /**
  124340. * Specifies the level of max blur that should be applied when using the depth of field effect
  124341. */
  124342. export enum DepthOfFieldEffectBlurLevel {
  124343. /**
  124344. * Subtle blur
  124345. */
  124346. Low = 0,
  124347. /**
  124348. * Medium blur
  124349. */
  124350. Medium = 1,
  124351. /**
  124352. * Large blur
  124353. */
  124354. High = 2
  124355. }
  124356. /**
  124357. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  124358. */
  124359. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  124360. private _circleOfConfusion;
  124361. /**
  124362. * @hidden Internal, blurs from high to low
  124363. */
  124364. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  124365. private _depthOfFieldBlurY;
  124366. private _dofMerge;
  124367. /**
  124368. * @hidden Internal post processes in depth of field effect
  124369. */
  124370. _effects: Array<PostProcess>;
  124371. /**
  124372. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  124373. */
  124374. focalLength: number;
  124375. /**
  124376. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124377. */
  124378. fStop: number;
  124379. /**
  124380. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124381. */
  124382. focusDistance: number;
  124383. /**
  124384. * 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.
  124385. */
  124386. lensSize: number;
  124387. /**
  124388. * Creates a new instance DepthOfFieldEffect
  124389. * @param scene The scene the effect belongs to.
  124390. * @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.
  124391. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124392. * @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)
  124393. */
  124394. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  124395. /**
  124396. * Get the current class name of the current effet
  124397. * @returns "DepthOfFieldEffect"
  124398. */
  124399. getClassName(): string;
  124400. /**
  124401. * 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.
  124402. */
  124403. depthTexture: RenderTargetTexture;
  124404. /**
  124405. * Disposes each of the internal effects for a given camera.
  124406. * @param camera The camera to dispose the effect on.
  124407. */
  124408. disposeEffects(camera: Camera): void;
  124409. /**
  124410. * @hidden Internal
  124411. */
  124412. _updateEffects(): void;
  124413. /**
  124414. * Internal
  124415. * @returns if all the contained post processes are ready.
  124416. * @hidden
  124417. */
  124418. _isReady(): boolean;
  124419. }
  124420. }
  124421. declare module BABYLON {
  124422. /** @hidden */
  124423. export var displayPassPixelShader: {
  124424. name: string;
  124425. shader: string;
  124426. };
  124427. }
  124428. declare module BABYLON {
  124429. /**
  124430. * DisplayPassPostProcess which produces an output the same as it's input
  124431. */
  124432. export class DisplayPassPostProcess extends PostProcess {
  124433. /**
  124434. * Creates the DisplayPassPostProcess
  124435. * @param name The name of the effect.
  124436. * @param options The required width/height ratio to downsize to before computing the render pass.
  124437. * @param camera The camera to apply the render pass to.
  124438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124439. * @param engine The engine which the post process will be applied. (default: current engine)
  124440. * @param reusable If the post process can be reused on the same frame. (default: false)
  124441. */
  124442. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124443. }
  124444. }
  124445. declare module BABYLON {
  124446. /** @hidden */
  124447. export var filterPixelShader: {
  124448. name: string;
  124449. shader: string;
  124450. };
  124451. }
  124452. declare module BABYLON {
  124453. /**
  124454. * Applies a kernel filter to the image
  124455. */
  124456. export class FilterPostProcess extends PostProcess {
  124457. /** The matrix to be applied to the image */
  124458. kernelMatrix: Matrix;
  124459. /**
  124460. *
  124461. * @param name The name of the effect.
  124462. * @param kernelMatrix The matrix to be applied to the image
  124463. * @param options The required width/height ratio to downsize to before computing the render pass.
  124464. * @param camera The camera to apply the render pass to.
  124465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124466. * @param engine The engine which the post process will be applied. (default: current engine)
  124467. * @param reusable If the post process can be reused on the same frame. (default: false)
  124468. */
  124469. constructor(name: string,
  124470. /** The matrix to be applied to the image */
  124471. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124472. }
  124473. }
  124474. declare module BABYLON {
  124475. /** @hidden */
  124476. export var fxaaPixelShader: {
  124477. name: string;
  124478. shader: string;
  124479. };
  124480. }
  124481. declare module BABYLON {
  124482. /** @hidden */
  124483. export var fxaaVertexShader: {
  124484. name: string;
  124485. shader: string;
  124486. };
  124487. }
  124488. declare module BABYLON {
  124489. /**
  124490. * Fxaa post process
  124491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  124492. */
  124493. export class FxaaPostProcess extends PostProcess {
  124494. /** @hidden */
  124495. texelWidth: number;
  124496. /** @hidden */
  124497. texelHeight: number;
  124498. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124499. private _getDefines;
  124500. }
  124501. }
  124502. declare module BABYLON {
  124503. /** @hidden */
  124504. export var grainPixelShader: {
  124505. name: string;
  124506. shader: string;
  124507. };
  124508. }
  124509. declare module BABYLON {
  124510. /**
  124511. * The GrainPostProcess adds noise to the image at mid luminance levels
  124512. */
  124513. export class GrainPostProcess extends PostProcess {
  124514. /**
  124515. * The intensity of the grain added (default: 30)
  124516. */
  124517. intensity: number;
  124518. /**
  124519. * If the grain should be randomized on every frame
  124520. */
  124521. animated: boolean;
  124522. /**
  124523. * Creates a new instance of @see GrainPostProcess
  124524. * @param name The name of the effect.
  124525. * @param options The required width/height ratio to downsize to before computing the render pass.
  124526. * @param camera The camera to apply the render pass to.
  124527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124528. * @param engine The engine which the post process will be applied. (default: current engine)
  124529. * @param reusable If the post process can be reused on the same frame. (default: false)
  124530. * @param textureType Type of textures used when performing the post process. (default: 0)
  124531. * @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)
  124532. */
  124533. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124534. }
  124535. }
  124536. declare module BABYLON {
  124537. /** @hidden */
  124538. export var highlightsPixelShader: {
  124539. name: string;
  124540. shader: string;
  124541. };
  124542. }
  124543. declare module BABYLON {
  124544. /**
  124545. * Extracts highlights from the image
  124546. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124547. */
  124548. export class HighlightsPostProcess extends PostProcess {
  124549. /**
  124550. * Extracts highlights from the image
  124551. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124552. * @param name The name of the effect.
  124553. * @param options The required width/height ratio to downsize to before computing the render pass.
  124554. * @param camera The camera to apply the render pass to.
  124555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124556. * @param engine The engine which the post process will be applied. (default: current engine)
  124557. * @param reusable If the post process can be reused on the same frame. (default: false)
  124558. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  124559. */
  124560. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124561. }
  124562. }
  124563. declare module BABYLON {
  124564. /** @hidden */
  124565. export var mrtFragmentDeclaration: {
  124566. name: string;
  124567. shader: string;
  124568. };
  124569. }
  124570. declare module BABYLON {
  124571. /** @hidden */
  124572. export var geometryPixelShader: {
  124573. name: string;
  124574. shader: string;
  124575. };
  124576. }
  124577. declare module BABYLON {
  124578. /** @hidden */
  124579. export var geometryVertexShader: {
  124580. name: string;
  124581. shader: string;
  124582. };
  124583. }
  124584. declare module BABYLON {
  124585. /** @hidden */
  124586. interface ISavedTransformationMatrix {
  124587. world: Matrix;
  124588. viewProjection: Matrix;
  124589. }
  124590. /**
  124591. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  124592. */
  124593. export class GeometryBufferRenderer {
  124594. /**
  124595. * Constant used to retrieve the position texture index in the G-Buffer textures array
  124596. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  124597. */
  124598. static readonly POSITION_TEXTURE_TYPE: number;
  124599. /**
  124600. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  124601. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  124602. */
  124603. static readonly VELOCITY_TEXTURE_TYPE: number;
  124604. /**
  124605. * Dictionary used to store the previous transformation matrices of each rendered mesh
  124606. * in order to compute objects velocities when enableVelocity is set to "true"
  124607. * @hidden
  124608. */
  124609. _previousTransformationMatrices: {
  124610. [index: number]: ISavedTransformationMatrix;
  124611. };
  124612. /**
  124613. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  124614. * in order to compute objects velocities when enableVelocity is set to "true"
  124615. * @hidden
  124616. */
  124617. _previousBonesTransformationMatrices: {
  124618. [index: number]: Float32Array;
  124619. };
  124620. /**
  124621. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  124622. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  124623. */
  124624. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  124625. private _scene;
  124626. private _multiRenderTarget;
  124627. private _ratio;
  124628. private _enablePosition;
  124629. private _enableVelocity;
  124630. private _positionIndex;
  124631. private _velocityIndex;
  124632. protected _effect: Effect;
  124633. protected _cachedDefines: string;
  124634. /**
  124635. * Set the render list (meshes to be rendered) used in the G buffer.
  124636. */
  124637. renderList: Mesh[];
  124638. /**
  124639. * Gets wether or not G buffer are supported by the running hardware.
  124640. * This requires draw buffer supports
  124641. */
  124642. readonly isSupported: boolean;
  124643. /**
  124644. * Returns the index of the given texture type in the G-Buffer textures array
  124645. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  124646. * @returns the index of the given texture type in the G-Buffer textures array
  124647. */
  124648. getTextureIndex(textureType: number): number;
  124649. /**
  124650. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  124651. */
  124652. /**
  124653. * Sets whether or not objects positions are enabled for the G buffer.
  124654. */
  124655. enablePosition: boolean;
  124656. /**
  124657. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  124658. */
  124659. /**
  124660. * Sets wether or not objects velocities are enabled for the G buffer.
  124661. */
  124662. enableVelocity: boolean;
  124663. /**
  124664. * Gets the scene associated with the buffer.
  124665. */
  124666. readonly scene: Scene;
  124667. /**
  124668. * Gets the ratio used by the buffer during its creation.
  124669. * How big is the buffer related to the main canvas.
  124670. */
  124671. readonly ratio: number;
  124672. /** @hidden */
  124673. static _SceneComponentInitialization: (scene: Scene) => void;
  124674. /**
  124675. * Creates a new G Buffer for the scene
  124676. * @param scene The scene the buffer belongs to
  124677. * @param ratio How big is the buffer related to the main canvas.
  124678. */
  124679. constructor(scene: Scene, ratio?: number);
  124680. /**
  124681. * Checks wether everything is ready to render a submesh to the G buffer.
  124682. * @param subMesh the submesh to check readiness for
  124683. * @param useInstances is the mesh drawn using instance or not
  124684. * @returns true if ready otherwise false
  124685. */
  124686. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124687. /**
  124688. * Gets the current underlying G Buffer.
  124689. * @returns the buffer
  124690. */
  124691. getGBuffer(): MultiRenderTarget;
  124692. /**
  124693. * Gets the number of samples used to render the buffer (anti aliasing).
  124694. */
  124695. /**
  124696. * Sets the number of samples used to render the buffer (anti aliasing).
  124697. */
  124698. samples: number;
  124699. /**
  124700. * Disposes the renderer and frees up associated resources.
  124701. */
  124702. dispose(): void;
  124703. protected _createRenderTargets(): void;
  124704. private _copyBonesTransformationMatrices;
  124705. }
  124706. }
  124707. declare module BABYLON {
  124708. interface Scene {
  124709. /** @hidden (Backing field) */
  124710. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124711. /**
  124712. * Gets or Sets the current geometry buffer associated to the scene.
  124713. */
  124714. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124715. /**
  124716. * Enables a GeometryBufferRender and associates it with the scene
  124717. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  124718. * @returns the GeometryBufferRenderer
  124719. */
  124720. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  124721. /**
  124722. * Disables the GeometryBufferRender associated with the scene
  124723. */
  124724. disableGeometryBufferRenderer(): void;
  124725. }
  124726. /**
  124727. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  124728. * in several rendering techniques.
  124729. */
  124730. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  124731. /**
  124732. * The component name helpful to identify the component in the list of scene components.
  124733. */
  124734. readonly name: string;
  124735. /**
  124736. * The scene the component belongs to.
  124737. */
  124738. scene: Scene;
  124739. /**
  124740. * Creates a new instance of the component for the given scene
  124741. * @param scene Defines the scene to register the component in
  124742. */
  124743. constructor(scene: Scene);
  124744. /**
  124745. * Registers the component in a given scene
  124746. */
  124747. register(): void;
  124748. /**
  124749. * Rebuilds the elements related to this component in case of
  124750. * context lost for instance.
  124751. */
  124752. rebuild(): void;
  124753. /**
  124754. * Disposes the component and the associated ressources
  124755. */
  124756. dispose(): void;
  124757. private _gatherRenderTargets;
  124758. }
  124759. }
  124760. declare module BABYLON {
  124761. /** @hidden */
  124762. export var motionBlurPixelShader: {
  124763. name: string;
  124764. shader: string;
  124765. };
  124766. }
  124767. declare module BABYLON {
  124768. /**
  124769. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124770. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124771. * As an example, all you have to do is to create the post-process:
  124772. * var mb = new BABYLON.MotionBlurPostProcess(
  124773. * 'mb', // The name of the effect.
  124774. * scene, // The scene containing the objects to blur according to their velocity.
  124775. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124776. * camera // The camera to apply the render pass to.
  124777. * );
  124778. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124779. */
  124780. export class MotionBlurPostProcess extends PostProcess {
  124781. /**
  124782. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124783. */
  124784. motionStrength: number;
  124785. /**
  124786. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124787. */
  124788. /**
  124789. * Sets the number of iterations to be used for motion blur quality
  124790. */
  124791. motionBlurSamples: number;
  124792. private _motionBlurSamples;
  124793. private _geometryBufferRenderer;
  124794. /**
  124795. * Creates a new instance MotionBlurPostProcess
  124796. * @param name The name of the effect.
  124797. * @param scene The scene containing the objects to blur according to their velocity.
  124798. * @param options The required width/height ratio to downsize to before computing the render pass.
  124799. * @param camera The camera to apply the render pass to.
  124800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124801. * @param engine The engine which the post process will be applied. (default: current engine)
  124802. * @param reusable If the post process can be reused on the same frame. (default: false)
  124803. * @param textureType Type of textures used when performing the post process. (default: 0)
  124804. * @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)
  124805. */
  124806. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124807. /**
  124808. * Excludes the given skinned mesh from computing bones velocities.
  124809. * 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.
  124810. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  124811. */
  124812. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124813. /**
  124814. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  124815. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  124816. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  124817. */
  124818. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124819. /**
  124820. * Disposes the post process.
  124821. * @param camera The camera to dispose the post process on.
  124822. */
  124823. dispose(camera?: Camera): void;
  124824. }
  124825. }
  124826. declare module BABYLON {
  124827. /** @hidden */
  124828. export var refractionPixelShader: {
  124829. name: string;
  124830. shader: string;
  124831. };
  124832. }
  124833. declare module BABYLON {
  124834. /**
  124835. * Post process which applies a refractin texture
  124836. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124837. */
  124838. export class RefractionPostProcess extends PostProcess {
  124839. /** the base color of the refraction (used to taint the rendering) */
  124840. color: Color3;
  124841. /** simulated refraction depth */
  124842. depth: number;
  124843. /** the coefficient of the base color (0 to remove base color tainting) */
  124844. colorLevel: number;
  124845. private _refTexture;
  124846. private _ownRefractionTexture;
  124847. /**
  124848. * Gets or sets the refraction texture
  124849. * Please note that you are responsible for disposing the texture if you set it manually
  124850. */
  124851. refractionTexture: Texture;
  124852. /**
  124853. * Initializes the RefractionPostProcess
  124854. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124855. * @param name The name of the effect.
  124856. * @param refractionTextureUrl Url of the refraction texture to use
  124857. * @param color the base color of the refraction (used to taint the rendering)
  124858. * @param depth simulated refraction depth
  124859. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  124860. * @param camera The camera to apply the render pass to.
  124861. * @param options The required width/height ratio to downsize to before computing the render pass.
  124862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124863. * @param engine The engine which the post process will be applied. (default: current engine)
  124864. * @param reusable If the post process can be reused on the same frame. (default: false)
  124865. */
  124866. constructor(name: string, refractionTextureUrl: string,
  124867. /** the base color of the refraction (used to taint the rendering) */
  124868. color: Color3,
  124869. /** simulated refraction depth */
  124870. depth: number,
  124871. /** the coefficient of the base color (0 to remove base color tainting) */
  124872. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124873. /**
  124874. * Disposes of the post process
  124875. * @param camera Camera to dispose post process on
  124876. */
  124877. dispose(camera: Camera): void;
  124878. }
  124879. }
  124880. declare module BABYLON {
  124881. /** @hidden */
  124882. export var sharpenPixelShader: {
  124883. name: string;
  124884. shader: string;
  124885. };
  124886. }
  124887. declare module BABYLON {
  124888. /**
  124889. * The SharpenPostProcess applies a sharpen kernel to every pixel
  124890. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124891. */
  124892. export class SharpenPostProcess extends PostProcess {
  124893. /**
  124894. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  124895. */
  124896. colorAmount: number;
  124897. /**
  124898. * How much sharpness should be applied (default: 0.3)
  124899. */
  124900. edgeAmount: number;
  124901. /**
  124902. * Creates a new instance ConvolutionPostProcess
  124903. * @param name The name of the effect.
  124904. * @param options The required width/height ratio to downsize to before computing the render pass.
  124905. * @param camera The camera to apply the render pass to.
  124906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124907. * @param engine The engine which the post process will be applied. (default: current engine)
  124908. * @param reusable If the post process can be reused on the same frame. (default: false)
  124909. * @param textureType Type of textures used when performing the post process. (default: 0)
  124910. * @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)
  124911. */
  124912. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124913. }
  124914. }
  124915. declare module BABYLON {
  124916. /**
  124917. * PostProcessRenderPipeline
  124918. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124919. */
  124920. export class PostProcessRenderPipeline {
  124921. private engine;
  124922. private _renderEffects;
  124923. private _renderEffectsForIsolatedPass;
  124924. /**
  124925. * List of inspectable custom properties (used by the Inspector)
  124926. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  124927. */
  124928. inspectableCustomProperties: IInspectable[];
  124929. /**
  124930. * @hidden
  124931. */
  124932. protected _cameras: Camera[];
  124933. /** @hidden */
  124934. _name: string;
  124935. /**
  124936. * Gets pipeline name
  124937. */
  124938. readonly name: string;
  124939. /**
  124940. * Initializes a PostProcessRenderPipeline
  124941. * @param engine engine to add the pipeline to
  124942. * @param name name of the pipeline
  124943. */
  124944. constructor(engine: Engine, name: string);
  124945. /**
  124946. * Gets the class name
  124947. * @returns "PostProcessRenderPipeline"
  124948. */
  124949. getClassName(): string;
  124950. /**
  124951. * If all the render effects in the pipeline are supported
  124952. */
  124953. readonly isSupported: boolean;
  124954. /**
  124955. * Adds an effect to the pipeline
  124956. * @param renderEffect the effect to add
  124957. */
  124958. addEffect(renderEffect: PostProcessRenderEffect): void;
  124959. /** @hidden */
  124960. _rebuild(): void;
  124961. /** @hidden */
  124962. _enableEffect(renderEffectName: string, cameras: Camera): void;
  124963. /** @hidden */
  124964. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  124965. /** @hidden */
  124966. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124967. /** @hidden */
  124968. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124969. /** @hidden */
  124970. _attachCameras(cameras: Camera, unique: boolean): void;
  124971. /** @hidden */
  124972. _attachCameras(cameras: Camera[], unique: boolean): void;
  124973. /** @hidden */
  124974. _detachCameras(cameras: Camera): void;
  124975. /** @hidden */
  124976. _detachCameras(cameras: Nullable<Camera[]>): void;
  124977. /** @hidden */
  124978. _update(): void;
  124979. /** @hidden */
  124980. _reset(): void;
  124981. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  124982. /**
  124983. * Disposes of the pipeline
  124984. */
  124985. dispose(): void;
  124986. }
  124987. }
  124988. declare module BABYLON {
  124989. /**
  124990. * PostProcessRenderPipelineManager class
  124991. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124992. */
  124993. export class PostProcessRenderPipelineManager {
  124994. private _renderPipelines;
  124995. /**
  124996. * Initializes a PostProcessRenderPipelineManager
  124997. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124998. */
  124999. constructor();
  125000. /**
  125001. * Gets the list of supported render pipelines
  125002. */
  125003. readonly supportedPipelines: PostProcessRenderPipeline[];
  125004. /**
  125005. * Adds a pipeline to the manager
  125006. * @param renderPipeline The pipeline to add
  125007. */
  125008. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  125009. /**
  125010. * Attaches a camera to the pipeline
  125011. * @param renderPipelineName The name of the pipeline to attach to
  125012. * @param cameras the camera to attach
  125013. * @param unique if the camera can be attached multiple times to the pipeline
  125014. */
  125015. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  125016. /**
  125017. * Detaches a camera from the pipeline
  125018. * @param renderPipelineName The name of the pipeline to detach from
  125019. * @param cameras the camera to detach
  125020. */
  125021. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  125022. /**
  125023. * Enables an effect by name on a pipeline
  125024. * @param renderPipelineName the name of the pipeline to enable the effect in
  125025. * @param renderEffectName the name of the effect to enable
  125026. * @param cameras the cameras that the effect should be enabled on
  125027. */
  125028. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  125029. /**
  125030. * Disables an effect by name on a pipeline
  125031. * @param renderPipelineName the name of the pipeline to disable the effect in
  125032. * @param renderEffectName the name of the effect to disable
  125033. * @param cameras the cameras that the effect should be disabled on
  125034. */
  125035. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  125036. /**
  125037. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  125038. */
  125039. update(): void;
  125040. /** @hidden */
  125041. _rebuild(): void;
  125042. /**
  125043. * Disposes of the manager and pipelines
  125044. */
  125045. dispose(): void;
  125046. }
  125047. }
  125048. declare module BABYLON {
  125049. interface Scene {
  125050. /** @hidden (Backing field) */
  125051. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  125052. /**
  125053. * Gets the postprocess render pipeline manager
  125054. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125055. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  125056. */
  125057. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  125058. }
  125059. /**
  125060. * Defines the Render Pipeline scene component responsible to rendering pipelines
  125061. */
  125062. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  125063. /**
  125064. * The component name helpfull to identify the component in the list of scene components.
  125065. */
  125066. readonly name: string;
  125067. /**
  125068. * The scene the component belongs to.
  125069. */
  125070. scene: Scene;
  125071. /**
  125072. * Creates a new instance of the component for the given scene
  125073. * @param scene Defines the scene to register the component in
  125074. */
  125075. constructor(scene: Scene);
  125076. /**
  125077. * Registers the component in a given scene
  125078. */
  125079. register(): void;
  125080. /**
  125081. * Rebuilds the elements related to this component in case of
  125082. * context lost for instance.
  125083. */
  125084. rebuild(): void;
  125085. /**
  125086. * Disposes the component and the associated ressources
  125087. */
  125088. dispose(): void;
  125089. private _gatherRenderTargets;
  125090. }
  125091. }
  125092. declare module BABYLON {
  125093. /**
  125094. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  125095. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  125096. */
  125097. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125098. private _scene;
  125099. private _camerasToBeAttached;
  125100. /**
  125101. * ID of the sharpen post process,
  125102. */
  125103. private readonly SharpenPostProcessId;
  125104. /**
  125105. * @ignore
  125106. * ID of the image processing post process;
  125107. */
  125108. readonly ImageProcessingPostProcessId: string;
  125109. /**
  125110. * @ignore
  125111. * ID of the Fast Approximate Anti-Aliasing post process;
  125112. */
  125113. readonly FxaaPostProcessId: string;
  125114. /**
  125115. * ID of the chromatic aberration post process,
  125116. */
  125117. private readonly ChromaticAberrationPostProcessId;
  125118. /**
  125119. * ID of the grain post process
  125120. */
  125121. private readonly GrainPostProcessId;
  125122. /**
  125123. * Sharpen post process which will apply a sharpen convolution to enhance edges
  125124. */
  125125. sharpen: SharpenPostProcess;
  125126. private _sharpenEffect;
  125127. private bloom;
  125128. /**
  125129. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  125130. */
  125131. depthOfField: DepthOfFieldEffect;
  125132. /**
  125133. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125134. */
  125135. fxaa: FxaaPostProcess;
  125136. /**
  125137. * Image post processing pass used to perform operations such as tone mapping or color grading.
  125138. */
  125139. imageProcessing: ImageProcessingPostProcess;
  125140. /**
  125141. * Chromatic aberration post process which will shift rgb colors in the image
  125142. */
  125143. chromaticAberration: ChromaticAberrationPostProcess;
  125144. private _chromaticAberrationEffect;
  125145. /**
  125146. * Grain post process which add noise to the image
  125147. */
  125148. grain: GrainPostProcess;
  125149. private _grainEffect;
  125150. /**
  125151. * Glow post process which adds a glow to emissive areas of the image
  125152. */
  125153. private _glowLayer;
  125154. /**
  125155. * Animations which can be used to tweak settings over a period of time
  125156. */
  125157. animations: Animation[];
  125158. private _imageProcessingConfigurationObserver;
  125159. private _sharpenEnabled;
  125160. private _bloomEnabled;
  125161. private _depthOfFieldEnabled;
  125162. private _depthOfFieldBlurLevel;
  125163. private _fxaaEnabled;
  125164. private _imageProcessingEnabled;
  125165. private _defaultPipelineTextureType;
  125166. private _bloomScale;
  125167. private _chromaticAberrationEnabled;
  125168. private _grainEnabled;
  125169. private _buildAllowed;
  125170. /**
  125171. * Gets active scene
  125172. */
  125173. readonly scene: Scene;
  125174. /**
  125175. * Enable or disable the sharpen process from the pipeline
  125176. */
  125177. sharpenEnabled: boolean;
  125178. private _resizeObserver;
  125179. private _hardwareScaleLevel;
  125180. private _bloomKernel;
  125181. /**
  125182. * Specifies the size of the bloom blur kernel, relative to the final output size
  125183. */
  125184. bloomKernel: number;
  125185. /**
  125186. * Specifies the weight of the bloom in the final rendering
  125187. */
  125188. private _bloomWeight;
  125189. /**
  125190. * Specifies the luma threshold for the area that will be blurred by the bloom
  125191. */
  125192. private _bloomThreshold;
  125193. private _hdr;
  125194. /**
  125195. * The strength of the bloom.
  125196. */
  125197. bloomWeight: number;
  125198. /**
  125199. * The strength of the bloom.
  125200. */
  125201. bloomThreshold: number;
  125202. /**
  125203. * The scale of the bloom, lower value will provide better performance.
  125204. */
  125205. bloomScale: number;
  125206. /**
  125207. * Enable or disable the bloom from the pipeline
  125208. */
  125209. bloomEnabled: boolean;
  125210. private _rebuildBloom;
  125211. /**
  125212. * If the depth of field is enabled.
  125213. */
  125214. depthOfFieldEnabled: boolean;
  125215. /**
  125216. * Blur level of the depth of field effect. (Higher blur will effect performance)
  125217. */
  125218. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  125219. /**
  125220. * If the anti aliasing is enabled.
  125221. */
  125222. fxaaEnabled: boolean;
  125223. private _samples;
  125224. /**
  125225. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125226. */
  125227. samples: number;
  125228. /**
  125229. * If image processing is enabled.
  125230. */
  125231. imageProcessingEnabled: boolean;
  125232. /**
  125233. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  125234. */
  125235. glowLayerEnabled: boolean;
  125236. /**
  125237. * Gets the glow layer (or null if not defined)
  125238. */
  125239. readonly glowLayer: Nullable<GlowLayer>;
  125240. /**
  125241. * Enable or disable the chromaticAberration process from the pipeline
  125242. */
  125243. chromaticAberrationEnabled: boolean;
  125244. /**
  125245. * Enable or disable the grain process from the pipeline
  125246. */
  125247. grainEnabled: boolean;
  125248. /**
  125249. * @constructor
  125250. * @param name - The rendering pipeline name (default: "")
  125251. * @param hdr - If high dynamic range textures should be used (default: true)
  125252. * @param scene - The scene linked to this pipeline (default: the last created scene)
  125253. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  125254. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  125255. */
  125256. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  125257. /**
  125258. * Get the class name
  125259. * @returns "DefaultRenderingPipeline"
  125260. */
  125261. getClassName(): string;
  125262. /**
  125263. * Force the compilation of the entire pipeline.
  125264. */
  125265. prepare(): void;
  125266. private _hasCleared;
  125267. private _prevPostProcess;
  125268. private _prevPrevPostProcess;
  125269. private _setAutoClearAndTextureSharing;
  125270. private _depthOfFieldSceneObserver;
  125271. private _buildPipeline;
  125272. private _disposePostProcesses;
  125273. /**
  125274. * Adds a camera to the pipeline
  125275. * @param camera the camera to be added
  125276. */
  125277. addCamera(camera: Camera): void;
  125278. /**
  125279. * Removes a camera from the pipeline
  125280. * @param camera the camera to remove
  125281. */
  125282. removeCamera(camera: Camera): void;
  125283. /**
  125284. * Dispose of the pipeline and stop all post processes
  125285. */
  125286. dispose(): void;
  125287. /**
  125288. * Serialize the rendering pipeline (Used when exporting)
  125289. * @returns the serialized object
  125290. */
  125291. serialize(): any;
  125292. /**
  125293. * Parse the serialized pipeline
  125294. * @param source Source pipeline.
  125295. * @param scene The scene to load the pipeline to.
  125296. * @param rootUrl The URL of the serialized pipeline.
  125297. * @returns An instantiated pipeline from the serialized object.
  125298. */
  125299. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  125300. }
  125301. }
  125302. declare module BABYLON {
  125303. /** @hidden */
  125304. export var lensHighlightsPixelShader: {
  125305. name: string;
  125306. shader: string;
  125307. };
  125308. }
  125309. declare module BABYLON {
  125310. /** @hidden */
  125311. export var depthOfFieldPixelShader: {
  125312. name: string;
  125313. shader: string;
  125314. };
  125315. }
  125316. declare module BABYLON {
  125317. /**
  125318. * BABYLON.JS Chromatic Aberration GLSL Shader
  125319. * Author: Olivier Guyot
  125320. * Separates very slightly R, G and B colors on the edges of the screen
  125321. * Inspired by Francois Tarlier & Martins Upitis
  125322. */
  125323. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  125324. /**
  125325. * @ignore
  125326. * The chromatic aberration PostProcess id in the pipeline
  125327. */
  125328. LensChromaticAberrationEffect: string;
  125329. /**
  125330. * @ignore
  125331. * The highlights enhancing PostProcess id in the pipeline
  125332. */
  125333. HighlightsEnhancingEffect: string;
  125334. /**
  125335. * @ignore
  125336. * The depth-of-field PostProcess id in the pipeline
  125337. */
  125338. LensDepthOfFieldEffect: string;
  125339. private _scene;
  125340. private _depthTexture;
  125341. private _grainTexture;
  125342. private _chromaticAberrationPostProcess;
  125343. private _highlightsPostProcess;
  125344. private _depthOfFieldPostProcess;
  125345. private _edgeBlur;
  125346. private _grainAmount;
  125347. private _chromaticAberration;
  125348. private _distortion;
  125349. private _highlightsGain;
  125350. private _highlightsThreshold;
  125351. private _dofDistance;
  125352. private _dofAperture;
  125353. private _dofDarken;
  125354. private _dofPentagon;
  125355. private _blurNoise;
  125356. /**
  125357. * @constructor
  125358. *
  125359. * Effect parameters are as follow:
  125360. * {
  125361. * chromatic_aberration: number; // from 0 to x (1 for realism)
  125362. * edge_blur: number; // from 0 to x (1 for realism)
  125363. * distortion: number; // from 0 to x (1 for realism)
  125364. * grain_amount: number; // from 0 to 1
  125365. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  125366. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  125367. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  125368. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  125369. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  125370. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  125371. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  125372. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  125373. * }
  125374. * Note: if an effect parameter is unset, effect is disabled
  125375. *
  125376. * @param name The rendering pipeline name
  125377. * @param parameters - An object containing all parameters (see above)
  125378. * @param scene The scene linked to this pipeline
  125379. * @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)
  125380. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125381. */
  125382. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  125383. /**
  125384. * Get the class name
  125385. * @returns "LensRenderingPipeline"
  125386. */
  125387. getClassName(): string;
  125388. /**
  125389. * Gets associated scene
  125390. */
  125391. readonly scene: Scene;
  125392. /**
  125393. * Gets or sets the edge blur
  125394. */
  125395. edgeBlur: number;
  125396. /**
  125397. * Gets or sets the grain amount
  125398. */
  125399. grainAmount: number;
  125400. /**
  125401. * Gets or sets the chromatic aberration amount
  125402. */
  125403. chromaticAberration: number;
  125404. /**
  125405. * Gets or sets the depth of field aperture
  125406. */
  125407. dofAperture: number;
  125408. /**
  125409. * Gets or sets the edge distortion
  125410. */
  125411. edgeDistortion: number;
  125412. /**
  125413. * Gets or sets the depth of field distortion
  125414. */
  125415. dofDistortion: number;
  125416. /**
  125417. * Gets or sets the darken out of focus amount
  125418. */
  125419. darkenOutOfFocus: number;
  125420. /**
  125421. * Gets or sets a boolean indicating if blur noise is enabled
  125422. */
  125423. blurNoise: boolean;
  125424. /**
  125425. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  125426. */
  125427. pentagonBokeh: boolean;
  125428. /**
  125429. * Gets or sets the highlight grain amount
  125430. */
  125431. highlightsGain: number;
  125432. /**
  125433. * Gets or sets the highlight threshold
  125434. */
  125435. highlightsThreshold: number;
  125436. /**
  125437. * Sets the amount of blur at the edges
  125438. * @param amount blur amount
  125439. */
  125440. setEdgeBlur(amount: number): void;
  125441. /**
  125442. * Sets edge blur to 0
  125443. */
  125444. disableEdgeBlur(): void;
  125445. /**
  125446. * Sets the amout of grain
  125447. * @param amount Amount of grain
  125448. */
  125449. setGrainAmount(amount: number): void;
  125450. /**
  125451. * Set grain amount to 0
  125452. */
  125453. disableGrain(): void;
  125454. /**
  125455. * Sets the chromatic aberration amount
  125456. * @param amount amount of chromatic aberration
  125457. */
  125458. setChromaticAberration(amount: number): void;
  125459. /**
  125460. * Sets chromatic aberration amount to 0
  125461. */
  125462. disableChromaticAberration(): void;
  125463. /**
  125464. * Sets the EdgeDistortion amount
  125465. * @param amount amount of EdgeDistortion
  125466. */
  125467. setEdgeDistortion(amount: number): void;
  125468. /**
  125469. * Sets edge distortion to 0
  125470. */
  125471. disableEdgeDistortion(): void;
  125472. /**
  125473. * Sets the FocusDistance amount
  125474. * @param amount amount of FocusDistance
  125475. */
  125476. setFocusDistance(amount: number): void;
  125477. /**
  125478. * Disables depth of field
  125479. */
  125480. disableDepthOfField(): void;
  125481. /**
  125482. * Sets the Aperture amount
  125483. * @param amount amount of Aperture
  125484. */
  125485. setAperture(amount: number): void;
  125486. /**
  125487. * Sets the DarkenOutOfFocus amount
  125488. * @param amount amount of DarkenOutOfFocus
  125489. */
  125490. setDarkenOutOfFocus(amount: number): void;
  125491. private _pentagonBokehIsEnabled;
  125492. /**
  125493. * Creates a pentagon bokeh effect
  125494. */
  125495. enablePentagonBokeh(): void;
  125496. /**
  125497. * Disables the pentagon bokeh effect
  125498. */
  125499. disablePentagonBokeh(): void;
  125500. /**
  125501. * Enables noise blur
  125502. */
  125503. enableNoiseBlur(): void;
  125504. /**
  125505. * Disables noise blur
  125506. */
  125507. disableNoiseBlur(): void;
  125508. /**
  125509. * Sets the HighlightsGain amount
  125510. * @param amount amount of HighlightsGain
  125511. */
  125512. setHighlightsGain(amount: number): void;
  125513. /**
  125514. * Sets the HighlightsThreshold amount
  125515. * @param amount amount of HighlightsThreshold
  125516. */
  125517. setHighlightsThreshold(amount: number): void;
  125518. /**
  125519. * Disables highlights
  125520. */
  125521. disableHighlights(): void;
  125522. /**
  125523. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  125524. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  125525. */
  125526. dispose(disableDepthRender?: boolean): void;
  125527. private _createChromaticAberrationPostProcess;
  125528. private _createHighlightsPostProcess;
  125529. private _createDepthOfFieldPostProcess;
  125530. private _createGrainTexture;
  125531. }
  125532. }
  125533. declare module BABYLON {
  125534. /** @hidden */
  125535. export var ssao2PixelShader: {
  125536. name: string;
  125537. shader: string;
  125538. };
  125539. }
  125540. declare module BABYLON {
  125541. /** @hidden */
  125542. export var ssaoCombinePixelShader: {
  125543. name: string;
  125544. shader: string;
  125545. };
  125546. }
  125547. declare module BABYLON {
  125548. /**
  125549. * Render pipeline to produce ssao effect
  125550. */
  125551. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  125552. /**
  125553. * @ignore
  125554. * The PassPostProcess id in the pipeline that contains the original scene color
  125555. */
  125556. SSAOOriginalSceneColorEffect: string;
  125557. /**
  125558. * @ignore
  125559. * The SSAO PostProcess id in the pipeline
  125560. */
  125561. SSAORenderEffect: string;
  125562. /**
  125563. * @ignore
  125564. * The horizontal blur PostProcess id in the pipeline
  125565. */
  125566. SSAOBlurHRenderEffect: string;
  125567. /**
  125568. * @ignore
  125569. * The vertical blur PostProcess id in the pipeline
  125570. */
  125571. SSAOBlurVRenderEffect: string;
  125572. /**
  125573. * @ignore
  125574. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125575. */
  125576. SSAOCombineRenderEffect: string;
  125577. /**
  125578. * The output strength of the SSAO post-process. Default value is 1.0.
  125579. */
  125580. totalStrength: number;
  125581. /**
  125582. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  125583. */
  125584. maxZ: number;
  125585. /**
  125586. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  125587. */
  125588. minZAspect: number;
  125589. private _samples;
  125590. /**
  125591. * Number of samples used for the SSAO calculations. Default value is 8
  125592. */
  125593. samples: number;
  125594. private _textureSamples;
  125595. /**
  125596. * Number of samples to use for antialiasing
  125597. */
  125598. textureSamples: number;
  125599. /**
  125600. * Ratio object used for SSAO ratio and blur ratio
  125601. */
  125602. private _ratio;
  125603. /**
  125604. * Dynamically generated sphere sampler.
  125605. */
  125606. private _sampleSphere;
  125607. /**
  125608. * Blur filter offsets
  125609. */
  125610. private _samplerOffsets;
  125611. private _expensiveBlur;
  125612. /**
  125613. * If bilateral blur should be used
  125614. */
  125615. expensiveBlur: boolean;
  125616. /**
  125617. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  125618. */
  125619. radius: number;
  125620. /**
  125621. * The base color of the SSAO post-process
  125622. * The final result is "base + ssao" between [0, 1]
  125623. */
  125624. base: number;
  125625. /**
  125626. * Support test.
  125627. */
  125628. static readonly IsSupported: boolean;
  125629. private _scene;
  125630. private _depthTexture;
  125631. private _normalTexture;
  125632. private _randomTexture;
  125633. private _originalColorPostProcess;
  125634. private _ssaoPostProcess;
  125635. private _blurHPostProcess;
  125636. private _blurVPostProcess;
  125637. private _ssaoCombinePostProcess;
  125638. private _firstUpdate;
  125639. /**
  125640. * Gets active scene
  125641. */
  125642. readonly scene: Scene;
  125643. /**
  125644. * @constructor
  125645. * @param name The rendering pipeline name
  125646. * @param scene The scene linked to this pipeline
  125647. * @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 }
  125648. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125649. */
  125650. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125651. /**
  125652. * Get the class name
  125653. * @returns "SSAO2RenderingPipeline"
  125654. */
  125655. getClassName(): string;
  125656. /**
  125657. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125658. */
  125659. dispose(disableGeometryBufferRenderer?: boolean): void;
  125660. private _createBlurPostProcess;
  125661. /** @hidden */
  125662. _rebuild(): void;
  125663. private _bits;
  125664. private _radicalInverse_VdC;
  125665. private _hammersley;
  125666. private _hemisphereSample_uniform;
  125667. private _generateHemisphere;
  125668. private _createSSAOPostProcess;
  125669. private _createSSAOCombinePostProcess;
  125670. private _createRandomTexture;
  125671. /**
  125672. * Serialize the rendering pipeline (Used when exporting)
  125673. * @returns the serialized object
  125674. */
  125675. serialize(): any;
  125676. /**
  125677. * Parse the serialized pipeline
  125678. * @param source Source pipeline.
  125679. * @param scene The scene to load the pipeline to.
  125680. * @param rootUrl The URL of the serialized pipeline.
  125681. * @returns An instantiated pipeline from the serialized object.
  125682. */
  125683. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  125684. }
  125685. }
  125686. declare module BABYLON {
  125687. /** @hidden */
  125688. export var ssaoPixelShader: {
  125689. name: string;
  125690. shader: string;
  125691. };
  125692. }
  125693. declare module BABYLON {
  125694. /**
  125695. * Render pipeline to produce ssao effect
  125696. */
  125697. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  125698. /**
  125699. * @ignore
  125700. * The PassPostProcess id in the pipeline that contains the original scene color
  125701. */
  125702. SSAOOriginalSceneColorEffect: string;
  125703. /**
  125704. * @ignore
  125705. * The SSAO PostProcess id in the pipeline
  125706. */
  125707. SSAORenderEffect: string;
  125708. /**
  125709. * @ignore
  125710. * The horizontal blur PostProcess id in the pipeline
  125711. */
  125712. SSAOBlurHRenderEffect: string;
  125713. /**
  125714. * @ignore
  125715. * The vertical blur PostProcess id in the pipeline
  125716. */
  125717. SSAOBlurVRenderEffect: string;
  125718. /**
  125719. * @ignore
  125720. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125721. */
  125722. SSAOCombineRenderEffect: string;
  125723. /**
  125724. * The output strength of the SSAO post-process. Default value is 1.0.
  125725. */
  125726. totalStrength: number;
  125727. /**
  125728. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  125729. */
  125730. radius: number;
  125731. /**
  125732. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  125733. * Must not be equal to fallOff and superior to fallOff.
  125734. * Default value is 0.0075
  125735. */
  125736. area: number;
  125737. /**
  125738. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  125739. * Must not be equal to area and inferior to area.
  125740. * Default value is 0.000001
  125741. */
  125742. fallOff: number;
  125743. /**
  125744. * The base color of the SSAO post-process
  125745. * The final result is "base + ssao" between [0, 1]
  125746. */
  125747. base: number;
  125748. private _scene;
  125749. private _depthTexture;
  125750. private _randomTexture;
  125751. private _originalColorPostProcess;
  125752. private _ssaoPostProcess;
  125753. private _blurHPostProcess;
  125754. private _blurVPostProcess;
  125755. private _ssaoCombinePostProcess;
  125756. private _firstUpdate;
  125757. /**
  125758. * Gets active scene
  125759. */
  125760. readonly scene: Scene;
  125761. /**
  125762. * @constructor
  125763. * @param name - The rendering pipeline name
  125764. * @param scene - The scene linked to this pipeline
  125765. * @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 }
  125766. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  125767. */
  125768. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125769. /**
  125770. * Get the class name
  125771. * @returns "SSAORenderingPipeline"
  125772. */
  125773. getClassName(): string;
  125774. /**
  125775. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125776. */
  125777. dispose(disableDepthRender?: boolean): void;
  125778. private _createBlurPostProcess;
  125779. /** @hidden */
  125780. _rebuild(): void;
  125781. private _createSSAOPostProcess;
  125782. private _createSSAOCombinePostProcess;
  125783. private _createRandomTexture;
  125784. }
  125785. }
  125786. declare module BABYLON {
  125787. /** @hidden */
  125788. export var standardPixelShader: {
  125789. name: string;
  125790. shader: string;
  125791. };
  125792. }
  125793. declare module BABYLON {
  125794. /**
  125795. * Standard rendering pipeline
  125796. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125797. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  125798. */
  125799. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125800. /**
  125801. * Public members
  125802. */
  125803. /**
  125804. * Post-process which contains the original scene color before the pipeline applies all the effects
  125805. */
  125806. originalPostProcess: Nullable<PostProcess>;
  125807. /**
  125808. * Post-process used to down scale an image x4
  125809. */
  125810. downSampleX4PostProcess: Nullable<PostProcess>;
  125811. /**
  125812. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  125813. */
  125814. brightPassPostProcess: Nullable<PostProcess>;
  125815. /**
  125816. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  125817. */
  125818. blurHPostProcesses: PostProcess[];
  125819. /**
  125820. * Post-process array storing all the vertical blur post-processes used by the pipeline
  125821. */
  125822. blurVPostProcesses: PostProcess[];
  125823. /**
  125824. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  125825. */
  125826. textureAdderPostProcess: Nullable<PostProcess>;
  125827. /**
  125828. * Post-process used to create volumetric lighting effect
  125829. */
  125830. volumetricLightPostProcess: Nullable<PostProcess>;
  125831. /**
  125832. * Post-process used to smooth the previous volumetric light post-process on the X axis
  125833. */
  125834. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  125835. /**
  125836. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  125837. */
  125838. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  125839. /**
  125840. * Post-process used to merge the volumetric light effect and the real scene color
  125841. */
  125842. volumetricLightMergePostProces: Nullable<PostProcess>;
  125843. /**
  125844. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  125845. */
  125846. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  125847. /**
  125848. * Base post-process used to calculate the average luminance of the final image for HDR
  125849. */
  125850. luminancePostProcess: Nullable<PostProcess>;
  125851. /**
  125852. * Post-processes used to create down sample post-processes in order to get
  125853. * the average luminance of the final image for HDR
  125854. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  125855. */
  125856. luminanceDownSamplePostProcesses: PostProcess[];
  125857. /**
  125858. * Post-process used to create a HDR effect (light adaptation)
  125859. */
  125860. hdrPostProcess: Nullable<PostProcess>;
  125861. /**
  125862. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  125863. */
  125864. textureAdderFinalPostProcess: Nullable<PostProcess>;
  125865. /**
  125866. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  125867. */
  125868. lensFlareFinalPostProcess: Nullable<PostProcess>;
  125869. /**
  125870. * Post-process used to merge the final HDR post-process and the real scene color
  125871. */
  125872. hdrFinalPostProcess: Nullable<PostProcess>;
  125873. /**
  125874. * Post-process used to create a lens flare effect
  125875. */
  125876. lensFlarePostProcess: Nullable<PostProcess>;
  125877. /**
  125878. * Post-process that merges the result of the lens flare post-process and the real scene color
  125879. */
  125880. lensFlareComposePostProcess: Nullable<PostProcess>;
  125881. /**
  125882. * Post-process used to create a motion blur effect
  125883. */
  125884. motionBlurPostProcess: Nullable<PostProcess>;
  125885. /**
  125886. * Post-process used to create a depth of field effect
  125887. */
  125888. depthOfFieldPostProcess: Nullable<PostProcess>;
  125889. /**
  125890. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125891. */
  125892. fxaaPostProcess: Nullable<FxaaPostProcess>;
  125893. /**
  125894. * Represents the brightness threshold in order to configure the illuminated surfaces
  125895. */
  125896. brightThreshold: number;
  125897. /**
  125898. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  125899. */
  125900. blurWidth: number;
  125901. /**
  125902. * Sets if the blur for highlighted surfaces must be only horizontal
  125903. */
  125904. horizontalBlur: boolean;
  125905. /**
  125906. * Gets the overall exposure used by the pipeline
  125907. */
  125908. /**
  125909. * Sets the overall exposure used by the pipeline
  125910. */
  125911. exposure: number;
  125912. /**
  125913. * Texture used typically to simulate "dirty" on camera lens
  125914. */
  125915. lensTexture: Nullable<Texture>;
  125916. /**
  125917. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  125918. */
  125919. volumetricLightCoefficient: number;
  125920. /**
  125921. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  125922. */
  125923. volumetricLightPower: number;
  125924. /**
  125925. * Used the set the blur intensity to smooth the volumetric lights
  125926. */
  125927. volumetricLightBlurScale: number;
  125928. /**
  125929. * Light (spot or directional) used to generate the volumetric lights rays
  125930. * The source light must have a shadow generate so the pipeline can get its
  125931. * depth map
  125932. */
  125933. sourceLight: Nullable<SpotLight | DirectionalLight>;
  125934. /**
  125935. * For eye adaptation, represents the minimum luminance the eye can see
  125936. */
  125937. hdrMinimumLuminance: number;
  125938. /**
  125939. * For eye adaptation, represents the decrease luminance speed
  125940. */
  125941. hdrDecreaseRate: number;
  125942. /**
  125943. * For eye adaptation, represents the increase luminance speed
  125944. */
  125945. hdrIncreaseRate: number;
  125946. /**
  125947. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125948. */
  125949. /**
  125950. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125951. */
  125952. hdrAutoExposure: boolean;
  125953. /**
  125954. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  125955. */
  125956. lensColorTexture: Nullable<Texture>;
  125957. /**
  125958. * The overall strengh for the lens flare effect
  125959. */
  125960. lensFlareStrength: number;
  125961. /**
  125962. * Dispersion coefficient for lens flare ghosts
  125963. */
  125964. lensFlareGhostDispersal: number;
  125965. /**
  125966. * Main lens flare halo width
  125967. */
  125968. lensFlareHaloWidth: number;
  125969. /**
  125970. * Based on the lens distortion effect, defines how much the lens flare result
  125971. * is distorted
  125972. */
  125973. lensFlareDistortionStrength: number;
  125974. /**
  125975. * Configures the blur intensity used for for lens flare (halo)
  125976. */
  125977. lensFlareBlurWidth: number;
  125978. /**
  125979. * Lens star texture must be used to simulate rays on the flares and is available
  125980. * in the documentation
  125981. */
  125982. lensStarTexture: Nullable<Texture>;
  125983. /**
  125984. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  125985. * flare effect by taking account of the dirt texture
  125986. */
  125987. lensFlareDirtTexture: Nullable<Texture>;
  125988. /**
  125989. * Represents the focal length for the depth of field effect
  125990. */
  125991. depthOfFieldDistance: number;
  125992. /**
  125993. * Represents the blur intensity for the blurred part of the depth of field effect
  125994. */
  125995. depthOfFieldBlurWidth: number;
  125996. /**
  125997. * Gets how much the image is blurred by the movement while using the motion blur post-process
  125998. */
  125999. /**
  126000. * Sets how much the image is blurred by the movement while using the motion blur post-process
  126001. */
  126002. motionStrength: number;
  126003. /**
  126004. * Gets wether or not the motion blur post-process is object based or screen based.
  126005. */
  126006. /**
  126007. * Sets wether or not the motion blur post-process should be object based or screen based
  126008. */
  126009. objectBasedMotionBlur: boolean;
  126010. /**
  126011. * List of animations for the pipeline (IAnimatable implementation)
  126012. */
  126013. animations: Animation[];
  126014. /**
  126015. * Private members
  126016. */
  126017. private _scene;
  126018. private _currentDepthOfFieldSource;
  126019. private _basePostProcess;
  126020. private _fixedExposure;
  126021. private _currentExposure;
  126022. private _hdrAutoExposure;
  126023. private _hdrCurrentLuminance;
  126024. private _motionStrength;
  126025. private _isObjectBasedMotionBlur;
  126026. private _floatTextureType;
  126027. private _camerasToBeAttached;
  126028. private _ratio;
  126029. private _bloomEnabled;
  126030. private _depthOfFieldEnabled;
  126031. private _vlsEnabled;
  126032. private _lensFlareEnabled;
  126033. private _hdrEnabled;
  126034. private _motionBlurEnabled;
  126035. private _fxaaEnabled;
  126036. private _motionBlurSamples;
  126037. private _volumetricLightStepsCount;
  126038. private _samples;
  126039. /**
  126040. * @ignore
  126041. * Specifies if the bloom pipeline is enabled
  126042. */
  126043. BloomEnabled: boolean;
  126044. /**
  126045. * @ignore
  126046. * Specifies if the depth of field pipeline is enabed
  126047. */
  126048. DepthOfFieldEnabled: boolean;
  126049. /**
  126050. * @ignore
  126051. * Specifies if the lens flare pipeline is enabed
  126052. */
  126053. LensFlareEnabled: boolean;
  126054. /**
  126055. * @ignore
  126056. * Specifies if the HDR pipeline is enabled
  126057. */
  126058. HDREnabled: boolean;
  126059. /**
  126060. * @ignore
  126061. * Specifies if the volumetric lights scattering effect is enabled
  126062. */
  126063. VLSEnabled: boolean;
  126064. /**
  126065. * @ignore
  126066. * Specifies if the motion blur effect is enabled
  126067. */
  126068. MotionBlurEnabled: boolean;
  126069. /**
  126070. * Specifies if anti-aliasing is enabled
  126071. */
  126072. fxaaEnabled: boolean;
  126073. /**
  126074. * Specifies the number of steps used to calculate the volumetric lights
  126075. * Typically in interval [50, 200]
  126076. */
  126077. volumetricLightStepsCount: number;
  126078. /**
  126079. * Specifies the number of samples used for the motion blur effect
  126080. * Typically in interval [16, 64]
  126081. */
  126082. motionBlurSamples: number;
  126083. /**
  126084. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126085. */
  126086. samples: number;
  126087. /**
  126088. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  126089. * @constructor
  126090. * @param name The rendering pipeline name
  126091. * @param scene The scene linked to this pipeline
  126092. * @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)
  126093. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  126094. * @param cameras The array of cameras that the rendering pipeline will be attached to
  126095. */
  126096. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  126097. private _buildPipeline;
  126098. private _createDownSampleX4PostProcess;
  126099. private _createBrightPassPostProcess;
  126100. private _createBlurPostProcesses;
  126101. private _createTextureAdderPostProcess;
  126102. private _createVolumetricLightPostProcess;
  126103. private _createLuminancePostProcesses;
  126104. private _createHdrPostProcess;
  126105. private _createLensFlarePostProcess;
  126106. private _createDepthOfFieldPostProcess;
  126107. private _createMotionBlurPostProcess;
  126108. private _getDepthTexture;
  126109. private _disposePostProcesses;
  126110. /**
  126111. * Dispose of the pipeline and stop all post processes
  126112. */
  126113. dispose(): void;
  126114. /**
  126115. * Serialize the rendering pipeline (Used when exporting)
  126116. * @returns the serialized object
  126117. */
  126118. serialize(): any;
  126119. /**
  126120. * Parse the serialized pipeline
  126121. * @param source Source pipeline.
  126122. * @param scene The scene to load the pipeline to.
  126123. * @param rootUrl The URL of the serialized pipeline.
  126124. * @returns An instantiated pipeline from the serialized object.
  126125. */
  126126. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  126127. /**
  126128. * Luminance steps
  126129. */
  126130. static LuminanceSteps: number;
  126131. }
  126132. }
  126133. declare module BABYLON {
  126134. /** @hidden */
  126135. export var tonemapPixelShader: {
  126136. name: string;
  126137. shader: string;
  126138. };
  126139. }
  126140. declare module BABYLON {
  126141. /** Defines operator used for tonemapping */
  126142. export enum TonemappingOperator {
  126143. /** Hable */
  126144. Hable = 0,
  126145. /** Reinhard */
  126146. Reinhard = 1,
  126147. /** HejiDawson */
  126148. HejiDawson = 2,
  126149. /** Photographic */
  126150. Photographic = 3
  126151. }
  126152. /**
  126153. * Defines a post process to apply tone mapping
  126154. */
  126155. export class TonemapPostProcess extends PostProcess {
  126156. private _operator;
  126157. /** Defines the required exposure adjustement */
  126158. exposureAdjustment: number;
  126159. /**
  126160. * Creates a new TonemapPostProcess
  126161. * @param name defines the name of the postprocess
  126162. * @param _operator defines the operator to use
  126163. * @param exposureAdjustment defines the required exposure adjustement
  126164. * @param camera defines the camera to use (can be null)
  126165. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  126166. * @param engine defines the hosting engine (can be ignore if camera is set)
  126167. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  126168. */
  126169. constructor(name: string, _operator: TonemappingOperator,
  126170. /** Defines the required exposure adjustement */
  126171. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  126172. }
  126173. }
  126174. declare module BABYLON {
  126175. /** @hidden */
  126176. export var depthVertexShader: {
  126177. name: string;
  126178. shader: string;
  126179. };
  126180. }
  126181. declare module BABYLON {
  126182. /** @hidden */
  126183. export var volumetricLightScatteringPixelShader: {
  126184. name: string;
  126185. shader: string;
  126186. };
  126187. }
  126188. declare module BABYLON {
  126189. /** @hidden */
  126190. export var volumetricLightScatteringPassVertexShader: {
  126191. name: string;
  126192. shader: string;
  126193. };
  126194. }
  126195. declare module BABYLON {
  126196. /** @hidden */
  126197. export var volumetricLightScatteringPassPixelShader: {
  126198. name: string;
  126199. shader: string;
  126200. };
  126201. }
  126202. declare module BABYLON {
  126203. /**
  126204. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  126205. */
  126206. export class VolumetricLightScatteringPostProcess extends PostProcess {
  126207. private _volumetricLightScatteringPass;
  126208. private _volumetricLightScatteringRTT;
  126209. private _viewPort;
  126210. private _screenCoordinates;
  126211. private _cachedDefines;
  126212. /**
  126213. * If not undefined, the mesh position is computed from the attached node position
  126214. */
  126215. attachedNode: {
  126216. position: Vector3;
  126217. };
  126218. /**
  126219. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  126220. */
  126221. customMeshPosition: Vector3;
  126222. /**
  126223. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  126224. */
  126225. useCustomMeshPosition: boolean;
  126226. /**
  126227. * If the post-process should inverse the light scattering direction
  126228. */
  126229. invert: boolean;
  126230. /**
  126231. * The internal mesh used by the post-process
  126232. */
  126233. mesh: Mesh;
  126234. /**
  126235. * @hidden
  126236. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  126237. */
  126238. useDiffuseColor: boolean;
  126239. /**
  126240. * Array containing the excluded meshes not rendered in the internal pass
  126241. */
  126242. excludedMeshes: AbstractMesh[];
  126243. /**
  126244. * Controls the overall intensity of the post-process
  126245. */
  126246. exposure: number;
  126247. /**
  126248. * Dissipates each sample's contribution in range [0, 1]
  126249. */
  126250. decay: number;
  126251. /**
  126252. * Controls the overall intensity of each sample
  126253. */
  126254. weight: number;
  126255. /**
  126256. * Controls the density of each sample
  126257. */
  126258. density: number;
  126259. /**
  126260. * @constructor
  126261. * @param name The post-process name
  126262. * @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)
  126263. * @param camera The camera that the post-process will be attached to
  126264. * @param mesh The mesh used to create the light scattering
  126265. * @param samples The post-process quality, default 100
  126266. * @param samplingModeThe post-process filtering mode
  126267. * @param engine The babylon engine
  126268. * @param reusable If the post-process is reusable
  126269. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  126270. */
  126271. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  126272. /**
  126273. * Returns the string "VolumetricLightScatteringPostProcess"
  126274. * @returns "VolumetricLightScatteringPostProcess"
  126275. */
  126276. getClassName(): string;
  126277. private _isReady;
  126278. /**
  126279. * Sets the new light position for light scattering effect
  126280. * @param position The new custom light position
  126281. */
  126282. setCustomMeshPosition(position: Vector3): void;
  126283. /**
  126284. * Returns the light position for light scattering effect
  126285. * @return Vector3 The custom light position
  126286. */
  126287. getCustomMeshPosition(): Vector3;
  126288. /**
  126289. * Disposes the internal assets and detaches the post-process from the camera
  126290. */
  126291. dispose(camera: Camera): void;
  126292. /**
  126293. * Returns the render target texture used by the post-process
  126294. * @return the render target texture used by the post-process
  126295. */
  126296. getPass(): RenderTargetTexture;
  126297. private _meshExcluded;
  126298. private _createPass;
  126299. private _updateMeshScreenCoordinates;
  126300. /**
  126301. * Creates a default mesh for the Volumeric Light Scattering post-process
  126302. * @param name The mesh name
  126303. * @param scene The scene where to create the mesh
  126304. * @return the default mesh
  126305. */
  126306. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  126307. }
  126308. }
  126309. declare module BABYLON {
  126310. interface Scene {
  126311. /** @hidden (Backing field) */
  126312. _boundingBoxRenderer: BoundingBoxRenderer;
  126313. /** @hidden (Backing field) */
  126314. _forceShowBoundingBoxes: boolean;
  126315. /**
  126316. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  126317. */
  126318. forceShowBoundingBoxes: boolean;
  126319. /**
  126320. * Gets the bounding box renderer associated with the scene
  126321. * @returns a BoundingBoxRenderer
  126322. */
  126323. getBoundingBoxRenderer(): BoundingBoxRenderer;
  126324. }
  126325. interface AbstractMesh {
  126326. /** @hidden (Backing field) */
  126327. _showBoundingBox: boolean;
  126328. /**
  126329. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  126330. */
  126331. showBoundingBox: boolean;
  126332. }
  126333. /**
  126334. * Component responsible of rendering the bounding box of the meshes in a scene.
  126335. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  126336. */
  126337. export class BoundingBoxRenderer implements ISceneComponent {
  126338. /**
  126339. * The component name helpfull to identify the component in the list of scene components.
  126340. */
  126341. readonly name: string;
  126342. /**
  126343. * The scene the component belongs to.
  126344. */
  126345. scene: Scene;
  126346. /**
  126347. * Color of the bounding box lines placed in front of an object
  126348. */
  126349. frontColor: Color3;
  126350. /**
  126351. * Color of the bounding box lines placed behind an object
  126352. */
  126353. backColor: Color3;
  126354. /**
  126355. * Defines if the renderer should show the back lines or not
  126356. */
  126357. showBackLines: boolean;
  126358. /**
  126359. * @hidden
  126360. */
  126361. renderList: SmartArray<BoundingBox>;
  126362. private _colorShader;
  126363. private _vertexBuffers;
  126364. private _indexBuffer;
  126365. private _fillIndexBuffer;
  126366. private _fillIndexData;
  126367. /**
  126368. * Instantiates a new bounding box renderer in a scene.
  126369. * @param scene the scene the renderer renders in
  126370. */
  126371. constructor(scene: Scene);
  126372. /**
  126373. * Registers the component in a given scene
  126374. */
  126375. register(): void;
  126376. private _evaluateSubMesh;
  126377. private _activeMesh;
  126378. private _prepareRessources;
  126379. private _createIndexBuffer;
  126380. /**
  126381. * Rebuilds the elements related to this component in case of
  126382. * context lost for instance.
  126383. */
  126384. rebuild(): void;
  126385. /**
  126386. * @hidden
  126387. */
  126388. reset(): void;
  126389. /**
  126390. * Render the bounding boxes of a specific rendering group
  126391. * @param renderingGroupId defines the rendering group to render
  126392. */
  126393. render(renderingGroupId: number): void;
  126394. /**
  126395. * In case of occlusion queries, we can render the occlusion bounding box through this method
  126396. * @param mesh Define the mesh to render the occlusion bounding box for
  126397. */
  126398. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  126399. /**
  126400. * Dispose and release the resources attached to this renderer.
  126401. */
  126402. dispose(): void;
  126403. }
  126404. }
  126405. declare module BABYLON {
  126406. /** @hidden */
  126407. export var depthPixelShader: {
  126408. name: string;
  126409. shader: string;
  126410. };
  126411. }
  126412. declare module BABYLON {
  126413. /**
  126414. * This represents a depth renderer in Babylon.
  126415. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126416. */
  126417. export class DepthRenderer {
  126418. private _scene;
  126419. private _depthMap;
  126420. private _effect;
  126421. private readonly _storeNonLinearDepth;
  126422. private readonly _clearColor;
  126423. /** Get if the depth renderer is using packed depth or not */
  126424. readonly isPacked: boolean;
  126425. private _cachedDefines;
  126426. private _camera;
  126427. /**
  126428. * Specifiess that the depth renderer will only be used within
  126429. * the camera it is created for.
  126430. * This can help forcing its rendering during the camera processing.
  126431. */
  126432. useOnlyInActiveCamera: boolean;
  126433. /** @hidden */
  126434. static _SceneComponentInitialization: (scene: Scene) => void;
  126435. /**
  126436. * Instantiates a depth renderer
  126437. * @param scene The scene the renderer belongs to
  126438. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126439. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126440. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126441. */
  126442. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126443. /**
  126444. * Creates the depth rendering effect and checks if the effect is ready.
  126445. * @param subMesh The submesh to be used to render the depth map of
  126446. * @param useInstances If multiple world instances should be used
  126447. * @returns if the depth renderer is ready to render the depth map
  126448. */
  126449. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126450. /**
  126451. * Gets the texture which the depth map will be written to.
  126452. * @returns The depth map texture
  126453. */
  126454. getDepthMap(): RenderTargetTexture;
  126455. /**
  126456. * Disposes of the depth renderer.
  126457. */
  126458. dispose(): void;
  126459. }
  126460. }
  126461. declare module BABYLON {
  126462. interface Scene {
  126463. /** @hidden (Backing field) */
  126464. _depthRenderer: {
  126465. [id: string]: DepthRenderer;
  126466. };
  126467. /**
  126468. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  126469. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  126470. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126471. * @returns the created depth renderer
  126472. */
  126473. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  126474. /**
  126475. * Disables a depth renderer for a given camera
  126476. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  126477. */
  126478. disableDepthRenderer(camera?: Nullable<Camera>): void;
  126479. }
  126480. /**
  126481. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  126482. * in several rendering techniques.
  126483. */
  126484. export class DepthRendererSceneComponent implements ISceneComponent {
  126485. /**
  126486. * The component name helpfull to identify the component in the list of scene components.
  126487. */
  126488. readonly name: string;
  126489. /**
  126490. * The scene the component belongs to.
  126491. */
  126492. scene: Scene;
  126493. /**
  126494. * Creates a new instance of the component for the given scene
  126495. * @param scene Defines the scene to register the component in
  126496. */
  126497. constructor(scene: Scene);
  126498. /**
  126499. * Registers the component in a given scene
  126500. */
  126501. register(): void;
  126502. /**
  126503. * Rebuilds the elements related to this component in case of
  126504. * context lost for instance.
  126505. */
  126506. rebuild(): void;
  126507. /**
  126508. * Disposes the component and the associated ressources
  126509. */
  126510. dispose(): void;
  126511. private _gatherRenderTargets;
  126512. private _gatherActiveCameraRenderTargets;
  126513. }
  126514. }
  126515. declare module BABYLON {
  126516. /** @hidden */
  126517. export var outlinePixelShader: {
  126518. name: string;
  126519. shader: string;
  126520. };
  126521. }
  126522. declare module BABYLON {
  126523. /** @hidden */
  126524. export var outlineVertexShader: {
  126525. name: string;
  126526. shader: string;
  126527. };
  126528. }
  126529. declare module BABYLON {
  126530. interface Scene {
  126531. /** @hidden */
  126532. _outlineRenderer: OutlineRenderer;
  126533. /**
  126534. * Gets the outline renderer associated with the scene
  126535. * @returns a OutlineRenderer
  126536. */
  126537. getOutlineRenderer(): OutlineRenderer;
  126538. }
  126539. interface AbstractMesh {
  126540. /** @hidden (Backing field) */
  126541. _renderOutline: boolean;
  126542. /**
  126543. * Gets or sets a boolean indicating if the outline must be rendered as well
  126544. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  126545. */
  126546. renderOutline: boolean;
  126547. /** @hidden (Backing field) */
  126548. _renderOverlay: boolean;
  126549. /**
  126550. * Gets or sets a boolean indicating if the overlay must be rendered as well
  126551. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  126552. */
  126553. renderOverlay: boolean;
  126554. }
  126555. /**
  126556. * This class is responsible to draw bothe outline/overlay of meshes.
  126557. * It should not be used directly but through the available method on mesh.
  126558. */
  126559. export class OutlineRenderer implements ISceneComponent {
  126560. /**
  126561. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  126562. */
  126563. private static _StencilReference;
  126564. /**
  126565. * The name of the component. Each component must have a unique name.
  126566. */
  126567. name: string;
  126568. /**
  126569. * The scene the component belongs to.
  126570. */
  126571. scene: Scene;
  126572. /**
  126573. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  126574. */
  126575. zOffset: number;
  126576. private _engine;
  126577. private _effect;
  126578. private _cachedDefines;
  126579. private _savedDepthWrite;
  126580. /**
  126581. * Instantiates a new outline renderer. (There could be only one per scene).
  126582. * @param scene Defines the scene it belongs to
  126583. */
  126584. constructor(scene: Scene);
  126585. /**
  126586. * Register the component to one instance of a scene.
  126587. */
  126588. register(): void;
  126589. /**
  126590. * Rebuilds the elements related to this component in case of
  126591. * context lost for instance.
  126592. */
  126593. rebuild(): void;
  126594. /**
  126595. * Disposes the component and the associated ressources.
  126596. */
  126597. dispose(): void;
  126598. /**
  126599. * Renders the outline in the canvas.
  126600. * @param subMesh Defines the sumesh to render
  126601. * @param batch Defines the batch of meshes in case of instances
  126602. * @param useOverlay Defines if the rendering is for the overlay or the outline
  126603. */
  126604. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  126605. /**
  126606. * Returns whether or not the outline renderer is ready for a given submesh.
  126607. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  126608. * @param subMesh Defines the submesh to check readyness for
  126609. * @param useInstances Defines wheter wee are trying to render instances or not
  126610. * @returns true if ready otherwise false
  126611. */
  126612. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126613. private _beforeRenderingMesh;
  126614. private _afterRenderingMesh;
  126615. }
  126616. }
  126617. declare module BABYLON {
  126618. /**
  126619. * Class used to manage multiple sprites of different sizes on the same spritesheet
  126620. * @see http://doc.babylonjs.com/babylon101/sprites
  126621. */
  126622. export class SpritePackedManager extends SpriteManager {
  126623. /** defines the packed manager's name */
  126624. name: string;
  126625. /**
  126626. * Creates a new sprite manager from a packed sprite sheet
  126627. * @param name defines the manager's name
  126628. * @param imgUrl defines the sprite sheet url
  126629. * @param capacity defines the maximum allowed number of sprites
  126630. * @param scene defines the hosting scene
  126631. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  126632. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  126633. * @param samplingMode defines the smapling mode to use with spritesheet
  126634. * @param fromPacked set to true; do not alter
  126635. */
  126636. constructor(
  126637. /** defines the packed manager's name */
  126638. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  126639. }
  126640. }
  126641. declare module BABYLON {
  126642. /**
  126643. * Defines the list of states available for a task inside a AssetsManager
  126644. */
  126645. export enum AssetTaskState {
  126646. /**
  126647. * Initialization
  126648. */
  126649. INIT = 0,
  126650. /**
  126651. * Running
  126652. */
  126653. RUNNING = 1,
  126654. /**
  126655. * Done
  126656. */
  126657. DONE = 2,
  126658. /**
  126659. * Error
  126660. */
  126661. ERROR = 3
  126662. }
  126663. /**
  126664. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  126665. */
  126666. export abstract class AbstractAssetTask {
  126667. /**
  126668. * Task name
  126669. */ name: string;
  126670. /**
  126671. * Callback called when the task is successful
  126672. */
  126673. onSuccess: (task: any) => void;
  126674. /**
  126675. * Callback called when the task is not successful
  126676. */
  126677. onError: (task: any, message?: string, exception?: any) => void;
  126678. /**
  126679. * Creates a new AssetsManager
  126680. * @param name defines the name of the task
  126681. */
  126682. constructor(
  126683. /**
  126684. * Task name
  126685. */ name: string);
  126686. private _isCompleted;
  126687. private _taskState;
  126688. private _errorObject;
  126689. /**
  126690. * Get if the task is completed
  126691. */
  126692. readonly isCompleted: boolean;
  126693. /**
  126694. * Gets the current state of the task
  126695. */
  126696. readonly taskState: AssetTaskState;
  126697. /**
  126698. * Gets the current error object (if task is in error)
  126699. */
  126700. readonly errorObject: {
  126701. message?: string;
  126702. exception?: any;
  126703. };
  126704. /**
  126705. * Internal only
  126706. * @hidden
  126707. */
  126708. _setErrorObject(message?: string, exception?: any): void;
  126709. /**
  126710. * Execute the current task
  126711. * @param scene defines the scene where you want your assets to be loaded
  126712. * @param onSuccess is a callback called when the task is successfully executed
  126713. * @param onError is a callback called if an error occurs
  126714. */
  126715. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126716. /**
  126717. * Execute the current task
  126718. * @param scene defines the scene where you want your assets to be loaded
  126719. * @param onSuccess is a callback called when the task is successfully executed
  126720. * @param onError is a callback called if an error occurs
  126721. */
  126722. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126723. /**
  126724. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  126725. * This can be used with failed tasks that have the reason for failure fixed.
  126726. */
  126727. reset(): void;
  126728. private onErrorCallback;
  126729. private onDoneCallback;
  126730. }
  126731. /**
  126732. * Define the interface used by progress events raised during assets loading
  126733. */
  126734. export interface IAssetsProgressEvent {
  126735. /**
  126736. * Defines the number of remaining tasks to process
  126737. */
  126738. remainingCount: number;
  126739. /**
  126740. * Defines the total number of tasks
  126741. */
  126742. totalCount: number;
  126743. /**
  126744. * Defines the task that was just processed
  126745. */
  126746. task: AbstractAssetTask;
  126747. }
  126748. /**
  126749. * Class used to share progress information about assets loading
  126750. */
  126751. export class AssetsProgressEvent implements IAssetsProgressEvent {
  126752. /**
  126753. * Defines the number of remaining tasks to process
  126754. */
  126755. remainingCount: number;
  126756. /**
  126757. * Defines the total number of tasks
  126758. */
  126759. totalCount: number;
  126760. /**
  126761. * Defines the task that was just processed
  126762. */
  126763. task: AbstractAssetTask;
  126764. /**
  126765. * Creates a AssetsProgressEvent
  126766. * @param remainingCount defines the number of remaining tasks to process
  126767. * @param totalCount defines the total number of tasks
  126768. * @param task defines the task that was just processed
  126769. */
  126770. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  126771. }
  126772. /**
  126773. * Define a task used by AssetsManager to load meshes
  126774. */
  126775. export class MeshAssetTask extends AbstractAssetTask {
  126776. /**
  126777. * Defines the name of the task
  126778. */
  126779. name: string;
  126780. /**
  126781. * Defines the list of mesh's names you want to load
  126782. */
  126783. meshesNames: any;
  126784. /**
  126785. * Defines the root url to use as a base to load your meshes and associated resources
  126786. */
  126787. rootUrl: string;
  126788. /**
  126789. * Defines the filename of the scene to load from
  126790. */
  126791. sceneFilename: string;
  126792. /**
  126793. * Gets the list of loaded meshes
  126794. */
  126795. loadedMeshes: Array<AbstractMesh>;
  126796. /**
  126797. * Gets the list of loaded particle systems
  126798. */
  126799. loadedParticleSystems: Array<IParticleSystem>;
  126800. /**
  126801. * Gets the list of loaded skeletons
  126802. */
  126803. loadedSkeletons: Array<Skeleton>;
  126804. /**
  126805. * Gets the list of loaded animation groups
  126806. */
  126807. loadedAnimationGroups: Array<AnimationGroup>;
  126808. /**
  126809. * Callback called when the task is successful
  126810. */
  126811. onSuccess: (task: MeshAssetTask) => void;
  126812. /**
  126813. * Callback called when the task is successful
  126814. */
  126815. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  126816. /**
  126817. * Creates a new MeshAssetTask
  126818. * @param name defines the name of the task
  126819. * @param meshesNames defines the list of mesh's names you want to load
  126820. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  126821. * @param sceneFilename defines the filename of the scene to load from
  126822. */
  126823. constructor(
  126824. /**
  126825. * Defines the name of the task
  126826. */
  126827. name: string,
  126828. /**
  126829. * Defines the list of mesh's names you want to load
  126830. */
  126831. meshesNames: any,
  126832. /**
  126833. * Defines the root url to use as a base to load your meshes and associated resources
  126834. */
  126835. rootUrl: string,
  126836. /**
  126837. * Defines the filename of the scene to load from
  126838. */
  126839. sceneFilename: string);
  126840. /**
  126841. * Execute the current task
  126842. * @param scene defines the scene where you want your assets to be loaded
  126843. * @param onSuccess is a callback called when the task is successfully executed
  126844. * @param onError is a callback called if an error occurs
  126845. */
  126846. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126847. }
  126848. /**
  126849. * Define a task used by AssetsManager to load text content
  126850. */
  126851. export class TextFileAssetTask extends AbstractAssetTask {
  126852. /**
  126853. * Defines the name of the task
  126854. */
  126855. name: string;
  126856. /**
  126857. * Defines the location of the file to load
  126858. */
  126859. url: string;
  126860. /**
  126861. * Gets the loaded text string
  126862. */
  126863. text: string;
  126864. /**
  126865. * Callback called when the task is successful
  126866. */
  126867. onSuccess: (task: TextFileAssetTask) => void;
  126868. /**
  126869. * Callback called when the task is successful
  126870. */
  126871. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  126872. /**
  126873. * Creates a new TextFileAssetTask object
  126874. * @param name defines the name of the task
  126875. * @param url defines the location of the file to load
  126876. */
  126877. constructor(
  126878. /**
  126879. * Defines the name of the task
  126880. */
  126881. name: string,
  126882. /**
  126883. * Defines the location of the file to load
  126884. */
  126885. url: string);
  126886. /**
  126887. * Execute the current task
  126888. * @param scene defines the scene where you want your assets to be loaded
  126889. * @param onSuccess is a callback called when the task is successfully executed
  126890. * @param onError is a callback called if an error occurs
  126891. */
  126892. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126893. }
  126894. /**
  126895. * Define a task used by AssetsManager to load binary data
  126896. */
  126897. export class BinaryFileAssetTask extends AbstractAssetTask {
  126898. /**
  126899. * Defines the name of the task
  126900. */
  126901. name: string;
  126902. /**
  126903. * Defines the location of the file to load
  126904. */
  126905. url: string;
  126906. /**
  126907. * Gets the lodaded data (as an array buffer)
  126908. */
  126909. data: ArrayBuffer;
  126910. /**
  126911. * Callback called when the task is successful
  126912. */
  126913. onSuccess: (task: BinaryFileAssetTask) => void;
  126914. /**
  126915. * Callback called when the task is successful
  126916. */
  126917. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  126918. /**
  126919. * Creates a new BinaryFileAssetTask object
  126920. * @param name defines the name of the new task
  126921. * @param url defines the location of the file to load
  126922. */
  126923. constructor(
  126924. /**
  126925. * Defines the name of the task
  126926. */
  126927. name: string,
  126928. /**
  126929. * Defines the location of the file to load
  126930. */
  126931. url: string);
  126932. /**
  126933. * Execute the current task
  126934. * @param scene defines the scene where you want your assets to be loaded
  126935. * @param onSuccess is a callback called when the task is successfully executed
  126936. * @param onError is a callback called if an error occurs
  126937. */
  126938. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126939. }
  126940. /**
  126941. * Define a task used by AssetsManager to load images
  126942. */
  126943. export class ImageAssetTask extends AbstractAssetTask {
  126944. /**
  126945. * Defines the name of the task
  126946. */
  126947. name: string;
  126948. /**
  126949. * Defines the location of the image to load
  126950. */
  126951. url: string;
  126952. /**
  126953. * Gets the loaded images
  126954. */
  126955. image: HTMLImageElement;
  126956. /**
  126957. * Callback called when the task is successful
  126958. */
  126959. onSuccess: (task: ImageAssetTask) => void;
  126960. /**
  126961. * Callback called when the task is successful
  126962. */
  126963. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  126964. /**
  126965. * Creates a new ImageAssetTask
  126966. * @param name defines the name of the task
  126967. * @param url defines the location of the image to load
  126968. */
  126969. constructor(
  126970. /**
  126971. * Defines the name of the task
  126972. */
  126973. name: string,
  126974. /**
  126975. * Defines the location of the image to load
  126976. */
  126977. url: string);
  126978. /**
  126979. * Execute the current task
  126980. * @param scene defines the scene where you want your assets to be loaded
  126981. * @param onSuccess is a callback called when the task is successfully executed
  126982. * @param onError is a callback called if an error occurs
  126983. */
  126984. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126985. }
  126986. /**
  126987. * Defines the interface used by texture loading tasks
  126988. */
  126989. export interface ITextureAssetTask<TEX extends BaseTexture> {
  126990. /**
  126991. * Gets the loaded texture
  126992. */
  126993. texture: TEX;
  126994. }
  126995. /**
  126996. * Define a task used by AssetsManager to load 2D textures
  126997. */
  126998. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  126999. /**
  127000. * Defines the name of the task
  127001. */
  127002. name: string;
  127003. /**
  127004. * Defines the location of the file to load
  127005. */
  127006. url: string;
  127007. /**
  127008. * Defines if mipmap should not be generated (default is false)
  127009. */
  127010. noMipmap?: boolean | undefined;
  127011. /**
  127012. * Defines if texture must be inverted on Y axis (default is false)
  127013. */
  127014. invertY?: boolean | undefined;
  127015. /**
  127016. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127017. */
  127018. samplingMode: number;
  127019. /**
  127020. * Gets the loaded texture
  127021. */
  127022. texture: Texture;
  127023. /**
  127024. * Callback called when the task is successful
  127025. */
  127026. onSuccess: (task: TextureAssetTask) => void;
  127027. /**
  127028. * Callback called when the task is successful
  127029. */
  127030. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  127031. /**
  127032. * Creates a new TextureAssetTask object
  127033. * @param name defines the name of the task
  127034. * @param url defines the location of the file to load
  127035. * @param noMipmap defines if mipmap should not be generated (default is false)
  127036. * @param invertY defines if texture must be inverted on Y axis (default is false)
  127037. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127038. */
  127039. constructor(
  127040. /**
  127041. * Defines the name of the task
  127042. */
  127043. name: string,
  127044. /**
  127045. * Defines the location of the file to load
  127046. */
  127047. url: string,
  127048. /**
  127049. * Defines if mipmap should not be generated (default is false)
  127050. */
  127051. noMipmap?: boolean | undefined,
  127052. /**
  127053. * Defines if texture must be inverted on Y axis (default is false)
  127054. */
  127055. invertY?: boolean | undefined,
  127056. /**
  127057. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127058. */
  127059. samplingMode?: number);
  127060. /**
  127061. * Execute the current task
  127062. * @param scene defines the scene where you want your assets to be loaded
  127063. * @param onSuccess is a callback called when the task is successfully executed
  127064. * @param onError is a callback called if an error occurs
  127065. */
  127066. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127067. }
  127068. /**
  127069. * Define a task used by AssetsManager to load cube textures
  127070. */
  127071. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  127072. /**
  127073. * Defines the name of the task
  127074. */
  127075. name: string;
  127076. /**
  127077. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127078. */
  127079. url: string;
  127080. /**
  127081. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  127082. */
  127083. extensions?: string[] | undefined;
  127084. /**
  127085. * Defines if mipmaps should not be generated (default is false)
  127086. */
  127087. noMipmap?: boolean | undefined;
  127088. /**
  127089. * Defines the explicit list of files (undefined by default)
  127090. */
  127091. files?: string[] | undefined;
  127092. /**
  127093. * Gets the loaded texture
  127094. */
  127095. texture: CubeTexture;
  127096. /**
  127097. * Callback called when the task is successful
  127098. */
  127099. onSuccess: (task: CubeTextureAssetTask) => void;
  127100. /**
  127101. * Callback called when the task is successful
  127102. */
  127103. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  127104. /**
  127105. * Creates a new CubeTextureAssetTask
  127106. * @param name defines the name of the task
  127107. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127108. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  127109. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127110. * @param files defines the explicit list of files (undefined by default)
  127111. */
  127112. constructor(
  127113. /**
  127114. * Defines the name of the task
  127115. */
  127116. name: string,
  127117. /**
  127118. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127119. */
  127120. url: string,
  127121. /**
  127122. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  127123. */
  127124. extensions?: string[] | undefined,
  127125. /**
  127126. * Defines if mipmaps should not be generated (default is false)
  127127. */
  127128. noMipmap?: boolean | undefined,
  127129. /**
  127130. * Defines the explicit list of files (undefined by default)
  127131. */
  127132. files?: string[] | undefined);
  127133. /**
  127134. * Execute the current task
  127135. * @param scene defines the scene where you want your assets to be loaded
  127136. * @param onSuccess is a callback called when the task is successfully executed
  127137. * @param onError is a callback called if an error occurs
  127138. */
  127139. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127140. }
  127141. /**
  127142. * Define a task used by AssetsManager to load HDR cube textures
  127143. */
  127144. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  127145. /**
  127146. * Defines the name of the task
  127147. */
  127148. name: string;
  127149. /**
  127150. * Defines the location of the file to load
  127151. */
  127152. url: string;
  127153. /**
  127154. * Defines the desired size (the more it increases the longer the generation will be)
  127155. */
  127156. size: number;
  127157. /**
  127158. * Defines if mipmaps should not be generated (default is false)
  127159. */
  127160. noMipmap: boolean;
  127161. /**
  127162. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127163. */
  127164. generateHarmonics: boolean;
  127165. /**
  127166. * 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)
  127167. */
  127168. gammaSpace: boolean;
  127169. /**
  127170. * Internal Use Only
  127171. */
  127172. reserved: boolean;
  127173. /**
  127174. * Gets the loaded texture
  127175. */
  127176. texture: HDRCubeTexture;
  127177. /**
  127178. * Callback called when the task is successful
  127179. */
  127180. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  127181. /**
  127182. * Callback called when the task is successful
  127183. */
  127184. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  127185. /**
  127186. * Creates a new HDRCubeTextureAssetTask object
  127187. * @param name defines the name of the task
  127188. * @param url defines the location of the file to load
  127189. * @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.
  127190. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127191. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127192. * @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)
  127193. * @param reserved Internal use only
  127194. */
  127195. constructor(
  127196. /**
  127197. * Defines the name of the task
  127198. */
  127199. name: string,
  127200. /**
  127201. * Defines the location of the file to load
  127202. */
  127203. url: string,
  127204. /**
  127205. * Defines the desired size (the more it increases the longer the generation will be)
  127206. */
  127207. size: number,
  127208. /**
  127209. * Defines if mipmaps should not be generated (default is false)
  127210. */
  127211. noMipmap?: boolean,
  127212. /**
  127213. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127214. */
  127215. generateHarmonics?: boolean,
  127216. /**
  127217. * 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)
  127218. */
  127219. gammaSpace?: boolean,
  127220. /**
  127221. * Internal Use Only
  127222. */
  127223. reserved?: boolean);
  127224. /**
  127225. * Execute the current task
  127226. * @param scene defines the scene where you want your assets to be loaded
  127227. * @param onSuccess is a callback called when the task is successfully executed
  127228. * @param onError is a callback called if an error occurs
  127229. */
  127230. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127231. }
  127232. /**
  127233. * Define a task used by AssetsManager to load Equirectangular cube textures
  127234. */
  127235. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  127236. /**
  127237. * Defines the name of the task
  127238. */
  127239. name: string;
  127240. /**
  127241. * Defines the location of the file to load
  127242. */
  127243. url: string;
  127244. /**
  127245. * Defines the desired size (the more it increases the longer the generation will be)
  127246. */
  127247. size: number;
  127248. /**
  127249. * Defines if mipmaps should not be generated (default is false)
  127250. */
  127251. noMipmap: boolean;
  127252. /**
  127253. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127254. * but the standard material would require them in Gamma space) (default is true)
  127255. */
  127256. gammaSpace: boolean;
  127257. /**
  127258. * Gets the loaded texture
  127259. */
  127260. texture: EquiRectangularCubeTexture;
  127261. /**
  127262. * Callback called when the task is successful
  127263. */
  127264. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  127265. /**
  127266. * Callback called when the task is successful
  127267. */
  127268. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  127269. /**
  127270. * Creates a new EquiRectangularCubeTextureAssetTask object
  127271. * @param name defines the name of the task
  127272. * @param url defines the location of the file to load
  127273. * @param size defines the desired size (the more it increases the longer the generation will be)
  127274. * If the size is omitted this implies you are using a preprocessed cubemap.
  127275. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127276. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  127277. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  127278. * (default is true)
  127279. */
  127280. constructor(
  127281. /**
  127282. * Defines the name of the task
  127283. */
  127284. name: string,
  127285. /**
  127286. * Defines the location of the file to load
  127287. */
  127288. url: string,
  127289. /**
  127290. * Defines the desired size (the more it increases the longer the generation will be)
  127291. */
  127292. size: number,
  127293. /**
  127294. * Defines if mipmaps should not be generated (default is false)
  127295. */
  127296. noMipmap?: boolean,
  127297. /**
  127298. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127299. * but the standard material would require them in Gamma space) (default is true)
  127300. */
  127301. gammaSpace?: boolean);
  127302. /**
  127303. * Execute the current task
  127304. * @param scene defines the scene where you want your assets to be loaded
  127305. * @param onSuccess is a callback called when the task is successfully executed
  127306. * @param onError is a callback called if an error occurs
  127307. */
  127308. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127309. }
  127310. /**
  127311. * This class can be used to easily import assets into a scene
  127312. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  127313. */
  127314. export class AssetsManager {
  127315. private _scene;
  127316. private _isLoading;
  127317. protected _tasks: AbstractAssetTask[];
  127318. protected _waitingTasksCount: number;
  127319. protected _totalTasksCount: number;
  127320. /**
  127321. * Callback called when all tasks are processed
  127322. */
  127323. onFinish: (tasks: AbstractAssetTask[]) => void;
  127324. /**
  127325. * Callback called when a task is successful
  127326. */
  127327. onTaskSuccess: (task: AbstractAssetTask) => void;
  127328. /**
  127329. * Callback called when a task had an error
  127330. */
  127331. onTaskError: (task: AbstractAssetTask) => void;
  127332. /**
  127333. * Callback called when a task is done (whatever the result is)
  127334. */
  127335. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  127336. /**
  127337. * Observable called when all tasks are processed
  127338. */
  127339. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  127340. /**
  127341. * Observable called when a task had an error
  127342. */
  127343. onTaskErrorObservable: Observable<AbstractAssetTask>;
  127344. /**
  127345. * Observable called when all tasks were executed
  127346. */
  127347. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  127348. /**
  127349. * Observable called when a task is done (whatever the result is)
  127350. */
  127351. onProgressObservable: Observable<IAssetsProgressEvent>;
  127352. /**
  127353. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  127354. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127355. */
  127356. useDefaultLoadingScreen: boolean;
  127357. /**
  127358. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  127359. * when all assets have been downloaded.
  127360. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  127361. */
  127362. autoHideLoadingUI: boolean;
  127363. /**
  127364. * Creates a new AssetsManager
  127365. * @param scene defines the scene to work on
  127366. */
  127367. constructor(scene: Scene);
  127368. /**
  127369. * Add a MeshAssetTask to the list of active tasks
  127370. * @param taskName defines the name of the new task
  127371. * @param meshesNames defines the name of meshes to load
  127372. * @param rootUrl defines the root url to use to locate files
  127373. * @param sceneFilename defines the filename of the scene file
  127374. * @returns a new MeshAssetTask object
  127375. */
  127376. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  127377. /**
  127378. * Add a TextFileAssetTask to the list of active tasks
  127379. * @param taskName defines the name of the new task
  127380. * @param url defines the url of the file to load
  127381. * @returns a new TextFileAssetTask object
  127382. */
  127383. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  127384. /**
  127385. * Add a BinaryFileAssetTask to the list of active tasks
  127386. * @param taskName defines the name of the new task
  127387. * @param url defines the url of the file to load
  127388. * @returns a new BinaryFileAssetTask object
  127389. */
  127390. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  127391. /**
  127392. * Add a ImageAssetTask to the list of active tasks
  127393. * @param taskName defines the name of the new task
  127394. * @param url defines the url of the file to load
  127395. * @returns a new ImageAssetTask object
  127396. */
  127397. addImageTask(taskName: string, url: string): ImageAssetTask;
  127398. /**
  127399. * Add a TextureAssetTask to the list of active tasks
  127400. * @param taskName defines the name of the new task
  127401. * @param url defines the url of the file to load
  127402. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127403. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  127404. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  127405. * @returns a new TextureAssetTask object
  127406. */
  127407. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  127408. /**
  127409. * Add a CubeTextureAssetTask to the list of active tasks
  127410. * @param taskName defines the name of the new task
  127411. * @param url defines the url of the file to load
  127412. * @param extensions defines the extension to use to load the cube map (can be null)
  127413. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127414. * @param files defines the list of files to load (can be null)
  127415. * @returns a new CubeTextureAssetTask object
  127416. */
  127417. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  127418. /**
  127419. *
  127420. * Add a HDRCubeTextureAssetTask to the list of active tasks
  127421. * @param taskName defines the name of the new task
  127422. * @param url defines the url of the file to load
  127423. * @param size defines the size you want for the cubemap (can be null)
  127424. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127425. * @param generateHarmonics defines if you want to automatically generate (true by default)
  127426. * @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)
  127427. * @param reserved Internal use only
  127428. * @returns a new HDRCubeTextureAssetTask object
  127429. */
  127430. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  127431. /**
  127432. *
  127433. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  127434. * @param taskName defines the name of the new task
  127435. * @param url defines the url of the file to load
  127436. * @param size defines the size you want for the cubemap (can be null)
  127437. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127438. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  127439. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  127440. * @returns a new EquiRectangularCubeTextureAssetTask object
  127441. */
  127442. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  127443. /**
  127444. * Remove a task from the assets manager.
  127445. * @param task the task to remove
  127446. */
  127447. removeTask(task: AbstractAssetTask): void;
  127448. private _decreaseWaitingTasksCount;
  127449. private _runTask;
  127450. /**
  127451. * Reset the AssetsManager and remove all tasks
  127452. * @return the current instance of the AssetsManager
  127453. */
  127454. reset(): AssetsManager;
  127455. /**
  127456. * Start the loading process
  127457. * @return the current instance of the AssetsManager
  127458. */
  127459. load(): AssetsManager;
  127460. /**
  127461. * Start the loading process as an async operation
  127462. * @return a promise returning the list of failed tasks
  127463. */
  127464. loadAsync(): Promise<void>;
  127465. }
  127466. }
  127467. declare module BABYLON {
  127468. /**
  127469. * Wrapper class for promise with external resolve and reject.
  127470. */
  127471. export class Deferred<T> {
  127472. /**
  127473. * The promise associated with this deferred object.
  127474. */
  127475. readonly promise: Promise<T>;
  127476. private _resolve;
  127477. private _reject;
  127478. /**
  127479. * The resolve method of the promise associated with this deferred object.
  127480. */
  127481. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  127482. /**
  127483. * The reject method of the promise associated with this deferred object.
  127484. */
  127485. readonly reject: (reason?: any) => void;
  127486. /**
  127487. * Constructor for this deferred object.
  127488. */
  127489. constructor();
  127490. }
  127491. }
  127492. declare module BABYLON {
  127493. /**
  127494. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  127495. */
  127496. export class MeshExploder {
  127497. private _centerMesh;
  127498. private _meshes;
  127499. private _meshesOrigins;
  127500. private _toCenterVectors;
  127501. private _scaledDirection;
  127502. private _newPosition;
  127503. private _centerPosition;
  127504. /**
  127505. * Explodes meshes from a center mesh.
  127506. * @param meshes The meshes to explode.
  127507. * @param centerMesh The mesh to be center of explosion.
  127508. */
  127509. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  127510. private _setCenterMesh;
  127511. /**
  127512. * Get class name
  127513. * @returns "MeshExploder"
  127514. */
  127515. getClassName(): string;
  127516. /**
  127517. * "Exploded meshes"
  127518. * @returns Array of meshes with the centerMesh at index 0.
  127519. */
  127520. getMeshes(): Array<Mesh>;
  127521. /**
  127522. * Explodes meshes giving a specific direction
  127523. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  127524. */
  127525. explode(direction?: number): void;
  127526. }
  127527. }
  127528. declare module BABYLON {
  127529. /**
  127530. * Class used to help managing file picking and drag'n'drop
  127531. */
  127532. export class FilesInput {
  127533. /**
  127534. * List of files ready to be loaded
  127535. */
  127536. static readonly FilesToLoad: {
  127537. [key: string]: File;
  127538. };
  127539. /**
  127540. * Callback called when a file is processed
  127541. */
  127542. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  127543. private _engine;
  127544. private _currentScene;
  127545. private _sceneLoadedCallback;
  127546. private _progressCallback;
  127547. private _additionalRenderLoopLogicCallback;
  127548. private _textureLoadingCallback;
  127549. private _startingProcessingFilesCallback;
  127550. private _onReloadCallback;
  127551. private _errorCallback;
  127552. private _elementToMonitor;
  127553. private _sceneFileToLoad;
  127554. private _filesToLoad;
  127555. /**
  127556. * Creates a new FilesInput
  127557. * @param engine defines the rendering engine
  127558. * @param scene defines the hosting scene
  127559. * @param sceneLoadedCallback callback called when scene is loaded
  127560. * @param progressCallback callback called to track progress
  127561. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  127562. * @param textureLoadingCallback callback called when a texture is loading
  127563. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  127564. * @param onReloadCallback callback called when a reload is requested
  127565. * @param errorCallback callback call if an error occurs
  127566. */
  127567. 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);
  127568. private _dragEnterHandler;
  127569. private _dragOverHandler;
  127570. private _dropHandler;
  127571. /**
  127572. * Calls this function to listen to drag'n'drop events on a specific DOM element
  127573. * @param elementToMonitor defines the DOM element to track
  127574. */
  127575. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  127576. /**
  127577. * Release all associated resources
  127578. */
  127579. dispose(): void;
  127580. private renderFunction;
  127581. private drag;
  127582. private drop;
  127583. private _traverseFolder;
  127584. private _processFiles;
  127585. /**
  127586. * Load files from a drop event
  127587. * @param event defines the drop event to use as source
  127588. */
  127589. loadFiles(event: any): void;
  127590. private _processReload;
  127591. /**
  127592. * Reload the current scene from the loaded files
  127593. */
  127594. reload(): void;
  127595. }
  127596. }
  127597. declare module BABYLON {
  127598. /**
  127599. * Defines the root class used to create scene optimization to use with SceneOptimizer
  127600. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127601. */
  127602. export class SceneOptimization {
  127603. /**
  127604. * Defines the priority of this optimization (0 by default which means first in the list)
  127605. */
  127606. priority: number;
  127607. /**
  127608. * Gets a string describing the action executed by the current optimization
  127609. * @returns description string
  127610. */
  127611. getDescription(): string;
  127612. /**
  127613. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127614. * @param scene defines the current scene where to apply this optimization
  127615. * @param optimizer defines the current optimizer
  127616. * @returns true if everything that can be done was applied
  127617. */
  127618. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127619. /**
  127620. * Creates the SceneOptimization object
  127621. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127622. * @param desc defines the description associated with the optimization
  127623. */
  127624. constructor(
  127625. /**
  127626. * Defines the priority of this optimization (0 by default which means first in the list)
  127627. */
  127628. priority?: number);
  127629. }
  127630. /**
  127631. * Defines an optimization used to reduce the size of render target textures
  127632. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127633. */
  127634. export class TextureOptimization extends SceneOptimization {
  127635. /**
  127636. * Defines the priority of this optimization (0 by default which means first in the list)
  127637. */
  127638. priority: number;
  127639. /**
  127640. * 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
  127641. */
  127642. maximumSize: number;
  127643. /**
  127644. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127645. */
  127646. step: number;
  127647. /**
  127648. * Gets a string describing the action executed by the current optimization
  127649. * @returns description string
  127650. */
  127651. getDescription(): string;
  127652. /**
  127653. * Creates the TextureOptimization object
  127654. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127655. * @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
  127656. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127657. */
  127658. constructor(
  127659. /**
  127660. * Defines the priority of this optimization (0 by default which means first in the list)
  127661. */
  127662. priority?: number,
  127663. /**
  127664. * 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
  127665. */
  127666. maximumSize?: number,
  127667. /**
  127668. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127669. */
  127670. step?: number);
  127671. /**
  127672. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127673. * @param scene defines the current scene where to apply this optimization
  127674. * @param optimizer defines the current optimizer
  127675. * @returns true if everything that can be done was applied
  127676. */
  127677. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127678. }
  127679. /**
  127680. * Defines an optimization used to increase or decrease the rendering resolution
  127681. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127682. */
  127683. export class HardwareScalingOptimization extends SceneOptimization {
  127684. /**
  127685. * Defines the priority of this optimization (0 by default which means first in the list)
  127686. */
  127687. priority: number;
  127688. /**
  127689. * Defines the maximum scale to use (2 by default)
  127690. */
  127691. maximumScale: number;
  127692. /**
  127693. * Defines the step to use between two passes (0.5 by default)
  127694. */
  127695. step: number;
  127696. private _currentScale;
  127697. private _directionOffset;
  127698. /**
  127699. * Gets a string describing the action executed by the current optimization
  127700. * @return description string
  127701. */
  127702. getDescription(): string;
  127703. /**
  127704. * Creates the HardwareScalingOptimization object
  127705. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127706. * @param maximumScale defines the maximum scale to use (2 by default)
  127707. * @param step defines the step to use between two passes (0.5 by default)
  127708. */
  127709. constructor(
  127710. /**
  127711. * Defines the priority of this optimization (0 by default which means first in the list)
  127712. */
  127713. priority?: number,
  127714. /**
  127715. * Defines the maximum scale to use (2 by default)
  127716. */
  127717. maximumScale?: number,
  127718. /**
  127719. * Defines the step to use between two passes (0.5 by default)
  127720. */
  127721. step?: number);
  127722. /**
  127723. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127724. * @param scene defines the current scene where to apply this optimization
  127725. * @param optimizer defines the current optimizer
  127726. * @returns true if everything that can be done was applied
  127727. */
  127728. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127729. }
  127730. /**
  127731. * Defines an optimization used to remove shadows
  127732. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127733. */
  127734. export class ShadowsOptimization extends SceneOptimization {
  127735. /**
  127736. * Gets a string describing the action executed by the current optimization
  127737. * @return description string
  127738. */
  127739. getDescription(): string;
  127740. /**
  127741. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127742. * @param scene defines the current scene where to apply this optimization
  127743. * @param optimizer defines the current optimizer
  127744. * @returns true if everything that can be done was applied
  127745. */
  127746. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127747. }
  127748. /**
  127749. * Defines an optimization used to turn post-processes off
  127750. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127751. */
  127752. export class PostProcessesOptimization extends SceneOptimization {
  127753. /**
  127754. * Gets a string describing the action executed by the current optimization
  127755. * @return description string
  127756. */
  127757. getDescription(): string;
  127758. /**
  127759. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127760. * @param scene defines the current scene where to apply this optimization
  127761. * @param optimizer defines the current optimizer
  127762. * @returns true if everything that can be done was applied
  127763. */
  127764. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127765. }
  127766. /**
  127767. * Defines an optimization used to turn lens flares off
  127768. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127769. */
  127770. export class LensFlaresOptimization extends SceneOptimization {
  127771. /**
  127772. * Gets a string describing the action executed by the current optimization
  127773. * @return description string
  127774. */
  127775. getDescription(): string;
  127776. /**
  127777. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127778. * @param scene defines the current scene where to apply this optimization
  127779. * @param optimizer defines the current optimizer
  127780. * @returns true if everything that can be done was applied
  127781. */
  127782. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127783. }
  127784. /**
  127785. * Defines an optimization based on user defined callback.
  127786. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127787. */
  127788. export class CustomOptimization extends SceneOptimization {
  127789. /**
  127790. * Callback called to apply the custom optimization.
  127791. */
  127792. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  127793. /**
  127794. * Callback called to get custom description
  127795. */
  127796. onGetDescription: () => string;
  127797. /**
  127798. * Gets a string describing the action executed by the current optimization
  127799. * @returns description string
  127800. */
  127801. getDescription(): string;
  127802. /**
  127803. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127804. * @param scene defines the current scene where to apply this optimization
  127805. * @param optimizer defines the current optimizer
  127806. * @returns true if everything that can be done was applied
  127807. */
  127808. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127809. }
  127810. /**
  127811. * Defines an optimization used to turn particles off
  127812. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127813. */
  127814. export class ParticlesOptimization extends SceneOptimization {
  127815. /**
  127816. * Gets a string describing the action executed by the current optimization
  127817. * @return description string
  127818. */
  127819. getDescription(): string;
  127820. /**
  127821. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127822. * @param scene defines the current scene where to apply this optimization
  127823. * @param optimizer defines the current optimizer
  127824. * @returns true if everything that can be done was applied
  127825. */
  127826. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127827. }
  127828. /**
  127829. * Defines an optimization used to turn render targets off
  127830. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127831. */
  127832. export class RenderTargetsOptimization extends SceneOptimization {
  127833. /**
  127834. * Gets a string describing the action executed by the current optimization
  127835. * @return description string
  127836. */
  127837. getDescription(): string;
  127838. /**
  127839. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127840. * @param scene defines the current scene where to apply this optimization
  127841. * @param optimizer defines the current optimizer
  127842. * @returns true if everything that can be done was applied
  127843. */
  127844. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127845. }
  127846. /**
  127847. * Defines an optimization used to merge meshes with compatible materials
  127848. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127849. */
  127850. export class MergeMeshesOptimization extends SceneOptimization {
  127851. private static _UpdateSelectionTree;
  127852. /**
  127853. * Gets or sets a boolean which defines if optimization octree has to be updated
  127854. */
  127855. /**
  127856. * Gets or sets a boolean which defines if optimization octree has to be updated
  127857. */
  127858. static UpdateSelectionTree: boolean;
  127859. /**
  127860. * Gets a string describing the action executed by the current optimization
  127861. * @return description string
  127862. */
  127863. getDescription(): string;
  127864. private _canBeMerged;
  127865. /**
  127866. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127867. * @param scene defines the current scene where to apply this optimization
  127868. * @param optimizer defines the current optimizer
  127869. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  127870. * @returns true if everything that can be done was applied
  127871. */
  127872. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  127873. }
  127874. /**
  127875. * Defines a list of options used by SceneOptimizer
  127876. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127877. */
  127878. export class SceneOptimizerOptions {
  127879. /**
  127880. * Defines the target frame rate to reach (60 by default)
  127881. */
  127882. targetFrameRate: number;
  127883. /**
  127884. * Defines the interval between two checkes (2000ms by default)
  127885. */
  127886. trackerDuration: number;
  127887. /**
  127888. * Gets the list of optimizations to apply
  127889. */
  127890. optimizations: SceneOptimization[];
  127891. /**
  127892. * Creates a new list of options used by SceneOptimizer
  127893. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  127894. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  127895. */
  127896. constructor(
  127897. /**
  127898. * Defines the target frame rate to reach (60 by default)
  127899. */
  127900. targetFrameRate?: number,
  127901. /**
  127902. * Defines the interval between two checkes (2000ms by default)
  127903. */
  127904. trackerDuration?: number);
  127905. /**
  127906. * Add a new optimization
  127907. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  127908. * @returns the current SceneOptimizerOptions
  127909. */
  127910. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  127911. /**
  127912. * Add a new custom optimization
  127913. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  127914. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  127915. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127916. * @returns the current SceneOptimizerOptions
  127917. */
  127918. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  127919. /**
  127920. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  127921. * @param targetFrameRate defines the target frame rate (60 by default)
  127922. * @returns a SceneOptimizerOptions object
  127923. */
  127924. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127925. /**
  127926. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  127927. * @param targetFrameRate defines the target frame rate (60 by default)
  127928. * @returns a SceneOptimizerOptions object
  127929. */
  127930. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127931. /**
  127932. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  127933. * @param targetFrameRate defines the target frame rate (60 by default)
  127934. * @returns a SceneOptimizerOptions object
  127935. */
  127936. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127937. }
  127938. /**
  127939. * Class used to run optimizations in order to reach a target frame rate
  127940. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127941. */
  127942. export class SceneOptimizer implements IDisposable {
  127943. private _isRunning;
  127944. private _options;
  127945. private _scene;
  127946. private _currentPriorityLevel;
  127947. private _targetFrameRate;
  127948. private _trackerDuration;
  127949. private _currentFrameRate;
  127950. private _sceneDisposeObserver;
  127951. private _improvementMode;
  127952. /**
  127953. * Defines an observable called when the optimizer reaches the target frame rate
  127954. */
  127955. onSuccessObservable: Observable<SceneOptimizer>;
  127956. /**
  127957. * Defines an observable called when the optimizer enables an optimization
  127958. */
  127959. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  127960. /**
  127961. * Defines an observable called when the optimizer is not able to reach the target frame rate
  127962. */
  127963. onFailureObservable: Observable<SceneOptimizer>;
  127964. /**
  127965. * Gets a boolean indicating if the optimizer is in improvement mode
  127966. */
  127967. readonly isInImprovementMode: boolean;
  127968. /**
  127969. * Gets the current priority level (0 at start)
  127970. */
  127971. readonly currentPriorityLevel: number;
  127972. /**
  127973. * Gets the current frame rate checked by the SceneOptimizer
  127974. */
  127975. readonly currentFrameRate: number;
  127976. /**
  127977. * Gets or sets the current target frame rate (60 by default)
  127978. */
  127979. /**
  127980. * Gets or sets the current target frame rate (60 by default)
  127981. */
  127982. targetFrameRate: number;
  127983. /**
  127984. * Gets or sets the current interval between two checks (every 2000ms by default)
  127985. */
  127986. /**
  127987. * Gets or sets the current interval between two checks (every 2000ms by default)
  127988. */
  127989. trackerDuration: number;
  127990. /**
  127991. * Gets the list of active optimizations
  127992. */
  127993. readonly optimizations: SceneOptimization[];
  127994. /**
  127995. * Creates a new SceneOptimizer
  127996. * @param scene defines the scene to work on
  127997. * @param options defines the options to use with the SceneOptimizer
  127998. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  127999. * @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)
  128000. */
  128001. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  128002. /**
  128003. * Stops the current optimizer
  128004. */
  128005. stop(): void;
  128006. /**
  128007. * Reset the optimizer to initial step (current priority level = 0)
  128008. */
  128009. reset(): void;
  128010. /**
  128011. * Start the optimizer. By default it will try to reach a specific framerate
  128012. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  128013. */
  128014. start(): void;
  128015. private _checkCurrentState;
  128016. /**
  128017. * Release all resources
  128018. */
  128019. dispose(): void;
  128020. /**
  128021. * Helper function to create a SceneOptimizer with one single line of code
  128022. * @param scene defines the scene to work on
  128023. * @param options defines the options to use with the SceneOptimizer
  128024. * @param onSuccess defines a callback to call on success
  128025. * @param onFailure defines a callback to call on failure
  128026. * @returns the new SceneOptimizer object
  128027. */
  128028. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  128029. }
  128030. }
  128031. declare module BABYLON {
  128032. /**
  128033. * Class used to serialize a scene into a string
  128034. */
  128035. export class SceneSerializer {
  128036. /**
  128037. * Clear cache used by a previous serialization
  128038. */
  128039. static ClearCache(): void;
  128040. /**
  128041. * Serialize a scene into a JSON compatible object
  128042. * @param scene defines the scene to serialize
  128043. * @returns a JSON compatible object
  128044. */
  128045. static Serialize(scene: Scene): any;
  128046. /**
  128047. * Serialize a mesh into a JSON compatible object
  128048. * @param toSerialize defines the mesh to serialize
  128049. * @param withParents defines if parents must be serialized as well
  128050. * @param withChildren defines if children must be serialized as well
  128051. * @returns a JSON compatible object
  128052. */
  128053. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  128054. }
  128055. }
  128056. declare module BABYLON {
  128057. /**
  128058. * Class used to host texture specific utilities
  128059. */
  128060. export class TextureTools {
  128061. /**
  128062. * Uses the GPU to create a copy texture rescaled at a given size
  128063. * @param texture Texture to copy from
  128064. * @param width defines the desired width
  128065. * @param height defines the desired height
  128066. * @param useBilinearMode defines if bilinear mode has to be used
  128067. * @return the generated texture
  128068. */
  128069. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  128070. }
  128071. }
  128072. declare module BABYLON {
  128073. /**
  128074. * This represents the different options available for the video capture.
  128075. */
  128076. export interface VideoRecorderOptions {
  128077. /** Defines the mime type of the video. */
  128078. mimeType: string;
  128079. /** Defines the FPS the video should be recorded at. */
  128080. fps: number;
  128081. /** Defines the chunk size for the recording data. */
  128082. recordChunckSize: number;
  128083. /** The audio tracks to attach to the recording. */
  128084. audioTracks?: MediaStreamTrack[];
  128085. }
  128086. /**
  128087. * This can help with recording videos from BabylonJS.
  128088. * This is based on the available WebRTC functionalities of the browser.
  128089. *
  128090. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  128091. */
  128092. export class VideoRecorder {
  128093. private static readonly _defaultOptions;
  128094. /**
  128095. * Returns whether or not the VideoRecorder is available in your browser.
  128096. * @param engine Defines the Babylon Engine.
  128097. * @returns true if supported otherwise false.
  128098. */
  128099. static IsSupported(engine: Engine): boolean;
  128100. private readonly _options;
  128101. private _canvas;
  128102. private _mediaRecorder;
  128103. private _recordedChunks;
  128104. private _fileName;
  128105. private _resolve;
  128106. private _reject;
  128107. /**
  128108. * True when a recording is already in progress.
  128109. */
  128110. readonly isRecording: boolean;
  128111. /**
  128112. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  128113. * @param engine Defines the BabylonJS Engine you wish to record.
  128114. * @param options Defines options that can be used to customize the capture.
  128115. */
  128116. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  128117. /**
  128118. * Stops the current recording before the default capture timeout passed in the startRecording function.
  128119. */
  128120. stopRecording(): void;
  128121. /**
  128122. * Starts recording the canvas for a max duration specified in parameters.
  128123. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  128124. * If null no automatic download will start and you can rely on the promise to get the data back.
  128125. * @param maxDuration Defines the maximum recording time in seconds.
  128126. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  128127. * @return A promise callback at the end of the recording with the video data in Blob.
  128128. */
  128129. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  128130. /**
  128131. * Releases internal resources used during the recording.
  128132. */
  128133. dispose(): void;
  128134. private _handleDataAvailable;
  128135. private _handleError;
  128136. private _handleStop;
  128137. }
  128138. }
  128139. declare module BABYLON {
  128140. /**
  128141. * Class containing a set of static utilities functions for screenshots
  128142. */
  128143. export class ScreenshotTools {
  128144. /**
  128145. * Captures a screenshot of the current rendering
  128146. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128147. * @param engine defines the rendering engine
  128148. * @param camera defines the source camera
  128149. * @param size This parameter can be set to a single number or to an object with the
  128150. * following (optional) properties: precision, width, height. If a single number is passed,
  128151. * it will be used for both width and height. If an object is passed, the screenshot size
  128152. * will be derived from the parameters. The precision property is a multiplier allowing
  128153. * rendering at a higher or lower resolution
  128154. * @param successCallback defines the callback receives a single parameter which contains the
  128155. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128156. * src parameter of an <img> to display it
  128157. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128158. * Check your browser for supported MIME types
  128159. */
  128160. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  128161. /**
  128162. * Captures a screenshot of the current rendering
  128163. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128164. * @param engine defines the rendering engine
  128165. * @param camera defines the source camera
  128166. * @param size This parameter can be set to a single number or to an object with the
  128167. * following (optional) properties: precision, width, height. If a single number is passed,
  128168. * it will be used for both width and height. If an object is passed, the screenshot size
  128169. * will be derived from the parameters. The precision property is a multiplier allowing
  128170. * rendering at a higher or lower resolution
  128171. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128172. * Check your browser for supported MIME types
  128173. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128174. * to the src parameter of an <img> to display it
  128175. */
  128176. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  128177. /**
  128178. * Generates an image screenshot from the specified camera.
  128179. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128180. * @param engine The engine to use for rendering
  128181. * @param camera The camera to use for rendering
  128182. * @param size This parameter can be set to a single number or to an object with the
  128183. * following (optional) properties: precision, width, height. If a single number is passed,
  128184. * it will be used for both width and height. If an object is passed, the screenshot size
  128185. * will be derived from the parameters. The precision property is a multiplier allowing
  128186. * rendering at a higher or lower resolution
  128187. * @param successCallback The callback receives a single parameter which contains the
  128188. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128189. * src parameter of an <img> to display it
  128190. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128191. * Check your browser for supported MIME types
  128192. * @param samples Texture samples (default: 1)
  128193. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128194. * @param fileName A name for for the downloaded file.
  128195. */
  128196. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  128197. /**
  128198. * Generates an image screenshot from the specified camera.
  128199. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128200. * @param engine The engine to use for rendering
  128201. * @param camera The camera to use for rendering
  128202. * @param size This parameter can be set to a single number or to an object with the
  128203. * following (optional) properties: precision, width, height. If a single number is passed,
  128204. * it will be used for both width and height. If an object is passed, the screenshot size
  128205. * will be derived from the parameters. The precision property is a multiplier allowing
  128206. * rendering at a higher or lower resolution
  128207. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128208. * Check your browser for supported MIME types
  128209. * @param samples Texture samples (default: 1)
  128210. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128211. * @param fileName A name for for the downloaded file.
  128212. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128213. * to the src parameter of an <img> to display it
  128214. */
  128215. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  128216. /**
  128217. * Gets height and width for screenshot size
  128218. * @private
  128219. */
  128220. private static _getScreenshotSize;
  128221. }
  128222. }
  128223. declare module BABYLON {
  128224. /**
  128225. * A cursor which tracks a point on a path
  128226. */
  128227. export class PathCursor {
  128228. private path;
  128229. /**
  128230. * Stores path cursor callbacks for when an onchange event is triggered
  128231. */
  128232. private _onchange;
  128233. /**
  128234. * The value of the path cursor
  128235. */
  128236. value: number;
  128237. /**
  128238. * The animation array of the path cursor
  128239. */
  128240. animations: Animation[];
  128241. /**
  128242. * Initializes the path cursor
  128243. * @param path The path to track
  128244. */
  128245. constructor(path: Path2);
  128246. /**
  128247. * Gets the cursor point on the path
  128248. * @returns A point on the path cursor at the cursor location
  128249. */
  128250. getPoint(): Vector3;
  128251. /**
  128252. * Moves the cursor ahead by the step amount
  128253. * @param step The amount to move the cursor forward
  128254. * @returns This path cursor
  128255. */
  128256. moveAhead(step?: number): PathCursor;
  128257. /**
  128258. * Moves the cursor behind by the step amount
  128259. * @param step The amount to move the cursor back
  128260. * @returns This path cursor
  128261. */
  128262. moveBack(step?: number): PathCursor;
  128263. /**
  128264. * Moves the cursor by the step amount
  128265. * If the step amount is greater than one, an exception is thrown
  128266. * @param step The amount to move the cursor
  128267. * @returns This path cursor
  128268. */
  128269. move(step: number): PathCursor;
  128270. /**
  128271. * Ensures that the value is limited between zero and one
  128272. * @returns This path cursor
  128273. */
  128274. private ensureLimits;
  128275. /**
  128276. * Runs onchange callbacks on change (used by the animation engine)
  128277. * @returns This path cursor
  128278. */
  128279. private raiseOnChange;
  128280. /**
  128281. * Executes a function on change
  128282. * @param f A path cursor onchange callback
  128283. * @returns This path cursor
  128284. */
  128285. onchange(f: (cursor: PathCursor) => void): PathCursor;
  128286. }
  128287. }
  128288. declare module BABYLON {
  128289. /** @hidden */
  128290. export var blurPixelShader: {
  128291. name: string;
  128292. shader: string;
  128293. };
  128294. }
  128295. declare module BABYLON {
  128296. /** @hidden */
  128297. export var pointCloudVertexDeclaration: {
  128298. name: string;
  128299. shader: string;
  128300. };
  128301. }
  128302. // Mixins
  128303. interface Window {
  128304. mozIndexedDB: IDBFactory;
  128305. webkitIndexedDB: IDBFactory;
  128306. msIndexedDB: IDBFactory;
  128307. webkitURL: typeof URL;
  128308. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  128309. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  128310. WebGLRenderingContext: WebGLRenderingContext;
  128311. MSGesture: MSGesture;
  128312. CANNON: any;
  128313. AudioContext: AudioContext;
  128314. webkitAudioContext: AudioContext;
  128315. PointerEvent: any;
  128316. Math: Math;
  128317. Uint8Array: Uint8ArrayConstructor;
  128318. Float32Array: Float32ArrayConstructor;
  128319. mozURL: typeof URL;
  128320. msURL: typeof URL;
  128321. VRFrameData: any; // WebVR, from specs 1.1
  128322. DracoDecoderModule: any;
  128323. setImmediate(handler: (...args: any[]) => void): number;
  128324. }
  128325. interface HTMLCanvasElement {
  128326. requestPointerLock(): void;
  128327. msRequestPointerLock?(): void;
  128328. mozRequestPointerLock?(): void;
  128329. webkitRequestPointerLock?(): void;
  128330. /** Track wether a record is in progress */
  128331. isRecording: boolean;
  128332. /** Capture Stream method defined by some browsers */
  128333. captureStream(fps?: number): MediaStream;
  128334. }
  128335. interface CanvasRenderingContext2D {
  128336. msImageSmoothingEnabled: boolean;
  128337. }
  128338. interface MouseEvent {
  128339. mozMovementX: number;
  128340. mozMovementY: number;
  128341. webkitMovementX: number;
  128342. webkitMovementY: number;
  128343. msMovementX: number;
  128344. msMovementY: number;
  128345. }
  128346. interface Navigator {
  128347. mozGetVRDevices: (any: any) => any;
  128348. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128349. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128350. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128351. webkitGetGamepads(): Gamepad[];
  128352. msGetGamepads(): Gamepad[];
  128353. webkitGamepads(): Gamepad[];
  128354. }
  128355. interface HTMLVideoElement {
  128356. mozSrcObject: any;
  128357. }
  128358. interface Math {
  128359. fround(x: number): number;
  128360. imul(a: number, b: number): number;
  128361. }
  128362. interface WebGLRenderingContext {
  128363. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  128364. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  128365. vertexAttribDivisor(index: number, divisor: number): void;
  128366. createVertexArray(): any;
  128367. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  128368. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  128369. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  128370. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  128371. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  128372. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  128373. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  128374. // Queries
  128375. createQuery(): WebGLQuery;
  128376. deleteQuery(query: WebGLQuery): void;
  128377. beginQuery(target: number, query: WebGLQuery): void;
  128378. endQuery(target: number): void;
  128379. getQueryParameter(query: WebGLQuery, pname: number): any;
  128380. getQuery(target: number, pname: number): any;
  128381. MAX_SAMPLES: number;
  128382. RGBA8: number;
  128383. READ_FRAMEBUFFER: number;
  128384. DRAW_FRAMEBUFFER: number;
  128385. UNIFORM_BUFFER: number;
  128386. HALF_FLOAT_OES: number;
  128387. RGBA16F: number;
  128388. RGBA32F: number;
  128389. R32F: number;
  128390. RG32F: number;
  128391. RGB32F: number;
  128392. R16F: number;
  128393. RG16F: number;
  128394. RGB16F: number;
  128395. RED: number;
  128396. RG: number;
  128397. R8: number;
  128398. RG8: number;
  128399. UNSIGNED_INT_24_8: number;
  128400. DEPTH24_STENCIL8: number;
  128401. MIN: number;
  128402. MAX: number;
  128403. /* Multiple Render Targets */
  128404. drawBuffers(buffers: number[]): void;
  128405. readBuffer(src: number): void;
  128406. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  128407. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  128408. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  128409. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  128410. // Occlusion Query
  128411. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  128412. ANY_SAMPLES_PASSED: number;
  128413. QUERY_RESULT_AVAILABLE: number;
  128414. QUERY_RESULT: number;
  128415. }
  128416. interface WebGLProgram {
  128417. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  128418. }
  128419. interface EXT_disjoint_timer_query {
  128420. QUERY_COUNTER_BITS_EXT: number;
  128421. TIME_ELAPSED_EXT: number;
  128422. TIMESTAMP_EXT: number;
  128423. GPU_DISJOINT_EXT: number;
  128424. QUERY_RESULT_EXT: number;
  128425. QUERY_RESULT_AVAILABLE_EXT: number;
  128426. queryCounterEXT(query: WebGLQuery, target: number): void;
  128427. createQueryEXT(): WebGLQuery;
  128428. beginQueryEXT(target: number, query: WebGLQuery): void;
  128429. endQueryEXT(target: number): void;
  128430. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  128431. deleteQueryEXT(query: WebGLQuery): void;
  128432. }
  128433. interface WebGLUniformLocation {
  128434. _currentState: any;
  128435. }
  128436. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  128437. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  128438. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  128439. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128440. interface WebGLRenderingContext {
  128441. readonly RASTERIZER_DISCARD: number;
  128442. readonly DEPTH_COMPONENT24: number;
  128443. readonly TEXTURE_3D: number;
  128444. readonly TEXTURE_2D_ARRAY: number;
  128445. readonly TEXTURE_COMPARE_FUNC: number;
  128446. readonly TEXTURE_COMPARE_MODE: number;
  128447. readonly COMPARE_REF_TO_TEXTURE: number;
  128448. readonly TEXTURE_WRAP_R: number;
  128449. readonly HALF_FLOAT: number;
  128450. readonly RGB8: number;
  128451. readonly RED_INTEGER: number;
  128452. readonly RG_INTEGER: number;
  128453. readonly RGB_INTEGER: number;
  128454. readonly RGBA_INTEGER: number;
  128455. readonly R8_SNORM: number;
  128456. readonly RG8_SNORM: number;
  128457. readonly RGB8_SNORM: number;
  128458. readonly RGBA8_SNORM: number;
  128459. readonly R8I: number;
  128460. readonly RG8I: number;
  128461. readonly RGB8I: number;
  128462. readonly RGBA8I: number;
  128463. readonly R8UI: number;
  128464. readonly RG8UI: number;
  128465. readonly RGB8UI: number;
  128466. readonly RGBA8UI: number;
  128467. readonly R16I: number;
  128468. readonly RG16I: number;
  128469. readonly RGB16I: number;
  128470. readonly RGBA16I: number;
  128471. readonly R16UI: number;
  128472. readonly RG16UI: number;
  128473. readonly RGB16UI: number;
  128474. readonly RGBA16UI: number;
  128475. readonly R32I: number;
  128476. readonly RG32I: number;
  128477. readonly RGB32I: number;
  128478. readonly RGBA32I: number;
  128479. readonly R32UI: number;
  128480. readonly RG32UI: number;
  128481. readonly RGB32UI: number;
  128482. readonly RGBA32UI: number;
  128483. readonly RGB10_A2UI: number;
  128484. readonly R11F_G11F_B10F: number;
  128485. readonly RGB9_E5: number;
  128486. readonly RGB10_A2: number;
  128487. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  128488. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  128489. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  128490. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  128491. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  128492. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  128493. 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;
  128494. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  128495. readonly TRANSFORM_FEEDBACK: number;
  128496. readonly INTERLEAVED_ATTRIBS: number;
  128497. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  128498. createTransformFeedback(): WebGLTransformFeedback;
  128499. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  128500. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  128501. beginTransformFeedback(primitiveMode: number): void;
  128502. endTransformFeedback(): void;
  128503. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  128504. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128505. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128506. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128507. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  128508. }
  128509. interface ImageBitmap {
  128510. readonly width: number;
  128511. readonly height: number;
  128512. close(): void;
  128513. }
  128514. interface WebGLQuery extends WebGLObject {
  128515. }
  128516. declare var WebGLQuery: {
  128517. prototype: WebGLQuery;
  128518. new(): WebGLQuery;
  128519. };
  128520. interface WebGLSampler extends WebGLObject {
  128521. }
  128522. declare var WebGLSampler: {
  128523. prototype: WebGLSampler;
  128524. new(): WebGLSampler;
  128525. };
  128526. interface WebGLSync extends WebGLObject {
  128527. }
  128528. declare var WebGLSync: {
  128529. prototype: WebGLSync;
  128530. new(): WebGLSync;
  128531. };
  128532. interface WebGLTransformFeedback extends WebGLObject {
  128533. }
  128534. declare var WebGLTransformFeedback: {
  128535. prototype: WebGLTransformFeedback;
  128536. new(): WebGLTransformFeedback;
  128537. };
  128538. interface WebGLVertexArrayObject extends WebGLObject {
  128539. }
  128540. declare var WebGLVertexArrayObject: {
  128541. prototype: WebGLVertexArrayObject;
  128542. new(): WebGLVertexArrayObject;
  128543. };
  128544. // Type definitions for WebVR API
  128545. // Project: https://w3c.github.io/webvr/
  128546. // Definitions by: six a <https://github.com/lostfictions>
  128547. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128548. interface VRDisplay extends EventTarget {
  128549. /**
  128550. * Dictionary of capabilities describing the VRDisplay.
  128551. */
  128552. readonly capabilities: VRDisplayCapabilities;
  128553. /**
  128554. * z-depth defining the far plane of the eye view frustum
  128555. * enables mapping of values in the render target depth
  128556. * attachment to scene coordinates. Initially set to 10000.0.
  128557. */
  128558. depthFar: number;
  128559. /**
  128560. * z-depth defining the near plane of the eye view frustum
  128561. * enables mapping of values in the render target depth
  128562. * attachment to scene coordinates. Initially set to 0.01.
  128563. */
  128564. depthNear: number;
  128565. /**
  128566. * An identifier for this distinct VRDisplay. Used as an
  128567. * association point in the Gamepad API.
  128568. */
  128569. readonly displayId: number;
  128570. /**
  128571. * A display name, a user-readable name identifying it.
  128572. */
  128573. readonly displayName: string;
  128574. readonly isConnected: boolean;
  128575. readonly isPresenting: boolean;
  128576. /**
  128577. * If this VRDisplay supports room-scale experiences, the optional
  128578. * stage attribute contains details on the room-scale parameters.
  128579. */
  128580. readonly stageParameters: VRStageParameters | null;
  128581. /**
  128582. * Passing the value returned by `requestAnimationFrame` to
  128583. * `cancelAnimationFrame` will unregister the callback.
  128584. * @param handle Define the hanle of the request to cancel
  128585. */
  128586. cancelAnimationFrame(handle: number): void;
  128587. /**
  128588. * Stops presenting to the VRDisplay.
  128589. * @returns a promise to know when it stopped
  128590. */
  128591. exitPresent(): Promise<void>;
  128592. /**
  128593. * Return the current VREyeParameters for the given eye.
  128594. * @param whichEye Define the eye we want the parameter for
  128595. * @returns the eye parameters
  128596. */
  128597. getEyeParameters(whichEye: string): VREyeParameters;
  128598. /**
  128599. * Populates the passed VRFrameData with the information required to render
  128600. * the current frame.
  128601. * @param frameData Define the data structure to populate
  128602. * @returns true if ok otherwise false
  128603. */
  128604. getFrameData(frameData: VRFrameData): boolean;
  128605. /**
  128606. * Get the layers currently being presented.
  128607. * @returns the list of VR layers
  128608. */
  128609. getLayers(): VRLayer[];
  128610. /**
  128611. * Return a VRPose containing the future predicted pose of the VRDisplay
  128612. * when the current frame will be presented. The value returned will not
  128613. * change until JavaScript has returned control to the browser.
  128614. *
  128615. * The VRPose will contain the position, orientation, velocity,
  128616. * and acceleration of each of these properties.
  128617. * @returns the pose object
  128618. */
  128619. getPose(): VRPose;
  128620. /**
  128621. * Return the current instantaneous pose of the VRDisplay, with no
  128622. * prediction applied.
  128623. * @returns the current instantaneous pose
  128624. */
  128625. getImmediatePose(): VRPose;
  128626. /**
  128627. * The callback passed to `requestAnimationFrame` will be called
  128628. * any time a new frame should be rendered. When the VRDisplay is
  128629. * presenting the callback will be called at the native refresh
  128630. * rate of the HMD. When not presenting this function acts
  128631. * identically to how window.requestAnimationFrame acts. Content should
  128632. * make no assumptions of frame rate or vsync behavior as the HMD runs
  128633. * asynchronously from other displays and at differing refresh rates.
  128634. * @param callback Define the eaction to run next frame
  128635. * @returns the request handle it
  128636. */
  128637. requestAnimationFrame(callback: FrameRequestCallback): number;
  128638. /**
  128639. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  128640. * Repeat calls while already presenting will update the VRLayers being displayed.
  128641. * @param layers Define the list of layer to present
  128642. * @returns a promise to know when the request has been fulfilled
  128643. */
  128644. requestPresent(layers: VRLayer[]): Promise<void>;
  128645. /**
  128646. * Reset the pose for this display, treating its current position and
  128647. * orientation as the "origin/zero" values. VRPose.position,
  128648. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  128649. * updated when calling resetPose(). This should be called in only
  128650. * sitting-space experiences.
  128651. */
  128652. resetPose(): void;
  128653. /**
  128654. * The VRLayer provided to the VRDisplay will be captured and presented
  128655. * in the HMD. Calling this function has the same effect on the source
  128656. * canvas as any other operation that uses its source image, and canvases
  128657. * created without preserveDrawingBuffer set to true will be cleared.
  128658. * @param pose Define the pose to submit
  128659. */
  128660. submitFrame(pose?: VRPose): void;
  128661. }
  128662. declare var VRDisplay: {
  128663. prototype: VRDisplay;
  128664. new(): VRDisplay;
  128665. };
  128666. interface VRLayer {
  128667. leftBounds?: number[] | Float32Array | null;
  128668. rightBounds?: number[] | Float32Array | null;
  128669. source?: HTMLCanvasElement | null;
  128670. }
  128671. interface VRDisplayCapabilities {
  128672. readonly canPresent: boolean;
  128673. readonly hasExternalDisplay: boolean;
  128674. readonly hasOrientation: boolean;
  128675. readonly hasPosition: boolean;
  128676. readonly maxLayers: number;
  128677. }
  128678. interface VREyeParameters {
  128679. /** @deprecated */
  128680. readonly fieldOfView: VRFieldOfView;
  128681. readonly offset: Float32Array;
  128682. readonly renderHeight: number;
  128683. readonly renderWidth: number;
  128684. }
  128685. interface VRFieldOfView {
  128686. readonly downDegrees: number;
  128687. readonly leftDegrees: number;
  128688. readonly rightDegrees: number;
  128689. readonly upDegrees: number;
  128690. }
  128691. interface VRFrameData {
  128692. readonly leftProjectionMatrix: Float32Array;
  128693. readonly leftViewMatrix: Float32Array;
  128694. readonly pose: VRPose;
  128695. readonly rightProjectionMatrix: Float32Array;
  128696. readonly rightViewMatrix: Float32Array;
  128697. readonly timestamp: number;
  128698. }
  128699. interface VRPose {
  128700. readonly angularAcceleration: Float32Array | null;
  128701. readonly angularVelocity: Float32Array | null;
  128702. readonly linearAcceleration: Float32Array | null;
  128703. readonly linearVelocity: Float32Array | null;
  128704. readonly orientation: Float32Array | null;
  128705. readonly position: Float32Array | null;
  128706. readonly timestamp: number;
  128707. }
  128708. interface VRStageParameters {
  128709. sittingToStandingTransform?: Float32Array;
  128710. sizeX?: number;
  128711. sizeY?: number;
  128712. }
  128713. interface Navigator {
  128714. getVRDisplays(): Promise<VRDisplay[]>;
  128715. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  128716. }
  128717. interface Window {
  128718. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  128719. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  128720. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  128721. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128722. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128723. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  128724. }
  128725. interface Gamepad {
  128726. readonly displayId: number;
  128727. }
  128728. type XRSessionMode =
  128729. | "inline"
  128730. | "immersive-vr"
  128731. | "immersive-ar";
  128732. type XRReferenceSpaceType =
  128733. | "viewer"
  128734. | "local"
  128735. | "local-floor"
  128736. | "bounded-floor"
  128737. | "unbounded";
  128738. type XREnvironmentBlendMode =
  128739. | "opaque"
  128740. | "additive"
  128741. | "alpha-blend";
  128742. type XRVisibilityState =
  128743. | "visible"
  128744. | "visible-blurred"
  128745. | "hidden";
  128746. type XRHandedness =
  128747. | "none"
  128748. | "left"
  128749. | "right";
  128750. type XRTargetRayMode =
  128751. | "gaze"
  128752. | "tracked-pointer"
  128753. | "screen";
  128754. type XREye =
  128755. | "none"
  128756. | "left"
  128757. | "right";
  128758. interface XRSpace extends EventTarget {
  128759. }
  128760. interface XRRenderState {
  128761. depthNear?: number;
  128762. depthFar?: number;
  128763. inlineVerticalFieldOfView?: number;
  128764. baseLayer?: XRWebGLLayer;
  128765. }
  128766. interface XRInputSource {
  128767. handedness: XRHandedness;
  128768. targetRayMode: XRTargetRayMode;
  128769. targetRaySpace: XRSpace;
  128770. gripSpace: XRSpace | undefined;
  128771. gamepad: Gamepad | undefined;
  128772. profiles: Array<string>;
  128773. }
  128774. interface XRSession {
  128775. addEventListener: Function;
  128776. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  128777. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  128778. requestAnimationFrame: Function;
  128779. end(): Promise<void>;
  128780. renderState: XRRenderState;
  128781. inputSources: Array<XRInputSource>;
  128782. }
  128783. interface XRReferenceSpace extends XRSpace {
  128784. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  128785. onreset: any;
  128786. }
  128787. interface XRFrame {
  128788. session: XRSession;
  128789. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  128790. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  128791. }
  128792. interface XRViewerPose extends XRPose {
  128793. views: Array<XRView>;
  128794. }
  128795. interface XRPose {
  128796. transform: XRRigidTransform;
  128797. emulatedPosition: boolean;
  128798. }
  128799. declare var XRWebGLLayer: {
  128800. prototype: XRWebGLLayer;
  128801. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  128802. };
  128803. interface XRWebGLLayer {
  128804. framebuffer: WebGLFramebuffer;
  128805. framebufferWidth: number;
  128806. framebufferHeight: number;
  128807. getViewport: Function;
  128808. }
  128809. interface XRRigidTransform {
  128810. position: DOMPointReadOnly;
  128811. orientation: DOMPointReadOnly;
  128812. matrix: Float32Array;
  128813. inverse: XRRigidTransform;
  128814. }
  128815. interface XRView {
  128816. eye: XREye;
  128817. projectionMatrix: Float32Array;
  128818. transform: XRRigidTransform;
  128819. }
  128820. interface XRInputSourceChangeEvent {
  128821. session: XRSession;
  128822. removed: Array<XRInputSource>;
  128823. added: Array<XRInputSource>;
  128824. }